net/dns: only populate OSConfig.Hosts when MagicDNS is enabled
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, illumos) (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / crossmin (amd64, solaris) (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, illumos) (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / crossmin (amd64, solaris) (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions
Previously we were doing this unconditionally. Updates #14428 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
This commit is contained in:
@ -246,8 +246,10 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
|
|||||||
// the OS.
|
// the OS.
|
||||||
rcfg.Hosts = cfg.Hosts
|
rcfg.Hosts = cfg.Hosts
|
||||||
routes := map[dnsname.FQDN][]*dnstype.Resolver{} // assigned conditionally to rcfg.Routes below.
|
routes := map[dnsname.FQDN][]*dnstype.Resolver{} // assigned conditionally to rcfg.Routes below.
|
||||||
|
var propagateHostsToOS bool
|
||||||
for suffix, resolvers := range cfg.Routes {
|
for suffix, resolvers := range cfg.Routes {
|
||||||
if len(resolvers) == 0 {
|
if len(resolvers) == 0 {
|
||||||
|
propagateHostsToOS = true
|
||||||
rcfg.LocalDomains = append(rcfg.LocalDomains, suffix)
|
rcfg.LocalDomains = append(rcfg.LocalDomains, suffix)
|
||||||
} else {
|
} else {
|
||||||
routes[suffix] = resolvers
|
routes[suffix] = resolvers
|
||||||
@ -256,7 +258,7 @@ func (m *Manager) compileConfig(cfg Config) (rcfg resolver.Config, ocfg OSConfig
|
|||||||
|
|
||||||
// Similarly, the OS always gets search paths.
|
// Similarly, the OS always gets search paths.
|
||||||
ocfg.SearchDomains = cfg.SearchDomains
|
ocfg.SearchDomains = cfg.SearchDomains
|
||||||
if m.goos == "windows" {
|
if propagateHostsToOS && m.goos == "windows" {
|
||||||
ocfg.Hosts = compileHostEntries(cfg)
|
ocfg.Hosts = compileHostEntries(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,6 +836,76 @@ func TestManager(t *testing.T) {
|
|||||||
},
|
},
|
||||||
goos: "darwin",
|
goos: "darwin",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "populate-hosts-magicdns",
|
||||||
|
in: Config{
|
||||||
|
Routes: upstreams(
|
||||||
|
"corp.com", "2.2.2.2",
|
||||||
|
"ts.com", ""),
|
||||||
|
Hosts: hosts(
|
||||||
|
"dave.ts.com.", "1.2.3.4",
|
||||||
|
"bradfitz.ts.com.", "2.3.4.5"),
|
||||||
|
SearchDomains: fqdns("ts.com", "universe.tf"),
|
||||||
|
},
|
||||||
|
split: true,
|
||||||
|
os: OSConfig{
|
||||||
|
Hosts: []*HostEntry{
|
||||||
|
{
|
||||||
|
Addr: netip.MustParseAddr("2.3.4.5"),
|
||||||
|
Hosts: []string{
|
||||||
|
"bradfitz.ts.com.",
|
||||||
|
"bradfitz",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Addr: netip.MustParseAddr("1.2.3.4"),
|
||||||
|
Hosts: []string{
|
||||||
|
"dave.ts.com.",
|
||||||
|
"dave",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Nameservers: mustIPs("100.100.100.100"),
|
||||||
|
SearchDomains: fqdns("ts.com", "universe.tf"),
|
||||||
|
MatchDomains: fqdns("corp.com", "ts.com"),
|
||||||
|
},
|
||||||
|
rs: resolver.Config{
|
||||||
|
Routes: upstreams("corp.com.", "2.2.2.2"),
|
||||||
|
Hosts: hosts(
|
||||||
|
"dave.ts.com.", "1.2.3.4",
|
||||||
|
"bradfitz.ts.com.", "2.3.4.5"),
|
||||||
|
LocalDomains: fqdns("ts.com."),
|
||||||
|
},
|
||||||
|
goos: "windows",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Regression test for https://github.com/tailscale/tailscale/issues/14428
|
||||||
|
name: "nopopulate-hosts-nomagicdns",
|
||||||
|
in: Config{
|
||||||
|
Routes: upstreams(
|
||||||
|
"corp.com", "2.2.2.2",
|
||||||
|
"ts.com", "1.1.1.1"),
|
||||||
|
Hosts: hosts(
|
||||||
|
"dave.ts.com.", "1.2.3.4",
|
||||||
|
"bradfitz.ts.com.", "2.3.4.5"),
|
||||||
|
SearchDomains: fqdns("ts.com", "universe.tf"),
|
||||||
|
},
|
||||||
|
split: true,
|
||||||
|
os: OSConfig{
|
||||||
|
Nameservers: mustIPs("100.100.100.100"),
|
||||||
|
SearchDomains: fqdns("ts.com", "universe.tf"),
|
||||||
|
MatchDomains: fqdns("corp.com", "ts.com"),
|
||||||
|
},
|
||||||
|
rs: resolver.Config{
|
||||||
|
Routes: upstreams(
|
||||||
|
"corp.com.", "2.2.2.2",
|
||||||
|
"ts.com", "1.1.1.1"),
|
||||||
|
Hosts: hosts(
|
||||||
|
"dave.ts.com.", "1.2.3.4",
|
||||||
|
"bradfitz.ts.com.", "2.3.4.5"),
|
||||||
|
},
|
||||||
|
goos: "windows",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
trIP := cmp.Transformer("ipStr", func(ip netip.Addr) string { return ip.String() })
|
trIP := cmp.Transformer("ipStr", func(ip netip.Addr) string { return ip.String() })
|
||||||
|
Reference in New Issue
Block a user