fix: gateway robustness — re-detect on user actions and VPN interface changes#10
Merged
fix: gateway robustness — re-detect on user actions and VPN interface changes#10
Conversation
Gateway was stale when VPN switched interfaces (e.g. utun4 → utun5), causing addDomain/toggleDomain to silently skip route application. Now all user-triggered actions re-detect the gateway if nil, VPN interface changes trigger automatic re-routing, and NWPathMonitor tracks interface names (not just types) to catch utun transitions.
- Reset lastInterfaceNames in restartNetworkMonitor() (was missing after PR addition) - Fix data race on networkDebounceWorkItem by moving access to main thread - Guard interface != nil in VPN switch handler to prevent spurious re-routes - Make ensureGateway() time-aware (re-detect if >10s stale, not just nil) - Add 10s cooldown for VPN interface flapping to prevent rapid re-route storms - Validate gateway as IPv4 in getGatewayForService and parseDefaultGateway - Replace isApplyingRoutes Bool with ref-counted begin/endApplyingRoutes() - Replace force-unwrap in ensureGateway() with safe if-let binding - Bump CFBundleVersion to 20 - Revert Cask version to 1.8.0 (let make full-release handle version+SHA atomically)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
addDomain,toggleDomain,toggleService,retryFailedDomain,setAllDomainsEnabled, andsetAllServicesEnablednow callensureGateway()inside their async Tasks, re-detecting the gateway if it's nil instead of silently skipping route applicationcheckVPNStatusnow detects when VPN stays connected but switches interfaces (e.g., utun4 → utun5) and automatically re-applies all routes through the new gatewaySet<NWInterface.InterfaceType>) missed, since all utun interfaces are.otherProblem
When VPN switched interfaces (common with GlobalProtect reconnects),
localGatewaybecame stale/nil. Adding a domain would save it to config but silently skip route application — the user saw the domain in the list and assumed it was bypassing VPN. The only workaround was manually clicking "Refresh Routes".Test plan