|
|
|
@ -17,20 +17,22 @@ import (
|
|
|
|
|
"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 }
|
|
|
|
|