From 69bc471e19ac527e4b8e6a01a27ba31e82818e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 1 Aug 2022 20:51:45 +0800 Subject: [PATCH] Fix udp write back --- gvisor_udp.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gvisor_udp.go b/gvisor_udp.go index 0d1ea84..755735e 100644 --- a/gvisor_udp.go +++ b/gvisor_udp.go @@ -56,6 +56,9 @@ type UDPBackWriter struct { sourcePort uint16 } +func (w *UDPBackWriter) WriteIsThreadUnsafe() { +} + func (w *UDPBackWriter) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error { defer buffer.Release() @@ -81,6 +84,7 @@ func (w *UDPBackWriter) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) packet := stack.NewPacketBuffer(stack.PacketBufferOptions{ ReserveHeaderBytes: header.UDPMinimumSize + int(route.MaxHeaderLength()), Payload: gBuffer.NewWithData(buffer.Bytes()), + OnRelease: buffer.Release, }) defer packet.DecRef()