Added automatic path requests. Bumped version to 0.0.4.

This commit is contained in:
Mark Qvist 2021-05-17 21:54:28 +02:00
parent 4215bd186e
commit 5f578f93b3
2 changed files with 13 additions and 8 deletions

View File

@ -455,7 +455,7 @@ class LXMRouter:
MAX_DELIVERY_ATTEMPTS = 3
PROCESSING_INTERVAL = 5
DELIVERY_RETRY_WAIT = 15
LINK_MAX_INACTIVITY = 30
LINK_MAX_INACTIVITY = 10*60
def __init__(self):
self.pending_inbound = []
@ -597,7 +597,8 @@ class LXMRouter:
closed_links.append(link_hash)
for link_hash in closed_links:
self.direct_links.pop(link_hash)
cleaned_link = self.direct_links.pop(link_hash)
RNS.log("Cleaned link "+str(cleaned_link), RNS.LOG_DEBUG)
def fail_message(self, lxmessage):
RNS.log(str(lxmessage)+" failed to send", RNS.LOG_DEBUG)
@ -665,10 +666,14 @@ class LXMRouter:
lxmessage.delivery_attempts += 1
lxmessage.next_delivery_attempt = time.time() + LXMRouter.DELIVERY_RETRY_WAIT
if lxmessage.delivery_attempts < LXMRouter.MAX_DELIVERY_ATTEMPTS:
RNS.log("Establishing link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" for delivery attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
delivery_link = RNS.Link(lxmessage.get_destination())
delivery_link.link_established_callback(self.process_outbound)
self.direct_links[delivery_destination_hash] = delivery_link
if RNS.Transport.has_path(lxmessage.get_destination().hash):
RNS.log("Establishing link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" for delivery attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
delivery_link = RNS.Link(lxmessage.get_destination())
delivery_link.link_established_callback(self.process_outbound)
self.direct_links[delivery_destination_hash] = delivery_link
else:
RNS.log("No path known for delivery attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+". Requesting path...", RNS.LOG_DEBUG)
RNS.Transport.request_path(lxmessage.get_destination().hash)
else:
RNS.log("Max delivery attempts reached for direct "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
self.fail_message(lxmessage)

View File

@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="lxmf",
version="0.0.2",
version="0.0.4",
author="Mark Qvist",
author_email="mark@unsigned.io",
description="Lightweight Extensible Message Format for Reticulum",
@ -18,6 +18,6 @@ setuptools.setup(
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
install_requires=['rns'],
install_requires=['rns>=0.2.0'],
python_requires='>=3.6',
)