Revert "fix: ensure client connection is closed properly in HandleClient method"

This reverts commit 96144c6986.
This commit is contained in:
SunBK201 2025-10-28 15:52:09 +08:00
parent 96144c6986
commit f15424d692

View File

@ -70,10 +70,9 @@ func (s *Server) Start() (err error) {
// handleClient performs SOCKS5 negotiation and dispatches TCP/UDP handling.
func (s *Server) HandleClient(client net.Conn) {
defer client.Close()
// Handshake (no auth)
if err := s.socks5Auth(client); err != nil {
_ = client.Close()
return
}
@ -82,10 +81,12 @@ func (s *Server) HandleClient(client net.Conn) {
if cmd == socksCmdUDP {
// UDP Associate
s.handleUDPAssociate(client)
_ = client.Close()
return
}
logrus.Debugf("[%s][%s] ParseSocks5Request failed: %s",
client.RemoteAddr().String(), destAddrPort, err.Error())
_ = client.Close()
return
}
@ -93,6 +94,7 @@ func (s *Server) HandleClient(client net.Conn) {
target, err := s.socks5Connect(client, destAddrPort)
if err != nil {
logrus.Debug("Connect failed: ", err)
_ = client.Close()
return
}
s.forwardTCP(client, target, destAddrPort)