Skip to content

Commit 2b41455

Browse files
committed
Fix udpnat2 handler again
1 parent 23b0180 commit 2b41455

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

common/udpnat2/conn.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,20 @@ func (c *natConn) WaitReadPacket() (buffer *buf.Buffer, destination M.Socksaddr,
7777

7878
func (c *natConn) SetHandler(handler N.UDPHandlerEx) {
7979
c.handlerAccess.Lock()
80-
defer c.handlerAccess.Unlock()
8180
c.handler = handler
8281
c.readWaitOptions = N.NewReadWaitOptions(c.writer, handler)
82+
c.handlerAccess.Unlock()
83+
fetch:
84+
for {
85+
select {
86+
case packet := <-c.packetChan:
87+
c.handler.NewPacketEx(packet.Buffer, packet.Destination)
88+
N.PutPacketBuffer(packet)
89+
continue fetch
90+
default:
91+
break fetch
92+
}
93+
}
8394
}
8495

8596
func (c *natConn) Timeout() time.Duration {

0 commit comments

Comments
 (0)