重构代码结构,优化连接管理和日志记录

This commit is contained in:
2025-02-28 09:45:31 +08:00
parent 037c2c53c6
commit 06bcaf8bc7
15 changed files with 82 additions and 102 deletions

View File

@@ -253,7 +253,13 @@ func (s *Server) handleConnect(ctx context.Context, conn net.Conn, req *Request)
}
slog.Info("需要向 " + req.DestAddr.Address() + " 建立连接")
s.Conn <- ProxyConn{conn, req.realDestAddr.Address()}
select {
case <-s.ctx.Done():
if conn != nil {
utils.Close(conn)
}
case s.Conn <- ProxyConn{conn, req.realDestAddr.Address()}:
}
return nil
}