[client] Fix iOS DNS upstream routing for deselected exit nodes#5803
[client] Fix iOS DNS upstream routing for deselected exit nodes#5803
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDNS address propagation was added to the iOS startup path: Changes
Sequence Diagram(s)(omitted — changes are straightforward plumbing without new multi-component sequential flow that requires visualization) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@client/internal/dns/server.go`:
- Around line 193-199: The root-zone handler is being created too early because
addHostRootZone() is called immediately after newDefaultServer(...) and thus
captures a nil s.routeMatch before SetRouteChecker(...) is injected; remove the
immediate call to addHostRootZone() here and instead invoke addHostRootZone()
from SetRouteChecker (or make addHostRootZone lazy/refreshable) so the handler
is created after the server's routeMatch is set; update references to ds (the
server returned by newDefaultServer) to ensure addHostRootZone uses the
populated routeMatch when called.
In `@client/ios/NetBirdSDK/client.go`:
- Around line 164-168: The hostDNS list for iOS only includes IPv4 resolvers
which breaks DNS on IPv6-only networks; update the hostDNS construction used
when calling c.connectClient.RunOniOS to include IPv6 fallback addresses (e.g.,
parse and append IPv6 resolver AddrPort entries like [2606:4700:4700::1111]:53
and [2606:4700:4700::1001]:53) using netip.MustParseAddrPort so both v4 and v6
upstreams are provided to c.dnsManager; ensure the variable name hostDNS and the
call c.connectClient.RunOniOS(fd, c.networkChangeListener, c.dnsManager,
hostDNS, c.stateFile) remain unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e44a6b1f-b0dd-4421-8eeb-a7105f34d38a
📒 Files selected for processing (5)
client/internal/connect.goclient/internal/dns/server.goclient/internal/engine.goclient/internal/routemanager/notifier/notifier_ios.goclient/ios/NetBirdSDK/client.go
💤 Files with no reviewable changes (1)
- client/internal/routemanager/notifier/notifier_ios.go
| log.Debugf("iOS host dns address list is: %v", hostsDnsList) | ||
| ds := newDefaultServer(ctx, wgInterface, NewServiceViaMemory(wgInterface), statusRecorder, nil, disableSys) | ||
| ds.iosDnsManager = iosDnsManager | ||
| ds.hostsDNSHolder.set(hostsDnsList) | ||
| ds.permanent = true | ||
| ds.addHostRootZone() | ||
| return ds |
There was a problem hiding this comment.
Root fallback handler is created too early for route-aware upstream routing.
At Line 198, addHostRootZone() runs before the engine injects SetRouteChecker(...). The handler snapshots s.routeMatch at creation, so it can stay nil and skip selected-route matching.
🔧 Proposed fix (outside this hunk, in SetRouteChecker)
func (s *DefaultServer) SetRouteChecker(f func(netip.Addr) bool) {
s.mux.Lock()
defer s.mux.Unlock()
s.routeMatch = f
+ if s.permanent {
+ s.deregisterHandler([]string{nbdns.RootZone}, PriorityDefault)
+ s.addHostRootZone()
+ }
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@client/internal/dns/server.go` around lines 193 - 199, The root-zone handler
is being created too early because addHostRootZone() is called immediately after
newDefaultServer(...) and thus captures a nil s.routeMatch before
SetRouteChecker(...) is injected; remove the immediate call to addHostRootZone()
here and instead invoke addHostRootZone() from SetRouteChecker (or make
addHostRootZone lazy/refreshable) so the handler is created after the server's
routeMatch is set; update references to ds (the server returned by
newDefaultServer) to ensure addHostRootZone uses the populated routeMatch when
called.
| hostDNS := []netip.AddrPort{ | ||
| netip.MustParseAddrPort("1.1.1.1:53"), | ||
| netip.MustParseAddrPort("1.0.0.1:53"), | ||
| } | ||
| return c.connectClient.RunOniOS(fd, c.networkChangeListener, c.dnsManager, hostDNS, c.stateFile) |
There was a problem hiding this comment.
Add IPv6 fallback resolvers for iOS host DNS.
Line 164 configures only IPv4 upstreams. On IPv6-only networks, fallback DNS can fail and leave unmatched queries unresolved.
🔧 Proposed fix
hostDNS := []netip.AddrPort{
netip.MustParseAddrPort("1.1.1.1:53"),
netip.MustParseAddrPort("1.0.0.1:53"),
+ netip.MustParseAddrPort("[2606:4700:4700::1111]:53"),
+ netip.MustParseAddrPort("[2606:4700:4700::1001]:53"),
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@client/ios/NetBirdSDK/client.go` around lines 164 - 168, The hostDNS list for
iOS only includes IPv4 resolvers which breaks DNS on IPv6-only networks; update
the hostDNS construction used when calling c.connectClient.RunOniOS to include
IPv6 fallback addresses (e.g., parse and append IPv6 resolver AddrPort entries
like [2606:4700:4700::1111]:53 and [2606:4700:4700::1001]:53) using
netip.MustParseAddrPort so both v4 and v6 upstreams are provided to
c.dnsManager; ensure the variable name hostDNS and the call
c.connectClient.RunOniOS(fd, c.networkChangeListener, c.dnsManager, hostDNS,
c.stateFile) remain unchanged.
|



Describe your changes
away from the utun-bound socket after exit node deselection
DNS queries arriving via the 0.0.0.0/0 tunnel route had no handler and were silently dropped
Test plan
Issue ticket number and link
Stack
Checklist
Documentation
Select exactly one:
Docs PR URL (required if "docs added" is checked)
Paste the PR link from https://github.com/netbirdio/docs here:
https://github.com/netbirdio/docs/pull/__
Summary by CodeRabbit