chore: cleanup natTable's api

This commit is contained in:
wwqgtxx
2023-02-18 13:16:07 +08:00
parent 59cd89a9c9
commit fc50392ec7
24 changed files with 47 additions and 85 deletions

View File

@ -207,7 +207,7 @@ func ReCreateSocks(port int, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAd
log.Infoln("SOCKS proxy listening at: %s", socksListener.Address())
}
func ReCreateRedir(port int, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter) {
func ReCreateRedir(port int, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter, natTable C.NatTable) {
redirMux.Lock()
defer redirMux.Unlock()
@ -245,7 +245,7 @@ func ReCreateRedir(port int, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAd
return
}
redirUDPListener, err = tproxy.NewUDP(addr, udpIn)
redirUDPListener, err = tproxy.NewUDP(addr, udpIn, natTable)
if err != nil {
log.Warnln("Failed to start Redir UDP Listener: %s", err)
}
@ -403,7 +403,7 @@ func ReCreateTuic(config LC.TuicServer, tcpIn chan<- C.ConnContext, udpIn chan<-
return
}
func ReCreateTProxy(port int, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter) {
func ReCreateTProxy(port int, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter, natTable C.NatTable) {
tproxyMux.Lock()
defer tproxyMux.Unlock()
@ -441,7 +441,7 @@ func ReCreateTProxy(port int, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketA
return
}
tproxyUDPListener, err = tproxy.NewUDP(addr, udpIn)
tproxyUDPListener, err = tproxy.NewUDP(addr, udpIn, natTable)
if err != nil {
log.Warnln("Failed to start TProxy UDP Listener: %s", err)
}
@ -719,7 +719,7 @@ func PatchTunnel(tunnels []LC.Tunnel, tcpIn chan<- C.ConnContext, udpIn chan<- C
}
}
func PatchInboundListeners(newListenerMap map[string]C.InboundListener, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter, dropOld bool) {
func PatchInboundListeners(newListenerMap map[string]C.InboundListener, tcpIn chan<- C.ConnContext, udpIn chan<- C.PacketAdapter, natTable C.NatTable, dropOld bool) {
inboundMux.Lock()
defer inboundMux.Unlock()
@ -731,7 +731,7 @@ func PatchInboundListeners(newListenerMap map[string]C.InboundListener, tcpIn ch
continue
}
}
if err := newListener.Listen(tcpIn, udpIn); err != nil {
if err := newListener.Listen(tcpIn, udpIn, natTable); err != nil {
log.Errorln("Listener %s listen err: %s", name, err.Error())
continue
}