Net core: a moment without an address is not a network change

When Wi-Fi briefly lost its address (DHCP renew), the empty snapshot became the baseline
and the same address coming back looked like a move, restarting the core for nothing.
Empty snapshots are ignored now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
maksarsanjeev
2026-10-16 02:24:12 +03:00
parent cd119d3b8f
commit 7e5937ab3f
+5 -2
View File
@@ -346,8 +346,11 @@ final class NetCore: ObservableObject {
try? await Task.sleep(for: .seconds(4)) try? await Task.sleep(for: .seconds(4))
guard !Task.isCancelled else { return } guard !Task.isCancelled else { return }
let now = Self.physicalAddresses() let now = Self.physicalAddresses()
let moved = lastAddresses != nil && now != lastAddresses && !now.isEmpty // A moment without an address (DHCP renew, Wi-Fi blip) is not another network:
lastAddresses = now // only a change between two real addresses counts, else the core would restart
// when the same address comes back.
let moved = !now.isEmpty && lastAddresses != nil && now != lastAddresses
if !now.isEmpty { lastAddresses = now }
if moved { if moved {
// Another network: the WireGuard tunnels (Amnezia, clients) are still bound to // Another network: the WireGuard tunnels (Amnezia, clients) are still bound to
// the old address — a clean core restart re-binds them without leaking. // the old address — a clean core restart re-binds them without leaking.