Browse Source

only sync if needed

pull/1789/head
Bernd Storath 2 months ago
parent
commit
fe4167d1e6
  1. 7
      src/server/utils/WireGuard.ts

7
src/server/utils/WireGuard.ts

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

Loading…
Cancel
Save