Skip to content

Commit

Permalink
Fix: hot recreate socks should ignore when receive same address
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Oct 13, 2019
1 parent e22ff74 commit 521a190
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions proxy/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,31 @@ 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
}
}

if socksUDPListener != nil {
if socksUDPListener.Address() != addr {
socksUDPListener.Close()
socksUDPListener = nil
} else {
shouldUDPIgnore = true
}
}

if shouldTCPIgnore && shouldUDPIgnore {
return nil
}

if portIsZero(addr) {
return nil
}
Expand Down

0 comments on commit 521a190

Please sign in to comment.