From 24b12270dbbef075427b93b43dfc276cb6027453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Mon, 23 Mar 2026 19:37:57 +0800 Subject: [PATCH] Fix system stack rewriting TUN subnet destinations to loopback The acceptLoop was rewriting any TCP destination within the TUN address prefix to 127.0.0.1/::1. This incorrectly caught the gateway address and other subnet addresses, not just the interface address itself. --- stack_system.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/stack_system.go b/stack_system.go index fa54db3..e2cdd45 100644 --- a/stack_system.go +++ b/stack_system.go @@ -330,23 +330,7 @@ func (s *System) acceptLoop(listener net.Listener) { s.logger.Trace(E.New("unknown session with port ", connPort)) continue } - destination := M.SocksaddrFromNetIP(session.Destination) - if destination.Addr.Is4() { - for _, prefix := range s.inet4Prefixes { - if prefix.Contains(destination.Addr) { - destination.Addr = netip.AddrFrom4([4]byte{127, 0, 0, 1}) - break - } - } - } else { - for _, prefix := range s.inet6Prefixes { - if prefix.Contains(destination.Addr) { - destination.Addr = netip.AddrFrom16([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}) - break - } - } - } - go s.handler.NewConnectionEx(s.ctx, conn, M.SocksaddrFromNetIP(session.Source), destination, nil) + go s.handler.NewConnectionEx(s.ctx, conn, M.SocksaddrFromNetIP(session.Source), M.SocksaddrFromNetIP(session.Destination), nil) } }