Skip to content

Commit

Permalink
upstream: imp docs
Browse files Browse the repository at this point in the history
  • Loading branch information
schzhn committed Nov 28, 2024
1 parent 0e89c40 commit 4170865
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions upstream/doh.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,14 @@ func (p *dnsOverHTTPS) Close() (err error) {
return err
}

// closeClient cleans up resources used by client if necessary. Note, that at
// this point it should only be done for HTTP/3 as it may leak due to keep-alive
// connections.
// closeClient cleans up resources used by client if necessary. Note that this
// should be done for HTTP/3, as it can lead to resource leaks due to keep-alive
// connections, and for HTTP/2 due to idle connections.
func (p *dnsOverHTTPS) closeClient(client *http.Client) (err error) {
if p.transportH2 != nil {
p.transportH2.CloseIdleConnections()
}

if isHTTP3(client) {
return client.Transport.(io.Closer).Close()
} else if p.transportH2 != nil {
p.transportH2.CloseIdleConnections()
}

return nil
Expand Down Expand Up @@ -481,16 +479,13 @@ func (p *dnsOverHTTPS) createTransport() (t http.RoundTripper, err error) {
// Explicitly configure transport to use HTTP/2.
//
// See https://github.com/AdguardTeam/dnsproxy/issues/11.
var transportH2 *http2.Transport
transportH2, err = http2.ConfigureTransports(transport)
p.transportH2, err = http2.ConfigureTransports(transport)
if err != nil {
return nil, err
}

// Enable HTTP/2 pings on idle connections.
transportH2.ReadIdleTimeout = transportDefaultReadIdleTimeout

p.transportH2 = transportH2
p.transportH2.ReadIdleTimeout = transportDefaultReadIdleTimeout

return transport, nil
}
Expand Down

0 comments on commit 4170865

Please sign in to comment.