1
0
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:
Cassian433
2026-10-08 12:34:41 +05:30
committed by GitHub
parent 1354e52e6f
commit 80101933c0
+9 -2
View File
@@ -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" {