Switch connection state lookups to use the packet.Info struct

Also, rename the Direction attribute on packet.Info to Inbound
This commit is contained in:
Daniel
2020-05-18 17:08:32 +02:00
parent 0036d25672
commit 7649859ba6
10 changed files with 95 additions and 139 deletions

View File

@@ -91,15 +91,15 @@ func checkSelfCommunication(conn *network.Connection, pkt packet.Packet) bool {
pktInfo := pkt.Info()
if conn.Process().Pid >= 0 && pktInfo.Src.Equal(pktInfo.Dst) {
// get PID
otherPid, _, err := state.Lookup(
pktInfo.Version,
pktInfo.Protocol,
pktInfo.RemoteIP(),
pktInfo.RemotePort(),
pktInfo.LocalIP(),
pktInfo.LocalPort(),
pktInfo.Direction,
)
otherPid, _, err := state.Lookup(&packet.Info{
Inbound: !pktInfo.Inbound, // we want to know the process on the other end
Version: pktInfo.Version,
Protocol: pktInfo.Protocol,
Src: pktInfo.Src,
SrcPort: pktInfo.SrcPort,
Dst: pktInfo.Dst,
DstPort: pktInfo.DstPort,
})
if err != nil {
log.Warningf("filter: failed to find local peer process PID: %s", err)
} else {