Compare commits

..
69 Commits
Author SHA1 Message Date
Mark Qvist a0793f6677 Set delivery and propagation link costs 2026-11-06 12:25:47 +01:00
Mark Qvist 2059784a55 Retain on propagation success 2026-11-05 12:46:06 +01:00
Mark Qvist 2b09146a15 Improved display name decode 2026-11-04 12:59:53 +01:00
Mark Qvist c7a902f0aa Merged SQLite storage backend 2026-11-04 00:54:22 +01:00
Mark Qvist d845503b33 Throttle stamp cost persists 2026-11-03 13:14:17 +01:00
Mark Qvist 40dcd7d084 Made PN peer throttle time configurable 2026-11-02 21:05:20 +01:00
Mark Qvist 8ded002689 Fixed missing transient ID cancel 2026-11-02 16:29:36 +01:00
Mark Qvist 810c345de8 Prepared announce filtering 2026-11-01 23:14:03 +01:00
Mark Qvist 2c69fd3684 Cleanup 2026-11-01 10:44:34 +01:00
Mark Qvist 3297f21e62 Fixed int config value getters 2026-10-30 22:42:36 +01:00
Mark Qvist 6e898e67ad Refactoring for fractional-value stamp support 2026-10-30 22:14:59 +01:00
Mark Qvist 1df7ebcdd5 Cleanup 2026-10-28 13:04:49 +01:00
Mark Qvist cc702b75a7 Updated version 2026-10-28 13:04:06 +01:00
Mark Qvist 98e09bbec0 Refactored LXStamper to use RNS.Stamps 2026-10-28 13:03:21 +01:00
Mark Qvist 86692183d9 Fixed non-existent variable in log message 2026-10-26 00:16:26 +01:00
Mark Qvist c98bca2dce Cleanup 2026-10-24 00:44:01 +02:00
Mark Qvist d6df0f7e91 Cleanup 2026-10-24 00:02:23 +02:00
Mark Qvist 700a462674 Improved stamper 2026-10-23 23:53:21 +02:00
Mark Qvist 01387b15f4 Updated version 2026-10-19 15:34:58 +02:00
Mark Qvist 308498e68b Ensure positive durations on stamp-related timing 2026-10-19 15:32:37 +02:00
Mark Qvist e8ba024832 Updated versions 2026-10-05 15:15:24 +02:00
Mark Qvist 5745f85647 Added outbound queue hold mechanism and improved slow-medium processing, by Zenith 2026-10-05 15:14:49 +02:00
Mark Qvist c3ff2d6dc2 Added version signalling to propagation node announce metadata 2026-09-30 14:41:07 +02:00
Mark Qvist aa7137d840 Cleanup 2026-09-30 14:01:14 +02:00
Mark Qvist 247008105a Improved outbound processing error and callback handling 2026-09-30 13:59:40 +02:00
Mark Qvist 3fc60af1ab Fixed regression introduced in 7789e0b that caused incorrect max payload size calculation for opportunistic messages, by JRG 2026-09-30 13:14:35 +02:00
Mark Qvist 3290c4e63d Cleanup 2026-09-30 11:20:09 +02:00
Mark Qvist 599bb67080 Updated versions 2026-09-28 18:48:30 +02:00
Mark Qvist db2bd9e0e5 Added micron readme 2026-09-28 17:03:51 +02:00
Mark Qvist e52016c20f Updated readme 2026-09-26 21:09:17 +02:00
Mark Qvist 6fb5a366b1 Updated versions 2026-09-25 16:19:25 +02:00
Mark Qvist 43a077b291 Ensure sequential processing in process_outbound 2026-09-25 15:19:43 +02:00
Mark Qvist 170e71d5a9 Set awaiting_path on opportunistic path rediscovery 2026-09-25 15:17:58 +02:00
Mark Qvist beac6bcd1c Use medium aware timeouts and debouncing in outbound processing, by Zenith 2026-09-25 15:11:26 +02:00
Mark Qvist acaa9e30ed Use canonical medium-aware path request handler in LXMPeer, by Zenith 2026-09-25 12:08:27 +02:00
Mark Qvist fbc821ebb9 Prepare announce handlers for medium-aware timeout handling, by Zenith 2026-09-25 12:05:34 +02:00
Mark Qvist 0889401ca1 Prepare LXMessage for medium-aware timeout handling, by Zenith 2026-09-25 11:37:35 +02:00
Mark Qvist 1dc8097212 Adjusted loglevel 2026-09-02 14:40:12 +02:00
Mark Qvist 41cdce67c1 Adjusted loglevel 2026-08-19 14:48:40 +02:00
Mark Qvist c939e25361 Fixed failed PN peer path resolution not triggering sync backoff 2026-07-30 13:34:16 +02:00
Mark Qvist da1b9c0e08 Updated versions 2026-07-26 18:02:12 +02:00
Mark Qvist 795fdaa2b0 Updated versions 2026-07-20 18:49:54 +02:00
Mark Qvist 7bb4bcfbc8 Updated logging 2026-07-20 18:48:52 +02:00
Mark Qvist d909619eb1 Added inbound message resource transfer tracking and ability to cancel incoming messages 2026-07-16 15:16:09 +02:00
Mark Qvist 5769d46389 Improved logging 2026-07-16 10:22:12 +02:00
Mark Qvist 3e2cd361af Updated version 2026-07-16 02:52:56 +02:00
Mark Qvist 241b29cc92 Yes, it will run on potato, then 2026-07-16 02:50:10 +02:00
Mark Qvist ca02fa5221 Added lxmd config options stamp_cost, sequential_pn_stamp_validation, static_peers_bypass_sequential, max_inbound_syncs. Added name sanitization to peers output. 2026-07-16 02:10:50 +02:00
Mark Qvist 982c9fc743 Early sync complete if no messages exist after requirements filtration 2026-07-16 01:11:36 +02:00
Mark Qvist 4a93697511 Fixed PN peer offer preparation not adhering to minimum accepted stamp cost for message offer filtration 2026-07-15 20:41:58 +02:00
Mark Qvist 548be107c8 Added transient ID processing locks 2026-07-15 20:08:14 +02:00
Mark Qvist 8395793bad Ensure atomic writes 2026-07-12 01:27:38 +02:00
Mark Qvist fb0fd24c98 Updated versions 2026-07-10 15:39:15 +02:00
Mark Qvist fab12ad9bf Updated build scripts 2026-06-01 14:26:47 +02:00
Mark Qvist a29c4a0e17 Updated version 2026-06-01 00:03:39 +02:00
Mark Qvist 20864133a3 Fixed typo 2026-05-31 22:10:48 +02:00
Mark Qvist c877efaec1 Updated version 2026-05-29 09:58:06 +02:00
Mark Qvist 11b2480223 Updated versions 2026-05-29 09:57:51 +02:00
Jeremy O'Brien 5be161cb1e Prevent message write race among different processes touching the same message 2026-05-28 08:44:22 -04:00
Mark Qvist bf924c739c Cleanup 2026-05-27 12:28:58 +02:00
Mark Qvist 044f3d2879 Updated versions 2026-05-26 23:32:02 +02:00
Mark Qvist 312e0a8ded Updated version 2026-05-26 13:18:33 +02:00
Mark Qvist 575fb7d77d Prevent LXM persist race in write_to_directory when messages change state within very short time spans 2026-05-26 13:17:46 +02:00
Mark Qvist 2ac2b100ae Automatically drop LXMs from blackholed identities 2026-05-26 13:14:05 +02:00
Mark Qvist 599406ed0f Activated compression support signalling 2026-05-25 16:59:24 +02:00
Parnikkapore 55620bf45c Fix lxmd crash when defaulting --config to ~/.config/lxmd/ 2026-05-25 00:46:59 +02:00
Mark Qvist b53a3ce37d Clarified FIELD_THREAD 2026-05-24 23:16:15 +02:00
Mark Qvist 764758d185 Added reply, reaction and comment field standards to LXMF.py 2026-05-24 22:59:57 +02:00
Mark Qvist b415a136f3 Updated makefile 2026-05-21 17:58:59 +02:00
16 changed files with 1908 additions and 784 deletions

No files matched your search

-11
View File
@@ -1,11 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: ✨ Feature Request or Idea
url: https://github.com/markqvist/Reticulum/discussions/new?category=ideas
about: Propose and discuss features and ideas
- name: 💬 Questions, Help & Discussion
about: Ask anything, or get help
url: https://github.com/markqvist/Reticulum/discussions/new/choose
- name: 📖 Read the Reticulum Manual
url: https://markqvist.github.io/Reticulum/manual/
about: The complete documentation for Reticulum
-35
View File
@@ -1,35 +0,0 @@
---
name: "\U0001F41B Bug Report"
about: Report a reproducible bug
title: ''
labels: ''
assignees: ''
---
**Read the Contribution Guidelines**
Before creating a bug report on this issue tracker, you **must** read the [Contribution Guidelines](https://github.com/markqvist/Reticulum/blob/master/Contributing.md). Issues that do not follow the contribution guidelines **will be deleted without comment**.
- The issue tracker is used by developers of this project. **Do not use it to ask general questions, or for support requests**.
- Ideas and feature requests can be made on the [Discussions](https://github.com/markqvist/Reticulum/discussions). **Only** feature requests accepted by maintainers and developers are tracked and included on the issue tracker. **Do not post feature requests here**.
- After reading the [Contribution Guidelines](https://github.com/markqvist/Reticulum/blob/master/Contributing.md), **delete this section only** (*"Read the Contribution Guidelines"*) from your bug report, **and fill in all the other sections**.
**Describe the Bug**
A clear and concise description of what the bug is.
**To Reproduce**
Describe in detail how to reproduce the bug.
**Expected Behavior**
A clear and concise description of what you expected to happen.
**Logs & Screenshots**
Please include any relevant log output. If applicable, also add screenshots to help explain your problem.
**System Information**
- OS and version
- Python version
- Program version
**Additional context**
Add any other context about the problem here.
+10 -2
View File
@@ -22,7 +22,7 @@ class LXMFDeliveryAnnounceHandler:
for lxmessage in self.lxmrouter.pending_outbound:
if destination_hash == lxmessage.destination_hash:
if lxmessage.method == LXMessage.DIRECT or lxmessage.method == LXMessage.OPPORTUNISTIC:
if (lxmessage.method == LXMessage.DIRECT or lxmessage.method == LXMessage.OPPORTUNISTIC) and lxmessage.awaiting_path:
lxmessage.next_delivery_attempt = time.time()
def outbound_trigger():
@@ -44,7 +44,7 @@ class LXMFPropagationAnnounceHandler:
if destination_hash == self.lxmrouter.get_outbound_propagation_node():
if pn_announce_data_is_valid(app_data):
for lxmessage in self.lxmrouter.pending_outbound:
if lxmessage.method == LXMessage.PROPAGATED:
if lxmessage.method == LXMessage.PROPAGATED and lxmessage.awaiting_path:
lxmessage.next_delivery_attempt = time.time()
def outbound_trigger():
@@ -64,6 +64,14 @@ class LXMFPropagationAnnounceHandler:
propagation_stamp_cost_flexibility = int(data[5][1])
peering_cost = int(data[5][2])
metadata = data[6]
# Transitional mechanism, extract the real, fractional-value
# propagation stamp cost if available.
if len(data) > 7:
propagation_stamp_cost = data[7][0]
propagation_stamp_cost_flexibility = data[7][1]
peering_cost = data[7][2]
# TODO: Remove above after 1.6.2 ###########################
if destination_hash in self.lxmrouter.static_peers:
static_peer = self.lxmrouter.peers[destination_hash]
+70 -12
View File
@@ -12,7 +12,7 @@ FIELD_ICON_APPEARANCE = 0x04
FIELD_FILE_ATTACHMENTS = 0x05
FIELD_IMAGE = 0x06
FIELD_AUDIO = 0x07
FIELD_THREAD = 0x08
FIELD_THREAD = 0x08 # Bytes, full thread ID hash
FIELD_COMMANDS = 0x09
FIELD_RESULTS = 0x0A
FIELD_GROUP = 0x0B
@@ -20,6 +20,16 @@ FIELD_TICKET = 0x0C
FIELD_EVENT = 0x0D
FIELD_RNR_REFS = 0x0E
FIELD_RENDERER = 0x0F
FIELD_REPLY_TO = 0x30 # Bytes, full LXMessage.hash
FIELD_REPLY_QUOTE = 0x31 # Bytes, quoted content in UTF-8 encoding
FIELD_REACTION = 0x40 # Dict, see "Reaction dict indices" below
FIELD_COMMENT = 0x41 # Dict, see "Comment dict indices" below
FIELD_CONTINUATION = 0x42 # Dict, see "Continuation dict indices" below
# Unallocated fields between 0x00 and 0x80, both included,
# should be considered reserved for future extensibility
# For experimental and unstable features, it is recommended
# to use fields above 0xFF.
# For usecases such as including custom data structures,
# embedding or encapsulating other data types or protocols
@@ -91,6 +101,30 @@ RENDERER_MICRON = 0x01
RENDERER_MARKDOWN = 0x02
RENDERER_BBCODE = 0x03
# Clients choose how to handle reaction content, if at all.
# While reactions are typically a single unicode emoji or
# similar, the exact implementation and sanitization is
# left up to the client. When using the FIELD_REACTION
# field, the contents is a dict with the following keys:
REACTION_TO = 0x00 # Bytes, full LXMessage.hash
REACTION_CONTENT = 0x01 # Bytes, the reaction content in UTF-8 encoding
# Clients choose how to handle messages intended as comments
# for other message, if at all. The actual comment content
# is carried as the normal LXM content, meaning clients that
# do not support comments will display them as normal messages.
# When using the FIELD_COMMENT field, the contents is a dict
# with the following keys:
COMMENT_FOR = 0x00 # Bytes, full LXMessage.hash
# Clients choose how to handle messages that continue earlier
# messages, if at all. The actual continuation content is
# carried as the normal LXM content, meaning clients that
# do not support continuations will display them as normal.
# When using the FIELD_CONTINUATION field, the contents is a
# dict with the following keys:
CONTINUATION_OF = 0x00 # Bytes, full LXMessage.hash
# Optional propagation node metadata fields. These
# fields may be highly unstable in allocation and
# availability until the version 1.0.0 release, so use
@@ -101,6 +135,7 @@ PN_META_SYNC_STRATUM = 0x02
PN_META_SYNC_THROTTLE = 0x03
PN_META_AUTH_BAND = 0x04
PN_META_UTIL_PRESSURE = 0x05
PN_META_IMPL_NAME = 0xFE
PN_META_CUSTOM = 0xFF
# Supported functionality codes for signalling
@@ -120,7 +155,11 @@ def display_name_from_app_data(app_data=None):
else:
# Version 0.5.0+ announce format
if (app_data[0] >= 0x90 and app_data[0] <= 0x9f) or app_data[0] == 0xdc:
peer_data = msgpack.unpackb(app_data)
try: peer_data = msgpack.unpackb(app_data)
except Exception as e:
RNS.log(f"Could not decode display name in included announce data. The contained exception was: {e}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
return None
if type(peer_data) == list:
if len(peer_data) < 1: return None
else:
@@ -131,12 +170,15 @@ def display_name_from_app_data(app_data=None):
decoded = dn.decode("utf-8").replace("\x00", "").strip()
return decoded
except Exception as e:
RNS.log(f"Could not decode display name in included announce data. The contained exception was: {e}", RNS.LOG_ERROR)
RNS.log(f"Could not decode display name in included announce data. The contained exception was: {e}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
return None
# Original announce format
# Legacy announce format
else:
return app_data.decode("utf-8")
try: return app_data.decode("utf-8")
except Exception as e:
RNS.log(f"Could not decode display name in legacy announce data. The contained exception was: {e}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
return None
def stamp_cost_from_app_data(app_data=None):
if app_data == None or app_data == b"": return None
@@ -146,7 +188,12 @@ def stamp_cost_from_app_data(app_data=None):
peer_data = msgpack.unpackb(app_data)
if type(peer_data) == list:
if len(peer_data) < 2: return None
else: return peer_data[1]
else:
if len(peer_data) > 3:
cost_type = type(peer_data[3])
if cost_type == float or cost_type == int: return peer_data[3]
else: return peer_data[1]
else: return peer_data[1]
# Original announce format
else: return None
@@ -184,9 +231,10 @@ def pn_stamp_cost_from_app_data(app_data=None):
else:
if pn_announce_data_is_valid(app_data):
data = msgpack.unpackb(app_data)
return data[5][0]
else:
return None
if len(data) > 7: return data[7][0]
else: return data[5][0]
else: return None
def pn_announce_data_is_valid(data):
try:
@@ -202,13 +250,23 @@ def pn_announce_data_is_valid(data):
try: int(data[4])
except: raise ValueError("Invalid announce data: Could not decode propagation sync limit")
if type(data[5]) != list: raise ValueError("Invalid announce data: Could not decode stamp costs")
try: int(data[5][0])
try: float(data[5][0])
except: raise ValueError("Invalid announce data: Could not decode target stamp cost")
try: int(data[5][1])
try: float(data[5][1])
except: raise ValueError("Invalid announce data: Could not decode stamp cost flexibility")
try: int(data[5][2])
try: float(data[5][2])
except: raise ValueError("Invalid announce data: Could not decode peering cost")
if type(data[6]) != dict: raise ValueError("Invalid announce data: Could not decode metadata")
# TODO: Transitional mechanism, remove after 1.6.2
if len(data) > 7:
if type(data[7]) != list: raise ValueError("Invalid announce data: Could not decode fractional stamp costs")
try: float(data[7][0])
except: raise ValueError("Invalid announce data: Could not decode target stamp cost")
try: float(data[7][1])
except: raise ValueError("Invalid announce data: Could not decode stamp cost flexibility")
try: float(data[7][2])
except: raise ValueError("Invalid announce data: Could not decode peering cost")
except Exception as e:
RNS.log(f"Could not validate propagation node announce data: {e}", RNS.LOG_DEBUG)
+23 -14
View File
@@ -79,17 +79,17 @@ class LXMPeer:
else: peer.propagation_sync_limit = peer.propagation_transfer_limit
if "propagation_stamp_cost" in dictionary:
try: peer.propagation_stamp_cost = int(dictionary["propagation_stamp_cost"])
try: peer.propagation_stamp_cost = float(dictionary["propagation_stamp_cost"])
except: peer.propagation_stamp_cost = None
else: peer.propagation_stamp_cost = None
if "propagation_stamp_cost_flexibility" in dictionary:
try: peer.propagation_stamp_cost_flexibility = int(dictionary["propagation_stamp_cost_flexibility"])
try: peer.propagation_stamp_cost_flexibility = float(dictionary["propagation_stamp_cost_flexibility"])
except: peer.propagation_stamp_cost_flexibility = None
else: peer.propagation_stamp_cost_flexibility = None
if "peering_cost" in dictionary:
try: peer.peering_cost = int(dictionary["peering_cost"])
try: peer.peering_cost = float(dictionary["peering_cost"])
except: peer.peering_cost = None
else: peer.peering_cost = None
@@ -217,9 +217,11 @@ class LXMPeer:
self.router = router
self.destination_hash = destination_hash
self.identity = RNS.Identity.recall(destination_hash)
if self.identity != None:
self.destination = RNS.Destination(self.identity, RNS.Destination.OUT, RNS.Destination.SINGLE, APP_NAME, "propagation")
self.resolve_identity()
def resolve_identity(self):
self.identity = RNS.Identity.recall(self.destination_hash)
if self.identity != None: self.destination = RNS.Destination(self.identity, RNS.Destination.OUT, RNS.Destination.SINGLE, APP_NAME, "propagation")
else:
self.destination = None
RNS.log(f"Could not recall identity for LXMF propagation peer {RNS.prettyhexrep(self.destination_hash)}, will retry identity resolution on next sync", RNS.LOG_WARNING)
@@ -250,7 +252,7 @@ class LXMPeer:
return False
if self.identity == None:
self.identity = RNS.Identity.recall(destination_hash)
self.identity = RNS.Identity.recall(self.destination_hash)
if self.identity == None:
RNS.log(f"Could not update peering key for {self} since its identity could not be recalled", RNS.LOG_ERROR)
return False
@@ -294,15 +296,18 @@ class LXMPeer:
else:
if not RNS.Transport.has_path(self.destination_hash):
RNS.log("No path to peer "+RNS.prettyhexrep(self.destination_hash)+" exists, requesting...", RNS.LOG_DEBUG)
RNS.Transport.request_path(self.destination_hash)
self.router.request_path(self.destination_hash)
time.sleep(LXMPeer.PATH_REQUEST_GRACE)
if not RNS.Transport.has_path(self.destination_hash):
RNS.log("Path request was not answered, retrying sync with peer "+RNS.prettyhexrep(self.destination_hash)+" later", RNS.LOG_DEBUG)
self.sync_backoff += LXMPeer.SYNC_BACKOFF_STEP
self.next_sync_attempt = time.time() + self.sync_backoff
self.alive = False
RNS.log(f"Path request was not answered, retrying sync with peer {RNS.prettyhexrep(self.destination_hash)} later", RNS.LOG_DEBUG)
else:
if self.identity == None:
self.identity = RNS.Identity.recall(destination_hash)
self.identity = RNS.Identity.recall(self.destination_hash)
if self.identity != None:
self.destination = RNS.Destination(self.identity, RNS.Destination.OUT, RNS.Destination.SINGLE, APP_NAME, "propagation")
@@ -328,7 +333,7 @@ class LXMPeer:
self.alive = True
self.last_heard = time.time()
self.sync_backoff = 0
min_accepted_cost = min(0, self.propagation_stamp_cost-self.propagation_stamp_cost_flexibility)
min_accepted_cost = max(0, self.propagation_stamp_cost-self.propagation_stamp_cost_flexibility)
RNS.log("Synchronisation link to peer "+RNS.prettyhexrep(self.destination_hash)+" established, preparing sync offer...", RNS.LOG_DEBUG)
unhandled_entries = []
@@ -378,9 +383,13 @@ class LXMPeer:
cumulative_size += lxm_transfer_size
unhandled_ids.append(transient_id)
if len(unhandled_ids) == 0:
RNS.log(f"Sync requested for {self}, but no unhandled messages exist after offer preparation. Sync complete.", RNS.LOG_DEBUG)
return
offer = [self.peering_key[0], unhandled_ids]
RNS.log(f"Offering {len(unhandled_ids)} messages to peer {RNS.prettyhexrep(self.destination.hash)} ({RNS.prettysize(len(msgpack.packb(unhandled_ids)))})", RNS.LOG_VERBOSE)
RNS.log(f"Offering {len(unhandled_ids)} messages to peer {RNS.prettyhexrep(self.destination.hash)}", RNS.LOG_VERBOSE)
self.last_offer = unhandled_ids
self.link.request(LXMPeer.OFFER_REQUEST_PATH, offer, response_callback=self.offer_response, failed_callback=self.request_failed)
self.state = LXMPeer.REQUEST_SENT
@@ -404,7 +413,7 @@ class LXMPeer:
if response == LXMPeer.ERROR_NO_IDENTITY:
if self.link != None:
RNS.log("Remote peer indicated that no identification was received, retrying...", RNS.LOG_VERBOSE)
self.link.identify()
self.link.identify(self.router.identity)
self.state = LXMPeer.LINK_READY
self.sync()
return
@@ -503,7 +512,7 @@ class LXMPeer:
rate_str = ""
if self.current_sync_transfer_started != None:
self.sync_transfer_rate = (resource.get_transfer_size()*8)/(time.time()-self.current_sync_transfer_started)
self.sync_transfer_rate = (resource.get_transfer_size()*8) / max(time.time()-self.current_sync_transfer_started, 1E-6)
rate_str = f" at {RNS.prettyspeed(self.sync_transfer_rate)}"
RNS.log(f"Syncing {len(self.currently_transferring_messages)} messages to peer {RNS.prettyhexrep(self.destination_hash)} completed{rate_str}", RNS.LOG_VERBOSE)
+815 -241
View File
File diff suppressed because it is too large. Load diff
+55 -25
View File
@@ -8,6 +8,7 @@ import multiprocessing
import LXMF.LXStamper as LXStamper
from .LXMF import APP_NAME, compression_support_from_app_data
from threading import Lock
class LXMessage:
@@ -63,8 +64,8 @@ class LXMessage:
# With an MTU of 500, the maximum amount of data
# we can send in a single encrypted packet is
# 391 bytes.
ENCRYPTED_PACKET_MDU = RNS.Packet.ENCRYPTED_MDU + TIMESTAMP_SIZE
# 383 bytes.
ENCRYPTED_PACKET_MDU = RNS.Packet.ENCRYPTED_MDU
# The max content length we can fit in LXMF message
# inside a single RNS packet is the encrypted MDU, minus
@@ -73,7 +74,7 @@ class LXMessage:
# field of the packet, therefore we also add the length
# of a destination hash to the calculation. With default
# RNS and LXMF parameters, the largest single-packet
# LXMF message we can send is 295 bytes. If a message
# LXMF message we can send is 287 bytes. If a message
# is larger than that, a Reticulum link will be used.
ENCRYPTED_PACKET_MAX_CONTENT = ENCRYPTED_PACKET_MDU - LXMF_OVERHEAD + DESTINATION_LENGTH
@@ -94,7 +95,7 @@ class LXMessage:
PLAIN_PACKET_MAX_CONTENT = PLAIN_PACKET_MDU - LXMF_OVERHEAD + DESTINATION_LENGTH
# Descriptive strings regarding transport encryption
ENCRYPTION_DESCRIPTION_AES = "AES-128"
ENCRYPTION_DESCRIPTION_AES = "AES-256"
ENCRYPTION_DESCRIPTION_EC = "Curve25519"
ENCRYPTION_DESCRIPTION_UNENCRYPTED = "Unencrypted"
@@ -168,6 +169,7 @@ class LXMessage:
self.paper_packed = None
self.incoming = False
self.source_blackholed = False
self.signature_validated = False
self.unverified_reason = None
self.ratchet_id = None
@@ -175,6 +177,11 @@ class LXMessage:
self.representation = LXMessage.UNKNOWN
self.desired_method = desired_method
self.delivery_attempts = 0
self.sent_on_path = False
self.awaiting_path = False
self.max_delivery_attempts = None
self.transport_encrypted = False
self.transport_encryption = None
self.ratchet_id = None
@@ -183,7 +190,10 @@ class LXMessage:
self.__delivery_destination = None
self.__delivery_callback = None
self.__pn_encrypted_data = None
self.__persist_lock = Lock()
self.failed_callback = None
self.receipt_timeout = None
self.concluded_callback = None
self.deferred_stamp_generating = False
@@ -463,10 +473,15 @@ class LXMessage:
if self.method == LXMessage.OPPORTUNISTIC:
lxm_packet = self.__as_packet()
lxm_packet.send().set_delivery_callback(self.__mark_delivered)
receipt = lxm_packet.send()
self.progress = 0.50
self.ratchet_id = lxm_packet.ratchet_id
self.state = LXMessage.SENT
if receipt:
receipt.set_delivery_callback(self.__mark_delivered)
if self.receipt_timeout: receipt.set_timeout(max(receipt.timeout, self.receipt_timeout))
if receipt.status == RNS.PacketReceipt.DELIVERED: self.__mark_delivered(receipt)
else: RNS.log(f"No receipt generated on sent opportunistic {self}", RNS.LOG_WARNING)
elif self.method == LXMessage.DIRECT:
self.state = LXMessage.SENDING
@@ -476,12 +491,14 @@ class LXMessage:
receipt = lxm_packet.send()
self.ratchet_id = self.__delivery_destination.link_id
if receipt:
self.progress = 0.50
receipt.set_delivery_callback(self.__mark_delivered)
receipt.set_timeout_callback(self.__link_packet_timed_out)
self.progress = 0.50
if receipt.status == RNS.PacketReceipt.DELIVERED: self.__mark_delivered(receipt)
else:
if self.__delivery_destination:
self.__delivery_destination.teardown()
self.state = LXMessage.OUTBOUND
elif self.representation == LXMessage.RESOURCE:
self.resource_representation = self.__as_resource()
@@ -494,11 +511,13 @@ class LXMessage:
if self.representation == LXMessage.PACKET:
receipt = self.__as_packet().send()
if receipt:
self.progress = 0.50
receipt.set_delivery_callback(self.__mark_propagated)
receipt.set_timeout_callback(self.__link_packet_timed_out)
self.progress = 0.50
if receipt.status == RNS.PacketReceipt.DELIVERED: self.__mark_propagated(receipt)
else:
self.__delivery_destination.teardown()
self.state = LXMessage.OUTBOUND
elif self.representation == LXMessage.RESOURCE:
self.resource_representation = self.__as_resource()
@@ -556,10 +575,13 @@ class LXMessage:
self.transport_encryption = LXMessage.ENCRYPTION_DESCRIPTION_UNENCRYPTED
def __mark_delivered(self, receipt = None):
if self.state == LXMessage.DELIVERED: return
RNS.log("Received delivery notification for "+str(self), RNS.LOG_DEBUG)
self.state = LXMessage.DELIVERED
self.progress = 1.0
if self.concluded_callback != None and callable(self.concluded_callback): self.concluded_callback(self)
if self.__delivery_callback != None and callable(self.__delivery_callback):
try:
self.__delivery_callback(self)
@@ -568,10 +590,13 @@ class LXMessage:
RNS.trace_exception(e)
def __mark_propagated(self, receipt = None):
if self.state == LXMessage.SENT: return
RNS.log("Received propagation success notification for "+str(self), RNS.LOG_DEBUG)
self.state = LXMessage.SENT
self.progress = 1.0
if self.concluded_callback != None and callable(self.concluded_callback): self.concluded_callback(self)
if self.__delivery_callback != None and callable(self.__delivery_callback):
try:
self.__delivery_callback(self)
@@ -648,9 +673,9 @@ class LXMessage:
raise ConnectionError("Tried to synthesize resource for LXMF message on a link that was not active")
if self.method == LXMessage.DIRECT:
return RNS.Resource(self.packed, self.__delivery_destination, callback = self.__resource_concluded, progress_callback = self.__update_transfer_progress, auto_compress=self.auto_compress)
return RNS.Resource(self.packed, self.__delivery_destination, callback=self.__resource_concluded, progress_callback=self.__update_transfer_progress, auto_compress=self.auto_compress)
elif self.method == LXMessage.PROPAGATED:
return RNS.Resource(self.propagation_packed, self.__delivery_destination, callback = self.__propagation_resource_concluded, progress_callback = self.__update_transfer_progress)
return RNS.Resource(self.propagation_packed, self.__delivery_destination, app_flag=True, callback=self.__propagation_resource_concluded, progress_callback=self.__update_transfer_progress)
else:
return None
@@ -671,25 +696,26 @@ class LXMessage:
def write_to_directory(self, directory_path):
file_name = RNS.hexrep(self.hash, delimit=False)
file_path = directory_path+"/"+file_name
tmp_path = file_path+".tmp."+str(os.getpid() or time.time())
tmp_path = file_path+".tmp."+str(os.getpid() or time.time())+"."+RNS.hexrep(os.urandom(8), delimit=False)
try:
with open(tmp_path, "wb") as file:
file.write(self.packed_container())
file.flush()
try: os.fsync(file.fileno())
except OSError: pass
os.replace(tmp_path, file_path)
return file_path
except Exception as e:
with self.__persist_lock:
try:
if os.path.exists(tmp_path): os.unlink(tmp_path)
except Exception: pass
with open(tmp_path, "wb") as file:
file.write(self.packed_container())
file.flush()
try: os.fsync(file.fileno())
except OSError as e: RNS.log(f"Error while waiting for persist fsync for {self}: {e}", RNS.LOG_WARNING)
RNS.log("Error while writing LXMF message to file \""+str(file_path)+"\". The contained exception was: "+str(e), RNS.LOG_ERROR)
return None
os.replace(tmp_path, file_path)
return file_path
except Exception as e:
try:
if os.path.exists(tmp_path): os.unlink(tmp_path)
except Exception as e: RNS.log(f"Error while cleaning temporary file {tmp_path} for {self}: {e}", RNS.LOG_ERROR)
RNS.log(f"Error while writing LXMF message to file \"{file_path}\". The contained exception was: {e}", RNS.LOG_ERROR)
return None
def as_uri(self, finalise=True):
if not self.packed:
@@ -796,6 +822,10 @@ class LXMessage:
message.set_title_from_bytes(title_bytes)
message.set_content_from_bytes(content_bytes)
try:
if source_identity != None: message.source_blackholed = RNS.Reticulum.get_instance().is_blackholed(source_identity)
except Exception as e: RNS.log(f"Could not determine message source blackhole status: {e}", RNS.LOG_WARNING)
try:
if source:
if source.identity.validate(signature, signed_part):
+15 -420
View File
@@ -1,80 +1,27 @@
import RNS
import RNS.vendor.umsgpack as msgpack
import RNS.Stamps
import os
import sys
import time
import math
import itertools
import contextlib
import multiprocessing
from RNS.Stamps import stamp_workblock
from RNS.Stamps import stamp_valid
from RNS.Stamps import stamp_value
from RNS.Stamps import cancel_work
# LXMF-specific stamp parameters
WORKBLOCK_EXPAND_ROUNDS = 3000
WORKBLOCK_EXPAND_ROUNDS_PN = 1000
WORKBLOCK_EXPAND_ROUNDS_PEERING = 25
STAMP_SIZE = RNS.Identity.HASHLENGTH//8
PN_VALIDATION_POOL_MIN_SIZE = 256
USE_WORKER_MANAGER = False
active_jobs = {}
if sys.version_info[0] >= 3 and sys.version_info[1] >= 14:
USE_WORKER_MANAGER = True
@contextlib.contextmanager
def worker_context(ctx, stamp_cost, workblock, message_id):
stop_event = ctx.Event()
result_queue = ctx.Queue(1)
rounds_queue = ctx.Queue()
active_jobs[message_id] = [stop_event, result_queue]
job_procs = []
try: yield stop_event, result_queue, rounds_queue, job_procs
finally:
if message_id in active_jobs: del active_jobs[message_id]
stop_event.set()
for p in job_procs:
if p.is_alive(): p.terminate()
for p in job_procs: p.join(timeout=0.5)
result_queue.close()
result_queue.join_thread()
rounds_queue.close()
rounds_queue.join_thread()
stop_event.clear()
def stamp_workblock(material, expand_rounds=WORKBLOCK_EXPAND_ROUNDS):
wb_st = time.time()
workblock = b""
for n in range(expand_rounds):
workblock += RNS.Cryptography.hkdf(length=256,
derive_from=material,
salt=RNS.Identity.full_hash(material+msgpack.packb(n)),
context=None)
wb_time = time.time() - wb_st
# RNS.log(f"Stamp workblock size {RNS.prettysize(len(workblock))}, generated in {round(wb_time*1000,2)}ms", RNS.LOG_DEBUG)
return workblock
def stamp_value(workblock, stamp):
value = 0
bits = 256
material = RNS.Identity.full_hash(workblock+stamp)
i = int.from_bytes(material, byteorder="big")
while ((i & (1 << (bits - 1))) == 0):
i = (i << 1)
value += 1
return value
def stamp_valid(stamp, target_cost, workblock):
target = 0b1 << 256-target_cost
result = RNS.Identity.full_hash(workblock+stamp)
if int.from_bytes(result, byteorder="big") > target: return False
else: return True
# Wrapper that forces the LXMF-specific stamp size
def generate_stamp(message_id, stamp_cost, expand_rounds=WORKBLOCK_EXPAND_ROUNDS, no_expand=False):
return RNS.Stamps.generate_stamp(message_id, stamp_cost, expand_rounds=expand_rounds, no_expand=no_expand, size=STAMP_SIZE)
def validate_peering_key(peering_id, peering_key, target_cost):
workblock = stamp_workblock(peering_id, expand_rounds=WORKBLOCK_EXPAND_ROUNDS_PEERING)
@@ -120,363 +67,6 @@ def validate_pn_stamps(transient_list, target_cost):
if len(transient_list) <= PN_VALIDATION_POOL_MIN_SIZE or non_mp_platform: return validate_pn_stamps_job_simple(transient_list, target_cost)
else: return validate_pn_stamps_job_multip(transient_list, target_cost)
def generate_stamp(message_id, stamp_cost, expand_rounds=WORKBLOCK_EXPAND_ROUNDS):
RNS.log(f"Generating stamp with cost {stamp_cost} for {RNS.prettyhexrep(message_id)}...", RNS.LOG_DEBUG)
workblock = stamp_workblock(message_id, expand_rounds=expand_rounds)
start_time = time.time()
stamp = None
rounds = 0
value = 0
if RNS.vendor.platformutils.is_windows() or RNS.vendor.platformutils.is_darwin(): stamp, rounds = job_simple(stamp_cost, workblock, message_id)
elif RNS.vendor.platformutils.is_android(): stamp, rounds = job_android(stamp_cost, workblock, message_id)
else:
if USE_WORKER_MANAGER: stamp, rounds = job_linux_managed(stamp_cost, workblock, message_id)
else: stamp, rounds = job_linux(stamp_cost, workblock, message_id)
duration = time.time() - start_time
speed = rounds/duration
if stamp != None: value = stamp_value(workblock, stamp)
RNS.log(f"Stamp with value {value} generated in {RNS.prettytime(duration)}, {rounds} rounds, {int(speed)} rounds per second", RNS.LOG_DEBUG)
return stamp, value
def cancel_work(message_id):
if RNS.vendor.platformutils.is_windows() or RNS.vendor.platformutils.is_darwin():
try:
if message_id in active_jobs:
active_jobs[message_id] = True
except Exception as e:
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
elif RNS.vendor.platformutils.is_android():
try:
if message_id in active_jobs:
active_jobs[message_id] = True
except Exception as e:
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
else:
try:
if message_id in active_jobs:
stop_event = active_jobs[message_id][0]
result_queue = active_jobs[message_id][1]
stop_event.set()
result_queue.put(None)
active_jobs.pop(message_id)
except Exception as e:
RNS.log("Error while terminating stamp generation workers: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
def job_simple(stamp_cost, workblock, message_id):
# A simple, single-process stamp generator.
# should work on any platform, and is used
# as a fall-back, in case of limited multi-
# processing and/or acceleration support.
platform = RNS.vendor.platformutils.get_platform()
RNS.log(f"Running stamp generation on {platform}, work limited to single CPU core. This will be slower than ideal.", RNS.LOG_WARNING)
rounds = 0
pstamp = os.urandom(256//8)
st = time.time()
active_jobs[message_id] = False;
def sv(s, c, w):
target = 0b1<<256-c; m = w+s
result = RNS.Identity.full_hash(m)
if int.from_bytes(result, byteorder="big") > target: return False
else: return True
while not sv(pstamp, stamp_cost, workblock) and not active_jobs[message_id]:
pstamp = os.urandom(256//8); rounds += 1
if rounds % 2500 == 0:
speed = rounds / (time.time()-st)
RNS.log(f"Stamp generation running. {rounds} rounds completed so far, {int(speed)} rounds per second", RNS.LOG_DEBUG)
if active_jobs[message_id] == True:
pstamp = None
active_jobs.pop(message_id)
return pstamp, rounds
def job_linux_managed(stamp_cost, workblock, message_id):
ctx = multiprocessing.get_context("fork")
cores = multiprocessing.cpu_count()
jobs = cores if cores <= 12 else int(cores/2)
allow_kill = True
stamp = None
total_rounds = 0
with worker_context(ctx, stamp_cost, workblock, message_id) as (stop_event, result_queue, rounds_queue, job_procs):
RNS.log(f"Starting {jobs} stamp generation workers", RNS.LOG_DEBUG)
def job(stop_event, sc, wb, worker_id):
terminated = False
rounds = 0
pstamp = os.urandom(256//8)
def sv(s, c, w):
target = 0b1<<256-c; m = w+s
result = RNS.Identity.full_hash(m)
if int.from_bytes(result, byteorder="big") > target: return False
else: return True
while not stop_event.is_set() and not sv(pstamp, sc, wb):
pstamp = os.urandom(256//8); rounds += 1
if not stop_event.is_set():
stop_event.set()
try: result_queue.put_nowait(pstamp)
except: pass
try: rounds_queue.put_nowait(rounds)
except: pass
for jpn in range(jobs):
p = ctx.Process(target=job, args=(stop_event, stamp_cost, workblock, jpn), daemon=True)
job_procs.append(p)
p.start()
try: stamp = result_queue.get(timeout=None)
except Exception as e:
RNS.log(f"Failed to get result from workers: {e}", RNS.LOG_ERROR)
stamp = None
# Collect any potential spurious
# results from worker queue.
try:
while True: result_queue.get_nowait()
except: pass
for j in range(jobs):
nrounds = 0
try:
nrounds = rounds_queue.get(timeout=2)
except Exception as e:
RNS.log(f"Failed to get round stats part {j}: {e}", RNS.LOG_ERROR)
total_rounds += nrounds
all_exited = False
exit_timeout = time.time() + 5
while time.time() < exit_timeout:
if not any(p.is_alive() for p in job_procs):
all_exited = True
break
time.sleep(0.1)
if not all_exited:
RNS.log("Stamp generation IPC timeout, possible worker deadlock. Terminating remaining processes.", RNS.LOG_ERROR)
if allow_kill:
for j in range(jobs):
process = job_procs[j]
process.kill()
else:
return None
else:
for j in range(jobs):
process = job_procs[j]
process.join()
# RNS.log(f"Joined {j} / {process}", RNS.LOG_DEBUG) # TODO: Remove
return stamp, total_rounds
def job_linux(stamp_cost, workblock, message_id):
allow_kill = True
stamp = None
total_rounds = 0
cores = multiprocessing.cpu_count()
jobs = cores if cores <= 12 else int(cores/2)
stop_event = multiprocessing.Event()
result_queue = multiprocessing.Queue(1)
rounds_queue = multiprocessing.Queue()
def job(stop_event, pn, sc, wb):
terminated = False
rounds = 0
pstamp = os.urandom(256//8)
def sv(s, c, w):
target = 0b1<<256-c; m = w+s
result = RNS.Identity.full_hash(m)
if int.from_bytes(result, byteorder="big") > target:
return False
else:
return True
while not stop_event.is_set() and not sv(pstamp, sc, wb):
pstamp = os.urandom(256//8); rounds += 1
if not stop_event.is_set():
stop_event.set()
result_queue.put(pstamp)
rounds_queue.put(rounds)
job_procs = []
RNS.log(f"Starting {jobs} stamp generation workers", RNS.LOG_DEBUG)
for jpn in range(jobs):
process = multiprocessing.get_context("fork").Process(target=job, kwargs={"stop_event": stop_event, "pn": jpn, "sc": stamp_cost, "wb": workblock}, daemon=True)
job_procs.append(process)
process.start()
active_jobs[message_id] = [stop_event, result_queue]
stamp = result_queue.get()
# Collect any potential spurious
# results from worker queue.
try:
while True: result_queue.get_nowait()
except: pass
for j in range(jobs):
nrounds = 0
try:
nrounds = rounds_queue.get(timeout=2)
except Exception as e:
RNS.log(f"Failed to get round stats part {j}: {e}", RNS.LOG_ERROR)
total_rounds += nrounds
all_exited = False
exit_timeout = time.time() + 5
while time.time() < exit_timeout:
if not any(p.is_alive() for p in job_procs):
all_exited = True
break
time.sleep(0.1)
if not all_exited:
RNS.log("Stamp generation IPC timeout, possible worker deadlock. Terminating remaining processes.", RNS.LOG_ERROR)
if allow_kill:
for j in range(jobs):
process = job_procs[j]
process.kill()
else:
return None
else:
for j in range(jobs):
process = job_procs[j]
process.join()
# RNS.log(f"Joined {j} / {process}", RNS.LOG_DEBUG) # TODO: Remove
return stamp, total_rounds
def job_android(stamp_cost, workblock, message_id):
# Semaphore support is flaky to non-existent on
# Android, so we need to manually dispatch and
# manage workloads here, while periodically
# checking in on the progress.
stamp = None
start_time = time.time()
total_rounds = 0
rounds_per_worker = 1000
use_nacl = False
try:
import nacl.encoding
import nacl.hash
use_nacl = True
except:
pass
if use_nacl:
def full_hash(m):
return nacl.hash.sha256(m, encoder=nacl.encoding.RawEncoder)
else:
def full_hash(m):
return RNS.Identity.full_hash(m)
def sv(s, c, w):
target = 0b1<<256-c
m = w+s
result = full_hash(m)
if int.from_bytes(result, byteorder="big") > target:
return False
else:
return True
wm = multiprocessing.Manager()
jobs = multiprocessing.cpu_count()
def job(procnum=None, results_dict=None, wb=None, sc=None, jr=None):
# RNS.log(f"Worker {procnum} starting for {jr} rounds...") # TODO: Remove
try:
rounds = 0
found_stamp = None
while True:
pstamp = os.urandom(256//8)
rounds += 1
if sv(pstamp, sc, wb):
found_stamp = pstamp
break
if rounds >= jr:
# RNS.log(f"Worker {procnum} found no result in {rounds} rounds") # TODO: Remove
break
results_dict[procnum] = [found_stamp, rounds]
except Exception as e:
RNS.log(f"Stamp generation worker error: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
active_jobs[message_id] = False;
RNS.log(f"Dispatching {jobs} workers for stamp generation...", RNS.LOG_DEBUG) # TODO: Remove
results_dict = wm.dict()
while stamp == None and active_jobs[message_id] == False:
job_procs = []
try:
for pnum in range(jobs):
pargs = {"procnum":pnum, "results_dict": results_dict, "wb": workblock, "sc":stamp_cost, "jr":rounds_per_worker}
process = multiprocessing.Process(target=job, kwargs=pargs)
job_procs.append(process)
process.start()
for process in job_procs:
process.join()
for j in results_dict:
r = results_dict[j]
total_rounds += r[1]
if r[0] != None:
stamp = r[0]
if stamp == None:
elapsed = time.time() - start_time
speed = total_rounds/elapsed
RNS.log(f"Stamp generation running. {total_rounds} rounds completed so far, {int(speed)} rounds per second", RNS.LOG_DEBUG)
except Exception as e:
RNS.log(f"Stamp generation job error: {e}")
RNS.trace_exception(e)
active_jobs.pop(message_id)
return stamp, total_rounds
# def stamp_value_linear(workblock, stamp):
# value = 0
# bits = 256
# material = RNS.Identity.full_hash(workblock+stamp)
# s = int.from_bytes(material, byteorder="big")
# return s.bit_count()
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
@@ -515,6 +105,11 @@ if __name__ == "__main__":
message_id = os.urandom(32)
generate_stamp(message_id, cost, expand_rounds=WORKBLOCK_EXPAND_ROUNDS_PEERING)
RNS.log("", RNS.LOG_DEBUG)
RNS.log("Testing non-expanded workblock generation", RNS.LOG_DEBUG)
message_id = os.urandom(32)
generate_stamp(message_id, cost, expand_rounds=0)
# transient_list = []
# st = time.time(); count = 10000
# for i in range(count): transient_list.append(os.urandom(256))
+502
View File
@@ -0,0 +1,502 @@
import os
import time
import sqlite3
import threading
import RNS
import RNS.vendor.umsgpack as msgpack
class LXMFStore:
CURRENT_VERSION = 1
TRANSIENT_ID_LENGTH = RNS.Identity.HASHLENGTH//8
DESTINATION_LENGTH = RNS.Identity.TRUNCATED_HASHLENGTH//8
TICKET_LENGTH = RNS.Identity.TRUNCATED_HASHLENGTH//8
IMPORT_CHUNK = 4096
CULL_CHUNK = 4096
IN_CHUNK = 512
VACUUM_PAGES = 512
def __init__(self, db_path):
if sqlite3.threadsafety < 3: raise RuntimeError("Storage backend requires a SQLite build with serialized threading support")
self.db_path = db_path
self._conn = None
self._conn_lock = threading.Lock()
self._close_warned = False
self._conn = sqlite3.connect(db_path, check_same_thread=False, isolation_level=None)
self._conn.execute("PRAGMA auto_vacuum=INCREMENTAL")
self._conn.execute("PRAGMA journal_mode=WAL")
self._conn.execute("PRAGMA synchronous=NORMAL")
self._conn.execute("PRAGMA journal_size_limit=8388608")
self._conn.execute("PRAGMA busy_timeout=1500")
self.__create_schema()
def close(self):
with self._conn_lock:
if self._conn != None:
try: self._conn.execute("PRAGMA optimize")
except Exception: pass
self._conn.close()
self._conn = None
def __create_schema(self):
db_version = self._conn.execute("PRAGMA user_version").fetchone()[0]
if db_version > self.CURRENT_VERSION:
RNS.log(f"Cannot open store {self.db_path}: database version {db_version} is newer than supported version {self.CURRENT_VERSION}", RNS.LOG_CRITICAL)
self._conn.close(); self._conn = None
raise ValueError(f"Store database version {db_version} is newer than supported version {self.CURRENT_VERSION}")
try:
self._conn.execute("BEGIN")
self._conn.execute("""CREATE TABLE IF NOT EXISTS stamp_costs (
destination_hash BLOB PRIMARY KEY,
updated REAL NOT NULL,
used REAL,
cost REAL)""")
self._conn.execute("""CREATE TABLE IF NOT EXISTS delivered_transient_ids (
transient_id BLOB PRIMARY KEY,
received REAL NOT NULL)""")
self._conn.execute("""CREATE TABLE IF NOT EXISTS processed_transient_ids (
transient_id BLOB PRIMARY KEY,
received REAL NOT NULL)""")
self._conn.execute("""CREATE TABLE IF NOT EXISTS tickets_outbound (
destination_hash BLOB PRIMARY KEY,
expires REAL NOT NULL,
ticket BLOB NOT NULL)""")
self._conn.execute("""CREATE TABLE IF NOT EXISTS tickets_inbound (
ticket BLOB PRIMARY KEY,
destination_hash BLOB NOT NULL,
expires REAL NOT NULL)""")
self._conn.execute("""CREATE TABLE IF NOT EXISTS ticket_deliveries (
destination_hash BLOB PRIMARY KEY,
timestamp REAL NOT NULL)""")
self._conn.execute("CREATE INDEX IF NOT EXISTS idx_delivered_received ON delivered_transient_ids (received)")
self._conn.execute("CREATE INDEX IF NOT EXISTS idx_processed_received ON processed_transient_ids (received)")
self._conn.execute("CREATE INDEX IF NOT EXISTS idx_stampcost_updated ON stamp_costs (updated)")
self._conn.execute("CREATE INDEX IF NOT EXISTS idx_tickets_in_dest ON tickets_inbound (destination_hash)")
self._conn.execute(f"PRAGMA user_version = {self.CURRENT_VERSION}")
self._conn.execute("COMMIT")
except Exception as e:
RNS.log(f"Could not initialise store schema at {self.db_path}. The contained exception was: {e}", RNS.LOG_CRITICAL)
try: self._conn.execute("ROLLBACK")
except Exception: pass
self._conn.close(); self._conn = None
raise
def _ready(self):
if self._conn == None:
if not self._close_warned:
self._close_warned = True
RNS.log("Store operation attempted after close", RNS.LOG_ERROR)
return False
else: return True
def _claim(self, table, key_column, key, ts_column, timestamp):
try:
with self._conn_lock:
if not self._ready(): return True
cursor = self._conn.execute(f"INSERT INTO {table} ({key_column}, {ts_column}) VALUES (?, ?) ON CONFLICT({key_column}) DO NOTHING", (key, timestamp))
return cursor.rowcount == 1
except Exception as e:
RNS.log(f"Could not claim entry in {table} of store, treating as claimed. The contained exception was: {e}", RNS.LOG_ERROR)
return True
def _upsert_timestamp(self, table, key_column, key, ts_column, timestamp):
try:
with self._conn_lock:
if not self._ready(): return False
self._conn.execute(f"INSERT INTO {table} ({key_column}, {ts_column}) VALUES (?, ?) ON CONFLICT({key_column}) DO UPDATE SET {ts_column}=excluded.{ts_column}", (key, timestamp))
return True
except Exception as e:
RNS.log(f"Could not upsert entry in {table} of store. The contained exception was: {e}", RNS.LOG_ERROR)
return False
def _cull(self, table, ts_column, cutoff, max_entries):
try:
with self._conn_lock:
if not self._ready(): return 0
cursor = self._conn.execute(f"DELETE FROM {table} WHERE rowid IN (SELECT rowid FROM {table} WHERE {ts_column} < ? LIMIT {int(max_entries)})", (cutoff,))
return cursor.rowcount
except Exception as e:
RNS.log(f"Could not cull entries in {table} of store. The contained exception was: {e}", RNS.LOG_ERROR)
return 0
########################
# Outbound Stamp Costs #
########################
def update_stamp_cost(self, destination_hash, cost):
try:
with self._conn_lock:
if not self._ready(): return False
self._conn.execute("INSERT INTO stamp_costs (destination_hash, updated, used, cost) VALUES (?, ?, NULL, ?) ON CONFLICT(destination_hash) DO UPDATE SET updated=excluded.updated, cost=excluded.cost", (destination_hash, time.time(), cost))
return True
except Exception as e:
RNS.log(f"Could not update outbound stamp cost in store. The contained exception was: {e}", RNS.LOG_ERROR)
return False
def get_outbound_stamp_cost(self, destination_hash):
if not self._ready(): return None
cost = None
try:
with self._conn_lock:
if not self._ready(): return None
row = self._conn.execute("SELECT cost FROM stamp_costs WHERE destination_hash=?", (destination_hash,)).fetchone()
if row != None and len(row) > 0:
cost = row[0]
try: self._conn.execute("UPDATE stamp_costs SET used=? WHERE destination_hash=?", (time.time(), destination_hash))
except Exception as e: RNS.log(f"Could not update stamp cost usage time in store. The contained exception was: {e}", RNS.LOG_ERROR)
except Exception as e:
RNS.log(f"Could not recall outbound stamp cost from store. The contained exception was: {e}", RNS.LOG_ERROR)
return None
return cost
def cull_stamp_costs(self, cutoff, max_entries=CULL_CHUNK): return self._cull("stamp_costs", "updated", cutoff, max_entries)
##############################
# Transient ID Deduplication #
##############################
def has_delivered(self, transient_id):
if not self._ready(): return False
try:
with self._conn_lock:
if not self._ready(): return False
row = self._conn.execute("SELECT transient_id FROM delivered_transient_ids WHERE transient_id=?", (transient_id,)).fetchone()
return row != None
except Exception as e:
RNS.log(f"Could not query delivered transient ID in store. The contained exception was: {e}", RNS.LOG_ERROR)
return False
def known_delivered(self, transient_ids):
known = set()
if not self._ready(): return known
try:
with self._conn_lock:
if not self._ready(): return known
ids = list(set(transient_id for transient_id in transient_ids if type(transient_id) == bytes))
for i in range(0, len(ids), self.IN_CHUNK):
chunk = ids[i:i+self.IN_CHUNK]
marks = ",".join("?"*len(chunk))
for row in self._conn.execute(f"SELECT transient_id FROM delivered_transient_ids WHERE transient_id IN ({marks})", chunk):
known.add(row[0])
except Exception as e:
RNS.log(f"Could not query known delivered transient IDs in store. The contained exception was: {e}", RNS.LOG_ERROR)
return set()
return known
def mark_locally_delivered(self, transient_id, received): return self._upsert_timestamp("delivered_transient_ids", "transient_id", transient_id, "received", received)
def unconditionally_mark_processed(self, transient_id, received): return self._upsert_timestamp("processed_transient_ids", "transient_id", transient_id, "received", received)
def conditionally_claim_delivered(self, transient_id, received): return self._claim("delivered_transient_ids", "transient_id", transient_id, "received", received)
def conditionally_claim_processed(self, transient_id, received): return self._claim("processed_transient_ids", "transient_id", transient_id, "received", received)
def cull_processed(self, cutoff, max_entries=CULL_CHUNK): return self._cull("processed_transient_ids", "received", cutoff, max_entries)
def cull_delivered(self, cutoff, max_entries=CULL_CHUNK): return self._cull("delivered_transient_ids", "received", cutoff, max_entries)
###########
# Tickets #
###########
def remember_ticket(self, destination_hash, ticket_entry):
try:
expires, ticket = ticket_entry[0], ticket_entry[1]
with self._conn_lock:
if not self._ready(): return False
self._conn.execute("INSERT INTO tickets_outbound (destination_hash, expires, ticket) VALUES (?, ?, ?) ON CONFLICT(destination_hash) DO UPDATE SET expires=excluded.expires, ticket=excluded.ticket", (destination_hash, expires, ticket))
return True
except Exception as e:
RNS.log(f"Could not remember ticket in store. The contained exception was: {e}", RNS.LOG_ERROR)
return False
def get_outbound_ticket(self, destination_hash):
if not self._ready(): return None
try:
with self._conn_lock:
if not self._ready(): return None
row = self._conn.execute("SELECT ticket FROM tickets_outbound WHERE destination_hash=? AND expires > ?", (destination_hash, time.time())).fetchone()
if row != None: return row[0]
else: return None
except Exception as e:
RNS.log(f"Could not recall outbound ticket from store. The contained exception was: {e}", RNS.LOG_ERROR)
return None
def get_outbound_ticket_expiry(self, destination_hash):
if not self._ready(): return None
try:
with self._conn_lock:
if not self._ready(): return None
row = self._conn.execute("SELECT expires FROM tickets_outbound WHERE destination_hash=? AND expires > ?", (destination_hash, time.time())).fetchone()
if row != None: return row[0]
else: return None
except Exception as e:
RNS.log(f"Could not recall outbound ticket expiry from store. The contained exception was: {e}", RNS.LOG_ERROR)
return None
def get_reusable_inbound_ticket(self, destination_hash, renew_before):
if not self._ready(): return None
try:
with self._conn_lock:
if not self._ready(): return None
row = self._conn.execute("SELECT expires, ticket FROM tickets_inbound WHERE destination_hash=? AND expires > ? ORDER BY expires DESC LIMIT 1", (destination_hash, time.time()+renew_before)).fetchone()
if row != None: return [row[0], row[1]]
else: return None
except Exception as e:
RNS.log(f"Could not recall reusable inbound ticket from store. The contained exception was: {e}", RNS.LOG_ERROR)
return None
def store_inbound_ticket(self, destination_hash, ticket, expires):
try:
with self._conn_lock:
if not self._ready(): return False
self._conn.execute("INSERT INTO tickets_inbound (ticket, destination_hash, expires) VALUES (?, ?, ?) ON CONFLICT(ticket) DO UPDATE SET destination_hash=excluded.destination_hash, expires=excluded.expires", (ticket, destination_hash, expires))
return True
except Exception as e:
RNS.log(f"Could not save inbound ticket in store. The contained exception was: {e}", RNS.LOG_ERROR)
return False
def get_inbound_tickets(self, destination_hash):
if not self._ready(): return None
try:
with self._conn_lock:
if not self._ready(): return None
tickets = [row[0] for row in self._conn.execute("SELECT ticket FROM tickets_inbound WHERE destination_hash=? AND expires > ?", (destination_hash, time.time()))]
if len(tickets) > 0: return tickets
else: return None
except Exception as e:
RNS.log(f"Could not recall inbound tickets from store. The contained exception was: {e}", RNS.LOG_ERROR)
return None
def get_last_ticket_delivery(self, destination_hash):
if not self._ready(): return None
try:
with self._conn_lock:
if not self._ready(): return None
row = self._conn.execute("SELECT timestamp FROM ticket_deliveries WHERE destination_hash=?", (destination_hash,)).fetchone()
if row != None: return row[0]
else: return None
except Exception as e:
RNS.log(f"Could not recall last ticket delivery from store. The contained exception was: {e}", RNS.LOG_ERROR)
return None
def mark_last_ticket_delivery(self, destination_hash, timestamp):
try:
with self._conn_lock:
if not self._ready(): return False
self._conn.execute("INSERT INTO ticket_deliveries (destination_hash, timestamp) VALUES (?, ?) ON CONFLICT(destination_hash) DO UPDATE SET timestamp=excluded.timestamp", (destination_hash, timestamp))
return True
except Exception as e:
RNS.log(f"Could not record last ticket delivery in store. The contained exception was: {e}", RNS.LOG_ERROR)
return False
def cull_tickets_outbound(self, cutoff, max_entries=CULL_CHUNK): return self._cull("tickets_outbound", "expires", cutoff, max_entries)
def cull_tickets_inbound(self, cutoff, max_entries=CULL_CHUNK): return self._cull("tickets_inbound", "expires", cutoff, max_entries)
###############
# Maintenance #
###############
def incremental_vacuum(self, max_pages=VACUUM_PAGES):
try:
with self._conn_lock:
if not self._ready(): return 0
freed = 0
while freed < int(max_pages):
before = self._conn.execute("PRAGMA freelist_count").fetchone()[0]
self._conn.execute(f"PRAGMA incremental_vacuum({int(max_pages)-freed})")
after = self._conn.execute("PRAGMA freelist_count").fetchone()[0]
if after >= before: break
freed += before-after
return freed
except Exception as e:
RNS.log(f"Could not run incremental vacuum on store. The contained exception was: {e}", RNS.LOG_ERROR)
return 0
############################
# Legacy Storage Migration #
############################
def import_legacy_delivered(self, path): return self.__import_legacy_timestamps(path, "delivered_transient_ids")
def import_legacy_processed(self, path): return self.__import_legacy_timestamps(path, "processed_transient_ids")
def __import_legacy_timestamps(self, path, table):
st = time.time()
try:
with open(path, "rb") as legacy_file: legacy = msgpack.unpackb(legacy_file.read())
except Exception as e:
RNS.log(f"Could not read legacy transient ID cache at {path}: {e}", RNS.LOG_ERROR)
return -1
if not type(legacy) == dict:
RNS.log(f"Invalid data format in legacy transient ID cache at {path}, not importing", RNS.LOG_ERROR)
return -1
rows = []
for transient_id, timestamp in legacy.items():
if type(transient_id) == bytes and len(transient_id) == self.TRANSIENT_ID_LENGTH and type(timestamp) in (int, float) and timestamp > 0:
rows.append((transient_id, float(timestamp)))
imported = -1
with self._conn_lock:
if self._ready():
try:
self._conn.execute("BEGIN")
for i in range(0, len(rows), self.IMPORT_CHUNK): self._conn.executemany(f"INSERT OR IGNORE INTO {table} (transient_id, received) VALUES (?, ?)", rows[i:i+self.IMPORT_CHUNK])
self._conn.execute("COMMIT")
imported = len(rows)
except Exception as e:
RNS.log(f"Could not import legacy transient ID cache at {path} into store. The contained exception was: {e}", RNS.LOG_ERROR)
try: self._conn.execute("ROLLBACK")
except Exception: pass
if imported >= 0:
try: os.replace(path, path+".imported")
except Exception as e: RNS.log(f"Could not mark legacy file {path} as imported: {e}", RNS.LOG_WARNING)
RNS.log(f"Imported {imported} entries from {os.path.split(path)[-1]} into store in {RNS.prettyshorttime(time.time()-st)}", RNS.LOG_VERBOSE)
return imported
def import_legacy_stamp_costs(self, path):
st = time.time()
try:
with open(path, "rb") as legacy_file: legacy = msgpack.unpackb(legacy_file.read())
except Exception as e:
RNS.log(f"Could not read legacy outbound stamp cost cache at {path}: {e}", RNS.LOG_ERROR)
return -1
if not type(legacy) == dict:
RNS.log(f"Invalid data format in legacy outbound stamp cost cache at {path}, not importing", RNS.LOG_ERROR)
return -1
rows = []
for destination_hash, entry in legacy.items():
if type(destination_hash) == bytes and len(destination_hash) == self.DESTINATION_LENGTH and type(entry) in (list, tuple) and len(entry) >= 2:
last_heard, cost = entry[0], entry[1]
if type(last_heard) not in (int, float): continue
if cost != None and type(cost) not in (int, float): continue
rows.append((destination_hash, float(last_heard), cost))
imported = -1
with self._conn_lock:
if self._ready():
try:
self._conn.execute("BEGIN")
for i in range(0, len(rows), self.IMPORT_CHUNK): self._conn.executemany("INSERT OR IGNORE INTO stamp_costs (destination_hash, updated, used, cost) VALUES (?, ?, NULL, ?)", rows[i:i+self.IMPORT_CHUNK])
self._conn.execute("COMMIT")
imported = len(rows)
except Exception as e:
RNS.log(f"Could not import legacy outbound stamp cost cache at {path} into store. The contained exception was: {e}", RNS.LOG_ERROR)
try: self._conn.execute("ROLLBACK")
except Exception: pass
if imported >= 0:
try: os.replace(path, path+".imported")
except Exception as e: RNS.log(f"Could not mark legacy file {path} as imported: {e}", RNS.LOG_WARNING)
RNS.log(f"Imported {imported} entries from {os.path.split(path)[-1]} into store in {RNS.prettyshorttime(time.time()-st)}", RNS.LOG_VERBOSE)
return imported
def import_legacy_tickets(self, path):
st = time.time()
try:
with open(path, "rb") as legacy_file: legacy = msgpack.unpackb(legacy_file.read())
except Exception as e:
RNS.log(f"Could not read legacy available tickets file at {path}: {e}", RNS.LOG_ERROR)
return -1
if not type(legacy) == dict:
RNS.log(f"Invalid data format in legacy available tickets file at {path}, not importing", RNS.LOG_ERROR)
return -1
rows_outbound = []
rows_inbound = []
rows_deliveries = []
outbound = legacy.get("outbound"); inbound = legacy.get("inbound"); last_deliveries = legacy.get("last_deliveries")
if type(outbound) == dict:
for destination_hash, entry in outbound.items():
if type(destination_hash) == bytes and len(destination_hash) == self.DESTINATION_LENGTH and type(entry) in (list, tuple) and len(entry) >= 2:
if type(entry[0]) in (int, float) and type(entry[1]) == bytes and len(entry[1]) == self.TICKET_LENGTH:
rows_outbound.append((destination_hash, float(entry[0]), entry[1]))
if type(inbound) == dict:
for destination_hash, tickets in inbound.items():
if not (type(destination_hash) == bytes and len(destination_hash) == self.DESTINATION_LENGTH and type(tickets) == dict): continue
for ticket, entry in tickets.items():
if type(ticket) == bytes and len(ticket) == self.TICKET_LENGTH and type(entry) in (list, tuple) and len(entry) >= 1:
if type(entry[0]) in (int, float):
rows_inbound.append((ticket, destination_hash, float(entry[0])))
if type(last_deliveries) == dict:
for destination_hash, timestamp in last_deliveries.items():
if type(destination_hash) == bytes and len(destination_hash) == self.DESTINATION_LENGTH and type(timestamp) in (int, float):
rows_deliveries.append((destination_hash, float(timestamp)))
total = len(rows_outbound)+len(rows_inbound)+len(rows_deliveries)
imported = -1
with self._conn_lock:
if self._ready():
try:
self._conn.execute("BEGIN")
for i in range(0, len(rows_outbound), self.IMPORT_CHUNK): self._conn.executemany("INSERT OR IGNORE INTO tickets_outbound (destination_hash, expires, ticket) VALUES (?, ?, ?)", rows_outbound[i:i+self.IMPORT_CHUNK])
for i in range(0, len(rows_inbound), self.IMPORT_CHUNK): self._conn.executemany("INSERT OR IGNORE INTO tickets_inbound (ticket, destination_hash, expires) VALUES (?, ?, ?)", rows_inbound[i:i+self.IMPORT_CHUNK])
for i in range(0, len(rows_deliveries), self.IMPORT_CHUNK): self._conn.executemany("INSERT OR IGNORE INTO ticket_deliveries (destination_hash, timestamp) VALUES (?, ?)", rows_deliveries[i:i+self.IMPORT_CHUNK])
self._conn.execute("COMMIT")
imported = total
except Exception as e:
RNS.log(f"Could not import available tickets file at {path} into store. The contained exception was: {e}", RNS.LOG_ERROR)
try: self._conn.execute("ROLLBACK")
except Exception: pass
if imported >= 0:
try: os.replace(path, path+".imported")
except Exception as e: RNS.log(f"Could not mark legacy file {path} as imported: {e}", RNS.LOG_WARNING)
RNS.log(f"Imported {imported} entries from {os.path.split(path)[-1]} into store in {RNS.prettyshorttime(time.time()-st)}", RNS.LOG_VERBOSE)
return imported
+165 -18
View File
@@ -87,12 +87,17 @@ def apply_config():
else:
active_configuration["peer_announce_interval"] = None
if "lxmf" in lxmd_config and "stamp_cost" in lxmd_config["lxmf"]:
active_configuration["peer_stamp_cost"] = max(1, lxmd_config["lxmf"].as_float("stamp_cost"))
else:
active_configuration["peer_stamp_cost"] = 12.0
if "lxmf" in lxmd_config and "delivery_transfer_max_accepted_size" in lxmd_config["lxmf"]:
active_configuration["delivery_transfer_max_accepted_size"] = lxmd_config["lxmf"].as_float("delivery_transfer_max_accepted_size")
if active_configuration["delivery_transfer_max_accepted_size"] < 0.38:
active_configuration["delivery_transfer_max_accepted_size"] = 0.38
else:
active_configuration["delivery_transfer_max_accepted_size"] = 1000
active_configuration["delivery_transfer_max_accepted_size"] = 1
if "lxmf" in lxmd_config and "on_inbound" in lxmd_config["lxmf"]:
active_configuration["on_inbound"] = lxmd_config["lxmf"]["on_inbound"]
@@ -130,6 +135,21 @@ def apply_config():
else:
active_configuration["autopeer_maxdepth"] = None
if "propagation" in lxmd_config and "sequential_pn_stamp_validation" in lxmd_config["propagation"]:
active_configuration["sequential_pn_stamp_validation"] = lxmd_config["propagation"].as_bool("sequential_pn_stamp_validation")
else:
active_configuration["sequential_pn_stamp_validation"] = True
if "propagation" in lxmd_config and "static_peers_bypass_sequential" in lxmd_config["propagation"]:
active_configuration["static_peers_bypass_sequential"] = lxmd_config["propagation"].as_bool("static_peers_bypass_sequential")
else:
active_configuration["static_peers_bypass_sequential"] = True
if "propagation" in lxmd_config and "max_inbound_syncs" in lxmd_config["propagation"]:
active_configuration["max_inbound_syncs"] = max(1, lxmd_config["propagation"].as_int("max_inbound_syncs"))
else:
active_configuration["max_inbound_syncs"] = 3
if "propagation" in lxmd_config and "announce_interval" in lxmd_config["propagation"]:
active_configuration["node_announce_interval"] = lxmd_config["propagation"].as_int("announce_interval")*60
else:
@@ -164,28 +184,35 @@ def apply_config():
active_configuration["propagation_sync_max_accepted_size"] = 256*40
if "propagation" in lxmd_config and "propagation_stamp_cost_target" in lxmd_config["propagation"]:
active_configuration["propagation_stamp_cost_target"] = lxmd_config["propagation"].as_int("propagation_stamp_cost_target")
active_configuration["propagation_stamp_cost_target"] = lxmd_config["propagation"].as_float("propagation_stamp_cost_target")
if active_configuration["propagation_stamp_cost_target"] < LXMF.LXMRouter.PROPAGATION_COST_MIN:
active_configuration["propagation_stamp_cost_target"] = LXMF.LXMRouter.PROPAGATION_COST_MIN
else:
active_configuration["propagation_stamp_cost_target"] = LXMF.LXMRouter.PROPAGATION_COST
if "propagation" in lxmd_config and "propagation_stamp_cost_flexibility" in lxmd_config["propagation"]:
active_configuration["propagation_stamp_cost_flexibility"] = lxmd_config["propagation"].as_int("propagation_stamp_cost_flexibility")
active_configuration["propagation_stamp_cost_flexibility"] = lxmd_config["propagation"].as_float("propagation_stamp_cost_flexibility")
if active_configuration["propagation_stamp_cost_flexibility"] < 0:
active_configuration["propagation_stamp_cost_flexibility"] = 0
else:
active_configuration["propagation_stamp_cost_flexibility"] = LXMF.LXMRouter.PROPAGATION_COST_FLEX
if "propagation" in lxmd_config and "propagation_stamp_throttle" in lxmd_config["propagation"]:
active_configuration["propagation_stamp_throttle"] = lxmd_config["propagation"].as_float("propagation_stamp_throttle")*60
if active_configuration["propagation_stamp_throttle"] < LXMF.LXMRouter.PN_STAMP_THROTTLE:
active_configuration["propagation_stamp_throttle"] = LXMF.LXMRouter.PN_STAMP_THROTTLE
else:
active_configuration["propagation_stamp_throttle"] = LXMF.LXMRouter.PN_STAMP_THROTTLE
if "propagation" in lxmd_config and "peering_cost" in lxmd_config["propagation"]:
active_configuration["peering_cost"] = lxmd_config["propagation"].as_int("peering_cost")
active_configuration["peering_cost"] = lxmd_config["propagation"].as_float("peering_cost")
if active_configuration["peering_cost"] < 0:
active_configuration["peering_cost"] = 0
else:
active_configuration["peering_cost"] = LXMF.LXMRouter.PEERING_COST
if "propagation" in lxmd_config and "remote_peering_cost_max" in lxmd_config["propagation"]:
active_configuration["remote_peering_cost_max"] = lxmd_config["propagation"].as_int("remote_peering_cost_max")
active_configuration["remote_peering_cost_max"] = lxmd_config["propagation"].as_float("remote_peering_cost_max")
if active_configuration["remote_peering_cost_max"] < 0:
active_configuration["remote_peering_cost_max"] = 0
else:
@@ -285,8 +312,7 @@ def lxmf_delivery(lxm):
processing_command = command+" \""+written_path+"\""
return_code = subprocess.call(shlex.split(processing_command), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else:
RNS.log("No action defined for inbound messages, ignoring", RNS.LOG_DEBUG)
else: RNS.log("No action defined for inbound messages, ignoring", RNS.LOG_DEBUG)
except Exception as e:
RNS.log("Error occurred while processing received message "+str(lxm)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
@@ -307,7 +333,7 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
if configdir == None:
if os.path.isdir("/etc/lxmd") and os.path.isfile("/etc/lxmd/config"):
configdir = "/etc/lxmd"
elif os.path.isdir(RNS.Reticulum.userdir+"/.config/lxmd") and os.path.isfile(Reticulum.userdir+"/.config/lxmd/config"):
elif os.path.isdir(RNS.Reticulum.userdir+"/.config/lxmd") and os.path.isfile(RNS.Reticulum.userdir+"/.config/lxmd/config"):
configdir = RNS.Reticulum.userdir+"/.config/lxmd"
else:
configdir = RNS.Reticulum.userdir+"/.lxmd"
@@ -383,6 +409,9 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
propagation_limit = active_configuration["propagation_transfer_max_accepted_size"],
propagation_cost = active_configuration["propagation_stamp_cost_target"],
propagation_cost_flexibility = active_configuration["propagation_stamp_cost_flexibility"],
sequential_validation = active_configuration["sequential_pn_stamp_validation"],
static_sequential = not active_configuration["static_peers_bypass_sequential"],
max_inbound_syncs = active_configuration["max_inbound_syncs"],
peering_cost = active_configuration["peering_cost"],
max_peering_cost = active_configuration["remote_peering_cost_max"],
sync_limit = active_configuration["propagation_sync_max_accepted_size"],
@@ -390,6 +419,7 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
max_peers = active_configuration["max_peers"],
static_peers = active_configuration["static_peers"],
from_static_only = active_configuration["from_static_only"],
pn_stamp_throttle = active_configuration["propagation_stamp_throttle"],
name = active_configuration["node_name"])
message_router.register_delivery_callback(lxmf_delivery)
@@ -397,7 +427,8 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
for destination_hash in active_configuration["ignored_lxmf_destinations"]:
message_router.ignore_destination(destination_hash)
lxmf_destination = message_router.register_delivery_identity(identity, display_name=active_configuration["display_name"])
lxmf_destination = message_router.register_delivery_identity(identity, display_name=active_configuration["display_name"],
stamp_cost=active_configuration["peer_stamp_cost"])
RNS.Identity.remember(
packet_hash=None,
@@ -770,7 +801,7 @@ def get_status(remote=None, configdir=None, rnsconfigdir=None, verbosity=0, quie
srxb = RNS.prettysize(p["rx_bytes"]); stxb = RNS.prettysize(p["tx_bytes"]); pmo = pm["offered"]; pmout = pm["outgoing"]
pmi = pm["incoming"]; pmuh = pm["unhandled"]; ar = round(p["acceptance_rate"]*100, 2)
if p["name"] == None: nn = ""
else: nn = p["name"].strip().replace("\n", "").replace("\r", "")
else: nn = sanitize_name(p["name"])
if len(nn) > 45: nn = f"{nn[:45]}..."
print(f"{ind}{t}{RNS.prettyhexrep(peer_id)}")
if len(nn): print(f"{ind*2}Name : {nn}")
@@ -822,7 +853,7 @@ def _remote_init(configdir=None, rnsconfigdir=None, verbosity=0, quietness=0, id
if identity_path == None:
if configdir == None:
if os.path.isdir("/etc/lxmd") and os.path.isfile("/etc/lxmd/config"): configdir = "/etc/lxmd"
elif os.path.isdir(RNS.Reticulum.userdir+"/.config/lxmd") and os.path.isfile(Reticulum.userdir+"/.config/lxmd/config"): configdir = RNS.Reticulum.userdir+"/.config/lxmd"
elif os.path.isdir(RNS.Reticulum.userdir+"/.config/lxmd") and os.path.isfile(RNS.Reticulum.userdir+"/.config/lxmd/config"): configdir = RNS.Reticulum.userdir+"/.config/lxmd"
else: configdir = RNS.Reticulum.userdir+"/.lxmd"
configpath = configdir+"/config"
@@ -1004,7 +1035,7 @@ autopeer_maxdepth = 6
# You can configure the target stamp cost
# required to deliver messages via this node.
# propagation_stamp_cost_target = 16
# propagation_stamp_cost_target = 16.0
# If set higher than 0, the stamp cost flexi-
# bility option will make this node accept
@@ -1013,13 +1044,25 @@ autopeer_maxdepth = 6
# not from peers directly). This allows the
# network to gradually adjust stamp cost.
# propagation_stamp_cost_flexibility = 3
# propagation_stamp_cost_flexibility = 3.0
# If a peer delivers messages with stamp costs
# not conforming to this node's targets, it'll
# be throttled, by default for 5 minutes. You
# can configure the throttle period, and for
# constrained nodes, it may be a good idea to
# set a much higher throttle time. Real LXMF
# propagation nodes will never deliver messages
# with lower stamp values than required by the
# receiving node.
# propagation_stamp_throttle = 5
# The peering_cost option configures the target
# value required for a remote node to peer with
# and deliver messages to this node.
# peering_cost = 18
# peering_cost = 18.0
# You can configure the maximum peering cost
# of remote nodes that this node will peer with.
@@ -1029,7 +1072,7 @@ autopeer_maxdepth = 6
# more computation time during initial peering
# when generating the peering key.
# remote_peering_cost_max = 26
# remote_peering_cost_max = 26.0
# You can tell the LXMF message router to
# prioritise storage for one or more
@@ -1060,6 +1103,33 @@ autopeer_maxdepth = 6
# from_static_only = True
# By default, stamp validation jobs for PN
# sync batches will run sequentially. If
# a peer offers messages while another batch
# is already processing, it will receive a
# throttle response to indicate that it can
# retry later. If you have a fast system, you
# can disable this to accept and validate
# everything as soon as it is offered.
# sequential_pn_stamp_validation = yes
# You can configure whether static peers are
# allowed have their PN syncs processed as
# soon as they are offered, regardless of
# whether another batch is already validating.
# static_peers_bypass_sequential = yes
# You can configure how many concurrent inbound
# propagation sync transfers will be accepted.
# Once this number is reached, nodes offering
# messages will receive a throttle response to
# indicate that they can retry later. On a slow
# system, it's a good idea to change this to 1.
# max_inbound_syncs = 3
# By default, any destination is allowed to
# connect and download messages, but you can
# optionally restrict this. If you enable
@@ -1089,13 +1159,18 @@ announce_at_start = no
# announce_interval = 360
# You can configure the required stamp cost for
# incoming messages.
# stamp_cost = 12
# The maximum accepted unpacked size for mes-
# sages received directly from other peers,
# specified in kilobytes. Messages larger than
# this will be rejected before the transfer
# begins.
delivery_transfer_max_accepted_size = 1000
delivery_transfer_max_accepted_size = 1
# You can configure an external program to be run
# every time a message is received. The program
@@ -1122,5 +1197,77 @@ loglevel = 4
"""
if __name__ == "__main__":
main()
import re
import unicodedata
STRIP_BLOCKS_RE = re.compile(
'['
'\U0001F600-\U0001F64F' # Emoticons
'\U0001F300-\U0001F5FF' # Misc Symbols & Pictographs
'\U0001F680-\U0001F6FF' # Transport & Map Symbols
'\U0001F700-\U0001F77F' # Alchemical Symbols
'\U0001F780-\U0001F7FF' # Geometric Shapes Extended
'\U0001F800-\U0001F8FF' # Supplemental Arrows-C
'\U0001F900-\U0001F9FF' # Supplemental Symbols & Pictographs
'\U0001FA00-\U0001FA6F' # Chess Symbols
'\U0001FA70-\U0001FAFF' # Symbols & Pictographs Extended-A
'\U0001F1E0-\U0001F1FF' # Flags (iOS/regional indicators)
'\u2600-\u26FF' # Misc Symbols (☀, ☁, ☂, etc.)
'\u2700-\u27BF' # Dingbats (✂, ✈, ✉, etc.)
'\uFE00-\uFE0F' # Variation Selectors
'\U000E0100-\U000E01EF' # Variation Selectors Supplement
'\U0001F3FB-\U0001F3FF' # Emoji modifiers (skin tones)
']+',
flags=re.UNICODE
)
STRIP_CONTROL_RE = re.compile(
'['
'\x00-\x08' # C0 controls (NUL-BS)
'\x0B\x0C' # VT, FF
'\x0E-\x1F' # C0 controls (SO-US)
'\x7F-\x9F' # DEL and C1 controls
'\u200B-\u200F' # Zero-width chars, LRM, RLM, etc.
'\u202A-\u202E' # Bidi embedding controls
'\u2060-\u206F' # Format chars (word joiner, etc.)
'\uFEFF' # BOM / Zero Width NBSP
'\uFFF0-\uFFF8' # Specials
']+',
flags=re.UNICODE
)
STRIP_PRIVATE_RE = re.compile(
'['
'\uD800-\uDFFF' # Surrogates
'\uE000-\uF8FF' # Private Use Area
'\uF900-\uFAFF' # CJK Compatibility Ideographs (keep? strip for safety)
'\uFE10-\uFE1F' # Vertical Forms
'\uFE20-\uFE2F' # Combining Half Marks
'\U000F0000-\U000FFFFF' # Supplementary Private Use Area-A
'\U00100000-\U0010FFFF' # Supplementary Private Use Area-B
']+',
flags=re.UNICODE
)
def sanitize_name(name):
if name is None: return None
name = str(name)
name = unicodedata.normalize('NFKC', name)
result = []
for char in name:
cat = unicodedata.category(char)
cat_prefix = cat[0] if cat else 'C'
if cat_prefix in ('L', 'N', 'P'): result.append(char)
elif cat == 'Zs': result.append(' ')
elif cat in ('Zl', 'Zp'): result.append(' ')
elif cat == 'Mc': result.append(char)
elif cat == 'Lm': result.append(char)
name = ''.join(result)
name = STRIP_BLOCKS_RE.sub('', name)
name = STRIP_CONTROL_RE.sub('', name)
name = STRIP_PRIVATE_RE.sub('', name)
name = re.sub(r'\s+', ' ', name)
name = name.strip()
return name
if __name__ == "__main__": main()
+1 -1
View File
@@ -1 +1 @@
__version__ = "0.9.9"
__version__ = "1.3.0"
+6 -1
View File
@@ -26,5 +26,10 @@ build_spkg: remove_symlinks build_sdist create_symlinks
release: remove_symlinks build_wheel build_spkg create_symlinks
upload:
@echo Ready to publish release over Reticulum
@read VOID
rngit release rns://7649a50d84610232d1416b41d2896aff/reticulum/lxmf create $$(python setup.py --getversion):dist --name lxmf
upload-pip:
@echo Uploading to PyPi...
twine upload dist/*
twine upload dist/*.whl dist/*.tar.gz
+12 -2
View File
@@ -1,14 +1,24 @@
# Lightweight Extensible Message Format
LXMF is a simple and flexible messaging format and delivery protocol that allows a wide variety of implementations, while using as little bandwidth as possible. It is built on top of [Reticulum](a8d24177d946de4f1f0a0fe1af9a1338:/page/repo.mu`g=reticulum|r=reticulum) and offers zero-conf message routing, end-to-end encryption and Forward Secrecy, and can be transported over any kind of medium that Reticulum supports.
> [!WARNING]
> Several hastily launched, incorrect, and in most cases entirely LLM-generated fakes of LXMF and associated tools are currently being circulated and marketed. Most of these "projects" violate the open source license that LXMF was published under, but claim independent ownership and license grants. Such claims or grants are **not** legally valid, and **not** recognized by the LXMF authors and copyright holders.
>
> Any claimed assertion of copyright or grant of license that such projects are making are [void grants](https://reticulum.network/manual/brandolinis.html#void-grants-legal-foundations-of-machine-generated-code). Both the violators themselves, and **all** downstream projects using the infringing derivatives, are **directly** and **personally** liable for the legal consequences.
>
> For more detailed information, see the relevant sections of the [Brandolini's Reference](https://reticulum.network/manual/brandolinis.html) chapter of the Reticulum Manual. For software and projects recognized by the Reticulum community, see the [Programs Using Reticulum](https://reticulum.network/manual/software.html) chapter.
>
> Do **not** use these "projects", they are a hazard to the entire ecosystem we have been carefully building over the last ten years.
LXMF is a simple and flexible messaging format and delivery protocol that allows a wide variety of implementations, while using as little bandwidth as possible. It is built on top of [Reticulum](https://reticulum.network) and offers zero-conf message routing, end-to-end encryption and Forward Secrecy, and can be transported over any kind of medium that Reticulum supports.
LXMF is efficient enough that it can deliver messages over extremely low-bandwidth systems such as packet radio or LoRa. Encrypted LXMF messages can also be encoded as QR-codes or text-based URIs, allowing completely analog *paper message* transport.
User-facing clients built on LXMF include:
- [Sideband](https://unsigned.io/sideband)
- [MeshChat](https://github.com/liamcottle/reticulum-meshchat)
- [MeshChatX](https://meshchatx.com/)
- [Nomad Network](https://unsigned.io/nomadnet)
- [Columba](https://github.com/torlando-tech/columba)
Community-provided tools and utilities for LXMF include:
+227
View File
@@ -0,0 +1,227 @@
>Lightweight Extensible Message Format
LXMF is a simple and flexible messaging format and delivery protocol that allows a wide variety of implementations, while using as little bandwidth as possible. It is built on top of `_`!`[Reticulum`https://reticulum.network]`!`_ and offers zero-conf message routing, end-to-end encryption and Forward Secrecy, and can be transported over any kind of medium that Reticulum supports.
LXMF is efficient enough that it can deliver messages over extremely low-bandwidth systems such as packet radio or LoRa. Encrypted LXMF messages can also be encoded as QR-codes or text-based URIs, allowing completely analog `*paper message`* transport.
User-facing clients built on LXMF include:
• `_`!`[Sideband`https://unsigned.io/sideband]`!`_
• `_`!`[MeshChatX`https://meshchatx.com/]`!`_
• `_`!`[Nomad Network`https://unsigned.io/nomadnet]`!`_
• `_`!`[Columba`https://github.com/torlando-tech/columba]`!`_
Community-provided tools and utilities for LXMF include:
• `_`!`[LXMFy`https://lxmfy.quad4.io/]`!`_
• `_`!`[LXMF-Bot`https://github.com/randogoth/lxmf-bot]`!`_
• `_`!`[LXMF Messageboard`https://github.com/chengtripp/lxmf_messageboard]`!`_
• `_`!`[LXMEvent`https://github.com/faragher/LXMEvent]`!`_
• `_`!`[RangeMap`https://github.com/faragher/RangeMap]`!`_
• `_`!`[LXMF Tools`https://github.com/SebastianObi/LXMF-Tools]`!`_
>>Structure
LXMF messages are stored in a simple and efficient format, that's easy to parse and write.
>>>The format follows this general structure:
• Destination
• Source
• Ed25519 Signature
• Payload
• Timestamp
• Content
• Title
• Fields
>>>And these rules:
1. A LXMF message is identified by its `!message-id`!, which is a SHA-256 hash of the `!Destination`!, `!Source`! and `!Payload`!. The message-id is never included directly in the message, since it can always be inferred from the message itself.
In some cases the actual message-id cannot be inferred, for example when a Propagation Node is storing an encrypted message for an offline user. In these cases a `*transient-id`* is used to identify the message while in storage or transit.
2. `!Destination`!, `!Source`!, `!Signature`! and `!Payload`! parts are mandatory, as is the `!Timestamp`! part of the payload.
• The `!Destination`! and `!Source`! fields are 16-byte Reticulum destination hashes
• The `!Signature`! field is a 64-byte Ed25519 signature of the `!Destination`!, `!Source`!, `!Payload`! and `!message-id`!
• The `!Payload`! part is a `_`!`[msgpacked`https://msgpack.org]`!`_ list containing four items:
1. The `!Timestamp`! is a double-precision floating point number representing the number of seconds since the UNIX epoch.
2. The `!Content`! is the optional content or body of the message
3. The `!Title`! is an optional title for the message
4. The `!Fields`! is an optional dictionary
3. The `!Content`!, `!Title`! and `!Fields`! parts must be included in the message structure, but can be left empty.
4. The `!Fields`! part can be left empty, or contain a dictionary of any structure or depth.
>>Usage Examples
LXMF offers flexibility to implement many different messaging schemes, ranging from human communication to machine control and sensor monitoring. Here are a few examples:
• A messaging system for passing short, simple messages between human users, akin to SMS can be implemented using only the `!Content`! field, and leaving all other optional fields empty.
• For sending full-size mail, an email-like system can be implemented using the `!Title`! and `!Content`! fields to store "subject" and "body" parts of the message, and optionally the `!Fields`! part can be used to store attachments or other metadata.
• Machine-control messages or sensor readings can be implemented using command structures embedded in the `!Fields`! dictionary.
• Distributed discussion or news-groups, akin to USENET or similar systems, can be implemented using the relevant fields and LXMF Propagation Nodes. Broadcast bulletins can be implemented in a similar fashion.
>>Propagation Nodes
LXM Propagation Nodes offer a way to store and forward messages to users or endpoints that are not directly reachable at the time of message emission. Propagation Nodes can also provide infrastructure for distributed bulletin, news or discussion boards.
When Propagation Nodes exist on a Reticulum network, they will by default peer with each other and synchronise messages, automatically creating an encrypted, distributed message store. Users and other endpoints can retrieve messages destined for them from any available Propagation Nodes on the network.
>>The LXM Router
The LXM Router handles transporting messages over a Reticulum network, managing delivery receipts, outbound and inbound queues, and is the point of API interaction for client programs. The LXM Router also implements functionality for acting as an LXMF Propagation Node.
Programatically, using the LXM Router to send a message is as simple as:
`BT282828`Fddd
`FTff7b72import`f `FT7ee787LXMF`f
`FTe6edf3lxm_router`f `FTff7b72=`f `FTe6edf3LXMF`f`FTff7b72.`f`FTd2a8ffLXMRouter`f`FTb4b4b4(`f`FTb4b4b4)`f
`FTe6edf3message`f `FTff7b72=`f `FTe6edf3LXMF`f`FTff7b72.`f`FTd2a8ffLXMessage`f`FTb4b4b4(`f`FTe6edf3destination`f`FTb4b4b4,`f `FTe6edf3source`f`FTb4b4b4,`f `FTa5d6ff"`f`FTa5d6ffThis is a short, simple message.`f`FTa5d6ff"`f`FTb4b4b4)`f
`FTe6edf3lxm_router`f`FTff7b72.`f`FTd2a8ffhandle_outbound`f`FTb4b4b4(`f`FTe6edf3message`f`FTb4b4b4)`f
`f`b
The LXM Router then handles the heavy lifting, such as message packing, encryption, delivery confirmation, path lookup, routing, retries and failure notifications.
>>Transport Encryption
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.
• 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.
• 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 to the Reticulum GROUP destination type, the message will be encrypted using the symmetric AES-128 key of the GROUP destination.
>>Wire Format & Overhead
Assuming the default Reticulum configuration, the binary wire-format is as follows:
• 16 bytes destination hash
• 16 bytes source hash
• 64 bytes Ed25519 signature
• Remaining bytes of `_`!`[msgpack`https://msgpack.org]`!`_ payload data, in accordance with the structure defined above
The complete message overhead for LXMF is only 111 bytes, which in return gives you timestamped, digitally signed, infinitely extensible, end-to-end encrypted, zero-conf routed, minimal-infrastructure messaging that's easy to use and build applications with.
>>Code Examples
Before writing your own programs using LXMF, you need to have a basic understanding of how the `_`!`[Reticulum`https://reticulum.network]`!`_ protocol and API works. Please see the `_`!`[Reticulum Manual`https://reticulum.network/manual/]`!`_. For a few simple examples of how to send and receive messages with LXMF, please see the `_`!`[receiver example`:/page/blob.mu`g=reticulum|r=lxmf|ref=HEAD|path=./docs/example_receiver.py]`!`_ and the `_`!`[sender example`:/page/blob.mu`g=reticulum|r=lxmf|ref=HEAD|path=./docs/example_sender.py]`!`_ included in this repository.
>>Example Paper Message
You can try out the paper messaging functionality by using the following QR code. It is a paper message sent to the LXMF address `BT383838`Fddd6b3362bd2c1dbf87b66a85f79a8d8c75`f`b. To be able to decrypt and read the message, you will need to import the following Reticulum Identity to an LXMF messaging app:
`BT383838`Fddd3BPTDTQCRZPKJT3TXAJCMQFMOYWIM3OCLKPWMG4HCF2T4CH3YZHVNHNRDU6QAZWV2KBHMWBNT2C62TQEVC5GLFM4MN25VLZFSK3ADRQ=`f`b
The `_`!`[Sideband`https://unsigned.io/sideband]`!`_ application allows you to do this easily. After you have imported the identity into an app of your choice, you can scan the following QR code and open it in the app, where it will be decrypted and added as a message.
`_`!`[Paper message QR code`a8d24177d946de4f1f0a0fe1af9a1338:/page/blob.mu`g=reticulum|r=lxmf|ref=HEAD|path=docs/paper_msg_test.png]`!`_
You can also find the entire message in this link:
`BT282828`Fddd
`=
lxm://azNivSwdv4e2aoX3mo2MdTAozuI7BlzrLlHULmnVgpz3dNT9CMPVwgywzCJP8FVogj5j_kU7j7ywuvBNcr45kRTrd19c3iHenmnSDe4VEd6FuGsAiT0Khzl7T81YZHPTDhRNp0FdhDE9AJ7uphw7zKMyqhHHxOxqrYeBeKF66gpPxDceqjsOApvsSwggjcuHBx9OxOBy05XmnJxA1unCKgvNfOFYc1T47luxoY3c0dLOJnJPwZuFRytx2TXlQNZzOJ28yTEygIfkDqEO9mZi5lgev7XZJ0DvgioQxMIyoCm7lBUzfq66zW3SQj6vHHph7bhr36dLOCFgk4fZA6yia2MlTT9KV66Tn2l8mPNDlvuSAJhwDA_xx2PN9zKadCjo9sItkAp8r-Ss1CzoUWZUAyT1oDw7ly6RrzGBG-e3eM3CL6u1juIeFiHby7_3cON-6VTUuk4xR5nwKlFTu5vsYMVXe5H3VahiDSS4Q1aqX7I
`=
`f`b
On operating systems that allow for registering custom URI-handlers, you can click the link, and it will be decoded directly in your LXMF client. This works with Sideband on Android.
>>Installation
If you want to try out LXMF, you can install it with pip:
`BT282828`Fddd
pip install lxmf
`f`b
If you are using an operating system that blocks normal user package installation via `BT383838`Fdddpip`f`b,
you can return `BT383838`Fdddpip`f`b to normal behaviour by editing the `BT383838`Fddd~/.config/pip/pip.conf`f`b file,
and adding the following directive in the `BT383838`Fddd[global]`f`b section:
`BT282828`Fddd
[global]
break-system-packages = true
`f`b
Alternatively, you can use the `BT383838`Fdddpipx`f`b tool to install Reticulum in an isolated environment:
`BT282828`Fddd
pipx install lxmf
`f`b
>>Daemon Included
The `BT383838`Fdddlxmf`f`b package comes with the `BT383838`Fdddlxmd`f`b program, a fully functional (but lightweight) LXMF message router and propagation node daemon. After installing the `BT383838`Fdddlxmf`f`b package, you can run `BT383838`Fdddlxmd --help`f`b to learn more about the command-line options:
`BT282828`Fddd
$ lxmd --help
usage: lxmd [-h] [--config CONFIG] [--rnsconfig RNSCONFIG] [-p] [-i PATH] [-v] [-q] [-s] [--exampleconfig] [--version]
Lightweight Extensible Messaging Daemon
options:
-h, --help show this help message and exit
--config CONFIG path to alternative lxmd config directory
--rnsconfig RNSCONFIG
path to alternative Reticulum config directory
-p, --propagation-node
run an LXMF Propagation Node
-i PATH, --on-inbound PATH
executable to run when a message is received
-v, --verbose
-q, --quiet
-s, --service lxmd is running as a service and should log to file
--exampleconfig print verbose configuration example to stdout and exit
--version show program's version number and exit
`f`b
Or run `BT383838`Fdddlxmd --exampleconfig`f`b to generate a commented example configuration documenting all the available configuration directives.
>>Support LXMF Development
You can help support the continued development of open, free and private communications systems by donating via one of the following channels:
• Monero:
`BT282828`Fddd
`=
84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w
`=
`f`b
• Bitcoin
`BT282828`Fddd
`=
bc1pgqgu8h8xvj4jtafslq396v7ju7hkgymyrzyqft4llfslz5vp99psqfk3a6
`=
`f`b
• Ethereum
`BT282828`Fddd
`=
0x91C421DdfB8a30a49A71d63447ddb54cEBe3465E
`=
`f`b
• Liberapay: https://liberapay.com/Reticulum/
• Ko-Fi: https://ko-fi.com/markqvist
>>Caveat Emptor
LXMF is beta software, and should be considered experimental. While it has been built with cryptography best practices very foremost in mind, it `*has not`* been externally security audited, and there could very well be privacy-breaking bugs. If you want to help out, or help sponsor an audit, please do get in touch.
>>Development Roadmap
LXMF is actively being developed, and the following improvements and features are currently planned for implementation:
• Sneakernet and physical transport functionality
• Content Destinations, and easy to use API for group messaging and discussion threads
• Write and release full API and protocol documentation
• Documenting and possibly expanding LXMF limits and priorities
+1 -1
View File
@@ -1,2 +1,2 @@
qrcode>=7.4.2
rns>=1.0.0
rns>=1.6.0
+6 -1
View File
@@ -1,3 +1,4 @@
import sys
import setuptools
with open("README.md", "r") as fh:
@@ -5,6 +6,10 @@ with open("README.md", "r") as fh:
exec(open("LXMF/_version.py", "r").read())
if "--getversion" in sys.argv:
print(__version__, end="")
exit(0)
setuptools.setup(
name="lxmf",
version=__version__,
@@ -26,6 +31,6 @@ setuptools.setup(
'lxmd=LXMF.Utilities.lxmd:main',
]
},
install_requires=["rns>=1.3.0"],
install_requires=["rns>=1.6.0"],
python_requires=">=3.7",
)