From 147078d588b59e7e8f255f3c83d7546b5778c504 Mon Sep 17 00:00:00 2001 From: Markus Linnala Date: Sun, 20 Oct 2019 18:11:08 +0300 Subject: [PATCH] cleanup: serversInfo: parse host from ServerAddrStr with ExtractHostAndPort Use only one method to parse host from port. --- dnscrypt-proxy/serversInfo.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dnscrypt-proxy/serversInfo.go b/dnscrypt-proxy/serversInfo.go index c4b00858..39c9e4d1 100644 --- a/dnscrypt-proxy/serversInfo.go +++ b/dnscrypt-proxy/serversInfo.go @@ -327,8 +327,7 @@ func fetchDNSCryptServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp func fetchDoHServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isNew bool) (ServerInfo, error) { if len(stamp.ServerAddrStr) > 0 { - addrStr := stamp.ServerAddrStr - ipOnly := addrStr[:strings.LastIndex(addrStr, ":")] + ipOnly, _ := ExtractHostAndPort(stamp.ServerAddrStr, -1) proxy.xTransport.cachedIPs.Lock() proxy.xTransport.cachedIPs.cache[stamp.ProviderName] = ipOnly proxy.xTransport.cachedIPs.Unlock()