chore: unconditionally allow clients with passwords for password-free socks5 inbound (#2123)

This commit is contained in:
ayanamist 2025-06-24 18:04:42 +08:00 committed by xishang0128
parent 2c55dc2557
commit 5c6aa433ca
No known key found for this signature in database
GPG Key ID: 02DAB1BEA331D06C
2 changed files with 12 additions and 0 deletions

View File

@ -41,3 +41,11 @@ func NewAuthenticator(users []AuthUser) Authenticator {
}
return au
}
var AlwaysValid Authenticator = alwaysValid{}
type alwaysValid struct{}
func (alwaysValid) Verify(string, string) bool { return true }
func (alwaysValid) Users() []string { return nil }

View File

@ -118,6 +118,10 @@ func ServerHandshake(rw net.Conn, authenticator auth.Authenticator) (addr Addr,
return
}
if nmethods == 1 && buf[0] == 0x02 /* will use password */ && authenticator == nil {
authenticator = auth.AlwaysValid
}
// write VER METHOD
if authenticator != nil {
if _, err = rw.Write([]byte{5, 2}); err != nil {