aboutsummaryrefslogtreecommitdiff
path: root/fasthttpproxy
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2020-04-23 15:05:56 +0200
committerGravatar Erik Dubbelboer <erik@dubbelboer.com> 2020-04-23 15:05:56 +0200
commit571315f30a6ba21a36d70cf5c2b4e3dcb871eb04 (patch)
treeadd9420bb44d72c154fe66e8ab16bbdb6303d8a8 /fasthttpproxy
parentRemove unnecessary check (diff)
downloadfasthttp-571315f30a6ba21a36d70cf5c2b4e3dcb871eb04.tar.gz
fasthttp-571315f30a6ba21a36d70cf5c2b4e3dcb871eb04.tar.bz2
fasthttp-571315f30a6ba21a36d70cf5c2b4e3dcb871eb04.zip
Only base64 the proxy auth once
Diffstat (limited to 'fasthttpproxy')
-rw-r--r--fasthttpproxy/http.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/fasthttpproxy/http.go b/fasthttpproxy/http.go
index 2879408..62de1d0 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