mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Add option to use custom DNS server for client
This is useful for systems like Android which doesn't follow normal DNS conventions like /etc/resolv.conf, so normal golang DNS (ie when CGO_ENABLED=0) fails on Android.
This commit is contained in:
parent
738a637385
commit
d09391cc75
13
client.go
13
client.go
@ -40,8 +40,21 @@ func NewBoringProxyClient() *BoringProxyClient {
|
||||
name := flagSet.String("client-name", "", "Client name")
|
||||
user := flagSet.String("user", "admin", "user")
|
||||
certDir := flagSet.String("cert-dir", "", "TLS cert directory")
|
||||
dnsServer := flagSet.String("dns-server", "", "Custom DNS server")
|
||||
flagSet.Parse(os.Args[2:])
|
||||
|
||||
if *dnsServer != "" {
|
||||
net.DefaultResolver = &net.Resolver{
|
||||
PreferGo: true,
|
||||
Dial: func(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
d := net.Dialer{
|
||||
Timeout: time.Millisecond * time.Duration(10000),
|
||||
}
|
||||
return d.DialContext(ctx, "udp", fmt.Sprintf("%s:53", *dnsServer))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
certmagic.DefaultACME.DisableHTTPChallenge = true
|
||||
|
||||
if *certDir != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user