mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-02 03:17:37 +03:00
Fix udpnat2 handler again
This commit is contained in:
parent
23b0180a1b
commit
2b41455f5a
1 changed files with 12 additions and 1 deletions
|
@ -77,9 +77,20 @@ func (c *natConn) WaitReadPacket() (buffer *buf.Buffer, destination M.Socksaddr,
|
|||
|
||||
func (c *natConn) SetHandler(handler N.UDPHandlerEx) {
|
||||
c.handlerAccess.Lock()
|
||||
defer c.handlerAccess.Unlock()
|
||||
c.handler = handler
|
||||
c.readWaitOptions = N.NewReadWaitOptions(c.writer, handler)
|
||||
c.handlerAccess.Unlock()
|
||||
fetch:
|
||||
for {
|
||||
select {
|
||||
case packet := <-c.packetChan:
|
||||
c.handler.NewPacketEx(packet.Buffer, packet.Destination)
|
||||
N.PutPacketBuffer(packet)
|
||||
continue fetch
|
||||
default:
|
||||
break fetch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *natConn) Timeout() time.Duration {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue