Skip to content

Commit

Permalink
Only base64 the proxy auth once
Browse files Browse the repository at this point in the history
  • Loading branch information
erikdubbelboer committed Apr 23, 2020
1 parent 503e363 commit 571315f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions fasthttpproxy/http.go
Expand Up @@ -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
Expand Down

0 comments on commit 571315f

Please sign in to comment.