diff --git a/component/auth/auth.go b/component/auth/auth.go index 176b21d7..11078a06 100644 --- a/component/auth/auth.go +++ b/component/auth/auth.go @@ -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 } diff --git a/transport/socks5/socks5.go b/transport/socks5/socks5.go index 5f699bb0..c71ef3f6 100644 --- a/transport/socks5/socks5.go +++ b/transport/socks5/socks5.go @@ -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 {