Compare commits

...
13 Commits
Author SHA1 Message Date
Mark Qvist bd3ace0885 Updated version 2022-04-15 11:30:08 +02:00
Mark Qvist ed4effdab7 Fixed invalid name in peer culling. Thanks Stephan :) 2022-04-13 11:33:27 +02:00
Mark Qvist 2d1828513f Fixed destination type reference 2022-04-13 11:14:41 +02:00
Mark Qvist 505176b6ee Fixed delivery method default. Thanks Stephan ;) 2022-04-13 11:10:21 +02:00
Mark Qvist 853e70dcbe Dependency bump 2022-03-28 15:19:43 +02:00
Mark Qvist 38cc471eaf Improved error handling 2022-03-25 20:25:00 +01:00
Mark Qvist 704930f91a Updated version 2022-03-25 20:24:36 +01:00
Mark Qvist 137db1e6a3 Added path request retry on link initial link failure 2021-12-11 19:56:35 +01:00
Mark Qvist 5e8b2d87af Updated dependency version 2021-12-10 20:08:25 +01:00
Mark Qvist 38b6f7651c Peer cleanup fix 2021-12-10 18:36:18 +01:00
Mark Qvist 6aa793252f Updated version 2021-12-01 20:16:36 +01:00
Mark Qvist 1ca2493c36 Added makefile 2021-12-01 19:28:27 +01:00
Mark Qvist 38bbf19421 Error handling 2021-12-01 19:28:19 +01:00
3 changed files with 76 additions and 28 deletions

No files matched your search

+50 -25
View File
@@ -228,7 +228,7 @@ class LXMessage:
# If no desired delivery method has been defined,
# one will be chosen according to these rules:
if self.desired_method == None:
self.desired_method == LXMessage.DIRECT
self.desired_method = LXMessage.DIRECT
# TODO: Expand rules to something more intelligent
if self.desired_method == LXMessage.OPPORTUNISTIC:
@@ -308,7 +308,7 @@ class LXMessage:
if self.__destination.type == RNS.Destination.SINGLE:
self.transport_encrypted = True
self.transport_encryption = LXMessage.ENCRYPTION_DESCRIPTION_EC
elif destination_type == RNS.Destination.GROUP:
elif self.__destination.type == RNS.Destination.GROUP:
self.transport_encrypted = True
self.transport_encryption = LXMessage.ENCRYPTION_DESCRIPTION_AES
else:
@@ -405,26 +405,28 @@ class LXMessage:
else:
return None
def packed_container(self):
if not self.packed:
self.pack()
container = {
"state": self.state,
"lxmf_bytes": self.packed,
"transport_encrypted": self.transport_encrypted,
"transport_encryption": self.transport_encryption,
"method": self.method
}
return msgpack.packb(container)
def write_to_directory(self, directory_path):
file_name = RNS.hexrep(self.hash, delimit=False)
file_path = directory_path+"/"+file_name
try:
if not self.packed:
self.pack()
container = {
"state": self.state,
"lxmf_bytes": self.packed,
"transport_encrypted": self.transport_encrypted,
"transport_encryption": self.transport_encryption,
"method": self.method
}
packed_container = msgpack.packb(container)
file = open(file_path, "wb")
file.write(packed_container)
file.write(self.packed_container())
file.close()
return file_path
@@ -796,14 +798,16 @@ class LXMPeer:
return "<Unknown>"
class LXMRouter:
MAX_DELIVERY_ATTEMPTS = 3
MAX_DELIVERY_ATTEMPTS = 4
PROCESSING_INTERVAL = 5
DELIVERY_RETRY_WAIT = 15
DELIVERY_RETRY_WAIT = 12
PATH_REQUEST_WAIT = 5
LINK_MAX_INACTIVITY = 10*60
MESSAGE_EXPIRY = 30*24*60*60
NODE_ANNOUNCE_DELAY = 20
AUTOPEER = True
AUTOPEER_MAXDEPTH = 4
@@ -1228,8 +1232,14 @@ class LXMRouter:
self.announce_propagation_node()
def announce_propagation_node(self):
data = msgpack.packb([self.propagation_node, int(time.time())])
self.propagation_destination.announce(app_data=data)
def delayed_announce():
time.sleep(LXMRouter.NODE_ANNOUNCE_DELAY)
data = msgpack.packb([self.propagation_node, int(time.time())])
self.propagation_destination.announce(app_data=data)
da_thread = threading.Thread(target=delayed_announce)
da_thread.setDaemon(True)
da_thread.start()
def offer_request(self, path, data, request_id, remote_identity, requested_at):
if remote_identity == None:
@@ -1563,9 +1573,13 @@ class LXMRouter:
RNS.log("Selected waiting peer "+str(selected_index)+": "+RNS.prettyhexrep(selected_peer.destination.hash), RNS.LOG_DEBUG)
selected_peer.sync()
for peer in culled_peers:
RNS.log("Removing peer "+RNS.prettyhexrep(peer)+" due to excessive unreachability", RNS.LOG_WARNING)
self.peers.pop(peer_id)
for peer_id in culled_peers:
RNS.log("Removing peer "+RNS.prettyhexrep(peer_id)+" due to excessive unreachability", RNS.LOG_WARNING)
try:
if peer_id in self.peers:
self.peers.pop(peer_id)
except Exception as e:
RNS.log("Error while removing peer "+RNS.prettyhexrep(peer_id)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
def fail_message(self, lxmessage):
@@ -1624,7 +1638,18 @@ class LXMRouter:
else:
RNS.log("Waiting for proof for "+str(lxmessage)+" sent as link packet", RNS.LOG_DEBUG)
elif direct_link.status == RNS.Link.CLOSED:
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" was closed", RNS.LOG_DEBUG)
if direct_link.activated_at != None:
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" was closed", RNS.LOG_DEBUG)
else:
if not hasattr(lxmessage, "path_request_retried"):
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" was never activated, retrying path request...", RNS.LOG_DEBUG)
RNS.Transport.request_path(lxmessage.get_destination().hash)
lxmessage.path_request_retried = True
else:
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" was never activated", RNS.LOG_DEBUG)
lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
lxmessage.set_delivery_destination(None)
self.direct_links.pop(delivery_destination_hash)
lxmessage.next_delivery_attempt = time.time() + LXMRouter.DELIVERY_RETRY_WAIT
@@ -1707,4 +1732,4 @@ class LXMRouter:
else:
RNS.log("Max delivery attempts reached for propagated "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
self.fail_message(lxmessage)
self.fail_message(lxmessage)
+23
View File
@@ -0,0 +1,23 @@
all: release
clean:
@echo Cleaning...
-rm -r ./build
-rm -r ./dist
remove_symlinks:
@echo Removing symlinks for build...
-rm ./RNS
create_symlinks:
@echo Creating symlinks...
-ln -s ../Reticulum/RNS ./
build_wheel:
python3 setup.py sdist bdist_wheel
release: remove_symlinks build_wheel create_symlinks
upload:
@echo Uploading to PyPi...
twine upload dist/*
+3 -3
View File
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="lxmf",
version="0.1.2",
version="0.1.5",
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>=0.2.8'],
install_requires=['rns>=0.3.4'],
python_requires='>=3.6',
)
)