Skip to content

Commit 0f00cd2

Browse files
committed
DoH/ODoH: strip optional port number when caching a hostname
Fixes #1861
1 parent 8178f34 commit 0f00cd2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

dnscrypt-proxy/serversInfo.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ func route(proxy *Proxy, name string, serverProto stamps.StampProtoType) (*Relay
482482
if len(relayCandidateStamp.ServerAddrStr) > 0 {
483483
ipOnly, _ := ExtractHostAndPort(relayCandidateStamp.ServerAddrStr, -1)
484484
if ip := ParseIP(ipOnly); ip != nil {
485-
proxy.xTransport.saveCachedIP(relayCandidateStamp.ProviderName, ip, -1*time.Second)
485+
host, _ := ExtractHostAndPort(relayCandidateStamp.ProviderName, -1)
486+
proxy.xTransport.saveCachedIP(host, ip, -1*time.Second)
486487
}
487488
}
488489
dlog.Noticef("Anonymizing queries for [%v] via [%v]", name, relayName)
@@ -607,7 +608,8 @@ func fetchDoHServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isN
607608
if len(stamp.ServerAddrStr) > 0 {
608609
ipOnly, _ := ExtractHostAndPort(stamp.ServerAddrStr, -1)
609610
if ip := ParseIP(ipOnly); ip != nil {
610-
proxy.xTransport.saveCachedIP(stamp.ProviderName, ip, -1*time.Second)
611+
host, _ := ExtractHostAndPort(stamp.ProviderName, -1)
612+
proxy.xTransport.saveCachedIP(host, ip, -1*time.Second)
611613
}
612614
}
613615
url := &url.URL{

0 commit comments

Comments
 (0)