mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
fix: ensure client connection is closed properly in HandleClient method
This commit is contained in:
parent
04ba532654
commit
96144c6986
@ -70,9 +70,10 @@ func (s *Server) Start() (err error) {
|
|||||||
|
|
||||||
// handleClient performs SOCKS5 negotiation and dispatches TCP/UDP handling.
|
// handleClient performs SOCKS5 negotiation and dispatches TCP/UDP handling.
|
||||||
func (s *Server) HandleClient(client net.Conn) {
|
func (s *Server) HandleClient(client net.Conn) {
|
||||||
|
defer client.Close()
|
||||||
|
|
||||||
// Handshake (no auth)
|
// Handshake (no auth)
|
||||||
if err := s.socks5Auth(client); err != nil {
|
if err := s.socks5Auth(client); err != nil {
|
||||||
_ = client.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,12 +82,10 @@ func (s *Server) HandleClient(client net.Conn) {
|
|||||||
if cmd == socksCmdUDP {
|
if cmd == socksCmdUDP {
|
||||||
// UDP Associate
|
// UDP Associate
|
||||||
s.handleUDPAssociate(client)
|
s.handleUDPAssociate(client)
|
||||||
_ = client.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logrus.Debugf("[%s][%s] ParseSocks5Request failed: %s",
|
logrus.Debugf("[%s][%s] ParseSocks5Request failed: %s",
|
||||||
client.RemoteAddr().String(), destAddrPort, err.Error())
|
client.RemoteAddr().String(), destAddrPort, err.Error())
|
||||||
_ = client.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +93,6 @@ func (s *Server) HandleClient(client net.Conn) {
|
|||||||
target, err := s.socks5Connect(client, destAddrPort)
|
target, err := s.socks5Connect(client, destAddrPort)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Debug("Connect failed: ", err)
|
logrus.Debug("Connect failed: ", err)
|
||||||
_ = client.Close()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.forwardTCP(client, target, destAddrPort)
|
s.forwardTCP(client, target, destAddrPort)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user