Skip DNS resolution on Tor services
This commit is contained in:
parent
0a535e28ab
commit
4b001e3b8e
|
@ -200,10 +200,14 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
host := url.Host
|
host := url.Host
|
||||||
|
resolveByProxy := false
|
||||||
|
if strings.HasSuffix(host, ".onion") {
|
||||||
|
resolveByProxy = true
|
||||||
|
}
|
||||||
xTransport.cachedIPs.RLock()
|
xTransport.cachedIPs.RLock()
|
||||||
cachedIP := xTransport.cachedIPs.cache[host]
|
cachedIP := xTransport.cachedIPs.cache[host]
|
||||||
xTransport.cachedIPs.RUnlock()
|
xTransport.cachedIPs.RUnlock()
|
||||||
if !xTransport.ignoreSystemDNS || len(cachedIP) > 0 {
|
if !xTransport.ignoreSystemDNS || len(cachedIP) > 0 || resolveByProxy {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
resp, err = client.Do(req)
|
resp, err = client.Do(req)
|
||||||
|
@ -242,7 +246,6 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
|
||||||
xTransport.cachedIPs.cache[host] = *foundIP
|
xTransport.cachedIPs.cache[host] = *foundIP
|
||||||
xTransport.cachedIPs.Unlock()
|
xTransport.cachedIPs.Unlock()
|
||||||
dlog.Debugf("[%s] IP address [%s] added to the cache", host, *foundIP)
|
dlog.Debugf("[%s] IP address [%s] added to the cache", host, *foundIP)
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
rtt := time.Since(start)
|
rtt := time.Since(start)
|
||||||
|
|
Loading…
Reference in New Issue