From aabc0d6fa07bc3d55f16e05c523f4db6b86ac14b Mon Sep 17 00:00:00 2001 From: Bernd Storath <999999bst@gmail.com> Date: Tue, 11 Feb 2025 09:21:47 +0100 Subject: [PATCH] fix default key gen --- src/server/utils/WireGuard.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server/utils/WireGuard.ts b/src/server/utils/WireGuard.ts index bf3e80fb..2b37b2d1 100644 --- a/src/server/utils/WireGuard.ts +++ b/src/server/utils/WireGuard.ts @@ -18,6 +18,8 @@ class WireGuard { /** * Generates and saves WireGuard config from database + * + * Make sure to pass an updated InterfaceType object */ async #saveWireguardConfig(wgInterface: InterfaceType) { const clients = await Database.clients.getAll(); @@ -122,7 +124,8 @@ class WireGuard { async Startup() { WG_DEBUG('Starting WireGuard...'); - const wgInterface = await Database.interfaces.get(); + // let as it has to refetch if keys change + let wgInterface = await Database.interfaces.get(); // default interface has no keys if ( @@ -134,6 +137,7 @@ class WireGuard { const publicKey = await wg.getPublicKey(privateKey); await Database.interfaces.updateKeyPair(privateKey, publicKey); + wgInterface = await Database.interfaces.get(); WG_DEBUG('New Wireguard Keys generated successfully.'); } WG_DEBUG(`Starting Wireguard Interface ${wgInterface.name}...`);