net/dns: fix handling non-IP single split DNS
Fixes #19834 Change-Id: I4d48efed00cd080b14c6fd713ff21e53a5a6ee3c Signed-off-by: Adrian Dewhurst <adrian@tailscale.com>
This commit is contained in:
committed by
Adrian Dewhurst
parent
5295e3e119
commit
5d8f401956
+8
-6
@@ -367,12 +367,14 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
|
||||
// workaround.
|
||||
isWindows := m.goos == "windows"
|
||||
isApple := (m.goos == "darwin" || m.goos == "ios")
|
||||
if len(cfg.singleResolverSet()) > 0 && m.os.SupportsSplitDNS() && !isWindows && !isApple {
|
||||
// Split DNS configuration requested, where all split domains
|
||||
// go to the same resolvers. We can let the OS do it.
|
||||
ocfg.Nameservers = toIPsOnly(cfg.singleResolverSet())
|
||||
ocfg.MatchDomains = cfg.matchDomains()
|
||||
return rcfg, ocfg, nil
|
||||
if m.os.SupportsSplitDNS() && !isWindows && !isApple {
|
||||
if srs := toIPsOnly(cfg.singleResolverSet()); len(srs) > 0 {
|
||||
// Split DNS configuration requested, where all split domains
|
||||
// go to the same resolvers. We can let the OS do it.
|
||||
ocfg.Nameservers = srs
|
||||
ocfg.MatchDomains = cfg.matchDomains()
|
||||
return rcfg, ocfg, nil
|
||||
}
|
||||
}
|
||||
|
||||
// Split DNS configuration with either multiple upstream routes,
|
||||
|
||||
@@ -957,6 +957,23 @@ func TestManager(t *testing.T) {
|
||||
},
|
||||
goos: "windows",
|
||||
},
|
||||
{
|
||||
// Regression test for #19834
|
||||
name: "single-doh-splitdns-no-magicdns",
|
||||
in: Config{
|
||||
Routes: upstreams(
|
||||
"example.com", "http://100.101.102.103:1234/dns-query"),
|
||||
},
|
||||
split: true,
|
||||
os: OSConfig{
|
||||
Nameservers: serviceAddr46,
|
||||
MatchDomains: fqdns("example.com"),
|
||||
},
|
||||
rs: resolver.Config{
|
||||
Routes: upstreams("example.com.", "http://100.101.102.103:1234/dns-query"),
|
||||
},
|
||||
goos: "linux",
|
||||
},
|
||||
}
|
||||
|
||||
trIP := cmp.Transformer("ipStr", func(ip netip.Addr) string { return ip.String() })
|
||||
|
||||
Reference in New Issue
Block a user