From 30b698adad06a6b8425dc1531537865675c73dff Mon Sep 17 00:00:00 2001 From: gganster Date: Tue, 4 Jun 2024 14:57:17 +0200 Subject: [PATCH] fix linting --- src/lib/WireGuard.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/lib/WireGuard.js b/src/lib/WireGuard.js index d0f58a94..80fc2a03 100644 --- a/src/lib/WireGuard.js +++ b/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.');