Skip to content

Commit 99cd9f1

Browse files
ui,popups: fixed exception getting node address when adding a new rule
When a popup was displayed to the user, if they took more than 120s to respond, the address of the node was lost. This is because the daemon has hardcoded a max timeout of 120s. If it fires, the call to AskRule is closed and the context is lost. In this situation, save the address of the node at the start of AskRule, so we can reuse it later.
1 parent 36f9242 commit 99cd9f1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

ui/opensnitch/service.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,9 @@ def AskRule(self, request, context):
751751

752752
# TODO: allow connections originated from ourselves: os.getpid() == request.pid)
753753
self._asking = True
754-
proto, addr = self._get_peer(context.peer())
755-
rule, timeout_triggered = self._prompt_dialog.promptUser(request, self._is_local_request(proto, addr), context.peer())
754+
peer = context.peer()
755+
proto, addr = self._get_peer(peer)
756+
rule, timeout_triggered = self._prompt_dialog.promptUser(request, self._is_local_request(proto, addr), peer)
756757
self._last_ping = datetime.now()
757758
self._asking = False
758759
if rule == None:
@@ -777,14 +778,14 @@ def AskRule(self, request, context):
777778
{
778779
'action': self.DELETE_RULE,
779780
'name': rule.name,
780-
'addr': context.peer()
781+
'addr': peer
781782
}
782783
)
783784
else:
784785
self._node_actions_trigger.emit(
785786
{
786787
'action': self.ADD_RULE,
787-
'peer': context.peer(),
788+
'peer': peer,
788789
'rule': rule
789790
}
790791
)

0 commit comments

Comments
 (0)