Automatically drop LXMs from blackholed identities

This commit is contained in:
Mark Qvist 2026-05-26 13:14:05 +02:00
commit 2ac2b100ae
2 changed files with 14 additions and 7 deletions

View file

@ -1735,11 +1735,13 @@ class LXMRouter:
def lxmf_delivery(self, lxmf_data, destination_type = None, phy_stats = None, ratchet_id = None, method = None, no_stamp_enforcement=False, allow_duplicate=False):
try:
message = LXMessage.unpack_from_bytes(lxmf_data)
if ratchet_id and not message.ratchet_id:
message.ratchet_id = ratchet_id
if method:
message.method = method
if message.source_blackholed:
RNS.log(f"Dropping LXM from blackholed identity {message.source.identity}", RNS.LOG_DEBUG)
return False
if ratchet_id and not message.ratchet_id: message.ratchet_id = ratchet_id
if method: message.method = method
if message.signature_validated and FIELD_TICKET in message.fields:
ticket_entry = message.fields[FIELD_TICKET]

View file

@ -168,6 +168,7 @@ class LXMessage:
self.paper_packed = None
self.incoming = False
self.source_blackholed = False
self.signature_validated = False
self.unverified_reason = None
self.ratchet_id = None
@ -678,7 +679,7 @@ class LXMessage:
file.write(self.packed_container())
file.flush()
try: os.fsync(file.fileno())
except OSError: pass
except OSError as e: RNS.log(f"Error while waiting for persist fsync for {self}: {e}", RNS.LOG_WARNING)
os.replace(tmp_path, file_path)
return file_path
@ -686,9 +687,9 @@ class LXMessage:
except Exception as e:
try:
if os.path.exists(tmp_path): os.unlink(tmp_path)
except Exception: pass
except Exception as e: RNS.log(f"Error while cleaning temporary file {tmp_path} for {self}: {e}", RNS.LOG_ERROR)
RNS.log("Error while writing LXMF message to file \""+str(file_path)+"\". The contained exception was: "+str(e), RNS.LOG_ERROR)
RNS.log(f"Error while writing LXMF message to file \"{file_path}\". The contained exception was: {e}", RNS.LOG_ERROR)
return None
def as_uri(self, finalise=True):
@ -796,6 +797,10 @@ class LXMessage:
message.set_title_from_bytes(title_bytes)
message.set_content_from_bytes(content_bytes)
try:
if source_identity != None: message.source_blackholed = RNS.Reticulum.get_instance().is_blackholed(source_identity)
except Exception as e: RNS.log(f"Could not determine message source blackhole status: {e}", RNS.LOG_WARNING)
try:
if source:
if source.identity.validate(signature, signed_part):