aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2020-05-31 12:15:29 +0200
committerPapoteur <papoteur@mageia.org>2020-05-31 12:15:29 +0200
commit42d7135849a9069b2e04f3107ca2bda9b53d103a (patch)
tree36c3aa6f659d2cb5975169c625764d16cb19aa90 /src
parentfbe6a0a6793b736aedb44182008586d17b5b4f94 (diff)
downloadnet_monitor-42d7135849a9069b2e04f3107ca2bda9b53d103a.tar
net_monitor-42d7135849a9069b2e04f3107ca2bda9b53d103a.tar.gz
net_monitor-42d7135849a9069b2e04f3107ca2bda9b53d103a.tar.bz2
net_monitor-42d7135849a9069b2e04f3107ca2bda9b53d103a.tar.xz
net_monitor-42d7135849a9069b2e04f3107ca2bda9b53d103a.zip
Add checking of present protocols, to avoid exception.
Diffstat (limited to 'src')
-rw-r--r--src/monitor.py7
-rwxr-xr-xsrc/net_monitor2
2 files changed, 8 insertions, 1 deletions
diff --git a/src/monitor.py b/src/monitor.py
index e7a3c12..3198b78 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -328,6 +328,13 @@ class Monitor:
pass
return routes, default_routes
+ def protocols_list(self):
+ protos = []
+ for proto in ["tcp", "tcp6", "udp", "udp6"]:
+ if os.path.exists("/proc/net/%s" % proto):
+ protos.append(proto)
+ return protos
+
def get_connections(self, proto="tcp"):
"""Reads active connections"""
connections=[]
diff --git a/src/net_monitor b/src/net_monitor
index cdd5c6d..4a8ddf9 100755
--- a/src/net_monitor
+++ b/src/net_monitor
@@ -559,7 +559,7 @@ class MonitorGui:
"""Updates connections"""
lstore = self.connections
lstore.clear()
- for proto in ["tcp", "tcp6", "udp", "udp6"]:
+ for proto in self.monitor.protocols_list():
connections = self.monitor.get_connections(proto=proto)
for loc_addr, loc_port, rem_addr, rem_port, status in connections:
iter = lstore.append()