[client] Add macOS default resolvers as fallback#5201
Conversation
📝 WalkthroughWalkthroughThe changes implement concurrency-safe tracking and retrieval of original nameservers in the macOS DNS configurator. DNS parsing was expanded to accumulate all server addresses, with a new accessor method providing thread-safe read access. Fallback handler deregistration logic was added for when no original nameservers exist. Test coverage includes unit tests for the getter, system DNS loading, and nameserver persistence across configuration transitions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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 |
828ab9b to
0d2ff11
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@client/internal/dns/host_darwin_test.go`:
- Around line 114-120: The test uses an incorrect struct field name for
systemConfigurator: change the literal field originalNameservers to the actual
field name origNameservers so the struct literal matches the systemConfigurator
definition (update the initializer that sets the nameserver slice in the test
where systemConfigurator is constructed).
In `@client/internal/dns/host_darwin.go`:
- Around line 252-256: The code only assigns dnsSettings.ServerIP for IPv4
addresses, leaving it invalid on IPv6-only systems; update the loop that parses
addresses (netip.ParseAddr) so dnsSettings.ServerIP is set to the first valid
address as a fallback but still prefer IPv4: when iterating addresses, append
ip.Unmap() to dnsSettings.ServerAddresses as before; if dnsSettings.ServerIP is
not valid, set it to ip.Unmap(); if ip.Is4() then always assign/overwrite
dnsSettings.ServerIP with ip.Unmap() so IPv4 wins when present but IPv6-only
systems still get a usable ServerIP for addLocalDNS.
- Around line 12-15: Assigning dnsSettings.ServerAddresses to s.origNameservers
creates a shared mutable reference; change the write to store a defensive copy
using slices.Clone (e.g., set s.origNameservers =
slices.Clone(dnsSettings.ServerAddresses)) to match the read-side defensive
clone in the code that uses slices.Clone when returning nameservers, and remove
any comment or conditional about Go version compatibility since slices is
supported (no need to worry about Go 1.25).
0d2ff11 to
144700c
Compare
|



Describe your changes
This PR adds the detected default upstream nameserves as fallback handlers in the handler chain (prio -100).
This is useful if there is a dns route like
test.example.orgthat makes macOS use the whole zone as match domain.Now if there is no other upstream nameserver configured, requests to
morespecific.test.example.orgwould fail since they're not matched by said DNS route.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
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.