From 5cf657773f4a5e27889b79cd41da3707539b2d6f Mon Sep 17 00:00:00 2001 From: zhengrui Date: Sun, 18 Mar 2018 09:50:49 +0800 Subject: [PATCH] fix #225 --- handler.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/handler.go b/handler.go index 84162b3..515e355 100644 --- a/handler.go +++ b/handler.go @@ -95,8 +95,18 @@ func (h *autoHandler) Handle(conn net.Conn) { cc := &bufferdConn{Conn: conn, br: br} switch b[0] { case gosocks4.Ver4: - cc.Close() - return // SOCKS4(a) does not suppport authentication method, so we ignore it for security reason. + options := &HandlerOptions{} + for _, opt := range h.options { + opt(options) + } + // SOCKS4(a) does not suppport authentication method, + // so we ignore it when credentials are specified for security reason. + if len(options.Users) > 0 { + cc.Close() + return + } + h := &socks4Handler{options} + h.Handle(cc) case gosocks5.Ver5: SOCKS5Handler(h.options...).Handle(cc) default: // http