mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
3eb13868f2
ref https://github.com/golang/go/issues/8877 ref https://github.com/v2ray/v2ray-core/issues/1909
29 lines
558 B
Go
29 lines
558 B
Go
package conf
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
"testing"
|
|
)
|
|
|
|
func TestBootstrapDNS(t *testing.T) {
|
|
const (
|
|
defaultNS = "8.8.8.8:53"
|
|
domain = "github.com"
|
|
)
|
|
var dialer net.Dialer
|
|
net.DefaultResolver = &net.Resolver{
|
|
PreferGo: true,
|
|
Dial: func(context context.Context, network, address string) (net.Conn, error) {
|
|
conn, err := dialer.DialContext(context, "udp", defaultNS)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return conn, nil
|
|
},
|
|
}
|
|
if ips, err := net.LookupIP(domain); len(ips) == 0 {
|
|
t.Error("set BootstrapDNS failed: ", err)
|
|
}
|
|
}
|