fix(routing): serialize route updates and correct VPN-gated route application

This commit is contained in:
2026-04-06 10:23:18 +00:00
parent 07cfe76cac
commit 68473f8550
15 changed files with 145 additions and 80 deletions

View File

@@ -267,7 +267,18 @@ export class VpnManager {
doc.vlanId = opts.vlanId;
}
this.clients.set(doc.clientId, doc);
await this.persistClient(doc);
try {
await this.persistClient(doc);
} catch (err) {
// Rollback: remove from in-memory map and daemon to stay consistent with DB
this.clients.delete(doc.clientId);
try {
await this.vpnServer!.removeClient(doc.clientId);
} catch {
// best-effort daemon cleanup
}
throw err;
}
// Sync per-client security to the running daemon
const security = this.buildClientSecurity(doc);