Skip to content

Commit fe4a397

Browse files
authored
Merge branch 'evilsocket:master' into list_subscriptions
2 parents 73a4ace + 5cbc2c6 commit fe4a397

16 files changed

Lines changed: 319 additions & 276 deletions

File tree

ui/opensnitch/config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Config:
4242
RulesTypes = (RULE_TYPE_LIST, RULE_TYPE_LISTS, RULE_TYPE_SIMPLE, RULE_TYPE_REGEXP, RULE_TYPE_NETWORK, RULE_TYPE_RANGE)
4343

4444
DEFAULT_TARGET_PROCESS = 0
45-
ACTION_DENY_IDX = 0
45+
ACTION_DROP_IDX = 0
4646
ACTION_ALLOW_IDX = 1
4747
ACTION_REJECT_IDX = 2
4848

@@ -109,6 +109,8 @@ class Config:
109109
DEFAULT_POPUP_ADVANCED_DSTPORT = "global/default_popup_advanced_dstport"
110110
DEFAULT_POPUP_ADVANCED_UID = "global/default_popup_advanced_uid"
111111
DEFAULT_POPUP_ADVANCED_CHECKSUM = "global/default_popup_advanced_checksum"
112+
DEFAULT_FW_INTERCEPTION_ENABLED = "global/interception_enabled"
113+
DEFAULT_PERSIST_INTERCEPTION_STATE = "global/persist_interception_state"
112114
DEFAULT_SERVER_ADDR = "global/server_address"
113115
DEFAULT_SERVER_MAX_MESSAGE_LENGTH = "global/server_max_message_length"
114116
DEFAULT_SERVER_MAX_WORKERS = "global/max_workers"
@@ -192,7 +194,7 @@ def __init__(self):
192194
if self.settings.value(self.DEFAULT_TIMEOUT_KEY) == None:
193195
self.setSettings(self.DEFAULT_TIMEOUT_KEY, self.DEFAULT_TIMEOUT)
194196
if self.settings.value(self.DEFAULT_ACTION_KEY) == None:
195-
self.setSettings(self.DEFAULT_ACTION_KEY, self.ACTION_DENY_IDX)
197+
self.setSettings(self.DEFAULT_ACTION_KEY, self.ACTION_DROP_IDX)
196198
if self.settings.value(self.DEFAULT_DURATION_KEY) == None:
197199
self.setSettings(self.DEFAULT_DURATION_KEY, self.DEFAULT_DURATION_IDX)
198200
if self.settings.value(self.DEFAULT_TARGET_KEY) == None:
@@ -234,6 +236,7 @@ def getDefaultAction(self):
234236
if _default_action == self.ACTION_ALLOW_IDX:
235237
return self.ACTION_ALLOW
236238
else:
239+
# TODO: use ACTION_DROP when 'drop' is added to the daemon
237240
return self.ACTION_DENY
238241

239242
def setRulesDurationFilter(self, ignore_temporary_rules=False, temp_rules=1):

ui/opensnitch/dialogs/events/dialog.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -999,10 +999,14 @@ def _cb_start_clicked(self):
999999
self.startButton.setIcon(self.iconStart)
10001000
return
10011001

1002-
self.update_interception_status(self.startButton.isChecked())
1003-
self._status_changed_trigger.emit(self.startButton.isChecked())
1002+
checked = self.startButton.isChecked()
1003+
if Config.get().getBool(Config.DEFAULT_PERSIST_INTERCEPTION_STATE, False):
1004+
Config.get().setSettings(Config.DEFAULT_FW_INTERCEPTION_ENABLED, checked)
10041005

1005-
if self.startButton.isChecked():
1006+
self.update_interception_status(checked)
1007+
self._status_changed_trigger.emit(checked)
1008+
1009+
if checked:
10061010
nid, noti = self.node_start_interception(callback=self._notification_callback)
10071011
else:
10081012
nid, noti = self.node_stop_interception(callback=self._notification_callback)

ui/opensnitch/dialogs/events/menu_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def table_menu_enable(self, cur_idx, model, selection, is_rule_enabled):
300300
nodes_updated.append(node)
301301

302302
for addr in nodes_updated:
303-
node = self.node_get_node(addr)
303+
node = self.node_get(addr)
304304
nid, ntf = self.node_reload_fw(addr, node['firewall'], self._notification_callback)
305305
self.save_ntf(nid, ntf)
306306

ui/opensnitch/dialogs/events/menus.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ def configure_rules_contextual_menu(self, pos):
270270
menu.addMenu(nodesMenu)
271271

272272
_actAllow = actionMenu.addAction(QC.translate("stats", "Allow"))
273-
_actDeny = actionMenu.addAction(QC.translate("stats", "Deny"))
273+
_actDrop = actionMenu.addAction(QC.translate("stats", "Drop"))
274274
_actReject = actionMenu.addAction(QC.translate("stats", "Reject"))
275275
menu.addMenu(actionMenu)
276276

@@ -352,7 +352,8 @@ def configure_rules_contextual_menu(self, pos):
352352
self.table_menu_change_rule_field(cur_idx, model, selection, "duration", Config.DURATION_UNTIL_RESTART)
353353
elif action == _actAllow:
354354
self.table_menu_change_rule_field(cur_idx, model, selection, "action", Config.ACTION_ALLOW)
355-
elif action == _actDeny:
355+
elif action == _actDrop:
356+
# TODO: use ACTION_DROP when 'drop' is added to the daemon
356357
self.table_menu_change_rule_field(cur_idx, model, selection, "action", Config.ACTION_DENY)
357358
elif action == _actReject:
358359
self.table_menu_change_rule_field(cur_idx, model, selection, "action", Config.ACTION_REJECT)

ui/opensnitch/dialogs/events/queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ def set_events_query(self, advanced_filter=None):
489489
if self.win.comboAction.currentIndex() == 1:
490490
action = f"action = \"{Config.ACTION_ALLOW}\""
491491
elif self.win.comboAction.currentIndex() == 2:
492+
# TODO: use ACTION_DROP when 'drop' is added to the daemon
492493
action = f"action = \"{Config.ACTION_DENY}\""
493494
elif self.win.comboAction.currentIndex() == 3:
494495
action = f"action = \"{Config.ACTION_REJECT}\""

ui/opensnitch/dialogs/preferences/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def load(win):
5151
win.spinUITimeout.setValue(win.default_timeout)
5252
win.spinUITimeout.setEnabled(not win.disable_popups)
5353
win.popupsCheck.setChecked(win.disable_popups)
54+
win.checkPersistInterception.setChecked(win.cfgMgr.getBool(win.cfgMgr.DEFAULT_PERSIST_INTERCEPTION_STATE, False))
5455

5556
win.showAdvancedCheck.setChecked(win.cfgMgr.getBool(win.cfgMgr.DEFAULT_POPUP_ADVANCED))
5657
win.dstIPCheck.setChecked(win.cfgMgr.getBool(win.cfgMgr.DEFAULT_POPUP_ADVANCED_DSTIP))
@@ -200,6 +201,11 @@ def save_ui_config(win):
200201
win.cfgMgr.setSettings(win.cfgMgr.DEFAULT_DISABLE_POPUPS, bool(win.popupsCheck.isChecked()))
201202
win.cfgMgr.setSettings(win.cfgMgr.DEFAULT_POPUP_POSITION, int(win.comboUIDialogPos.currentIndex()))
202203

204+
persist_interception = bool(win.checkPersistInterception.isChecked())
205+
win.cfgMgr.setSettings(win.cfgMgr.DEFAULT_PERSIST_INTERCEPTION_STATE, persist_interception)
206+
if not persist_interception:
207+
win.cfgMgr.setSettings(win.cfgMgr.DEFAULT_FW_INTERCEPTION_ENABLED, True)
208+
203209
win.cfgMgr.setSettings(win.cfgMgr.DEFAULT_POPUP_ADVANCED, bool(win.showAdvancedCheck.isChecked()))
204210
win.cfgMgr.setSettings(win.cfgMgr.DEFAULT_POPUP_ADVANCED_DSTIP, bool(win.dstIPCheck.isChecked()))
205211
win.cfgMgr.setSettings(win.cfgMgr.DEFAULT_POPUP_ADVANCED_DSTPORT, bool(win.dstPortCheck.isChecked()))
@@ -384,6 +390,7 @@ def build_node_config(win, addr):
384390
if win.comboNodeAddress.currentText() == "":
385391
return None, QC.translate("preferences", "Server address cannot be empty")
386392

393+
# TODO: use ACTION_DROP when 'drop' is added to the daemon
387394
node_action = Config.ACTION_DENY
388395
if win.comboNodeAction.currentIndex() == Config.ACTION_ALLOW_IDX:
389396
node_action = Config.ACTION_ALLOW

ui/opensnitch/dialogs/prompt/dialog.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,22 @@ def __init__(self, parent=None, appicon=None):
126126
self.allowButton.setIcon(self.allowIcon)
127127
self._allow_text = QC.translate("popups", "Allow")
128128
self._action_text = [
129-
QC.translate("popups", "Deny"),
129+
QC.translate("popups", "Drop"),
130130
QC.translate("popups", "Allow"),
131131
QC.translate("popups", "Reject")
132132
]
133133
self._action_icon = [denyIcon, self.allowIcon, rejectIcon]
134134

135135
m = QtWidgets.QMenu()
136-
m.addAction(denyIcon, self._action_text[Config.ACTION_DENY_IDX]).triggered.connect(
137-
lambda: self._on_action_clicked(Config.ACTION_DENY_IDX)
136+
m.addAction(denyIcon, self._action_text[Config.ACTION_DROP_IDX]).triggered.connect(
137+
lambda: self._on_action_clicked(Config.ACTION_DROP_IDX)
138138
)
139139
m.addAction(rejectIcon, self._action_text[Config.ACTION_REJECT_IDX]).triggered.connect(
140140
lambda: self._on_action_clicked(Config.ACTION_REJECT_IDX)
141141
)
142142
self.actionButton.setMenu(m)
143-
self.actionButton.setText(self._action_text[Config.ACTION_DENY_IDX])
144-
self.actionButton.setIcon(self._action_icon[Config.ACTION_DENY_IDX])
143+
self.actionButton.setText(self._action_text[Config.ACTION_DROP_IDX])
144+
self.actionButton.setIcon(self._action_icon[Config.ACTION_DROP_IDX])
145145
if self._default_action != Config.ACTION_ALLOW_IDX:
146146
self.actionButton.setText(self._action_text[self._default_action])
147147
self.actionButton.setIcon(self._action_icon[self._default_action])
@@ -431,7 +431,7 @@ def _set_cmd_action_text(self):
431431
if action_idx == Config.ACTION_ALLOW_IDX:
432432
self.allowButton.setText("{0} ({1})".format(self._allow_text, self._tick))
433433
self.allowButton.setIcon(self.allowIcon)
434-
self.actionButton.setText(self._action_text[Config.ACTION_DENY_IDX])
434+
self.actionButton.setText(self._action_text[Config.ACTION_DROP_IDX])
435435
else:
436436
self.allowButton.setText(self._allow_text)
437437
self.actionButton.setText("{0} ({1})".format(self._action_text[action_idx], self._tick))
@@ -604,7 +604,7 @@ def _on_action_clicked(self, action):
604604
def _on_deny_btn_clicked(self, action):
605605
self._default_action = self._cfg.getInt(self._cfg.DEFAULT_ACTION_KEY)
606606
if self._default_action == Config.ACTION_ALLOW_IDX:
607-
self._default_action = Config.ACTION_DENY_IDX
607+
self._default_action = Config.ACTION_DROP_IDX
608608
self._send_rule()
609609

610610
def _is_list_rule(self):
@@ -622,7 +622,8 @@ def _send_rule(self):
622622
self._rule.duration = utils.get_duration(self.durationCombo.currentIndex())
623623

624624
self._rule.action = Config.ACTION_ALLOW
625-
if self._default_action == Config.ACTION_DENY_IDX:
625+
if self._default_action == Config.ACTION_DROP_IDX:
626+
# TODO: use ACTION_DROP when 'drop' is added to the daemon
626627
self._rule.action = Config.ACTION_DENY
627628
elif self._default_action == Config.ACTION_REJECT_IDX:
628629
self._rule.action = Config.ACTION_REJECT

ui/opensnitch/dialogs/ruleseditor/dialog.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def load_rule(self, addr=None, rule=None):
344344
self.enableCheck.setChecked(rule.enabled)
345345
self.precedenceCheck.setChecked(rule.precedence)
346346
self.nologCheck.setChecked(rule.nolog)
347+
# TODO: use ACTION_DROP when 'drop' is added to the daemon
347348
if rule.action == Config.ACTION_DENY:
348349
self.actionDenyRadio.setChecked(True)
349350
elif rule.action == Config.ACTION_ALLOW:
@@ -420,6 +421,7 @@ def save_rule(self):
420421
self.rule.precedence = self.precedenceCheck.isChecked()
421422
self.rule.nolog = self.nologCheck.isChecked()
422423
self.rule.operator.type = Config.RULE_TYPE_SIMPLE
424+
# TODO: use ACTION_DROP when 'drop' is added to the daemon
423425
self.rule.action = Config.ACTION_DENY
424426
if self.actionAllowRadio.isChecked():
425427
self.rule.action = Config.ACTION_ALLOW

ui/opensnitch/notifications.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class DesktopNotifications():
3434
# must be a string
3535
ACTION_ID_OPEN = "action-open"
3636
ACTION_ID_ALLOW = "action-allow"
37-
ACTION_ID_DENY = "action-deny"
37+
ACTION_ID_DROP = "action-drop"
3838

3939
def __init__(self):
4040
self.ACTION_OPEN = QC.translate("popups", "Open")
4141
self.ACTION_ALLOW = QC.translate("popups", "Allow")
42-
self.ACTION_DENY = QC.translate("popups", "Deny")
42+
self.ACTION_DROP = QC.translate("popups", "Drop")
4343
self.IS_LIBNOTIFY_AVAILABLE = True
4444
self.DOES_SUPPORT_ACTIONS = True
4545
self.ntf2 = None
@@ -129,7 +129,7 @@ def ask(self, connection, timeout, callback):
129129
if self.DOES_SUPPORT_ACTIONS:
130130
ntf.set_urgency(self.ntf2.URGENCY_CRITICAL)
131131
ntf.add_action(self.ACTION_ID_ALLOW, self.ACTION_ALLOW, callback, connection)
132-
ntf.add_action(self.ACTION_ID_DENY, self.ACTION_DENY, callback, connection)
132+
ntf.add_action(self.ACTION_ID_DROP, self.ACTION_DROP, callback, connection)
133133
#ntf.add_action("open-gui", QC.translate("popups", "View"), callback, connection)
134134
ntf.set_category(self.CATEGORY_NETWORK)
135135
ntf.set_hint(self.HINT_DESKTOP_ENTRY, "opensnitch_ui")

ui/opensnitch/plugins/highlight/example/commonActionsDelegate.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
},
2222
{
2323
"text": [
24+
"drop",
2425
"deny",
2526
"☓ offline"
2627
],

0 commit comments

Comments
 (0)