Skip to content

Commit

Permalink
Change: remove InboundPort because already have OriginDst
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Aug 4, 2023
1 parent c0e51f8 commit 7c89301
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 5 deletions.
1 change: 0 additions & 1 deletion adapter/inbound/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion adapter/inbound/https.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 0 additions & 1 deletion adapter/inbound/socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
1 change: 0 additions & 1 deletion constant/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion rule/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 7c89301

Please sign in to comment.