Commit f9a9c0ba authored by wei.xuan's avatar wei.xuan

feat: add custom dns support

parent eed87e45
......@@ -21,6 +21,8 @@ var (
pprof bool
natServer string
account string
dnsServer string
enableDNS bool
)
var (
......@@ -36,16 +38,10 @@ func init() {
flag.BoolVar(&pprof, "pprof", false, "enable pprof")
flag.StringVar(&natServer, "natServer", common.DefNatAddr, "natServer")
flag.StringVar(&account, "account", "unknown", "account")
flag.StringVar(&dnsServer, "dnsServer", common.DNSServer, "custom dns server")
flag.BoolVar(&enableDNS, "enableDns", false, "enable custom dns server")
flag.Parse()
// for android
net.DefaultResolver = &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
return net.Dial("udp", common.DNSServer)
},
}
}
func initPprof() {
......@@ -56,6 +52,16 @@ func initPprof() {
log.Printf("enable pprof: %s", common.PprofAddr)
log.Fatal(http.ListenAndServe(common.PprofAddr, nil))
}()
// for android
if enableDNS {
net.DefaultResolver = &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
return net.Dial("udp", dnsServer)
},
}
}
}
func main() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment