|
|
@ -10,15 +10,27 @@ import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"net"
|
|
|
|
"net"
|
|
|
|
|
|
|
|
"runtime"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"golang.org/x/sync/singleflight"
|
|
|
|
"golang.org/x/sync/singleflight"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var single = &Resolver{
|
|
|
|
var single = func() *Resolver {
|
|
|
|
|
|
|
|
r := &Resolver{
|
|
|
|
Forward: &net.Resolver{PreferGo: true},
|
|
|
|
Forward: &net.Resolver{PreferGo: true},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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 r
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
// Get returns a caching Resolver singleton.
|
|
|
|
// Get returns a caching Resolver singleton.
|
|
|
|
func Get() *Resolver { return single }
|
|
|
|
func Get() *Resolver { return single }
|
|
|
|