From 571315f30a6ba21a36d70cf5c2b4e3dcb871eb04 Mon Sep 17 00:00:00 2001 From: Erik Dubbelboer Date: Thu, 23 Apr 2020 15:05:56 +0200 Subject: [PATCH] Only base64 the proxy auth once --- fasthttpproxy/http.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fasthttpproxy/http.go b/fasthttpproxy/http.go index 2879408aaf..62de1d0bdd 100644 --- a/fasthttpproxy/http.go +++ b/fasthttpproxy/http.go @@ -18,16 +18,14 @@ import ( // Dial: fasthttpproxy.FasthttpHTTPDialer("username:password@localhost:9050"), // } func FasthttpHTTPDialer(proxy string) fasthttp.DialFunc { - return func(addr string) (net.Conn, error) { - var auth string - - if strings.Contains(proxy, "@") { - split := strings.Split(proxy, "@") - auth = base64.StdEncoding.EncodeToString([]byte(split[0])) - proxy = split[1] - - } + var auth string + if strings.Contains(proxy, "@") { + split := strings.Split(proxy, "@") + auth = base64.StdEncoding.EncodeToString([]byte(split[0])) + proxy = split[1] + } + return func(addr string) (net.Conn, error) { conn, err := fasthttp.Dial(proxy) if err != nil { return nil, err