mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-25 19:15:34 +00:00
net/dnscache: initialize the single Resolver more directly
This commit is contained in:
parent
d07146aafb
commit
d44325295e
@ -17,20 +17,22 @@
|
||||
"golang.org/x/sync/singleflight"
|
||||
)
|
||||
|
||||
var single = func() *Resolver {
|
||||
r := &Resolver{
|
||||
Forward: &net.Resolver{PreferGo: true},
|
||||
}
|
||||
var single = &Resolver{
|
||||
Forward: &net.Resolver{PreferGo: preferGoResolver()},
|
||||
}
|
||||
|
||||
func preferGoResolver() bool {
|
||||
// There does not appear to be a local resolver running
|
||||
// on iOS, and NetworkExtension is good at isolating DNS.
|
||||
// So do not use the Go resolver on macOS/iOS.
|
||||
if runtime.GOOS == "darwin" {
|
||||
r.Forward.PreferGo = false
|
||||
return false
|
||||
}
|
||||
|
||||
return r
|
||||
}()
|
||||
// Otherwise, the Go resolver is fine and slightly preferred
|
||||
// since it's lighter, not using cgo calls & threads.
|
||||
return true
|
||||
}
|
||||
|
||||
// Get returns a caching Resolver singleton.
|
||||
func Get() *Resolver { return single }
|
||||
|
Loading…
Reference in New Issue
Block a user