mirror of
https://github.com/DNSCrypt/dnscrypt-proxy.git
synced 2025-01-01 00:57:32 +01:00
cleanup: xtransport: move onion check earlier to fail fast
This commit is contained in:
parent
df03065eaf
commit
345ec56cab
@ -211,6 +211,10 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
|
|||||||
url2.RawQuery = qs.Encode()
|
url2.RawQuery = qs.Encode()
|
||||||
url = &url2
|
url = &url2
|
||||||
}
|
}
|
||||||
|
host, _ := ExtractHostAndPort(url.Host, 0)
|
||||||
|
if xTransport.proxyDialer == nil && strings.HasSuffix(host, ".onion") {
|
||||||
|
return nil, 0, errors.New("Onion service is not reachable without Tor")
|
||||||
|
}
|
||||||
req := &http.Request{
|
req := &http.Request{
|
||||||
Method: method,
|
Method: method,
|
||||||
URL: url,
|
URL: url,
|
||||||
@ -223,10 +227,6 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string,
|
|||||||
req.Body = bc
|
req.Body = bc
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
host, _ := ExtractHostAndPort(url.Host, 0)
|
|
||||||
if xTransport.proxyDialer == nil && strings.HasSuffix(host, ".onion") {
|
|
||||||
return nil, 0, errors.New("Onion service is not reachable without Tor")
|
|
||||||
}
|
|
||||||
resolveByProxy := false
|
resolveByProxy := false
|
||||||
if xTransport.proxyDialer != nil || xTransport.httpProxyFunction != nil {
|
if xTransport.proxyDialer != nil || xTransport.httpProxyFunction != nil {
|
||||||
resolveByProxy = true
|
resolveByProxy = true
|
||||||
|
Loading…
Reference in New Issue
Block a user