Browse Source

invalidate cache to make restoreConfig work

pull/1244/head
Bernd Storath 12 months ago
parent
commit
cc673785de
  1. 8
      src/server/utils/WireGuard.ts

8
src/server/utils/WireGuard.ts

@ -45,6 +45,8 @@ class WireGuard {
} }
debug('Loading configuration...'); debug('Loading configuration...');
// TODO: Better way to invalidate cache
this.#configCache = null;
try { try {
const config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8'); const config = await fs.readFile(path.join(WG_PATH, 'wg0.json'), 'utf8');
const parsedConfig = JSON.parse(config); const parsedConfig = JSON.parse(config);
@ -130,8 +132,7 @@ PostDown = ${WG_POST_DOWN}
# Client: ${client.name} (${clientId}) # Client: ${client.name} (${clientId})
[Peer] [Peer]
PublicKey = ${client.publicKey} PublicKey = ${client.publicKey}
${ ${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
}AllowedIPs = ${client.address}/32`; }AllowedIPs = ${client.address}/32`;
} }
@ -233,8 +234,7 @@ ${WG_MTU ? `MTU = ${WG_MTU}\n` : ''}\
[Peer] [Peer]
PublicKey = ${config.server.publicKey} PublicKey = ${config.server.publicKey}
${ ${client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
client.preSharedKey ? `PresharedKey = ${client.preSharedKey}\n` : ''
}AllowedIPs = ${WG_ALLOWED_IPS} }AllowedIPs = ${WG_ALLOWED_IPS}
PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE} PersistentKeepalive = ${WG_PERSISTENT_KEEPALIVE}
Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`; Endpoint = ${WG_HOST}:${WG_CONFIG_PORT}`;

Loading…
Cancel
Save