Skip to content

Commit 41d01fd

Browse files
committed
Before probing HTTP/3, check a negative cache
When a previous probe to the same host already failed (stored as altPort == 0 in the altSupport cache), the probe is skipped and the request goes straight to HTTP/2. Fixes #3173
1 parent 24ccca0 commit 41d01fd

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

dnscrypt-proxy/xtransport.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,16 @@ func (xTransport *XTransport) Fetch(
653653

654654
if xTransport.h3Transport != nil {
655655
if xTransport.http3Probe {
656-
// Always try HTTP/3 first when http3_probe is enabled,
657-
// without checking for Alt-Svc
658-
client.Transport = xTransport.h3Transport
659-
dlog.Debugf("Probing HTTP/3 transport for [%s]", url.Host)
656+
xTransport.altSupport.RLock()
657+
altPort, inNegativeCache := xTransport.altSupport.cache[url.Host]
658+
inNegativeCache = inNegativeCache && altPort == 0
659+
xTransport.altSupport.RUnlock()
660+
if !inNegativeCache {
661+
client.Transport = xTransport.h3Transport
662+
dlog.Debugf("Probing HTTP/3 transport for [%s]", url.Host)
663+
} else {
664+
dlog.Debugf("Skipping HTTP/3 probe for [%s] - previously failed", url.Host)
665+
}
660666
} else {
661667
// Otherwise use traditional Alt-Svc detection
662668
xTransport.altSupport.RLock()

0 commit comments

Comments
 (0)