From 4a672d3de7ff3fb670b31f2623fc5a66db6417f6 Mon Sep 17 00:00:00 2001 From: y1n Date: Tue, 6 Dec 2022 22:42:24 +0800 Subject: [PATCH 1/2] Fixed a error caused by more @ character during proxy authentication --- fasthttpproxy/http.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fasthttpproxy/http.go b/fasthttpproxy/http.go index b814a4ccd5..a938a9d53b 100644 --- a/fasthttpproxy/http.go +++ b/fasthttpproxy/http.go @@ -34,9 +34,12 @@ func FasthttpHTTPDialer(proxy string) fasthttp.DialFunc { func FasthttpHTTPDialerTimeout(proxy string, timeout time.Duration) fasthttp.DialFunc { var auth string if strings.Contains(proxy, "@") { - split := strings.Split(proxy, "@") - auth = base64.StdEncoding.EncodeToString([]byte(split[0])) - proxy = split[1] + index := strings.LastIndex(proxy, "@") + auth = base64.StdEncoding.EncodeToString([]byte(proxy[:index])) + proxy = proxy[index:][1:] + //split := strings.Split(proxy, "@") + //auth = base64.StdEncoding.EncodeToString([]byte(split[0])) + //proxy = split[1] } return func(addr string) (net.Conn, error) { From 8ca13dff8a09187fd943cbd7200b03e897f64015 Mon Sep 17 00:00:00 2001 From: y1n Date: Wed, 7 Dec 2022 16:53:01 +0800 Subject: [PATCH 2/2] Fixed a error caused by more @ character during proxy authentication --- fasthttpproxy/http.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fasthttpproxy/http.go b/fasthttpproxy/http.go index a938a9d53b..9dd5a255be 100644 --- a/fasthttpproxy/http.go +++ b/fasthttpproxy/http.go @@ -36,10 +36,7 @@ func FasthttpHTTPDialerTimeout(proxy string, timeout time.Duration) fasthttp.Dia if strings.Contains(proxy, "@") { index := strings.LastIndex(proxy, "@") auth = base64.StdEncoding.EncodeToString([]byte(proxy[:index])) - proxy = proxy[index:][1:] - //split := strings.Split(proxy, "@") - //auth = base64.StdEncoding.EncodeToString([]byte(split[0])) - //proxy = split[1] + proxy = proxy[index+1:] } return func(addr string) (net.Conn, error) {