fea: support forwarding socks5.
Some checks failed
Coverage CI / build (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
Ubuntu CI / build (push) Has been cancelled

This commit is contained in:
Daniel Ding
2025-03-13 20:38:15 +08:00
parent 548e192003
commit f2abefa25e
8 changed files with 129 additions and 24 deletions

View File

@@ -22,15 +22,20 @@ func NewSocksProxy(cfg *config.SocksProxy) *SocksProxy {
// Create a SOCKS5 server
auth := cfg.Auth
authMethods := make([]socks5.Authenticator, 0, 2)
if len(auth.Username) > 0 {
if auth != nil && len(auth.Username) > 0 {
author := socks5.UserPassAuthenticator{
Credentials: socks5.StaticCredentials{
auth.Username: auth.Password,
},
}
authMethods = append(authMethods, author)
}
conf := &socks5.Config{
Backends: cfg.Backends,
AuthMethods: authMethods,
Logger: s.out,
}
conf := &socks5.Config{AuthMethods: authMethods}
server, err := socks5.New(conf)
if err != nil {
s.out.Error("NewSocksProxy %s", err)