MCPcopy
hub / github.com/evilsocket/opensnitch / _monitor_node_netstat

Method _monitor_node_netstat

ui/opensnitch/dialogs/stats.py:2910–2957  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2908 #self._reset_node_info()
2909
2910 def _monitor_node_netstat(self):
2911 # TODO:
2912 # - create a tasks package, to centralize/normalize tasks' names and
2913 # config
2914 self.netstatLabel.show()
2915
2916 nIdx = self.comboNetstatNodes.currentIndex()
2917 node_addr = self.comboNetstatNodes.itemData(nIdx)
2918 if node_addr == "":
2919 print("monitor_netstat_node: no nodes")
2920 self.netstatLabel.setText("")
2921 return
2922 if not self._nodes.is_connected(node_addr):
2923 print("monitor_node_netstat, node not connected:", node_addr)
2924 self.netstatLabel.setText("{0} node is not connected".format(node_addr))
2925 return
2926
2927 refreshIndex = self.comboNetstatInterval.currentIndex()
2928 if refreshIndex == 0:
2929 self._unmonitor_node_netstat(node_addr)
2930 return
2931
2932 refreshInterval = self.comboNetstatInterval.currentText()
2933 proto = self.comboNetstatProto.currentIndex()
2934 family = self.comboNetstatFamily.currentIndex()
2935 state = self.comboNetstatStates.currentIndex()
2936 config = '{"name": "sockets-monitor", "data": {"interval": "%s", "state": %d, "proto": %d, "family": %d}}' % (
2937 refreshInterval,
2938 int(self.comboNetstatStates.itemData(state)),
2939 int(self.comboNetstatProto.itemData(proto)),
2940 int(self.comboNetstatFamily.itemData(family))
2941 )
2942
2943 self.netstatLabel.setText(QC.translate("stats", "loading in {0}...".format(refreshInterval)))
2944
2945 noti = ui_pb2.Notification(
2946 clientName="",
2947 serverName="",
2948 type=ui_pb2.TASK_START,
2949 data=config,
2950 rules=[])
2951 nid = self._nodes.send_notification(
2952 node_addr, noti, self._notification_callback
2953 )
2954 if nid != None:
2955 self._notifications_sent[nid] = noti
2956
2957 self.LAST_NETSTAT_NODE = node_addr
2958
2959 def _unmonitor_node_netstat(self, node_addr):
2960 self.netstatLabel.hide()

Callers 2

_cb_tab_changedMethod · 0.95

Calls 4

is_connectedMethod · 0.80
showMethod · 0.45
send_notificationMethod · 0.45

Tested by

no test coverage detected