Skip to content

Commit

Permalink
android: only use google dns server when the default dns server canno…
Browse files Browse the repository at this point in the history
…t be obtained (#4236)
  • Loading branch information
fatedier committed May 23, 2024
1 parent 522e2c9 commit e680acf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
### Changes

* Updated the default value of `transport.tcpMuxKeepaliveInterval` from 60 to 30.
* On the Android platform, the Google DNS server is used only when the default DNS server cannot be obtained.
8 changes: 6 additions & 2 deletions pkg/util/system/system_android.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ func fixDNSResolver() {
// Note: If there are other methods to obtain the default DNS servers, the default DNS servers should be used preferentially.
net.DefaultResolver = &net.Resolver{
PreferGo: true,
Dial: func(ctx context.Context, network, _ string) (net.Conn, error) {
return net.Dial(network, "8.8.8.8:53")
Dial: func(ctx context.Context, network, addr string) (net.Conn, error) {
if addr == "127.0.0.1:53" || addr == "[::1]:53" {
addr = "8.8.8.8:53"
}
var d net.Dialer
return d.DialContext(ctx, network, addr)
},
}
}

0 comments on commit e680acf

Please sign in to comment.