chore: update proxy's udpConn when received a new packet

This commit is contained in:
wwqgtxx
2023-06-03 21:40:09 +08:00
committed by Larvan2
parent 6c7d1657a5
commit 1a44dcee55
11 changed files with 80 additions and 28 deletions

View File

@ -303,8 +303,11 @@ func handleUDPConn(packet C.PacketAdapter) {
key := packet.LocalAddr().String()
handle := func() bool {
pc := natTable.Get(key)
pc, proxy := natTable.Get(key)
if pc != nil {
if proxy != nil {
proxy.UpdateWriteBack(packet)
}
_ = handleUDPToRemote(packet, pc, metadata)
return true
}
@ -384,9 +387,10 @@ func handleUDPConn(packet C.PacketAdapter) {
}
oAddrPort := metadata.AddrPort()
natTable.Set(key, pc)
writeBackProxy := nat.NewWriteBackProxy(packet)
natTable.Set(key, pc, writeBackProxy)
go handleUDPToLocal(packet, pc, key, oAddrPort, fAddr)
go handleUDPToLocal(writeBackProxy, pc, key, oAddrPort, fAddr)
handle()
}()