Fix: hot recreate socks should ignore when receive same address

This commit is contained in:
Dreamacro 2019-10-13 23:51:26 +08:00
parent e22ff74e79
commit 521a190b0f

View file

@ -74,10 +74,15 @@ func ReCreateHTTP(port int) error {
func ReCreateSocks(port int) error { func ReCreateSocks(port int) error {
addr := genAddr(bindAddress, port, allowLan) addr := genAddr(bindAddress, port, allowLan)
shouldTCPIgnore := false
shouldUDPIgnore := false
if socksListener != nil { if socksListener != nil {
if socksListener.Address() != addr { if socksListener.Address() != addr {
socksListener.Close() socksListener.Close()
socksListener = nil socksListener = nil
} else {
shouldTCPIgnore = true
} }
} }
@ -85,9 +90,15 @@ func ReCreateSocks(port int) error {
if socksUDPListener.Address() != addr { if socksUDPListener.Address() != addr {
socksUDPListener.Close() socksUDPListener.Close()
socksUDPListener = nil socksUDPListener = nil
} else {
shouldUDPIgnore = true
} }
} }
if shouldTCPIgnore && shouldUDPIgnore {
return nil
}
if portIsZero(addr) { if portIsZero(addr) {
return nil return nil
} }