diff --git a/src/server/utils/WireGuard.ts b/src/server/utils/WireGuard.ts index 1ae62182..80c7ac45 100644 --- a/src/server/utils/WireGuard.ts +++ b/src/server/utils/WireGuard.ts @@ -201,6 +201,7 @@ class WireGuard { async cronJob() { const clients = await Database.clients.getAll(); + let needsSave = false; // Expires Feature for (const client of clients) { if (client.enabled !== true) continue; @@ -210,6 +211,7 @@ class WireGuard { ) { WG_DEBUG(`Client ${client.id} expired.`); await Database.clients.toggle(client.id, false); + needsSave = true; } } // One Time Link Feature @@ -220,10 +222,13 @@ class WireGuard { ) { WG_DEBUG(`OneTimeLink for Client ${client.id} expired.`); await Database.oneTimeLinks.delete(client.id); + // otl does not need wireguard sync } } - await this.saveConfig(); + if (needsSave) { + await this.saveConfig(); + } } }