flowKey returns the conntrack.Tuple (always oriented local→remote) and whether this packet is within our scope.
(dir platform.Direction, p pkt)
| 136 | // flowKey returns the conntrack.Tuple (always oriented local→remote) and |
| 137 | // whether this packet is within our scope. |
| 138 | func (e *Engine) flowKey(dir platform.Direction, p pkt) (conntrack.Tuple, bool) { |
| 139 | sc := e.cfg.Scope |
| 140 | var localAddr, remoteAddr netip.Addr |
| 141 | var localPort, remotePort uint16 |
| 142 | if dir == platform.DirOutbound { |
| 143 | localAddr, _ = netip.AddrFromSlice(p.srcIP[:]) |
| 144 | remoteAddr, _ = netip.AddrFromSlice(p.dstIP[:]) |
| 145 | localPort, remotePort = p.srcPort, p.dstPort |
| 146 | } else { |
| 147 | localAddr, _ = netip.AddrFromSlice(p.dstIP[:]) |
| 148 | remoteAddr, _ = netip.AddrFromSlice(p.srcIP[:]) |
| 149 | localPort, remotePort = p.dstPort, p.srcPort |
| 150 | } |
| 151 | if remoteAddr != sc.RemoteIP || remotePort != sc.RemotePort { |
| 152 | return conntrack.Tuple{}, false |
| 153 | } |
| 154 | return conntrack.Tuple{ |
| 155 | SrcIP: localAddr, SrcPort: localPort, |
| 156 | DstIP: remoteAddr, DstPort: remotePort, |
| 157 | }, true |
| 158 | } |
| 159 | |
| 160 | func (e *Engine) handleOutbound(key conntrack.Tuple, parsed pkt, p platform.Packet) { |
| 161 | switch { |