fix: IN-PORT not work in tproxy tcp inbound

https://github.com/MetaCubeX/mihomo/issues/1162
This commit is contained in:
wwqgtxx 2024-04-04 23:54:25 +08:00
parent c893e3c462
commit d1539e6c07

View File

@ -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...))
}