From 28ba20d73378a9d073028a390181630f99b154be Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 19 Apr 2021 21:30:39 -0700 Subject: [PATCH] tailcfg: add FallbackResolvers to DNSConfig. Signed-off-by: David Anderson --- tailcfg/tailcfg.go | 6 ++++-- tailcfg/tailcfg_clone.go | 17 +++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 1964b7ce0..08e4c962b 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -849,6 +849,10 @@ type DNSConfig struct { // Map keys must be fully-qualified DNS name suffixes, with a // trailing dot but no leading dot. Routes map[string][]DNSResolver `json:",omitempty"` + // FallbackResolvers is like Resolvers, but is only used if a + // split DNS configuration is requested in a configuration that + // doesn't work yet without explicit default resolvers. + FallbackResolvers []DNSResolver `json:",omitempty"` // Domains are the search domains to use. // Search domains must be FQDNs, but *without* the trailing dot. Domains []string `json:",omitempty"` @@ -865,8 +869,6 @@ type DNSConfig struct { Nameservers []netaddr.IP `json:",omitempty"` // PerDomain is not set by the control server, and does nothing. - // TODO(danderson): revise DNS configuration to make this useful - // again. PerDomain bool `json:",omitempty"` } diff --git a/tailcfg/tailcfg_clone.go b/tailcfg/tailcfg_clone.go index c21fcebe1..e6beefa01 100644 --- a/tailcfg/tailcfg_clone.go +++ b/tailcfg/tailcfg_clone.go @@ -198,6 +198,10 @@ func (src *DNSConfig) Clone() *DNSConfig { dst.Routes[k] = append([]DNSResolver{}, src.Routes[k]...) } } + dst.FallbackResolvers = make([]DNSResolver, len(src.FallbackResolvers)) + for i := range dst.FallbackResolvers { + dst.FallbackResolvers[i] = *src.FallbackResolvers[i].Clone() + } dst.Domains = append(src.Domains[:0:0], src.Domains...) dst.Nameservers = append(src.Nameservers[:0:0], src.Nameservers...) return dst @@ -206,12 +210,13 @@ func (src *DNSConfig) Clone() *DNSConfig { // A compilation failure here means this code must be regenerated, with command: // tailscale.com/cmd/cloner -type User,Node,Hostinfo,NetInfo,Login,DNSConfig,DNSResolver,RegisterResponse var _DNSConfigNeedsRegeneration = DNSConfig(struct { - Resolvers []DNSResolver - Routes map[string][]DNSResolver - Domains []string - Proxied bool - Nameservers []netaddr.IP - PerDomain bool + Resolvers []DNSResolver + Routes map[string][]DNSResolver + FallbackResolvers []DNSResolver + Domains []string + Proxied bool + Nameservers []netaddr.IP + PerDomain bool }{}) // Clone makes a deep copy of DNSResolver.