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:
@@ -346,8 +346,11 @@ final class NetCore: ObservableObject {
|
||||
try? await Task.sleep(for: .seconds(4))
|
||||
guard !Task.isCancelled else { return }
|
||||
let now = Self.physicalAddresses()
|
||||
let moved = lastAddresses != nil && now != lastAddresses && !now.isEmpty
|
||||
lastAddresses = now
|
||||
// A moment without an address (DHCP renew, Wi-Fi blip) is not another network:
|
||||
// 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 {
|
||||
// Another network: the WireGuard tunnels (Amnezia, clients) are still bound to
|
||||
// the old address — a clean core restart re-binds them without leaking.
|
||||
|
||||
Reference in New Issue
Block a user