diff --git a/proxy/socks/udp.go b/proxy/socks/udp.go index 1fe6fc8..d4b59a8 100644 --- a/proxy/socks/udp.go +++ b/proxy/socks/udp.go @@ -44,7 +44,6 @@ func NewUDPHandler(proxyHost string, proxyPort uint16, timeout time.Duration, fa fakeDns: fakeDns, sessionStater: sessionStater, timeout: timeout, - closed: false, } } @@ -241,13 +240,13 @@ func (h *udpHandler) ReceiveTo(conn core.UDPConn, data []byte, addr *net.UDPAddr } func (h *udpHandler) Close(conn core.UDPConn) { + h.Lock() + defer h.Unlock() + if h.closed { return } - h.Lock() - defer h.Unlock() - if remoteConn, ok := h.tcpConns[conn]; ok { remoteConn.Close() delete(h.tcpConns, conn)