From 40f7a6d3598d6113bc561de4dc7f3cd08e4c792f Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 2 Sep 2021 14:44:53 +0200 Subject: [PATCH] Added resource HMU/part request hash filter. Fixes #7. --- RNS/Link.py | 6 +++++- RNS/Resource.py | 1 + RNS/_version.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/RNS/Link.py b/RNS/Link.py index cae3321..00dc638 100644 --- a/RNS/Link.py +++ b/RNS/Link.py @@ -651,7 +651,11 @@ class Link: resource_hash = plaintext[1:RNS.Identity.HASHLENGTH//8+1] for resource in self.outgoing_resources: if resource.hash == resource_hash: - resource.request(plaintext) + # We need to check that this request has not been + # received before in order to avoid sequencing errors. + if not packet.packet_hash in resource.req_hashlist: + resource.req_hashlist.append(packet.packet_hash) + resource.request(plaintext) elif packet.context == RNS.Packet.RESOURCE_HMU: plaintext = self.decrypt(packet.data) diff --git a/RNS/Resource.py b/RNS/Resource.py index ec0b2e2..93aa82d 100644 --- a/RNS/Resource.py +++ b/RNS/Resource.py @@ -192,6 +192,7 @@ class Resource: self.request_id = request_id self.is_response = is_response + self.req_hashlist = [] self.receiver_min_consecutive_height = 0 if timeout != None: diff --git a/RNS/_version.py b/RNS/_version.py index 4f7052b..7a17bdd 100644 --- a/RNS/_version.py +++ b/RNS/_version.py @@ -1 +1 @@ -__version__ = "0.2.3" \ No newline at end of file +__version__ = "0.2.4" \ No newline at end of file