mirror of
https://github.com/markqvist/LXMF.git
synced 2024-10-01 01:35:36 -04:00
Allow ratchet enforcement and fixed opportunistic delivery queue handling
This commit is contained in:
parent
a9fe086bcf
commit
775ac7ff68
@ -58,7 +58,7 @@ class LXMRouter:
|
|||||||
#######################################################
|
#######################################################
|
||||||
|
|
||||||
def __init__(self, identity = None, storagepath = None, autopeer = AUTOPEER, autopeer_maxdepth = None,
|
def __init__(self, identity = None, storagepath = None, autopeer = AUTOPEER, autopeer_maxdepth = None,
|
||||||
propagation_limit = PROPAGATION_LIMIT, delivery_limit = DELIVERY_LIMIT):
|
propagation_limit = PROPAGATION_LIMIT, delivery_limit = DELIVERY_LIMIT, enforce_ratchets = False):
|
||||||
|
|
||||||
random.seed(os.urandom(10))
|
random.seed(os.urandom(10))
|
||||||
|
|
||||||
@ -93,6 +93,7 @@ class LXMRouter:
|
|||||||
self.information_storage_limit = None
|
self.information_storage_limit = None
|
||||||
self.propagation_per_transfer_limit = propagation_limit
|
self.propagation_per_transfer_limit = propagation_limit
|
||||||
self.delivery_per_transfer_limit = delivery_limit
|
self.delivery_per_transfer_limit = delivery_limit
|
||||||
|
self.enforce_ratchets = enforce_ratchets
|
||||||
|
|
||||||
self.wants_download_on_path_available_from = None
|
self.wants_download_on_path_available_from = None
|
||||||
self.wants_download_on_path_available_to = None
|
self.wants_download_on_path_available_to = None
|
||||||
@ -183,6 +184,8 @@ class LXMRouter:
|
|||||||
delivery_destination.set_packet_callback(self.delivery_packet)
|
delivery_destination.set_packet_callback(self.delivery_packet)
|
||||||
delivery_destination.set_link_established_callback(self.delivery_link_established)
|
delivery_destination.set_link_established_callback(self.delivery_link_established)
|
||||||
delivery_destination.display_name = display_name
|
delivery_destination.display_name = display_name
|
||||||
|
if self.enforce_ratchets:
|
||||||
|
delivery_destination.enforce_ratchets()
|
||||||
|
|
||||||
if display_name != None:
|
if display_name != None:
|
||||||
delivery_destination.set_default_app_data(display_name.encode("utf-8"))
|
delivery_destination.set_default_app_data(display_name.encode("utf-8"))
|
||||||
@ -1245,6 +1248,7 @@ class LXMRouter:
|
|||||||
delivery_destination = self.delivery_destinations[destination_hash]
|
delivery_destination = self.delivery_destinations[destination_hash]
|
||||||
encrypted_lxmf_data = lxmf_data[LXMessage.DESTINATION_LENGTH:]
|
encrypted_lxmf_data = lxmf_data[LXMessage.DESTINATION_LENGTH:]
|
||||||
decrypted_lxmf_data = delivery_destination.decrypt(encrypted_lxmf_data)
|
decrypted_lxmf_data = delivery_destination.decrypt(encrypted_lxmf_data)
|
||||||
|
if decrypted_lxmf_data != None:
|
||||||
delivery_data = lxmf_data[:LXMessage.DESTINATION_LENGTH]+decrypted_lxmf_data
|
delivery_data = lxmf_data[:LXMessage.DESTINATION_LENGTH]+decrypted_lxmf_data
|
||||||
self.lxmf_delivery(delivery_data, delivery_destination.type)
|
self.lxmf_delivery(delivery_data, delivery_destination.type)
|
||||||
self.locally_delivered_transient_ids[transient_id] = time.time()
|
self.locally_delivered_transient_ids[transient_id] = time.time()
|
||||||
@ -1326,7 +1330,7 @@ class LXMRouter:
|
|||||||
if lxmessage.state == LXMessage.DELIVERED:
|
if lxmessage.state == LXMessage.DELIVERED:
|
||||||
RNS.log("Delivery has occurred for "+str(lxmessage)+", removing from outbound queue", RNS.LOG_DEBUG)
|
RNS.log("Delivery has occurred for "+str(lxmessage)+", removing from outbound queue", RNS.LOG_DEBUG)
|
||||||
self.pending_outbound.remove(lxmessage)
|
self.pending_outbound.remove(lxmessage)
|
||||||
elif lxmessage.state == LXMessage.SENT:
|
elif lxmessage.method == LXMessage.PROPAGATED and lxmessage.state == LXMessage.SENT:
|
||||||
RNS.log("Propagation has occurred for "+str(lxmessage)+", removing from outbound queue", RNS.LOG_DEBUG)
|
RNS.log("Propagation has occurred for "+str(lxmessage)+", removing from outbound queue", RNS.LOG_DEBUG)
|
||||||
self.pending_outbound.remove(lxmessage)
|
self.pending_outbound.remove(lxmessage)
|
||||||
else:
|
else:
|
||||||
|
@ -351,7 +351,9 @@ class LXMessage:
|
|||||||
|
|
||||||
|
|
||||||
def determine_transport_encryption(self):
|
def determine_transport_encryption(self):
|
||||||
# TODO: Update transport encryption descriptions to account for ratchets
|
# TODO: These descriptions are old and outdated.
|
||||||
|
# Update the transport encryption descriptions to
|
||||||
|
# account for ratchets and other changes.
|
||||||
if self.method == LXMessage.OPPORTUNISTIC:
|
if self.method == LXMessage.OPPORTUNISTIC:
|
||||||
if self.__destination.type == RNS.Destination.SINGLE:
|
if self.__destination.type == RNS.Destination.SINGLE:
|
||||||
self.transport_encrypted = True
|
self.transport_encrypted = True
|
||||||
|
Loading…
Reference in New Issue
Block a user