Skip to content

Commit 89b36dc

Browse files
fix(http): use Google DNS by default
1 parent 6c4a487 commit 89b36dc

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

src/runtime/http/http.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package http
22

33
import (
4+
"context"
45
"net"
56
"net/http"
67
"time"
@@ -12,12 +13,23 @@ type httpClient interface {
1213
Do(req *http.Request) (*http.Response, error)
1314
}
1415

16+
func dialer() *net.Dialer {
17+
return &net.Dialer{
18+
Resolver: &net.Resolver{
19+
PreferGo: true,
20+
Dial: func(ctx context.Context, network, _ string) (net.Conn, error) {
21+
d := net.Dialer{Timeout: 10 * time.Second}
22+
return d.DialContext(ctx, network, "8.8.8.8:53") // Use Google DNS
23+
},
24+
},
25+
Timeout: 30 * time.Second,
26+
}
27+
}
28+
1529
var (
1630
defaultTransport http.RoundTripper = &http.Transport{
17-
Proxy: http.ProxyFromEnvironment,
18-
Dial: (&net.Dialer{
19-
Timeout: 10 * time.Second,
20-
}).Dial,
31+
Proxy: http.ProxyFromEnvironment,
32+
Dial: dialer().Dial,
2133
TLSHandshakeTimeout: 10 * time.Second,
2234
ResponseHeaderTimeout: 10 * time.Second,
2335
}

0 commit comments

Comments
 (0)