From 521a190b0f93a36e438a31ecd303342a43484ce0 Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Sun, 13 Oct 2019 23:51:26 +0800 Subject: [PATCH] Fix: hot recreate socks should ignore when receive same address --- proxy/listener.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/proxy/listener.go b/proxy/listener.go index 9e7d0311..79741581 100644 --- a/proxy/listener.go +++ b/proxy/listener.go @@ -74,10 +74,15 @@ func ReCreateHTTP(port int) error { func ReCreateSocks(port int) error { addr := genAddr(bindAddress, port, allowLan) + shouldTCPIgnore := false + shouldUDPIgnore := false + if socksListener != nil { if socksListener.Address() != addr { socksListener.Close() socksListener = nil + } else { + shouldTCPIgnore = true } } @@ -85,9 +90,15 @@ func ReCreateSocks(port int) error { if socksUDPListener.Address() != addr { socksUDPListener.Close() socksUDPListener = nil + } else { + shouldUDPIgnore = true } } + if shouldTCPIgnore && shouldUDPIgnore { + return nil + } + if portIsZero(addr) { return nil }