Skip to content

Commit 4c16729

Browse files
ui,pop-ups: improvements
- Be specific about user's preferences and respect all of them properly. - reset widgets before rendering a new connection.
1 parent 87be10c commit 4c16729

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

ui/opensnitch/dialogs/prompt/dialog.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ def _timeout_worker(self):
389389
@QtCore.pyqtSlot()
390390
def on_connection_prompt_triggered(self):
391391
self.stackedWidget.setCurrentIndex(constants.PAGE_MAIN)
392+
self.reset_widgets()
392393
self._render_connection(self._con)
393394
if self._tick > 0:
394395
self.show()
@@ -406,6 +407,20 @@ def on_timeout_triggered(self):
406407
self._timeout_triggered = True
407408
self._send_rule()
408409

410+
def reset_widgets(self):
411+
self.appNameLabel.setText("")
412+
self.appPathLabel.setText("")
413+
self.argsLabel.setText("")
414+
self.appDescriptionLabel.setText("")
415+
self.messageLabel.setText("")
416+
self.cwdLabel.setText("")
417+
self.sourceIPLabel.setText("")
418+
self.destIPLabel.setText("")
419+
self.destPortLabel.setText("")
420+
self.uidLabel.setText("")
421+
self.checksumLabel.setText("")
422+
self.labelChecksumStatus.setText("")
423+
409424
def _hide_widget(self, widget, hide):
410425
widget.setVisible(not hide)
411426

@@ -666,7 +681,7 @@ def _send_rule(self):
666681
if self._rule.operator.operand == Config.OPERAND_PROCESS_COMMAND:
667682
proc_args = " ".join(self._con.process_args)
668683
proc_args = proc_args.split(" ")
669-
if os.path.isabs(proc_args[0]) == False or proc_args[0].startswith("/proc"):
684+
if os.path.isabs(proc_args[0]) is False or proc_args[0].startswith("/proc"):
670685
is_list_rule = True
671686
data.append({"type": Config.RULE_TYPE_SIMPLE, "operand": Config.OPERAND_PROCESS_PATH, "data": str(self._con.process_path)})
672687

ui/opensnitch/dialogs/prompt/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,20 @@ def set_default_target(combo, con, cfg, app_name, app_args):
247247
# Sometimes the app_args is empty, so in that case we'll fallback to
248248
# app_path if it's not empty.
249249
# Otherwise select the destination port.
250-
if int(con.process_id) > 0 and app_name != "" and app_args != "":
250+
if saved_target == constants.TARGET_IDX_PID and int(con.process_id) > 0:
251+
combo.setCurrentIndex(constants.TARGET_IDX_PID)
252+
elif saved_target == constants.TARGET_IDX_UID:
253+
combo.setCurrentIndex(constants.TARGET_IDX_UID)
254+
elif saved_target == constants.TARGET_IDX_DST_IP:
255+
combo.setCurrentIndex(constants.TARGET_IDX_DST_IP)
256+
elif saved_target == constants.TARGET_IDX_DST_PORT:
257+
combo.setCurrentIndex(constants.TARGET_IDX_DST_PORT)
258+
elif int(con.process_id) > 0 and app_name != "" and app_args != "":
251259
combo.setCurrentIndex(saved_target)
252260
elif int(con.process_id) > 0 and app_name != "" and app_args == "":
253261
combo.setCurrentIndex(constants.TARGET_IDX_PROC_PATH)
254262
else:
255-
print("[warning] connection process details incomplete:", con)
263+
print("[warning] connection process details incomplete?", con)
256264
combo.setCurrentIndex(constants.TARGET_IDX_DST_PORT)
257265

258266
def get_combo_operator(data, comboText, con):

0 commit comments

Comments
 (0)