Fix: hot recreate socks should ignore when receive same address

This commit is contained in:
gVisor bot 2019-10-13 23:51:26 +08:00
parent 73ce51bc76
commit b0ae341bfa

View file

@ -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
}