From 86e55c5c1c4f6b32032bd3bf5a3309e7450e19ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 19 Feb 2023 18:56:38 +0800 Subject: [PATCH] Fix tproxy inbound --- inbound/tproxy.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inbound/tproxy.go b/inbound/tproxy.go index fa557425..be421ad3 100644 --- a/inbound/tproxy.go +++ b/inbound/tproxy.go @@ -100,9 +100,10 @@ type tproxyPacketWriter struct { func (w *tproxyPacketWriter) WritePacket(buffer *buf.Buffer, destination M.Socksaddr) error { defer buffer.Release() - if w.destination == destination && w.conn != nil { - _, err := w.conn.WriteToUDPAddrPort(buffer.Bytes(), M.AddrPortFromNet(w.source.LocalAddr())) - if err == nil { + conn := w.conn + if w.destination == destination && conn != nil { + _, err := conn.WriteToUDPAddrPort(buffer.Bytes(), M.AddrPortFromNet(w.source.LocalAddr())) + if err != nil { w.conn = nil } return err