From c893e3c462b20bb2a4c4f9ae1cd3a3bad352cccc Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Thu, 4 Apr 2024 21:25:27 +0800 Subject: [PATCH] fix: IN-PORT not work in http inbound https://github.com/MetaCubeX/mihomo/issues/1162 --- adapter/inbound/addition.go | 4 ++-- adapter/inbound/http.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adapter/inbound/addition.go b/adapter/inbound/addition.go index c38c1aa148..ed560818d8 100644 --- a/adapter/inbound/addition.go +++ b/adapter/inbound/addition.go @@ -47,7 +47,7 @@ func WithDstAddr(addr net.Addr) Addition { func WithSrcAddr(addr net.Addr) Addition { return func(metadata *C.Metadata) { m := C.Metadata{} - if err := m.SetRemoteAddr(addr);err ==nil{ + if err := m.SetRemoteAddr(addr); err == nil { metadata.SrcIP = m.DstIP metadata.SrcPort = m.DstPort } @@ -57,7 +57,7 @@ func WithSrcAddr(addr net.Addr) Addition { func WithInAddr(addr net.Addr) Addition { return func(metadata *C.Metadata) { m := C.Metadata{} - if err := m.SetRemoteAddr(addr);err ==nil{ + if err := m.SetRemoteAddr(addr); err == nil { metadata.InIP = m.DstIP metadata.InPort = m.DstPort } diff --git a/adapter/inbound/http.go b/adapter/inbound/http.go index 8f912fbe79..f7d45399fb 100644 --- a/adapter/inbound/http.go +++ b/adapter/inbound/http.go @@ -14,7 +14,7 @@ func NewHTTP(target socks5.Addr, srcConn net.Conn, conn net.Conn, additions ...A metadata.Type = C.HTTP metadata.RawSrcAddr = srcConn.RemoteAddr() metadata.RawDstAddr = srcConn.LocalAddr() - ApplyAdditions(metadata, WithSrcAddr(srcConn.RemoteAddr()), WithInAddr(conn.LocalAddr())) + ApplyAdditions(metadata, WithSrcAddr(srcConn.RemoteAddr()), WithInAddr(srcConn.LocalAddr())) ApplyAdditions(metadata, additions...) return conn, metadata }