mirror of
https://github.com/markqvist/Reticulum.git
synced 2026-08-27 04:08:58 +00:00
Signal blackholed status in validate_announce
This commit is contained in:
parent
42f6d64b9c
commit
60eb0509f2
2 changed files with 7 additions and 6 deletions
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue