mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-10-10 04:03:11 +08:00
fix: bound doh dials so ones the query gave up on cannot pile up (#3274)
This commit is contained in:
+9
-2
@@ -383,10 +383,17 @@ func (doh *dnsOverHTTPS) createClient(ctx context.Context) (*http.Client, error)
|
||||
// HTTP3 is enabled in the upstream options). If this attempt is successful,
|
||||
// it returns an HTTP3 transport, otherwise it returns the H1/H2 transport.
|
||||
func (doh *dnsOverHTTPS) createTransport(ctx context.Context) (t http.RoundTripper, err error) {
|
||||
// http.Transport dials in a context detached from the request, so a dial
|
||||
// that the query has given up on must still end on its own.
|
||||
transport := &http.Transport{
|
||||
DisableCompression: true,
|
||||
DialContext: doh.dialer.DialContext,
|
||||
IdleConnTimeout: transportDefaultIdleConnTimeout,
|
||||
DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, dialTimeout)
|
||||
defer cancel()
|
||||
return doh.dialer.DialContext(ctx, network, addr)
|
||||
},
|
||||
IdleConnTimeout: transportDefaultIdleConnTimeout,
|
||||
TLSHandshakeTimeout: dialTimeout,
|
||||
}
|
||||
|
||||
if doh.url.Scheme == "http" {
|
||||
|
||||
Reference in New Issue
Block a user