From d1539e6c0727dd3972300b8c2592311bc355d1d5 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Thu, 4 Apr 2024 23:54:25 +0800 Subject: [PATCH] fix: IN-PORT not work in tproxy tcp inbound https://github.com/MetaCubeX/mihomo/issues/1162 --- listener/tproxy/tproxy.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/listener/tproxy/tproxy.go b/listener/tproxy/tproxy.go index efb144a9a5..fa7e7dbe47 100644 --- a/listener/tproxy/tproxy.go +++ b/listener/tproxy/tproxy.go @@ -34,6 +34,8 @@ func (l *Listener) Close() error { func (l *Listener) handleTProxy(conn net.Conn, tunnel C.Tunnel, additions ...inbound.Addition) { target := socks5.ParseAddrToSocksAddr(conn.LocalAddr()) N.TCPKeepAlive(conn) + // TProxy's conn.LocalAddr() is target address, so we set from l.listener + additions = append([]inbound.Addition{inbound.WithInAddr(l.listener.Addr())}, additions...) tunnel.HandleTCPConn(inbound.NewSocket(target, conn, C.TPROXY, additions...)) }