Update WireGuard.js
This commit is contained in:
parent
1a11c6f396
commit
8800cd9b0d
|
@ -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…
Reference in New Issue