From b2aba3f6db59d016afa994604b3d4a85c70ca718 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 17 May 2022 19:43:51 +0200 Subject: [PATCH] Added ignore functionality --- LXMF/LXMF.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/LXMF/LXMF.py b/LXMF/LXMF.py index 9a486f7..a1d2b0f 100644 --- a/LXMF/LXMF.py +++ b/LXMF/LXMF.py @@ -843,6 +843,8 @@ class LXMRouter: self.direct_links = {} self.delivery_destinations = {} + self.ignored_list = [] + self.processing_outbound = False self.processing_inbound = False self.processing_count = 0 @@ -1136,6 +1138,10 @@ class LXMRouter: message.transport_encrypted = False message.transport_encryption = None + if message.source_hash in self.ignored_list: + RNS.log(str(self)+" ignored message from "+RNS.prettyhexrep(message.source_hash), RNS.LOG_DEBUG) + return False + if self.__delivery_callback != None and callable(self.__delivery_callback): try: self.__delivery_callback(message) @@ -1595,6 +1601,14 @@ class LXMRouter: RNS.log("Error while removing peer "+RNS.prettyhexrep(peer_id)+". The contained exception was: "+str(e), RNS.LOG_ERROR) + def ignore_destination(self, destination_hash): + if not destination_hash in self.ignored_list: + self.ignored_list.append(destination_hash) + + def unignore_destination(self, destination_hash): + if destination_hash in self.ignored_list: + self.ignored_list.remove(destination_hash) + def fail_message(self, lxmessage): RNS.log(str(lxmessage)+" failed to send", RNS.LOG_DEBUG) @@ -1605,6 +1619,9 @@ class LXMRouter: if lxmessage.failed_callback != None and callable(lxmessage.failed_callback): lxmessage.failed_callback(lxmessage) + def __str__(self): + return "" + def process_outbound(self, sender = None): if self.processing_outbound: return