From e23b6470b361154aca3f007752a8e6d1e710081b Mon Sep 17 00:00:00 2001 From: shimonoe Date: Mon, 24 Jul 2017 09:53:40 -0300 Subject: [PATCH 1/2] Changelog: - Added support for socks5 on http.Transport as a proxy --- gorequest.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gorequest.go b/gorequest.go index f928ca3..dcda8f0 100644 --- a/gorequest.go +++ b/gorequest.go @@ -30,6 +30,7 @@ import ( "path/filepath" "github.com/moul/http2curl" + "golang.org/x/net/proxy" "golang.org/x/net/publicsuffix" ) @@ -496,6 +497,12 @@ func (s *SuperAgent) Proxy(proxyUrl string) *SuperAgent { s.Errors = append(s.Errors, err) } else if proxyUrl == "" { s.Transport.Proxy = nil + } else if proxyUrl[:6] == "socks5" { + socks5Dialer, err := proxy.FromURL(parsedProxyUrl, proxy.Direct) + if err != nil { + s.Errors = append(s.Errors, err) + } + s.Transport = &http.Transport{Dial: socks5Dialer.Dial} } else { s.Transport.Proxy = http.ProxyURL(parsedProxyUrl) } From 087f6d25db277a2e309f9e24cb347f3613c6e1cc Mon Sep 17 00:00:00 2001 From: shimonoe Date: Wed, 26 Jul 2017 15:19:21 -0300 Subject: [PATCH 2/2] Changelog ========= - Fixed bug in socks5 detection. Parsed as a lower case and compared to "socks5" to match in case of case variation in input. --- gorequest.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gorequest.go b/gorequest.go index dcda8f0..47e93d1 100644 --- a/gorequest.go +++ b/gorequest.go @@ -497,7 +497,7 @@ func (s *SuperAgent) Proxy(proxyUrl string) *SuperAgent { s.Errors = append(s.Errors, err) } else if proxyUrl == "" { s.Transport.Proxy = nil - } else if proxyUrl[:6] == "socks5" { + } else if strings.ToLower(proxyUrl[:6]) == "socks5" { socks5Dialer, err := proxy.FromURL(parsedProxyUrl, proxy.Direct) if err != nil { s.Errors = append(s.Errors, err)