From 345ec56cab5eedabff0909fc59aeba1847db3bd4 Mon Sep 17 00:00:00 2001 From: Markus Linnala Date: Wed, 16 Oct 2019 13:17:57 +0300 Subject: [PATCH] cleanup: xtransport: move onion check earlier to fail fast --- dnscrypt-proxy/xtransport.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dnscrypt-proxy/xtransport.go b/dnscrypt-proxy/xtransport.go index 9bc7f14c..a4c4ab9d 100644 --- a/dnscrypt-proxy/xtransport.go +++ b/dnscrypt-proxy/xtransport.go @@ -211,6 +211,10 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string, url2.RawQuery = qs.Encode() 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{ Method: method, URL: url, @@ -223,10 +227,6 @@ func (xTransport *XTransport) Fetch(method string, url *url.URL, accept string, req.Body = bc } 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 if xTransport.proxyDialer != nil || xTransport.httpProxyFunction != nil { resolveByProxy = true