Browse Source

fix linting

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

20
src/lib/WireGuard.js

@ -46,7 +46,7 @@ module.exports = class WireGuard {
const publicKey = await Util.exec(`echo ${privateKey} | 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 = {
server: {
@ -88,7 +88,6 @@ module.exports = class WireGuard {
}
async __saveConfig(config) {
let result = `
# Note: Do not edit this file directly.
# Your changes will be overwritten!
@ -232,23 +231,26 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
const publicKey = await Util.exec(`echo ${privateKey} | wg pubkey`);
const preSharedKey = await Util.exec('wg genpsk');
/* ------ compute next IP address ------*/
/* ------ compute next IP address ------ */
const recursiveFindIpAdress = (o1, o2, o3, o4) => {
if (o4 > 255) {
if (WG_CIDR === 24)
if (WG_CIDR === 24) {
return null;
}
o3++;
o4 = 0;
}
if (o3 > 255) {
if (WG_CIDR === 16)
if (WG_CIDR === 16) {
return null;
}
o2++;
o3 = 0;
}
if (o2 > 255) {
if (WG_CIDR === 8)
if (WG_CIDR === 8) {
return null;
}
o1++;
o2 = 0;
}
@ -259,12 +261,12 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;
return `${o1}.${o2}.${o3}.${o4}`;
}
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)
));
const address = recursiveFindIpAdress(o1, o2, o3, 2);
/*------ end compute next IP address ------*/
/* ------ end compute next IP address ------ */
if (!address) {
throw new Error('Maximum number of clients reached.');

Loading…
Cancel
Save