Compare commits

...
14 Commits
8 changed files with 72 additions and 22 deletions

No files matched your search

+15
View File
@@ -1 +1,16 @@
APP_NAME = "lxmf" APP_NAME = "lxmf"
# WARNING! These field specifiers are floating and not
# yet final! Consider highly experiemental, and expect
# them to change in the future! You have been warned :)
FIELD_EMBEDDED_LXMS = 0x01
FIELD_TELEMETRY = 0x02
FIELD_TELEMETRY_STREAM = 0x03
FIELD_ICON_APPEARANCE = 0x04
FIELD_FILE_ATTACHMENTS = 0x05
FIELD_IMAGE = 0x06
FIELD_AUDIO = 0x07
FIELD_THREAD = 0x08
FIELD_COMMANDS = 0x09
FIELD_RESULTS = 0x0A
+1 -1
View File
@@ -22,7 +22,7 @@ class LXMPeer:
# Maximum amount of time a peer can # Maximum amount of time a peer can
# be unreachable before it is removed # be unreachable before it is removed
MAX_UNREACHABLE = 4*24*60*60 MAX_UNREACHABLE = 14*24*60*60
# Everytime consecutive time a sync # Everytime consecutive time a sync
# link fails to establish, add this # link fails to establish, add this
+44 -12
View File
@@ -19,7 +19,7 @@ class LXMRouter:
MAX_DELIVERY_ATTEMPTS = 5 MAX_DELIVERY_ATTEMPTS = 5
PROCESSING_INTERVAL = 4 PROCESSING_INTERVAL = 4
DELIVERY_RETRY_WAIT = 7 DELIVERY_RETRY_WAIT = 7
PATH_REQUEST_WAIT = 5 PATH_REQUEST_WAIT = 7
LINK_MAX_INACTIVITY = 10*60 LINK_MAX_INACTIVITY = 10*60
MESSAGE_EXPIRY = 30*24*60*60 MESSAGE_EXPIRY = 30*24*60*60
@@ -40,8 +40,12 @@ class LXMRouter:
PR_RECEIVING = 0x05 PR_RECEIVING = 0x05
PR_RESPONSE_RECEIVED = 0x06 PR_RESPONSE_RECEIVED = 0x06
PR_COMPLETE = 0x07 PR_COMPLETE = 0x07
PR_NO_IDENTITY_RCVD = 0xf0 PR_NO_PATH = 0xf0
PR_NO_ACCESS = 0xf1 PR_LINK_FAILED = 0xf1
PR_TRANSFER_FAILED = 0xf2
PR_NO_IDENTITY_RCVD = 0xf3
PR_NO_ACCESS = 0xf4
PR_FAILED = 0xfe
PR_ALL_MESSAGES = 0x00 PR_ALL_MESSAGES = 0x00
@@ -220,9 +224,9 @@ class LXMRouter:
if max_messages == None: if max_messages == None:
max_messages = LXMRouter.PR_ALL_MESSAGES max_messages = LXMRouter.PR_ALL_MESSAGES
self.propagation_transfer_progress = 0.0
self.propagation_transfer_max_messages = max_messages self.propagation_transfer_max_messages = max_messages
if self.outbound_propagation_node != None: if self.outbound_propagation_node != None:
self.propagation_transfer_progress = 0.0
if self.outbound_propagation_link != None and self.outbound_propagation_link.status == RNS.Link.ACTIVE: if self.outbound_propagation_link != None and self.outbound_propagation_link.status == RNS.Link.ACTIVE:
self.propagation_transfer_state = LXMRouter.PR_LINK_ESTABLISHED self.propagation_transfer_state = LXMRouter.PR_LINK_ESTABLISHED
self.outbound_propagation_link.identify(identity) self.outbound_propagation_link.identify(identity)
@@ -469,7 +473,16 @@ class LXMRouter:
if self.outbound_propagation_link != None and self.outbound_propagation_link.status == RNS.Link.CLOSED: if self.outbound_propagation_link != None and self.outbound_propagation_link.status == RNS.Link.CLOSED:
self.outbound_propagation_link = None self.outbound_propagation_link = None
self.acknowledge_sync_completion() if self.propagation_transfer_state == LXMRouter.PR_COMPLETE:
self.acknowledge_sync_completion()
elif self.propagation_transfer_state < LXMRouter.PR_LINK_ESTABLISHED:
self.acknowledge_sync_completion(failure_state=LXMRouter.PR_LINK_FAILED)
elif self.propagation_transfer_state >= LXMRouter.PR_LINK_ESTABLISHED and self.propagation_transfer_state < LXMRouter.PR_COMPLETE:
self.acknowledge_sync_completion(failure_state=LXMRouter.PR_TRANSFER_FAILED)
else:
RNS.log(f"Unknown propagation transfer state on link cleaning: {self.propagation_transfer_state}", RNS.LOG_DEBUG)
self.acknowledge_sync_completion()
RNS.log("Cleaned outbound propagation link", RNS.LOG_DEBUG) RNS.log("Cleaned outbound propagation link", RNS.LOG_DEBUG)
def clean_transient_id_caches(self): def clean_transient_id_caches(self):
@@ -647,7 +660,7 @@ class LXMRouter:
self.request_messages_from_propagation_node(self.wants_download_on_path_available_to, self.propagation_transfer_max_messages) self.request_messages_from_propagation_node(self.wants_download_on_path_available_to, self.propagation_transfer_max_messages)
else: else:
RNS.log("Propagation node path request timed out", RNS.LOG_DEBUG) RNS.log("Propagation node path request timed out", RNS.LOG_DEBUG)
self.acknowledge_sync_completion() self.acknowledge_sync_completion(failure_state=LXMRouter.PR_NO_PATH)
def identity_allowed(self, identity): def identity_allowed(self, identity):
if self.auth_required: if self.auth_required:
@@ -810,12 +823,15 @@ class LXMRouter:
if self.outbound_propagation_link != None: if self.outbound_propagation_link != None:
self.outbound_propagation_link.teardown() self.outbound_propagation_link.teardown()
def acknowledge_sync_completion(self, reset_state=False): def acknowledge_sync_completion(self, reset_state=False, failure_state=None):
self.propagation_transfer_last_result = None
if reset_state or self.propagation_transfer_state <= LXMRouter.PR_COMPLETE: if reset_state or self.propagation_transfer_state <= LXMRouter.PR_COMPLETE:
self.propagation_transfer_state = LXMRouter.PR_IDLE if failure_state == None:
self.propagation_transfer_state = LXMRouter.PR_IDLE
else:
self.propagation_transfer_state = failure_state
self.propagation_transfer_progress = 0.0 self.propagation_transfer_progress = 0.0
self.propagation_transfer_last_result = None
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
@@ -842,10 +858,15 @@ class LXMRouter:
self.pending_outbound.append(lxmessage) self.pending_outbound.append(lxmessage)
self.process_outbound() self.process_outbound()
def lxmf_delivery(self, lxmf_data, destination_type = None): def lxmf_delivery(self, lxmf_data, destination_type = None, phy_stats = None):
try: try:
message = LXMessage.unpack_from_bytes(lxmf_data) message = LXMessage.unpack_from_bytes(lxmf_data)
if phy_stats != None:
if "rssi" in phy_stats: message.rssi = phy_stats["rssi"]
if "snr" in phy_stats: message.snr = phy_stats["snr"]
if "q" in phy_stats: message.q = phy_stats["q"]
if destination_type == RNS.Destination.SINGLE: if destination_type == RNS.Destination.SINGLE:
message.transport_encrypted = True message.transport_encrypted = True
message.transport_encryption = LXMessage.ENCRYPTION_DESCRIPTION_EC message.transport_encryption = LXMessage.ENCRYPTION_DESCRIPTION_EC
@@ -885,7 +906,16 @@ class LXMRouter:
else: else:
lxmf_data = data lxmf_data = data
if self.lxmf_delivery(lxmf_data, packet.destination_type): try:
reticulum = RNS.Reticulum.get_instance()
if packet.rssi == None: packet.rssi = reticulum.get_packet_rssi(packet.packet_hash)
if packet.snr == None: packet.snr = reticulum.get_packet_snr(packet.packet_hash)
if packet.q == None: packet.q = reticulum.get_packet_q(packet.packet_hash)
except Exception as e:
RNS.log("Error while retrieving physical link stats for LXMF delivery packet: "+str(e), RNS.LOG_ERROR)
phy_stats = {"rssi": packet.rssi, "snr": packet.snr, "q": packet.q}
if self.lxmf_delivery(lxmf_data, packet.destination_type, phy_stats=phy_stats):
packet.prove() packet.prove()
except Exception as e: except Exception as e:
@@ -893,6 +923,7 @@ class LXMRouter:
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR) RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
def delivery_link_established(self, link): def delivery_link_established(self, link):
link.track_phy_stats(True)
link.set_packet_callback(self.delivery_packet) link.set_packet_callback(self.delivery_packet)
link.set_resource_strategy(RNS.Link.ACCEPT_ALL) link.set_resource_strategy(RNS.Link.ACCEPT_ALL)
link.set_resource_started_callback(self.resource_transfer_began) link.set_resource_started_callback(self.resource_transfer_began)
@@ -907,7 +938,8 @@ class LXMRouter:
def delivery_resource_concluded(self, resource): def delivery_resource_concluded(self, resource):
RNS.log("Transfer concluded for LXMF delivery resource "+str(resource), RNS.LOG_DEBUG) RNS.log("Transfer concluded for LXMF delivery resource "+str(resource), RNS.LOG_DEBUG)
if resource.status == RNS.Resource.COMPLETE: if resource.status == RNS.Resource.COMPLETE:
self.lxmf_delivery(resource.data.read(), resource.link.type) phy_stats = {"rssi": resource.link.rssi, "snr": resource.link.snr, "q": resource.link.q}
self.lxmf_delivery(resource.data.read(), resource.link.type, phy_stats=phy_stats)
### Peer Sync & Propagation ########################### ### Peer Sync & Propagation ###########################
+6 -4
View File
@@ -111,7 +111,6 @@ class LXMessage:
self.set_title_from_string(title) self.set_title_from_string(title)
self.set_content_from_string(content) self.set_content_from_string(content)
self.set_fields(fields) self.set_fields(fields)
self.payload = None self.payload = None
@@ -122,6 +121,9 @@ class LXMessage:
self.progress = None self.progress = None
self.state = LXMessage.DRAFT self.state = LXMessage.DRAFT
self.method = LXMessage.UNKNOWN self.method = LXMessage.UNKNOWN
self.rssi = None
self.snr = None
self.q = None
self.propagation_packed = None self.propagation_packed = None
self.paper_packed = None self.paper_packed = None
@@ -161,7 +163,7 @@ class LXMessage:
def set_fields(self, fields): def set_fields(self, fields):
if isinstance(fields, dict) or fields == None: if isinstance(fields, dict) or fields == None:
self.fields = fields self.fields = fields or {}
else: else:
raise ValueError("LXMessage property \"fields\" can only be dict or None") raise ValueError("LXMessage property \"fields\" can only be dict or None")
@@ -487,7 +489,6 @@ class LXMessage:
return None return None
def as_uri(self, finalise=True): def as_uri(self, finalise=True):
self.determine_transport_encryption()
if not self.packed: if not self.packed:
self.pack() self.pack()
@@ -499,6 +500,7 @@ class LXMessage:
lxm_uri = LXMessage.URI_SCHEMA+"://"+encoded_bytes.decode("utf-8").replace("=","") lxm_uri = LXMessage.URI_SCHEMA+"://"+encoded_bytes.decode("utf-8").replace("=","")
if finalise: if finalise:
self.determine_transport_encryption()
self.__mark_paper_generated() self.__mark_paper_generated()
return lxm_uri return lxm_uri
@@ -507,7 +509,6 @@ class LXMessage:
raise TypeError("Attempt to represent LXM with non-paper delivery method as URI") raise TypeError("Attempt to represent LXM with non-paper delivery method as URI")
def as_qr(self): def as_qr(self):
self.determine_transport_encryption()
if not self.packed: if not self.packed:
self.pack() self.pack()
@@ -522,6 +523,7 @@ class LXMessage:
data = self.as_uri(finalise=False), data = self.as_uri(finalise=False),
) )
self.determine_transport_encryption()
self.__mark_paper_generated() self.__mark_paper_generated()
return qr return qr
+1
View File
@@ -2,6 +2,7 @@ import os
import glob import glob
from .LXMessage import LXMessage from .LXMessage import LXMessage
from .LXMRouter import LXMRouter from .LXMRouter import LXMRouter
from .LXMF import *
from ._version import __version__ from ._version import __version__
+1 -1
View File
@@ -1 +1 @@
__version__ = "0.3.3" __version__ = "0.3.8"
+3 -3
View File
@@ -85,11 +85,11 @@ The LXM Router then handles the heavy lifting, such as message packing, encrypti
LXMF uses encryption provided by [Reticulum](https://reticulum.network), and thus uses end-to-end encryption by default. The delivery method of a message will influence which transport encryption scheme is used. LXMF uses encryption provided by [Reticulum](https://reticulum.network), and thus uses end-to-end encryption by default. The delivery method of a message will influence which transport encryption scheme is used.
- A message can be delivered opportunistically, embedded in a single Reticulum packet. In this cases the message will be opportunistically routed through the network, and will be encrypted with _ephemeral_ keys derived with _ECDH_ on _Curve25519_. This mode offers Perfect Forward Secrecy. - If a message is delivered over a Reticulum link (which is the default method), the message will be encrypted with ephemeral AES-128 keys derived with ECDH on Curve25519. This mode offers forward secrecy.
- If a message is delivered to the Reticulum GROUP destination type, the message will be transported using _AES-128_ encryption. - A message can be delivered opportunistically, embedded in a single Reticulum packet. In this cases the message will be opportunistically routed through the network, and will be encrypted with per-packet AES-128 keys derived with ECDH on Curve25519.
- If a message is delivered over a Reticulum link (which is the default method), the message will be encrypted with _ephemeral_ keys derived with _ECDH_ on _Curve25519_. This mode offers Perfect Forward Secrecy. - If a message is delivered to the Reticulum GROUP destination type, the message will be encrypted using the symmetric AES-128 key of the GROUP destination.
## Wire Format & Overhead ## Wire Format & Overhead
+1 -1
View File
@@ -25,6 +25,6 @@ setuptools.setup(
'lxmd=LXMF.Utilities.lxmd:main', 'lxmd=LXMF.Utilities.lxmd:main',
] ]
}, },
install_requires=['rns>=0.5.9'], install_requires=['rns>=0.6.4'],
python_requires='>=3.7', python_requires='>=3.7',
) )