udp: handle closed forwarding channel (#5470)

This commit is contained in:
fatedier
2026-08-09 15:31:11 +08:00
committed by GitHub
parent d1928f9689
commit 5b68148f11
2 changed files with 41 additions and 3 deletions
+7 -3
View File
@@ -63,9 +63,13 @@ func ForwardUserConn(udpConn *net.UDPConn, readCh <-chan *msg.UDPPacket, sendCh
// NewUDPPacket copies buf[:n], so the read buffer can be reused
udpMsg := NewUDPPacket(buf[:n], nil, remoteAddr)
select {
case sendCh <- udpMsg:
default:
if err = errors.PanicToError(func() {
select {
case sendCh <- udpMsg:
default:
}
}); err != nil {
return
}
}
}