Fix: listener patch diff

This commit is contained in:
Dreamacro
2021-08-01 00:35:37 +08:00
parent 3705996974
commit 1bfebd0d03
9 changed files with 158 additions and 88 deletions

View File

@ -20,15 +20,15 @@ var (
allowLan = false
bindAddress = "*"
socksListener *socks.Listener
socksUDPListener *socks.UDPListener
httpListener *http.Listener
redirListener *redir.Listener
redirUDPListener *tproxy.UDPListener
tproxyListener *tproxy.Listener
tproxyUDPListener *tproxy.UDPListener
mixedListener *mixed.Listener
mixedUDPLister *socks.UDPListener
socksListener C.Listener
socksUDPListener C.Listener
httpListener C.Listener
redirListener C.Listener
redirUDPListener C.Listener
tproxyListener C.Listener
tproxyUDPListener C.Listener
mixedListener C.Listener
mixedUDPLister C.Listener
// lock for recreate function
socksMux sync.Mutex
@ -69,7 +69,7 @@ func ReCreateHTTP(port int, tcpIn chan<- C.ConnContext) error {
addr := genAddr(bindAddress, port, allowLan)
if httpListener != nil {
if httpListener.Address() == addr {
if httpListener.RawAddress() == addr {
return nil
}
httpListener.Close()
@ -100,7 +100,7 @@ func ReCreateSocks(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P
shouldUDPIgnore := false
if socksListener != nil {
if socksListener.Address() != addr {
if socksListener.RawAddress() != addr {
socksListener.Close()
socksListener = nil
} else {
@ -109,7 +109,7 @@ func ReCreateSocks(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P
}
if socksUDPListener != nil {
if socksUDPListener.Address() != addr {
if socksUDPListener.RawAddress() != addr {
socksUDPListener.Close()
socksUDPListener = nil
} else {
@ -150,7 +150,7 @@ func ReCreateRedir(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P
addr := genAddr(bindAddress, port, allowLan)
if redirListener != nil {
if redirListener.Address() == addr {
if redirListener.RawAddress() == addr {
return nil
}
redirListener.Close()
@ -158,7 +158,7 @@ func ReCreateRedir(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P
}
if redirUDPListener != nil {
if redirUDPListener.Address() == addr {
if redirUDPListener.RawAddress() == addr {
return nil
}
redirUDPListener.Close()
@ -191,7 +191,7 @@ func ReCreateTProxy(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.
addr := genAddr(bindAddress, port, allowLan)
if tproxyListener != nil {
if tproxyListener.Address() == addr {
if tproxyListener.RawAddress() == addr {
return nil
}
tproxyListener.Close()
@ -199,7 +199,7 @@ func ReCreateTProxy(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.
}
if tproxyUDPListener != nil {
if tproxyUDPListener.Address() == addr {
if tproxyUDPListener.RawAddress() == addr {
return nil
}
tproxyUDPListener.Close()
@ -235,7 +235,7 @@ func ReCreateMixed(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P
shouldUDPIgnore := false
if mixedListener != nil {
if mixedListener.Address() != addr {
if mixedListener.RawAddress() != addr {
mixedListener.Close()
mixedListener = nil
} else {
@ -243,7 +243,7 @@ func ReCreateMixed(port int, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P
}
}
if mixedUDPLister != nil {
if mixedUDPLister.Address() != addr {
if mixedUDPLister.RawAddress() != addr {
mixedUDPLister.Close()
mixedUDPLister = nil
} else {