Browse Source

fix linting

pull/1087/head
gganster 2 years ago
committed by Philip H
parent
commit
30b698adad
  1. 16
      src/lib/WireGuard.js

16
src/lib/WireGuard.js

@ -46,7 +46,7 @@ module.exports = class WireGuard {
const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`, { const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`, {
log: 'echo ***hidden*** | wg pubkey', log: 'echo ***hidden*** | wg pubkey',
}); });
const address = Util.replaceAll(WG_DEFAULT_ADDRESS, "x", "1"); const address = Util.replaceAll(WG_DEFAULT_ADDRESS, 'x', '1');
config = { config = {
server: { server: {
@ -88,7 +88,6 @@ module.exports = class WireGuard {
} }
async __saveConfig(config) { async __saveConfig(config) {
let result = ` let result = `
# Note: Do not edit this file directly. # Note: Do not edit this file directly.
# Your changes will be overwritten! # Your changes will be overwritten!
@ -235,20 +234,23 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
/* ------ compute next IP address ------ */ /* ------ compute next IP address ------ */
const recursiveFindIpAdress = (o1, o2, o3, o4) => { const recursiveFindIpAdress = (o1, o2, o3, o4) => {
if (o4 > 255) { if (o4 > 255) {
if (WG_CIDR === 24) if (WG_CIDR === 24) {
return null; return null;
}
o3++; o3++;
o4 = 0; o4 = 0;
} }
if (o3 > 255) { if (o3 > 255) {
if (WG_CIDR === 16) if (WG_CIDR === 16) {
return null; return null;
}
o2++; o2++;
o3 = 0; o3 = 0;
} }
if (o2 > 255) { if (o2 > 255) {
if (WG_CIDR === 8) if (WG_CIDR === 8) {
return null; return null;
}
o1++; o1++;
o2 = 0; o2 = 0;
} }
@ -259,8 +261,8 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
return `${o1}.${o2}.${o3}.${o4}`; return `${o1}.${o2}.${o3}.${o4}`;
} }
return recursiveFindIpAdress(o1, o2, o3, o4 + 1); return recursiveFindIpAdress(o1, o2, o3, o4 + 1);
} };
const [o1, o2, o3, o4] = WG_DEFAULT_ADDRESS.split('.').map(i => ( const [o1, o2, o3] = WG_DEFAULT_ADDRESS.split('.').map((i) => (
i === 'x' ? 0 : parseInt(i, 10) i === 'x' ? 0 : parseInt(i, 10)
)); ));
const address = recursiveFindIpAdress(o1, o2, o3, 2); const address = recursiveFindIpAdress(o1, o2, o3, 2);

Loading…
Cancel
Save