Closed PeerXu closed 3 years ago
this is armon go-sock5 lib,not my this is the client request method then server try to match your request method,
func (sf *Server) authenticate(conn io.Writer, bufConn io.Reader,userAddr string, methods []byte) (*AuthContext, error) {
// Select a usable method
for _, auth := range sf.authMethods {
for _, method := range methods {
if auth.GetCode() == method {
return auth.Authenticate(bufConn, conn, userAddr)
}
}
}
the code just match the method you client request, not for ordered match.
@PeerXu see the code again, may a good feature. mathed ordered method
Thanks to share the great SOCKS5 library for golang, help me to implement a custom SOCKS5 server easily.
Problem:
In my situation, I need to try user-password method at first, if not required on client, try no-auth method later.
Solving:
I merge
Server.authMethods
andServer.authCustomMethods
toServer.authMethods
.Then Server check client request methods orderly, with
WithAuthMethods()
.