From 39e3854daca7b29c585ebaa0dee412ccd429d1e0 Mon Sep 17 00:00:00 2001 From: JRG Date: Tue, 18 Aug 2026 13:39:12 +0300 Subject: [PATCH] Link: reset watchdog if exception happens in receive --- RNS/Link.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/RNS/Link.py b/RNS/Link.py index d170f9a7..49ecad7e 100644 --- a/RNS/Link.py +++ b/RNS/Link.py @@ -928,6 +928,13 @@ class Link: def receive(self, packet): self.watchdog_lock = True + try: self.__receive(packet) + except Exception as e: + RNS.log(f"Error while receiving a packet: {e}", RNS.LOG_ERROR) + RNS.trace_exception(e) + finally: self.watchdog_lock = False + + def __receive(self, packet): if not self.status == Link.CLOSED and not (self.initiator and packet.context == RNS.Packet.KEEPALIVE and packet.data == bytes([0xFF])): if packet.receiving_interface != self.attached_interface: RNS.log(f"Link-associated packet received on unexpected interface {packet.receiving_interface} instead of {self.attached_interface}! Someone might be trying to manipulate your communication!", RNS.LOG_ERROR) @@ -1156,8 +1163,6 @@ class Link: threading.Thread(target=job, daemon=True).start() self.__update_phy_stats(packet, query_shared=True) - self.watchdog_lock = False - def encrypt(self, plaintext): try: if not self.token: