From 5ee48300821822cf64c253b131c480c0d57950fc Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Fri, 5 May 2017 14:42:41 +0200 Subject: [PATCH] Fixed connection->pid lookup. --- opensnitch/proc.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opensnitch/proc.py b/opensnitch/proc.py index d7e95f64..4b6ccc43 100644 --- a/opensnitch/proc.py +++ b/opensnitch/proc.py @@ -21,7 +21,9 @@ import logging import psutil def get_pid_by_connection( procmon, src_addr, src_p, dst_addr, dst_p, proto = 'tcp' ): - connections_list = [connection for connection in psutil.net_connections(kind=proto) if connection.laddr==(src_addr, src_p) and connection.raddr==(dst_addr, dst_p)] + connections_list = [ connection for connection in psutil.net_connections(kind=proto) \ + if connection.laddr==( src_addr, int(src_p) ) and \ + connection.raddr==( dst_addr, int(dst_p) ) ] # We always take the first element as we assume it contains only one, because # it should not be possible to keep two connections which are exactly the same.