From cf361bb9b1aac78350b29f11759bf4d687671308 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 1 Apr 2021 22:54:40 -0700 Subject: [PATCH] net/dns: remove PerDomain from Config. It's currently unused, and no longer makes sense with the upcoming DNS infrastructure. Keep it in tailcfg for now, since we need protocol compat for a bit longer. Signed-off-by: David Anderson --- ipn/ipnlocal/local.go | 1 - net/dns/config.go | 10 +--------- net/dns/manager.go | 16 ++-------------- net/dns/manager_linux.go | 3 +-- tailcfg/tailcfg.go | 9 ++++----- 5 files changed, 8 insertions(+), 31 deletions(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index 6f24c1f5c..62056b048 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -1452,7 +1452,6 @@ func (b *LocalBackend) authReconfig() { rcfg.DNS = dns.Config{ Nameservers: nm.DNS.Nameservers, Domains: nm.DNS.Domains, - PerDomain: nm.DNS.PerDomain, Proxied: proxied, } } diff --git a/net/dns/config.go b/net/dns/config.go index db08df7aa..e89eda86e 100644 --- a/net/dns/config.go +++ b/net/dns/config.go @@ -17,11 +17,6 @@ type Config struct { Nameservers []netaddr.IP // Domains are the search domains to use. Domains []string - // PerDomain indicates whether it is preferred to use Nameservers - // only for DNS queries for subdomains of Domains. - // Note that Nameservers may still be applied to all queries - // if the manager does not support per-domain settings. - PerDomain bool // Proxied indicates whether DNS requests are proxied through a dns.Resolver. // This enables MagicDNS. Proxied bool @@ -30,7 +25,7 @@ type Config struct { // Equal determines whether its argument and receiver // represent equivalent DNS configurations (then DNS reconfig is a no-op). func (lhs Config) Equal(rhs Config) bool { - if lhs.Proxied != rhs.Proxied || lhs.PerDomain != rhs.PerDomain { + if lhs.Proxied != rhs.Proxied { return false } @@ -71,7 +66,4 @@ type ManagerConfig struct { // Cleanup indicates that the manager is created for cleanup only. // A no-op manager will be instantiated if the system needs no cleanup. Cleanup bool - // PerDomain indicates that a manager capable of per-domain configuration is preferred. - // Certain managers are per-domain only; they will not be considered if this is false. - PerDomain bool } diff --git a/net/dns/manager.go b/net/dns/manager.go index 3c0ca6838..6e6d4cd92 100644 --- a/net/dns/manager.go +++ b/net/dns/manager.go @@ -45,10 +45,8 @@ type Manager struct { func NewManager(mconfig ManagerConfig) *Manager { mconfig.Logf = logger.WithPrefix(mconfig.Logf, "dns: ") m := &Manager{ - logf: mconfig.Logf, - impl: newManager(mconfig), - - config: Config{PerDomain: mconfig.PerDomain}, + logf: mconfig.Logf, + impl: newManager(mconfig), mconfig: mconfig, } @@ -72,16 +70,6 @@ func (m *Manager) Set(config Config) error { return err } - // Switching to and from per-domain mode may require a change of manager. - if config.PerDomain != m.config.PerDomain { - if err := m.impl.Down(); err != nil { - return err - } - m.mconfig.PerDomain = config.PerDomain - m.impl = newManager(m.mconfig) - m.logf("switched to %T", m.impl) - } - err := m.impl.Up(config) // If we save the config, we will not retry next time. Only do this on success. if err == nil { diff --git a/net/dns/manager_linux.go b/net/dns/manager_linux.go index f53aed7d3..6f995d4bf 100644 --- a/net/dns/manager_linux.go +++ b/net/dns/manager_linux.go @@ -6,8 +6,7 @@ package dns func newManager(mconfig ManagerConfig) managerImpl { switch { - // systemd-resolved should only activate per-domain. - case isResolvedActive() && mconfig.PerDomain: + case isResolvedActive(): if mconfig.Cleanup { return newNoopManager(mconfig) } else { diff --git a/tailcfg/tailcfg.go b/tailcfg/tailcfg.go index 0c8f1f83d..2ab061b63 100644 --- a/tailcfg/tailcfg.go +++ b/tailcfg/tailcfg.go @@ -769,13 +769,12 @@ type DNSConfig struct { Nameservers []netaddr.IP `json:",omitempty"` // Domains are the search domains to use. Domains []string `json:",omitempty"` - // PerDomain indicates whether it is preferred to use Nameservers - // only for DNS queries for subdomains of Domains. - // Some OSes and OS configurations don't support per-domain DNS configuration, - // in which case Nameservers applies to all DNS requests regardless of PerDomain's value. + // PerDomain is not set by the control server, and does nothing. + // TODO(danderson): revise DNS configuration to make this useful + // again. PerDomain bool // Proxied indicates whether DNS requests are proxied through a dns.Resolver. - // This enables MagicDNS. It is togglable independently of PerDomain. + // This enables MagicDNS. Proxied bool }