Browse Source

Update WireGuard.js

pull/549/head
Peter Lewis 2 years ago
committed by GitHub
parent
commit
8800cd9b0d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/lib/WireGuard.js

8
src/lib/WireGuard.js

@ -60,7 +60,7 @@ module.exports = class WireGuard {
await this.__saveConfig(config); await this.__saveConfig(config);
await Util.exec('wg-quick down wg0').catch(() => { }); await Util.exec('wg-quick down wg0').catch(() => { });
await Util.exec('wg-quick up wg0').catch(err => { await Util.exec('wg-quick up wg0').catch((err) => {
if (err && err.message && err.message.includes('Cannot find device "wg0"')) { if (err && err.message && err.message.includes('Cannot find device "wg0"')) {
throw new Error('WireGuard exited with the error: Cannot find device "wg0"\nThis usually means that your host\'s kernel does not support WireGuard!'); throw new Error('WireGuard exited with the error: Cannot find device "wg0"\nThis usually means that your host\'s kernel does not support WireGuard!');
} }
@ -156,7 +156,7 @@ AllowedIPs = ${client.address}/32`;
.trim() .trim()
.split('\n') .split('\n')
.slice(1) .slice(1)
.forEach(line => { .forEach((line) => {
const [ const [
publicKey, publicKey,
preSharedKey, // eslint-disable-line no-unused-vars preSharedKey, // eslint-disable-line no-unused-vars
@ -168,7 +168,7 @@ AllowedIPs = ${client.address}/32`;
persistentKeepalive, persistentKeepalive,
] = line.split('\t'); ] = line.split('\t');
const client = clients.find(client => client.publicKey === publicKey); const client = clients.find((client) => client.publicKey === publicKey);
if (!client) return; if (!client) return;
client.latestHandshakeAt = latestHandshakeAt === '0' client.latestHandshakeAt = latestHandshakeAt === '0'
@ -233,7 +233,7 @@ Endpoint = ${WG_HOST}:${WG_PORT}`;
// Calculate next IP // Calculate next IP
let address; let address;
for (let i = 2; i < 255; i++) { for (let i = 2; i < 255; i++) {
const client = Object.values(config.clients).find(client => { const client = Object.values(config.clients).find((client) => {
return client.address === WG_DEFAULT_ADDRESS.replace('x', i); return client.address === WG_DEFAULT_ADDRESS.replace('x', i);
}); });

Loading…
Cancel
Save