From 7c8930158629a0af936fd74b3e2d52aeafa2d6b2 Mon Sep 17 00:00:00 2001 From: Dreamacro <8615343+Dreamacro@users.noreply.github.com> Date: Fri, 4 Aug 2023 20:51:57 +0800 Subject: [PATCH] Change: remove InboundPort because already have OriginDst --- adapter/inbound/http.go | 1 - adapter/inbound/https.go | 1 - adapter/inbound/socket.go | 1 - constant/metadata.go | 1 - rule/port.go | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/adapter/inbound/http.go b/adapter/inbound/http.go index 4344c37..61f7b96 100644 --- a/adapter/inbound/http.go +++ b/adapter/inbound/http.go @@ -21,7 +21,6 @@ func NewHTTP(target socks5.Addr, source net.Addr, originTarget net.Addr, conn ne if originTarget != nil { if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil { metadata.OriginDst = addrPort - metadata.InboundPort = addrPort.Port() } } return context.NewConnContext(conn, metadata) diff --git a/adapter/inbound/https.go b/adapter/inbound/https.go index eae150a..7b9591d 100644 --- a/adapter/inbound/https.go +++ b/adapter/inbound/https.go @@ -19,7 +19,6 @@ func NewHTTPS(request *http.Request, conn net.Conn) *context.ConnContext { } if addrPort, err := netip.ParseAddrPort(conn.LocalAddr().String()); err == nil { metadata.OriginDst = addrPort - metadata.InboundPort = addrPort.Port() } return context.NewConnContext(conn, metadata) } diff --git a/adapter/inbound/socket.go b/adapter/inbound/socket.go index 9bec0ce..aaf8539 100644 --- a/adapter/inbound/socket.go +++ b/adapter/inbound/socket.go @@ -20,7 +20,6 @@ func NewSocket(target socks5.Addr, conn net.Conn, source C.Type) *context.ConnCo } if addrPort, err := netip.ParseAddrPort(conn.LocalAddr().String()); err == nil { metadata.OriginDst = addrPort - metadata.InboundPort = addrPort.Port() } return context.NewConnContext(conn, metadata) } diff --git a/constant/metadata.go b/constant/metadata.go index 32b1e4b..00e149c 100644 --- a/constant/metadata.go +++ b/constant/metadata.go @@ -69,7 +69,6 @@ type Metadata struct { DstIP net.IP `json:"destinationIP"` SrcPort Port `json:"sourcePort"` DstPort Port `json:"destinationPort"` - InboundPort uint16 `json:"inboundPort"` Host string `json:"host"` DNSMode DNSMode `json:"dnsMode"` ProcessPath string `json:"processPath"` diff --git a/rule/port.go b/rule/port.go index 3db1212..f6392a2 100644 --- a/rule/port.go +++ b/rule/port.go @@ -41,7 +41,7 @@ func (p *Port) Match(metadata *C.Metadata) bool { case PortTypeDest: return metadata.DstPort == p.port case PortTypeInbound: - return metadata.InboundPort == uint16(p.port) + return metadata.OriginDst.Port() == uint16(p.port) default: panic(fmt.Errorf("unknown port type: %v", p.portType)) }