From b722a038e61b1cc15918d8ec1da57a8176985dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 20 Oct 2026 05:25:14 +0800 Subject: [PATCH] Fix TUN loopback protection for ICMP --- protocol/direct/outbound.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocol/direct/outbound.go b/protocol/direct/outbound.go index c8f356df..96b8cb0f 100644 --- a/protocol/direct/outbound.go +++ b/protocol/direct/outbound.go @@ -185,6 +185,10 @@ func (h *Outbound) ListenPacket(ctx context.Context, destination M.Socksaddr) (n func (h *Outbound) PreMatchFlow(network string, destination netip.Addr) adapter.PreMatchAction { if network == N.NetworkICMP && h.icmpPort != nil { + if h.isMyLoopbackAddress(destination) { + h.logger.Error("reject ", network, " connection to ", destination, ": loopback connection to TUN range") + return adapter.PreMatchReject + } return adapter.PreMatchFlow } return adapter.PreMatchContinue