Implement review, use local var for pkt.Info

This commit is contained in:
Daniel
2020-04-08 15:19:00 +02:00
parent b5c4d04f6f
commit 3f7c467efc
2 changed files with 19 additions and 15 deletions

View File

@@ -51,14 +51,15 @@ func DecideOnConnection(conn *network.Connection, pkt packet.Packet) { //nolint:
// check if process is communicating with itself
if pkt != nil {
// TODO: evaluate the case where different IPs in the 127/8 net are used.
if conn.Process().Pid >= 0 && pkt.Info().Src.Equal(pkt.Info().Dst) {
pktInfo := pkt.Info()
if conn.Process().Pid >= 0 && pktInfo.Src.Equal(pktInfo.Dst) {
// get PID
otherPid, _, err := process.GetPidByEndpoints(
pkt.Info().RemoteIP(),
pkt.Info().RemotePort(),
pkt.Info().LocalIP(),
pkt.Info().LocalPort(),
pkt.Info().Protocol,
pktInfo.RemoteIP(),
pktInfo.RemotePort(),
pktInfo.LocalIP(),
pktInfo.LocalPort(),
pktInfo.Protocol,
)
if err != nil {
log.Warningf("filter: failed to find local peer process PID: %s", err)