Skip to content

Commit 59a1b84

Browse files
qbitbradfitz
authored andcommitted
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> (cherry picked from commit 411c6c3)
1 parent 296d10a commit 59a1b84

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

net/dns/resolvd.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"regexp"
1717
"strings"
1818

19+
"inet.af/netaddr"
1920
"tailscale.com/types/logger"
2021
"tailscale.com/util/dnsname"
2122
)
@@ -130,6 +131,25 @@ func (m resolvdManager) readResolvConf() (config OSConfig, err error) {
130131
config.SearchDomains = append(config.SearchDomains, fqdn)
131132
continue
132133
}
134+
135+
if strings.HasPrefix(line, "nameserver") {
136+
s := strings.TrimPrefix(line, "nameserver")
137+
parts := strings.Split(s, " # ")
138+
if len(parts) == 0 {
139+
return OSConfig{}, err
140+
}
141+
nameserver := strings.TrimSpace(parts[0])
142+
ip, err := netaddr.ParseIP(nameserver)
143+
if err != nil {
144+
return OSConfig{}, err
145+
}
146+
config.Nameservers = append(config.Nameservers, ip)
147+
continue
148+
}
149+
}
150+
151+
if err = scanner.Err(); err != nil {
152+
return OSConfig{}, err
133153
}
134154

135155
return config, nil

0 commit comments

Comments
 (0)