From b0f83e401f612d294d456730286be2ca44c82bf8 Mon Sep 17 00:00:00 2001 From: Excited Codes <61885669+ExcitedCodes@users.noreply.github.com> Date: Wed, 15 Sep 2021 16:45:57 +0800 Subject: [PATCH] Fix: socks4 request continues after authentication failed (#1624) --- transport/socks4/socks4.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/transport/socks4/socks4.go b/transport/socks4/socks4.go index c6b2f2db5..c06bea20f 100644 --- a/transport/socks4/socks4.go +++ b/transport/socks4/socks4.go @@ -91,6 +91,7 @@ func ServerHandshake(rw io.ReadWriter, authenticator auth.Authenticator) (addr s code = RequestGranted } else { code = RequestIdentdMismatched + err = ErrRequestIdentdMismatched } var reply [8]byte @@ -99,7 +100,10 @@ func ServerHandshake(rw io.ReadWriter, authenticator auth.Authenticator) (addr s copy(reply[4:8], dstIP) copy(reply[2:4], dstPort) - _, err = rw.Write(reply[:]) + _, wErr := rw.Write(reply[:]) + if err == nil { + err = wErr + } return }