From 229ef1f4245ffc06a93687d0e8ece8983aefbcac Mon Sep 17 00:00:00 2001 From: M09Ic Date: Thu, 6 Jun 2024 18:21:26 +0800 Subject: [PATCH] fix socks auth not work bug --- internal/ihttp/client.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/ihttp/client.go b/internal/ihttp/client.go index a2fa8f4..5127c0d 100644 --- a/internal/ihttp/client.go +++ b/internal/ihttp/client.go @@ -145,7 +145,16 @@ func customDialFunc(proxyAddr string, timeout time.Duration) fasthttp.DialFunc { } if strings.ToLower(u.Scheme) == "socks5" { return func(addr string) (net.Conn, error) { - dialer, err := proxy.SOCKS5("tcp", u.Host, nil, proxy.Direct) + var auth *proxy.Auth + username := u.User.Username() + password, ok := u.User.Password() + if ok { + auth = &proxy.Auth{ + User: username, + Password: password, + } + } + dialer, err := proxy.SOCKS5("tcp", u.Host, auth, proxy.Direct) if err != nil { return nil, err }