From e64d815033cca0eed4393c200d9258ce7438b849 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 19 Jul 2026 21:37:59 +0200 Subject: [PATCH] Fixed link stale teardown due to missing keepalive from initiator side when destination continously sends packets --- RNS/Link.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/RNS/Link.py b/RNS/Link.py index 14008b30..f0b469aa 100644 --- a/RNS/Link.py +++ b/RNS/Link.py @@ -746,7 +746,7 @@ class Link: last_inbound = max(max(self.last_inbound, self.last_proof), activated_at) now = time.time() - if now >= last_inbound + self.keepalive: + if now >= last_inbound + self.keepalive or now >= self.last_outbound + self.keepalive: if self.initiator and now >= self.last_keepalive + self.keepalive: self.send_keepalive() @@ -1099,9 +1099,10 @@ class Link: elif packet.context == RNS.Packet.KEEPALIVE: if not self.initiator and packet.data == bytes([0xFF]): - keepalive_packet = RNS.Packet(self, bytes([0xFE]), context=RNS.Packet.KEEPALIVE) - keepalive_packet.send() - self.had_outbound(is_keepalive = True) + if time.time() >= self.last_outbound + self.keepalive: + keepalive_packet = RNS.Packet(self, bytes([0xFE]), context=RNS.Packet.KEEPALIVE) + keepalive_packet.send() + self.had_outbound(is_keepalive = True) # TODO: find the most efficient way to allow multiple