mirror of
https://github.com/markqvist/LXMF.git
synced 2024-10-01 01:35:36 -04:00
Automatically reconfigure to direct delivery if opportunistic message content is too large
This commit is contained in:
parent
7789e0bc26
commit
b5d6ed3d9b
@ -536,6 +536,12 @@ class LXMRouter:
|
||||
def information_storage_size(self):
|
||||
pass
|
||||
|
||||
def delivery_link_available(self, destination_hash):
|
||||
if destination_hash in self.direct_links or destination_hash in self.backchannel_links:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
### Utility & Maintenance #############################
|
||||
#######################################################
|
||||
@ -1746,7 +1752,7 @@ class LXMRouter:
|
||||
|
||||
# Prepare link for backchannel communications
|
||||
delivery_destination_hash = lxmessage.get_destination().hash
|
||||
if delivery_destination_hash in self.direct_links:
|
||||
if lxmessage.method == LXMessage.DIRECT and delivery_destination_hash in self.direct_links:
|
||||
direct_link = self.direct_links[delivery_destination_hash]
|
||||
if not hasattr(direct_link, "backchannel_identified") or direct_link.backchannel_identified == False:
|
||||
if direct_link.initiator == True:
|
||||
|
@ -372,8 +372,16 @@ class LXMessage:
|
||||
# one will be chosen according to these rules:
|
||||
if self.desired_method == None:
|
||||
self.desired_method = LXMessage.DIRECT
|
||||
# TODO: Expand rules to something more intelligent
|
||||
|
||||
# If opportunistic delivery was requested, check
|
||||
# that message will fit within packet size limits
|
||||
if self.desired_method == LXMessage.OPPORTUNISTIC:
|
||||
if self.__destination.type == RNS.Destination.SINGLE:
|
||||
if content_size > LXMessage.ENCRYPTED_PACKET_MAX_CONTENT:
|
||||
RNS.log(f"Opportunistic delivery was requested for {self}, but content exceeds packet size limit. Falling back to link-based delivery.", RNS.LOG_DEBUG)
|
||||
self.desired_method = LXMessage.DIRECT
|
||||
|
||||
# Set delivery parameters according to delivery method
|
||||
if self.desired_method == LXMessage.OPPORTUNISTIC:
|
||||
if self.__destination.type == RNS.Destination.SINGLE:
|
||||
single_packet_content_limit = LXMessage.ENCRYPTED_PACKET_MAX_CONTENT
|
||||
@ -434,6 +442,7 @@ class LXMessage:
|
||||
if self.method == LXMessage.OPPORTUNISTIC:
|
||||
lxm_packet = self.__as_packet()
|
||||
lxm_packet.send().set_delivery_callback(self.__mark_delivered)
|
||||
self.progress = 0.50
|
||||
self.ratchet_id = lxm_packet.ratchet_id
|
||||
self.state = LXMessage.SENT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user