1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

DNS: refine Android bootstrap DNS logic (#767)

This commit is contained in:
CalmLong 2021-03-10 21:23:15 +08:00 committed by GitHub
parent d15d6a7beb
commit 630ec22108
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 18 deletions

View File

@ -160,10 +160,6 @@ func (c *DNSConfig) Build() (*dns.Config, error) {
config.NameServer = append(config.NameServer, ns)
}
if BootstrapDNS() {
newError("Bootstrap DNS: ", bootstrapDNS).AtWarning().WriteToLog()
}
if c.Hosts != nil && len(c.Hosts) > 0 {
domains := make([]string, 0, len(c.Hosts))
for domain := range c.Hosts {

View File

@ -1,9 +0,0 @@
// +build !android
package conf
const bootstrapDNS = ""
func BootstrapDNS() bool {
return false
}

View File

@ -7,12 +7,11 @@ import (
"net"
)
const bootstrapDNS = "8.8.8.8:53"
func BootstrapDNS() bool {
func init() {
const bootstrapDNS = "8.8.8.8:53"
var dialer net.Dialer
net.DefaultResolver = &net.Resolver{
PreferGo: false,
PreferGo: true,
Dial: func(context context.Context, _, _ string) (net.Conn, error) {
conn, err := dialer.DialContext(context, "udp", bootstrapDNS)
if err != nil {
@ -21,5 +20,5 @@ func BootstrapDNS() bool {
return conn, nil
},
}
return true
newError("Bootstrap DNS: ", bootstrapDNS).AtWarning().WriteToLog()
}