net/dns/resolvd: store nameservers

Currently only search domains are stored. This was an oversight
(under?) on my part.

As things are now, when MagicDNS is on and "Override local DNS" is
off, the dns forwarder has to timeout before names resolve. This
introduces a pretty annoying lang that makes everything feel
extremely slow. You will also see an error: "upstream nameservers
not set".

I tested with "Override local DNS" on and off. In both situations
things seem to function as expected (and quickly).

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
pull/3775/head
Aaron Bieber 3 years ago committed by Brad Fitzpatrick
parent c64af5e676
commit 411c6c316c

@ -16,6 +16,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"inet.af/netaddr"
"tailscale.com/types/logger" "tailscale.com/types/logger"
"tailscale.com/util/dnsname" "tailscale.com/util/dnsname"
) )
@ -130,6 +131,25 @@ func (m resolvdManager) readResolvConf() (config OSConfig, err error) {
config.SearchDomains = append(config.SearchDomains, fqdn) config.SearchDomains = append(config.SearchDomains, fqdn)
continue continue
} }
if strings.HasPrefix(line, "nameserver") {
s := strings.TrimPrefix(line, "nameserver")
parts := strings.Split(s, " # ")
if len(parts) == 0 {
return OSConfig{}, err
}
nameserver := strings.TrimSpace(parts[0])
ip, err := netaddr.ParseIP(nameserver)
if err != nil {
return OSConfig{}, err
}
config.Nameservers = append(config.Nameservers, ip)
continue
}
}
if err = scanner.Err(); err != nil {
return OSConfig{}, err
} }
return config, nil return config, nil

Loading…
Cancel
Save