mirror of
https://github.com/markqvist/Reticulum
synced 2026-11-22 23:10:32 +00:00
Signal blackholed status in validate_announce
This commit is contained in:
2 files changed
+7
-6
No files matched your search
+3
-2
@@ -508,7 +508,7 @@ class Identity:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def validate_announce(packet, only_validate_signature=False):
|
||||
def validate_announce(packet, only_validate_signature=False, signal_blackholed=False):
|
||||
try:
|
||||
if packet.packet_type == RNS.Packet.ANNOUNCE:
|
||||
keysize = Identity.KEYSIZE//8
|
||||
@@ -553,7 +553,8 @@ class Identity:
|
||||
if len(RNS.Transport.blackholed_identities) > 0:
|
||||
if announced_identity.hash in RNS.Transport.blackholed_identities:
|
||||
RNS.log(f"Invalidated and dropped announce from blackholed identity {RNS.prettyhexrep(announced_identity.hash)}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
return False
|
||||
if signal_blackholed: return "blackholed"
|
||||
else: return False
|
||||
|
||||
if announced_identity.pub != None and announced_identity.validate(signature, signed_data):
|
||||
if only_validate_signature:
|
||||
|
||||
+4
-4
@@ -1665,10 +1665,10 @@ class Transport:
|
||||
# Ingress limit announces early
|
||||
if packet.packet_type == RNS.Packet.ANNOUNCE:
|
||||
if not tc: traffic_class = Transport.TC_ANNOUNCE
|
||||
announce_signature_valid = RNS.Identity.validate_announce(packet, only_validate_signature=True)
|
||||
if not announce_signature_valid:
|
||||
if not packet.receiving_interface: return None
|
||||
else: return packet.receiving_interface.protocol_violation(f"Invalid announce signature for {RNS.prettyhexrep(packet.destination_hash)}") if not packet.destination_hash in Transport.blackholed_identities else None
|
||||
announce_signature_valid = RNS.Identity.validate_announce(packet, only_validate_signature=True, signal_blackholed=True)
|
||||
if announce_signature_valid == "blackholed": return None
|
||||
elif not announce_signature_valid:
|
||||
return packet.receiving_interface.protocol_violation(f"Invalid announce signature for {RNS.prettyhexrep(packet.destination_hash)}") if packet.receiving_interface else None
|
||||
|
||||
elif packet.receiving_interface != None: packet.receiving_interface.received_announce(size=len(packet.raw))
|
||||
announced_destination_known = packet.destination_hash in Transport.path_table
|
||||
|
||||
Reference in new issue
Block a user