Update udpant usages

This commit is contained in:
世界 2024-11-26 11:37:44 +08:00
parent c177abb523
commit 59a6bdc1fa
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
5 changed files with 34 additions and 20 deletions

View file

@ -37,10 +37,16 @@ func NewUDPForwarder(ctx context.Context, stack *stack.Stack, handler Handler, t
stack: stack,
handler: handler,
}
forwarder.udpNat = udpnat.New(handler, forwarder.PreparePacketConnection, timeout, true)
udpNat := udpnat.New(handler, forwarder.PreparePacketConnection, timeout, true)
udpNat.Start()
forwarder.udpNat = udpNat
return forwarder
}
func (f *UDPForwarder) Close() {
f.udpNat.Close()
}
func (f *UDPForwarder) HandlePacket(id stack.TransportEndpointID, pkt *stack.PacketBuffer) bool {
source := M.SocksaddrFrom(AddrFromAddress(id.RemoteAddress), id.RemotePort)
destination := M.SocksaddrFrom(AddrFromAddress(id.LocalAddress), id.LocalPort)