cleanup: serversInfo: parse host from ServerAddrStr with ExtractHostAndPort

Use only one method to parse host from port.
This commit is contained in:
Markus Linnala 2019-10-20 18:11:08 +03:00 committed by Frank Denis
parent 659ff4b19d
commit 147078d588
1 changed files with 1 additions and 2 deletions

View File

@ -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) { func fetchDoHServerInfo(proxy *Proxy, name string, stamp stamps.ServerStamp, isNew bool) (ServerInfo, error) {
if len(stamp.ServerAddrStr) > 0 { if len(stamp.ServerAddrStr) > 0 {
addrStr := stamp.ServerAddrStr ipOnly, _ := ExtractHostAndPort(stamp.ServerAddrStr, -1)
ipOnly := addrStr[:strings.LastIndex(addrStr, ":")]
proxy.xTransport.cachedIPs.Lock() proxy.xTransport.cachedIPs.Lock()
proxy.xTransport.cachedIPs.cache[stamp.ProviderName] = ipOnly proxy.xTransport.cachedIPs.cache[stamp.ProviderName] = ipOnly
proxy.xTransport.cachedIPs.Unlock() proxy.xTransport.cachedIPs.Unlock()