mirror of
https://github.com/markqvist/LXMF.git
synced 2024-10-01 01:35:36 -04:00
Cleanup
This commit is contained in:
parent
453772859d
commit
717240c8d4
@ -1299,7 +1299,7 @@ class LXMRouter:
|
|||||||
else:
|
else:
|
||||||
RNS.log(f"Received {message} with invalid stamp, but allowing anyway, since stamp enforcement is disabled", RNS.LOG_NOTICE)
|
RNS.log(f"Received {message} with invalid stamp, but allowing anyway, since stamp enforcement is disabled", RNS.LOG_NOTICE)
|
||||||
else:
|
else:
|
||||||
RNS.log(f"Received {message} valid stamp", RNS.LOG_DEBUG)
|
RNS.log(f"Received {message} with valid stamp", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
if phy_stats != None:
|
if phy_stats != None:
|
||||||
if "rssi" in phy_stats: message.rssi = phy_stats["rssi"]
|
if "rssi" in phy_stats: message.rssi = phy_stats["rssi"]
|
||||||
|
@ -264,10 +264,14 @@ class LXMessage:
|
|||||||
def validate_stamp(self, target_cost, tickets=None):
|
def validate_stamp(self, target_cost, tickets=None):
|
||||||
if tickets != None:
|
if tickets != None:
|
||||||
for ticket in tickets:
|
for ticket in tickets:
|
||||||
|
try:
|
||||||
if self.stamp == RNS.Identity.truncated_hash(ticket+self.message_id):
|
if self.stamp == RNS.Identity.truncated_hash(ticket+self.message_id):
|
||||||
RNS.log(f"Stamp on {self} validated by inbound ticket", RNS.LOG_DEBUG) # TODO: Remove at some point
|
RNS.log(f"Stamp on {self} validated by inbound ticket", RNS.LOG_DEBUG) # TODO: Remove at some point
|
||||||
self.stamp_value = LXMessage.COST_TICKET
|
self.stamp_value = LXMessage.COST_TICKET
|
||||||
return True
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log(f"Error while validating ticket: {e}", RNS.LOG_ERROR)
|
||||||
|
RNS.trace_exception(e)
|
||||||
|
|
||||||
if self.stamp == None:
|
if self.stamp == None:
|
||||||
return False
|
return False
|
||||||
@ -284,9 +288,10 @@ class LXMessage:
|
|||||||
# If an outbound ticket exists, use this for
|
# If an outbound ticket exists, use this for
|
||||||
# generating a valid stamp.
|
# generating a valid stamp.
|
||||||
if self.outbound_ticket != None and type(self.outbound_ticket) == bytes and len(self.outbound_ticket) == LXMessage.TICKET_LENGTH:
|
if self.outbound_ticket != None and type(self.outbound_ticket) == bytes and len(self.outbound_ticket) == LXMessage.TICKET_LENGTH:
|
||||||
RNS.log(f"Generating stamp with outbound ticket for {self}", RNS.LOG_DEBUG) # TODO: Remove at some point
|
generated_stamp = RNS.Identity.truncated_hash(self.outbound_ticket+self.message_id)
|
||||||
self.stamp_value = LXMessage.COST_TICKET
|
self.stamp_value = LXMessage.COST_TICKET
|
||||||
return RNS.Identity.truncated_hash(self.outbound_ticket+self.message_id)
|
RNS.log(f"Generated stamp with outbound ticket {RNS.hexrep(self.outbound_ticket)} for {self}", RNS.LOG_DEBUG) # TODO: Remove at some point
|
||||||
|
return generated_stamp
|
||||||
|
|
||||||
# If no stamp cost is required, we can just
|
# If no stamp cost is required, we can just
|
||||||
# return immediately.
|
# return immediately.
|
||||||
|
Loading…
Reference in New Issue
Block a user