From 0f00cd27f92cee434336c6d6cde9df26286d8dbe Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 6 Sep 2021 12:02:56 +0200 Subject: [PATCH] DoH/ODoH: strip optional port number when caching a hostname Fixes #1861 --- dnscrypt-proxy/serversInfo.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dnscrypt-proxy/serversInfo.go b/dnscrypt-proxy/serversInfo.go index d4cd757d..ad91263b 100644 --- a/dnscrypt-proxy/serversInfo.go +++ b/dnscrypt-proxy/serversInfo.go @@ -482,7 +482,8 @@ func route(proxy *Proxy, name string, serverProto stamps.StampProtoType) (*Relay if len(relayCandidateStamp.ServerAddrStr) > 0 { ipOnly, _ := ExtractHostAndPort(relayCandidateStamp.ServerAddrStr, -1) if ip := ParseIP(ipOnly); ip != nil { - proxy.xTransport.saveCachedIP(relayCandidateStamp.ProviderName, ip, -1*time.Second) + host, _ := ExtractHostAndPort(relayCandidateStamp.ProviderName, -1) + proxy.xTransport.saveCachedIP(host, ip, -1*time.Second) } } dlog.Noticef("Anonymizing queries for [%v] via [%v]", name, relayName) @@ -607,7 +608,8 @@ func fetchDoHServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isN if len(stamp.ServerAddrStr) > 0 { ipOnly, _ := ExtractHostAndPort(stamp.ServerAddrStr, -1) if ip := ParseIP(ipOnly); ip != nil { - proxy.xTransport.saveCachedIP(stamp.ProviderName, ip, -1*time.Second) + host, _ := ExtractHostAndPort(stamp.ProviderName, -1) + proxy.xTransport.saveCachedIP(host, ip, -1*time.Second) } } url := &url.URL{