diff --git a/src/server/utils/WireGuard.ts b/src/server/utils/WireGuard.ts index 54f37d24..a297a395 100644 --- a/src/server/utils/WireGuard.ts +++ b/src/server/utils/WireGuard.ts @@ -45,6 +45,8 @@ class WireGuard { } debug('Loading configuration...'); + // TODO: Better way to invalidate cache + this.#configCache = null; try { const config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8'); const parsedConfig = JSON.parse(config); @@ -77,7 +79,7 @@ class WireGuard { const config = await this.__buildConfig(); await this.__saveConfig(config); - await exec('wg-quick down wg0').catch(() => {}); + await exec('wg-quick down wg0').catch(() => { }); await exec('wg-quick up wg0').catch((err) => { if ( err && @@ -130,9 +132,8 @@ PostDown = ${WG_POST_DOWN} # Client: ${client.name} (${clientId}) [Peer] PublicKey = ${client.publicKey} -${ - client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' -}AllowedIPs = ${client.address}/32`; +${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' + }AllowedIPs = ${client.address}/32`; } debug('Config saving...'); @@ -233,9 +234,8 @@ ${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\ [Peer] PublicKey = ${config.server.publicKey} -${ - client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' -}AllowedIPs = ${WG_ALLOWED_IPS} +${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : '' + }AllowedIPs = ${WG_ALLOWED_IPS} PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE} Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`; } @@ -387,7 +387,7 @@ Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`; // Shutdown wireguard async Shutdown() { - await exec('wg-quick down wg0').catch(() => {}); + await exec('wg-quick down wg0').catch(() => { }); } }