Skip to content

Commit

Permalink
ui,popups: fixed exception getting node address when adding a new rule
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gustavo-iniguez-goya committed Dec 16, 2024
1 parent 36f9242 commit 99cd9f1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions ui/opensnitch/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -751,8 +751,9 @@ def AskRule(self, request, context):

# TODO: allow connections originated from ourselves: os.getpid() == request.pid)
self._asking = True
proto, addr = self._get_peer(context.peer())
rule, timeout_triggered = self._prompt_dialog.promptUser(request, self._is_local_request(proto, addr), context.peer())
peer = context.peer()
proto, addr = self._get_peer(peer)
rule, timeout_triggered = self._prompt_dialog.promptUser(request, self._is_local_request(proto, addr), peer)
self._last_ping = datetime.now()
self._asking = False
if rule == None:
Expand All @@ -777,14 +778,14 @@ def AskRule(self, request, context):
{
'action': self.DELETE_RULE,
'name': rule.name,
'addr': context.peer()
'addr': peer
}
)
else:
self._node_actions_trigger.emit(
{
'action': self.ADD_RULE,
'peer': context.peer(),
'peer': peer,
'rule': rule
}
)
Expand Down

0 comments on commit 99cd9f1

Please sign in to comment.