Browse Source

WireGuard.js: fixup lint errors

pull/700/head
Philip H 1 year ago
committed by GitHub
parent
commit
a73dbcc8e2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/lib/WireGuard.js

16
src/lib/WireGuard.js

@ -23,7 +23,7 @@ const {
WG_POST_UP, WG_POST_UP,
WG_PRE_DOWN, WG_PRE_DOWN,
WG_POST_DOWN, WG_POST_DOWN,
WG_INTERFACE WG_INTERFACE,
} = require('../config'); } = require('../config');
module.exports = class WireGuard { module.exports = class WireGuard {
@ -60,10 +60,10 @@ module.exports = class WireGuard {
} }
await this.__saveConfig(config); await this.__saveConfig(config);
await Util.exec('wg-quick down ' + WG_INTERFACE).catch(() => { }); await Util.exec(`wg-quick down ${WG_INTERFACE}`).catch(() => { });
await Util.exec('wg-quick up ' + WG_INTERFACE).catch(err => { await Util.exec(`wg-quick up ${WG_INTERFACE}`).catch((err) => {
if (err && err.message && err.message.includes('Cannot find device ' + WG_INTERFACE)) { if (err && err.message && err.message.includes(`Cannot find device ${WG_INTERFACE}`)) {
throw new Error('WireGuard exited with the error: Cannot find device ' + WG_INTERFACE + '\nThis usually means that your host\'s kernel does not support WireGuard!'); throw new Error(`WireGuard exited with the error: Cannot find device ${WG_INTERFACE}\nThis usually means that your host's kernel does not support WireGuard!`);
} }
throw err; throw err;
@ -119,7 +119,7 @@ AllowedIPs = ${client.address}/32`;
await fs.writeFile(path.join(WG_PATH, 'wg0.json'), JSON.stringify(config, false, 2), { await fs.writeFile(path.join(WG_PATH, 'wg0.json'), JSON.stringify(config, false, 2), {
mode: 0o660, mode: 0o660,
}); });
await fs.writeFile(path.join(WG_PATH, WG_INTERFACE + '.conf'), result, { await fs.writeFile(path.join(WG_PATH, `${WG_INTERFACE}.conf`), result, {
mode: 0o600, mode: 0o600,
}); });
debug('Config saved.'); debug('Config saved.');
@ -127,7 +127,7 @@ AllowedIPs = ${client.address}/32`;
async __syncConfig() { async __syncConfig() {
debug('Config syncing...'); debug('Config syncing...');
await Util.exec('wg syncconf ' + WG_INTERFACE + ' <(wg-quick strip ' + WG_INTERFACE + ')'); await Util.exec(`wg syncconf ${WG_INTERFACE} <(wg-quick strip ${WG_INTERFACE})`);
debug('Config synced.'); debug('Config synced.');
} }
@ -150,7 +150,7 @@ AllowedIPs = ${client.address}/32`;
})); }));
// Loop WireGuard status // Loop WireGuard status
const dump = await Util.exec('wg show ' + WG_INTERFACE + ' dump', { const dump = await Util.exec(`wg show ${WG_INTERFACE} dump`, {
log: false, log: false,
}); });
dump dump

Loading…
Cancel
Save