mirror of
https://github.com/markqvist/LXMF
synced 2026-11-27 13:52:19 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1e9fe969fd | ||
|
|
1d651a9b53 | ||
|
|
22493005dc | ||
|
|
7ecd3c0d5e | ||
|
|
64050d39bf | ||
|
|
c7489dc0fa | ||
|
|
bb1b9e4163 | ||
|
|
b3bc8e684e | ||
|
|
696c78ecea | ||
|
|
7aea4ea209 | ||
|
|
35dc771528 | ||
|
|
c369c6fc26 | ||
|
|
af2dd56707 | ||
|
|
1287cb9f11 | ||
|
|
820c92d38b | ||
|
|
9f051aea17 |
No files matched your search
@@ -0,0 +1,11 @@
|
|||||||
|
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
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
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 from your bug report.
|
||||||
|
|
||||||
|
**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.
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
FROM python:alpine
|
||||||
|
LABEL authors="Petr Blaha petr.blaha@cleverdata.cz"
|
||||||
|
USER root
|
||||||
|
RUN apk update
|
||||||
|
RUN apk add sdl2_ttf sdl2 build-base libc-dev pkgconfig gstreamer sdl2_mixer sdl2_image sdl2_pango linux-headers mesa-dev py3-virtualenv
|
||||||
|
|
||||||
|
RUN addgroup -S myuser && adduser -S -G myuser myuser
|
||||||
|
USER myuser
|
||||||
|
WORKDIR /home/myuser
|
||||||
|
|
||||||
|
RUN pip install --upgrade pip
|
||||||
|
|
||||||
|
|
||||||
|
ENV PATH="/home/myuser/.local/bin:${PATH}"
|
||||||
|
|
||||||
|
################### BEGIN LXMF ###########################################
|
||||||
|
|
||||||
|
COPY --chown=myuser:myuser requirements.txt requirements.txt
|
||||||
|
|
||||||
|
RUN pip install --user -r requirements.txt
|
||||||
|
|
||||||
|
|
||||||
|
COPY --chown=myuser:myuser . .
|
||||||
|
|
||||||
|
#Python create virtual environment
|
||||||
|
RUN virtualenv /home/myuser/LXMF/venv
|
||||||
|
RUN source /home/myuser/LXMF/venv/bin/activate
|
||||||
|
|
||||||
|
RUN make all
|
||||||
|
|
||||||
|
################### END LXMF ###########################################
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Run docker command one by one(all four), it will build LXMF artifact and copy to dist directory.
|
||||||
|
# No need to build locally and install dependencies
|
||||||
|
docker build -t lxmfdockerimage .
|
||||||
|
docker run -d -it --name lxmfdockercontainer lxmfdockerimage /bin/sh
|
||||||
|
docker cp lxmfdockercontainer:/home/myuser/dist .
|
||||||
|
docker rm -f lxmfdockercontainer
|
||||||
+11
-2
@@ -34,11 +34,20 @@ class LXMFPropagationAnnounceHandler:
|
|||||||
data = msgpack.unpackb(app_data)
|
data = msgpack.unpackb(app_data)
|
||||||
|
|
||||||
if self.lxmrouter.propagation_node and self.lxmrouter.autopeer:
|
if self.lxmrouter.propagation_node and self.lxmrouter.autopeer:
|
||||||
|
node_timebase = data[1]
|
||||||
|
propagation_transfer_limit = None
|
||||||
|
if len(data) >= 3:
|
||||||
|
try:
|
||||||
|
propagation_transfer_limit = float(data[2])
|
||||||
|
except:
|
||||||
|
propagation_transfer_limit = None
|
||||||
|
|
||||||
if data[0] == True:
|
if data[0] == True:
|
||||||
if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
|
if RNS.Transport.hops_to(destination_hash) <= self.lxmrouter.autopeer_maxdepth:
|
||||||
self.lxmrouter.peer(destination_hash, data[1])
|
self.lxmrouter.peer(destination_hash, node_timebase, propagation_transfer_limit)
|
||||||
|
|
||||||
elif data[0] == False:
|
elif data[0] == False:
|
||||||
self.lxmrouter.unpeer(destination_hash, data[1])
|
self.lxmrouter.unpeer(destination_hash, node_timebase)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while evaluating propagation node announce, ignoring announce.", RNS.LOG_DEBUG)
|
RNS.log("Error while evaluating propagation node announce, ignoring announce.", RNS.LOG_DEBUG)
|
||||||
|
|||||||
+60
-21
@@ -48,6 +48,14 @@ class LXMPeer:
|
|||||||
else:
|
else:
|
||||||
peer.link_establishment_rate = 0
|
peer.link_establishment_rate = 0
|
||||||
|
|
||||||
|
if "propagation_transfer_limit" in dictionary:
|
||||||
|
try:
|
||||||
|
peer.propagation_transfer_limit = float(dictionary["propagation_transfer_limit"])
|
||||||
|
except Exception as e:
|
||||||
|
peer.propagation_transfer_limit = None
|
||||||
|
else:
|
||||||
|
peer.propagation_transfer_limit = None
|
||||||
|
|
||||||
for transient_id in dictionary["handled_ids"]:
|
for transient_id in dictionary["handled_ids"]:
|
||||||
if transient_id in router.propagation_entries:
|
if transient_id in router.propagation_entries:
|
||||||
peer.handled_messages[transient_id] = router.propagation_entries[transient_id]
|
peer.handled_messages[transient_id] = router.propagation_entries[transient_id]
|
||||||
@@ -65,6 +73,7 @@ class LXMPeer:
|
|||||||
dictionary["last_heard"] = self.last_heard
|
dictionary["last_heard"] = self.last_heard
|
||||||
dictionary["destination_hash"] = self.destination_hash
|
dictionary["destination_hash"] = self.destination_hash
|
||||||
dictionary["link_establishment_rate"] = self.link_establishment_rate
|
dictionary["link_establishment_rate"] = self.link_establishment_rate
|
||||||
|
dictionary["propagation_transfer_limit"] = self.propagation_transfer_limit
|
||||||
|
|
||||||
handled_ids = []
|
handled_ids = []
|
||||||
for transient_id in self.handled_messages:
|
for transient_id in self.handled_messages:
|
||||||
@@ -87,12 +96,14 @@ class LXMPeer:
|
|||||||
self.sync_backoff = 0
|
self.sync_backoff = 0
|
||||||
self.peering_timebase = 0
|
self.peering_timebase = 0
|
||||||
self.link_establishment_rate = 0
|
self.link_establishment_rate = 0
|
||||||
|
self.propagation_transfer_limit = None
|
||||||
|
|
||||||
self.link = None
|
self.link = None
|
||||||
self.state = LXMPeer.IDLE
|
self.state = LXMPeer.IDLE
|
||||||
|
|
||||||
self.unhandled_messages = {}
|
self.unhandled_messages = {}
|
||||||
self.handled_messages = {}
|
self.handled_messages = {}
|
||||||
|
self.last_offer = []
|
||||||
|
|
||||||
self.router = router
|
self.router = router
|
||||||
self.destination_hash = destination_hash
|
self.destination_hash = destination_hash
|
||||||
@@ -133,11 +144,17 @@ class LXMPeer:
|
|||||||
self.sync_backoff = 0
|
self.sync_backoff = 0
|
||||||
|
|
||||||
RNS.log("Synchronisation link to peer "+RNS.prettyhexrep(self.destination_hash)+" established, preparing request...", RNS.LOG_DEBUG)
|
RNS.log("Synchronisation link to peer "+RNS.prettyhexrep(self.destination_hash)+" established, preparing request...", RNS.LOG_DEBUG)
|
||||||
|
unhandled_entries = []
|
||||||
unhandled_ids = []
|
unhandled_ids = []
|
||||||
purged_ids = []
|
purged_ids = []
|
||||||
for transient_id in self.unhandled_messages:
|
for transient_id in self.unhandled_messages:
|
||||||
if transient_id in self.router.propagation_entries:
|
if transient_id in self.router.propagation_entries:
|
||||||
unhandled_ids.append(transient_id)
|
unhandled_entry = [
|
||||||
|
transient_id,
|
||||||
|
self.router.get_weight(transient_id),
|
||||||
|
self.router.get_size(transient_id),
|
||||||
|
]
|
||||||
|
unhandled_entries.append(unhandled_entry)
|
||||||
else:
|
else:
|
||||||
purged_ids.append(transient_id)
|
purged_ids.append(transient_id)
|
||||||
|
|
||||||
@@ -145,11 +162,28 @@ class LXMPeer:
|
|||||||
RNS.log("Dropping unhandled message "+RNS.prettyhexrep(transient_id)+" for peer "+RNS.prettyhexrep(self.destination_hash)+" since it no longer exists in the message store.", RNS.LOG_DEBUG)
|
RNS.log("Dropping unhandled message "+RNS.prettyhexrep(transient_id)+" for peer "+RNS.prettyhexrep(self.destination_hash)+" since it no longer exists in the message store.", RNS.LOG_DEBUG)
|
||||||
self.unhandled_messages.pop(transient_id)
|
self.unhandled_messages.pop(transient_id)
|
||||||
|
|
||||||
|
unhandled_entries.sort(key=lambda e: e[1], reverse=False)
|
||||||
|
per_message_overhead = 16 # Really only 2 bytes, but set a bit higher for now
|
||||||
|
cumulative_size = 24 # Initialised to highest reasonable binary structure overhead
|
||||||
|
for unhandled_entry in unhandled_entries:
|
||||||
|
transient_id = unhandled_entry[0]
|
||||||
|
weight = unhandled_entry[1]
|
||||||
|
lxm_size = unhandled_entry[2]
|
||||||
|
next_size = cumulative_size + (lxm_size+per_message_overhead)
|
||||||
|
if self.propagation_transfer_limit != None and next_size > (self.propagation_transfer_limit*1000):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
cumulative_size += (lxm_size+per_message_overhead)
|
||||||
|
unhandled_ids.append(transient_id)
|
||||||
|
|
||||||
RNS.log("Sending sync request to peer "+str(self.destination), RNS.LOG_DEBUG)
|
RNS.log("Sending sync request to peer "+str(self.destination), RNS.LOG_DEBUG)
|
||||||
self.link.request(LXMPeer.OFFER_REQUEST_PATH, unhandled_ids, response_callback=self.offer_response, failed_callback=self.request_failed)
|
self.last_offer = unhandled_ids
|
||||||
|
self.link.request(LXMPeer.OFFER_REQUEST_PATH, self.last_offer, response_callback=self.offer_response, failed_callback=self.request_failed)
|
||||||
self.state = LXMPeer.REQUEST_SENT
|
self.state = LXMPeer.REQUEST_SENT
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Could not request sync to peer "+RNS.prettyhexrep(self.destination_hash)+" since its identity could not be recalled.", RNS.LOG_ERROR)
|
RNS.log("Could not request sync to peer "+RNS.prettyhexrep(self.destination_hash)+" since its identity could not be recalled.", RNS.LOG_ERROR)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Postponing sync with peer "+RNS.prettyhexrep(self.destination_hash)+" for "+RNS.prettytime(self.next_sync_attempt-time.time())+" due to previous failures", RNS.LOG_DEBUG)
|
RNS.log("Postponing sync with peer "+RNS.prettyhexrep(self.destination_hash)+" for "+RNS.prettytime(self.next_sync_attempt-time.time())+" due to previous failures", RNS.LOG_DEBUG)
|
||||||
if self.last_sync_attempt > self.last_heard:
|
if self.last_sync_attempt > self.last_heard:
|
||||||
@@ -159,8 +193,8 @@ class LXMPeer:
|
|||||||
RNS.log("Sync request to peer "+str(self.destination)+" failed", RNS.LOG_DEBUG)
|
RNS.log("Sync request to peer "+str(self.destination)+" failed", RNS.LOG_DEBUG)
|
||||||
if self.link != None:
|
if self.link != None:
|
||||||
self.link.teardown()
|
self.link.teardown()
|
||||||
else:
|
|
||||||
self.state = LXMPeer.IDLE
|
self.state = LXMPeer.IDLE
|
||||||
|
|
||||||
def offer_response(self, request_receipt):
|
def offer_response(self, request_receipt):
|
||||||
try:
|
try:
|
||||||
@@ -173,33 +207,31 @@ class LXMPeer:
|
|||||||
if response == LXMPeer.ERROR_NO_IDENTITY:
|
if response == LXMPeer.ERROR_NO_IDENTITY:
|
||||||
if self.link != None:
|
if self.link != None:
|
||||||
RNS.log("Remote peer indicated that no identification was received, retrying...", RNS.LOG_DEBUG)
|
RNS.log("Remote peer indicated that no identification was received, retrying...", RNS.LOG_DEBUG)
|
||||||
self.link.indentify()
|
self.link.identify()
|
||||||
self.state = LXMPeer.LINK_READY
|
self.state = LXMPeer.LINK_READY
|
||||||
self.sync()
|
self.sync()
|
||||||
|
|
||||||
elif response == False:
|
elif response == False:
|
||||||
# Peer already has all advertised messages
|
# Peer already has all advertised messages
|
||||||
for transient_id in self.unhandled_messages:
|
for transient_id in self.last_offer:
|
||||||
message_entry = self.unhandled_messages[transient_id]
|
if transient_id in self.unhandled_messages:
|
||||||
self.handled_messages[transient_id] = message_entry
|
self.handled_messages[transient_id] = self.unhandled_messages.pop(transient_id)
|
||||||
|
|
||||||
self.unhandled_messages = {}
|
|
||||||
|
|
||||||
elif response == True:
|
elif response == True:
|
||||||
# Peer wants all advertised messages
|
# Peer wants all advertised messages
|
||||||
for transient_id in self.unhandled_messages:
|
for transient_id in self.last_offer:
|
||||||
wanted_messages.append(self.unhandled_messages[transient_id])
|
wanted_messages.append(self.unhandled_messages[transient_id])
|
||||||
wanted_message_ids.append(transient_id)
|
wanted_message_ids.append(transient_id)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Peer wants some advertised messages
|
# Peer wants some advertised messages
|
||||||
peer_had_messages = []
|
for transient_id in self.last_offer.copy():
|
||||||
for transient_id in self.unhandled_messages.copy():
|
|
||||||
# If the peer did not want the message, it has
|
# If the peer did not want the message, it has
|
||||||
# already received it from another peer.
|
# already received it from another peer.
|
||||||
if not transient_id in response:
|
if not transient_id in response:
|
||||||
message_entry = self.unhandled_messages.pop(transient_id)
|
if transient_id in self.unhandled_messages:
|
||||||
self.handled_messages[transient_id] = message_entry
|
self.handled_messages[transient_id] = self.unhandled_messages.pop(transient_id)
|
||||||
|
|
||||||
for transient_id in response:
|
for transient_id in response:
|
||||||
wanted_messages.append(self.unhandled_messages[transient_id])
|
wanted_messages.append(self.unhandled_messages[transient_id])
|
||||||
@@ -222,8 +254,13 @@ class LXMPeer:
|
|||||||
resource = RNS.Resource(data, self.link, callback = self.resource_concluded)
|
resource = RNS.Resource(data, self.link, callback = self.resource_concluded)
|
||||||
resource.transferred_messages = wanted_message_ids
|
resource.transferred_messages = wanted_message_ids
|
||||||
self.state = LXMPeer.RESOURCE_TRANSFERRING
|
self.state = LXMPeer.RESOURCE_TRANSFERRING
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Peer "+RNS.prettyhexrep(self.destination_hash)+" did not request any of the available messages, sync completed", RNS.LOG_DEBUG)
|
RNS.log("Peer "+RNS.prettyhexrep(self.destination_hash)+" did not request any of the available messages, sync completed", RNS.LOG_DEBUG)
|
||||||
|
if self.link != None:
|
||||||
|
self.link.teardown()
|
||||||
|
|
||||||
|
self.link = None
|
||||||
self.state = LXMPeer.IDLE
|
self.state = LXMPeer.IDLE
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -236,25 +273,29 @@ class LXMPeer:
|
|||||||
self.link = None
|
self.link = None
|
||||||
self.state = LXMPeer.IDLE
|
self.state = LXMPeer.IDLE
|
||||||
|
|
||||||
|
|
||||||
def resource_concluded(self, resource):
|
def resource_concluded(self, resource):
|
||||||
if resource.status == RNS.Resource.COMPLETE:
|
if resource.status == RNS.Resource.COMPLETE:
|
||||||
for transient_id in resource.transferred_messages:
|
for transient_id in resource.transferred_messages:
|
||||||
message = self.unhandled_messages.pop(transient_id)
|
message = self.unhandled_messages.pop(transient_id)
|
||||||
self.handled_messages[transient_id] = message
|
self.handled_messages[transient_id] = message
|
||||||
|
|
||||||
|
if self.link != None:
|
||||||
|
self.link.teardown()
|
||||||
|
|
||||||
|
self.link = None
|
||||||
self.state = LXMPeer.IDLE
|
self.state = LXMPeer.IDLE
|
||||||
self.link.teardown()
|
|
||||||
RNS.log("Sync to peer "+RNS.prettyhexrep(self.destination_hash)+" completed", RNS.LOG_DEBUG)
|
RNS.log("Sync to peer "+RNS.prettyhexrep(self.destination_hash)+" completed", RNS.LOG_DEBUG)
|
||||||
self.alive = True
|
self.alive = True
|
||||||
self.last_heard = time.time()
|
self.last_heard = time.time()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Resource transfer for LXMF peer sync failed to "+str(self.destination), RNS.LOG_DEBUG)
|
RNS.log("Resource transfer for LXMF peer sync failed to "+str(self.destination), RNS.LOG_DEBUG)
|
||||||
if self.link != None:
|
if self.link != None:
|
||||||
self.link.teardown()
|
self.link.teardown()
|
||||||
else:
|
|
||||||
self.state = LXMPeer.IDLE
|
|
||||||
|
|
||||||
|
|
||||||
|
self.link = None
|
||||||
|
self.state = LXMPeer.IDLE
|
||||||
|
|
||||||
def link_established(self, link):
|
def link_established(self, link):
|
||||||
self.link.identify(self.router.identity)
|
self.link.identify(self.router.identity)
|
||||||
@@ -272,8 +313,6 @@ class LXMPeer:
|
|||||||
|
|
||||||
def handle_message(self, transient_id):
|
def handle_message(self, transient_id):
|
||||||
if not transient_id in self.handled_messages and not transient_id in self.unhandled_messages:
|
if not transient_id in self.handled_messages and not transient_id in self.unhandled_messages:
|
||||||
# TODO: Remove at some point
|
|
||||||
RNS.log("The message "+RNS.prettyhexrep(transient_id)+" was added to distribution queue for "+RNS.prettyhexrep(self.destination_hash), RNS.LOG_EXTREME)
|
|
||||||
self.unhandled_messages[transient_id] = self.router.propagation_entries[transient_id]
|
self.unhandled_messages[transient_id] = self.router.propagation_entries[transient_id]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
+140
-49
@@ -21,6 +21,7 @@ class LXMRouter:
|
|||||||
DELIVERY_RETRY_WAIT = 7
|
DELIVERY_RETRY_WAIT = 7
|
||||||
PATH_REQUEST_WAIT = 7
|
PATH_REQUEST_WAIT = 7
|
||||||
LINK_MAX_INACTIVITY = 10*60
|
LINK_MAX_INACTIVITY = 10*60
|
||||||
|
P_LINK_MAX_INACTIVITY = 3*60
|
||||||
|
|
||||||
MESSAGE_EXPIRY = 30*24*60*60
|
MESSAGE_EXPIRY = 30*24*60*60
|
||||||
|
|
||||||
@@ -30,30 +31,35 @@ class LXMRouter:
|
|||||||
AUTOPEER_MAXDEPTH = 4
|
AUTOPEER_MAXDEPTH = 4
|
||||||
FASTEST_N_RANDOM_POOL = 2
|
FASTEST_N_RANDOM_POOL = 2
|
||||||
|
|
||||||
PR_PATH_TIMEOUT = 10
|
PROPAGATION_LIMIT = 256
|
||||||
|
DELIVERY_LIMIT = 1000
|
||||||
|
|
||||||
PR_IDLE = 0x00
|
PR_PATH_TIMEOUT = 10
|
||||||
PR_PATH_REQUESTED = 0x01
|
|
||||||
PR_LINK_ESTABLISHING = 0x02
|
|
||||||
PR_LINK_ESTABLISHED = 0x03
|
|
||||||
PR_REQUEST_SENT = 0x04
|
|
||||||
PR_RECEIVING = 0x05
|
|
||||||
PR_RESPONSE_RECEIVED = 0x06
|
|
||||||
PR_COMPLETE = 0x07
|
|
||||||
PR_NO_PATH = 0xf0
|
|
||||||
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_IDLE = 0x00
|
||||||
|
PR_PATH_REQUESTED = 0x01
|
||||||
|
PR_LINK_ESTABLISHING = 0x02
|
||||||
|
PR_LINK_ESTABLISHED = 0x03
|
||||||
|
PR_REQUEST_SENT = 0x04
|
||||||
|
PR_RECEIVING = 0x05
|
||||||
|
PR_RESPONSE_RECEIVED = 0x06
|
||||||
|
PR_COMPLETE = 0x07
|
||||||
|
PR_NO_PATH = 0xf0
|
||||||
|
PR_LINK_FAILED = 0xf1
|
||||||
|
PR_TRANSFER_FAILED = 0xf2
|
||||||
|
PR_NO_IDENTITY_RCVD = 0xf3
|
||||||
|
PR_NO_ACCESS = 0xf4
|
||||||
|
PR_FAILED = 0xfe
|
||||||
|
|
||||||
|
PR_ALL_MESSAGES = 0x00
|
||||||
|
|
||||||
|
|
||||||
### Developer-facing API ##############################
|
### Developer-facing API ##############################
|
||||||
#######################################################
|
#######################################################
|
||||||
|
|
||||||
def __init__(self, identity = None, storagepath = None, autopeer = AUTOPEER, autopeer_maxdepth = None):
|
def __init__(self, identity = None, storagepath = None, autopeer = AUTOPEER, autopeer_maxdepth = None,
|
||||||
|
propagation_limit = PROPAGATION_LIMIT, delivery_limit = DELIVERY_LIMIT):
|
||||||
|
|
||||||
random.seed(os.urandom(10))
|
random.seed(os.urandom(10))
|
||||||
|
|
||||||
self.pending_inbound = []
|
self.pending_inbound = []
|
||||||
@@ -66,6 +72,7 @@ class LXMRouter:
|
|||||||
self.ignored_list = []
|
self.ignored_list = []
|
||||||
self.allowed_list = []
|
self.allowed_list = []
|
||||||
self.auth_required = False
|
self.auth_required = False
|
||||||
|
self.retain_synced_on_node = False
|
||||||
|
|
||||||
self.processing_outbound = False
|
self.processing_outbound = False
|
||||||
self.processing_inbound = False
|
self.processing_inbound = False
|
||||||
@@ -83,6 +90,8 @@ class LXMRouter:
|
|||||||
|
|
||||||
self.message_storage_limit = None
|
self.message_storage_limit = None
|
||||||
self.information_storage_limit = None
|
self.information_storage_limit = None
|
||||||
|
self.propagation_per_transfer_limit = propagation_limit
|
||||||
|
self.delivery_per_transfer_limit = delivery_limit
|
||||||
|
|
||||||
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
|
||||||
@@ -90,6 +99,7 @@ class LXMRouter:
|
|||||||
self.propagation_transfer_progress = 0.0
|
self.propagation_transfer_progress = 0.0
|
||||||
self.propagation_transfer_last_result = None
|
self.propagation_transfer_last_result = None
|
||||||
self.propagation_transfer_max_messages = None
|
self.propagation_transfer_max_messages = None
|
||||||
|
self.active_propagation_links = []
|
||||||
self.locally_delivered_transient_ids = {}
|
self.locally_delivered_transient_ids = {}
|
||||||
self.locally_processed_transient_ids = {}
|
self.locally_processed_transient_ids = {}
|
||||||
|
|
||||||
@@ -150,7 +160,13 @@ class LXMRouter:
|
|||||||
def announce_propagation_node(self):
|
def announce_propagation_node(self):
|
||||||
def delayed_announce():
|
def delayed_announce():
|
||||||
time.sleep(LXMRouter.NODE_ANNOUNCE_DELAY)
|
time.sleep(LXMRouter.NODE_ANNOUNCE_DELAY)
|
||||||
data = msgpack.packb([self.propagation_node, int(time.time())])
|
announce_data = [
|
||||||
|
self.propagation_node, # Boolean flag signalling propagation node state
|
||||||
|
int(time.time()), # Current node timebase
|
||||||
|
self.propagation_per_transfer_limit, # Per-transfer limit for message propagation in kilobytes
|
||||||
|
]
|
||||||
|
|
||||||
|
data = msgpack.packb(announce_data)
|
||||||
self.propagation_destination.announce(app_data=data)
|
self.propagation_destination.announce(app_data=data)
|
||||||
|
|
||||||
da_thread = threading.Thread(target=delayed_announce)
|
da_thread = threading.Thread(target=delayed_announce)
|
||||||
@@ -185,6 +201,12 @@ class LXMRouter:
|
|||||||
def get_outbound_propagation_node(self):
|
def get_outbound_propagation_node(self):
|
||||||
return self.outbound_propagation_node
|
return self.outbound_propagation_node
|
||||||
|
|
||||||
|
def set_retain_node_lxms(self, retain):
|
||||||
|
if retain == True:
|
||||||
|
self.retain_synced_on_node = True
|
||||||
|
else:
|
||||||
|
self.retain_synced_on_node = False
|
||||||
|
|
||||||
def set_authentication(self, required=None):
|
def set_authentication(self, required=None):
|
||||||
if required != None:
|
if required != None:
|
||||||
self.auth_required = required
|
self.auth_required = required
|
||||||
@@ -232,7 +254,7 @@ class LXMRouter:
|
|||||||
self.outbound_propagation_link.identify(identity)
|
self.outbound_propagation_link.identify(identity)
|
||||||
self.outbound_propagation_link.request(
|
self.outbound_propagation_link.request(
|
||||||
LXMPeer.MESSAGE_GET_PATH,
|
LXMPeer.MESSAGE_GET_PATH,
|
||||||
[None, None],
|
[None, None], # Set both want and have fields to None to get message list
|
||||||
response_callback=self.message_list_response,
|
response_callback=self.message_list_response,
|
||||||
failed_callback=self.message_get_failed
|
failed_callback=self.message_get_failed
|
||||||
)
|
)
|
||||||
@@ -317,7 +339,10 @@ class LXMRouter:
|
|||||||
peer = LXMPeer.from_bytes(serialised_peer, self)
|
peer = LXMPeer.from_bytes(serialised_peer, self)
|
||||||
if peer.identity != None:
|
if peer.identity != None:
|
||||||
self.peers[peer.destination_hash] = peer
|
self.peers[peer.destination_hash] = peer
|
||||||
RNS.log("Loaded peer "+RNS.prettyhexrep(peer.destination_hash)+" with "+str(len(peer.unhandled_messages))+" unhandled messages", RNS.LOG_DEBUG)
|
lim_str = ", no transfer limit"
|
||||||
|
if peer.propagation_transfer_limit != None:
|
||||||
|
lim_str = ", "+RNS.prettysize(peer.propagation_transfer_limit*1000)+" transfer limit"
|
||||||
|
RNS.log("Loaded peer "+RNS.prettyhexrep(peer.destination_hash)+" with "+str(len(peer.unhandled_messages))+" unhandled messages"+lim_str, RNS.LOG_DEBUG)
|
||||||
else:
|
else:
|
||||||
RNS.log("Peer "+RNS.prettyhexrep(peer.destination_hash)+" could not be loaded, because its identity could not be recalled. Dropping peer.", RNS.LOG_DEBUG)
|
RNS.log("Peer "+RNS.prettyhexrep(peer.destination_hash)+" could not be loaded, because its identity could not be recalled. Dropping peer.", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
@@ -471,6 +496,19 @@ class LXMRouter:
|
|||||||
cleaned_link = self.direct_links.pop(link_hash)
|
cleaned_link = self.direct_links.pop(link_hash)
|
||||||
RNS.log("Cleaned link "+str(cleaned_link), RNS.LOG_DEBUG)
|
RNS.log("Cleaned link "+str(cleaned_link), RNS.LOG_DEBUG)
|
||||||
|
|
||||||
|
try:
|
||||||
|
inactive_links = []
|
||||||
|
for link in self.active_propagation_links:
|
||||||
|
if link.no_data_for() > LXMRouter.P_LINK_MAX_INACTIVITY:
|
||||||
|
inactive_links.append(link)
|
||||||
|
|
||||||
|
for link in inactive_links:
|
||||||
|
self.active_propagation_links.remove(link)
|
||||||
|
link.teardown()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("An error occurred while cleaning inbound propagation links. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
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
|
||||||
if self.propagation_transfer_state == LXMRouter.PR_COMPLETE:
|
if self.propagation_transfer_state == LXMRouter.PR_COMPLETE:
|
||||||
@@ -507,6 +545,28 @@ class LXMRouter:
|
|||||||
self.locally_processed_transient_ids.pop(transient_id)
|
self.locally_processed_transient_ids.pop(transient_id)
|
||||||
RNS.log("Cleaned "+RNS.prettyhexrep(transient_id)+" from locally processed cache", RNS.LOG_DEBUG)
|
RNS.log("Cleaned "+RNS.prettyhexrep(transient_id)+" from locally processed cache", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
|
def get_weight(self, transient_id):
|
||||||
|
dst_hash = self.propagation_entries[transient_id][0]
|
||||||
|
lxm_rcvd = self.propagation_entries[transient_id][2]
|
||||||
|
lxm_size = self.propagation_entries[transient_id][3]
|
||||||
|
|
||||||
|
now = time.time()
|
||||||
|
age_weight = max(1, (now - lxm_rcvd)/60/60/24/4)
|
||||||
|
|
||||||
|
if dst_hash in self.prioritised_list:
|
||||||
|
priority_weight = 0.1
|
||||||
|
else:
|
||||||
|
priority_weight = 1.0
|
||||||
|
|
||||||
|
weight = priority_weight * age_weight * lxm_size
|
||||||
|
|
||||||
|
return weight
|
||||||
|
|
||||||
|
def get_size(self, transient_id):
|
||||||
|
lxm_size = self.propagation_entries[transient_id][3]
|
||||||
|
return lxm_size
|
||||||
|
|
||||||
|
|
||||||
def clean_message_store(self):
|
def clean_message_store(self):
|
||||||
# Check and remove expired messages
|
# Check and remove expired messages
|
||||||
now = time.time()
|
now = time.time()
|
||||||
@@ -548,22 +608,13 @@ class LXMRouter:
|
|||||||
bytes_needed = message_storage_size - self.message_storage_limit
|
bytes_needed = message_storage_size - self.message_storage_limit
|
||||||
bytes_cleaned = 0
|
bytes_cleaned = 0
|
||||||
|
|
||||||
now = time.time()
|
|
||||||
weighted_entries = []
|
weighted_entries = []
|
||||||
for transient_id in self.propagation_entries:
|
for transient_id in self.propagation_entries:
|
||||||
entry = self.propagation_entries[transient_id]
|
weighted_entries.append([
|
||||||
|
self.propagation_entries[transient_id],
|
||||||
dst_hash = entry[0]
|
self.get_weight(transient_id),
|
||||||
lxm_rcvd = entry[2]
|
transient_id
|
||||||
lxm_size = entry[3]
|
])
|
||||||
age_weight = max(1, (now - lxm_rcvd)/60/60/24/4)
|
|
||||||
if dst_hash in self.prioritised_list:
|
|
||||||
priority_weight = 0.1
|
|
||||||
else:
|
|
||||||
priority_weight = 1.0
|
|
||||||
|
|
||||||
weight = priority_weight * age_weight * lxm_size
|
|
||||||
weighted_entries.append([entry, weight, transient_id])
|
|
||||||
|
|
||||||
weighted_entries.sort(key=lambda we: we[1], reverse=True)
|
weighted_entries.sort(key=lambda we: we[1], reverse=True)
|
||||||
|
|
||||||
@@ -589,8 +640,7 @@ class LXMRouter:
|
|||||||
finally:
|
finally:
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
RNS.log("LXMF message store size is now "+RNS.prettysize(self.message_storage_size()), RNS.LOG_EXTREME)
|
RNS.log("LXMF message store size is now "+RNS.prettysize(self.message_storage_size())+" for "+str(len(self.propagation_entries))+" items", RNS.LOG_EXTREME)
|
||||||
RNS.log("PE len "+str(len(self.propagation_entries)))
|
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -653,7 +703,8 @@ class LXMRouter:
|
|||||||
job_thread.start()
|
job_thread.start()
|
||||||
|
|
||||||
def __request_messages_path_job(self):
|
def __request_messages_path_job(self):
|
||||||
while not RNS.Transport.has_path(self.wants_download_on_path_available_from) and time.time() < self.wants_download_on_path_available_timeout:
|
path_timeout = self.wants_download_on_path_available_timeout
|
||||||
|
while not RNS.Transport.has_path(self.wants_download_on_path_available_from) and time.time() < path_timeout:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
if RNS.Transport.has_path(self.wants_download_on_path_available_from):
|
if RNS.Transport.has_path(self.wants_download_on_path_available_from):
|
||||||
@@ -720,6 +771,16 @@ class LXMRouter:
|
|||||||
# Process wanted messages
|
# Process wanted messages
|
||||||
response_messages = []
|
response_messages = []
|
||||||
if data[0] != None and len(data[0]) > 0:
|
if data[0] != None and len(data[0]) > 0:
|
||||||
|
client_transfer_limit = None
|
||||||
|
if len(data) >= 3:
|
||||||
|
try:
|
||||||
|
client_transfer_limit = float(data[2])*1000
|
||||||
|
RNS.log("Client indicates transfer limit of "+RNS.prettysize(client_transfer_limit), RNS.LOG_DEBUG)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
per_message_overhead = 16 # Really only 2 bytes, but set a bit higher for now
|
||||||
|
cumulative_size = 24 # Initialised to highest reasonable binary structure overhead
|
||||||
for transient_id in data[0]:
|
for transient_id in data[0]:
|
||||||
if transient_id in self.propagation_entries and self.propagation_entries[transient_id][0] == remote_destination.hash:
|
if transient_id in self.propagation_entries and self.propagation_entries[transient_id][0] == remote_destination.hash:
|
||||||
try:
|
try:
|
||||||
@@ -728,9 +789,17 @@ class LXMRouter:
|
|||||||
|
|
||||||
message_file = open(filepath, "rb")
|
message_file = open(filepath, "rb")
|
||||||
lxmf_data = message_file.read()
|
lxmf_data = message_file.read()
|
||||||
response_messages.append(lxmf_data)
|
|
||||||
message_file.close()
|
message_file.close()
|
||||||
|
|
||||||
|
lxm_size = len(lxmf_data)
|
||||||
|
next_size = cumulative_size + (lxm_size+per_message_overhead)
|
||||||
|
|
||||||
|
if client_transfer_limit != None and next_size > client_transfer_limit:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
response_messages.append(lxmf_data)
|
||||||
|
cumulative_size += (lxm_size+per_message_overhead)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while processing message download request from "+RNS.prettyhexrep(remote_destination.hash)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Error while processing message download request from "+RNS.prettyhexrep(remote_destination.hash)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
@@ -760,7 +829,7 @@ class LXMRouter:
|
|||||||
wants = []
|
wants = []
|
||||||
if len(request_receipt.response) > 0:
|
if len(request_receipt.response) > 0:
|
||||||
for transient_id in request_receipt.response:
|
for transient_id in request_receipt.response:
|
||||||
if self.has_message(transient_id):
|
if not self.retain_synced_on_node and self.has_message(transient_id):
|
||||||
haves.append(transient_id)
|
haves.append(transient_id)
|
||||||
else:
|
else:
|
||||||
if self.propagation_transfer_max_messages == LXMRouter.PR_ALL_MESSAGES or len(wants) < self.propagation_transfer_max_messages:
|
if self.propagation_transfer_max_messages == LXMRouter.PR_ALL_MESSAGES or len(wants) < self.propagation_transfer_max_messages:
|
||||||
@@ -768,7 +837,7 @@ class LXMRouter:
|
|||||||
|
|
||||||
request_receipt.link.request(
|
request_receipt.link.request(
|
||||||
LXMPeer.MESSAGE_GET_PATH,
|
LXMPeer.MESSAGE_GET_PATH,
|
||||||
[wants, haves],
|
[wants, haves, self.delivery_per_transfer_limit],
|
||||||
response_callback=self.message_get_response,
|
response_callback=self.message_get_response,
|
||||||
failed_callback=self.message_get_failed,
|
failed_callback=self.message_get_failed,
|
||||||
progress_callback=self.message_get_progress
|
progress_callback=self.message_get_progress
|
||||||
@@ -925,7 +994,8 @@ class LXMRouter:
|
|||||||
def delivery_link_established(self, link):
|
def delivery_link_established(self, link):
|
||||||
link.track_phy_stats(True)
|
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_APP)
|
||||||
|
link.set_resource_callback(self.delivery_resource_advertised)
|
||||||
link.set_resource_started_callback(self.resource_transfer_began)
|
link.set_resource_started_callback(self.resource_transfer_began)
|
||||||
link.set_resource_concluded_callback(self.delivery_resource_concluded)
|
link.set_resource_concluded_callback(self.delivery_resource_concluded)
|
||||||
|
|
||||||
@@ -935,6 +1005,15 @@ class LXMRouter:
|
|||||||
def resource_transfer_began(self, resource):
|
def resource_transfer_began(self, resource):
|
||||||
RNS.log("Transfer began for LXMF delivery resource "+str(resource), RNS.LOG_DEBUG)
|
RNS.log("Transfer began for LXMF delivery resource "+str(resource), RNS.LOG_DEBUG)
|
||||||
|
|
||||||
|
def delivery_resource_advertised(self, resource):
|
||||||
|
size = resource.get_data_size()
|
||||||
|
limit = self.delivery_per_transfer_limit*1000
|
||||||
|
if limit != None and size > limit:
|
||||||
|
RNS.log("Rejecting "+RNS.prettysize(size)+" incoming LXMF delivery resource, since it exceeds the limit of "+RNS.prettysize(limit), RNS.LOG_DEBUG)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
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:
|
||||||
@@ -945,21 +1024,22 @@ class LXMRouter:
|
|||||||
### Peer Sync & Propagation ###########################
|
### Peer Sync & Propagation ###########################
|
||||||
#######################################################
|
#######################################################
|
||||||
|
|
||||||
def peer(self, destination_hash, timestamp):
|
def peer(self, destination_hash, timestamp, propagation_transfer_limit):
|
||||||
if destination_hash in self.peers:
|
if destination_hash in self.peers:
|
||||||
peer = self.peers[destination_hash]
|
peer = self.peers[destination_hash]
|
||||||
if timestamp > peer.peering_timebase:
|
if timestamp > peer.peering_timebase:
|
||||||
peer.alive = True
|
peer.alive = True
|
||||||
peer.sync_backoff = 0
|
peer.sync_backoff = 0
|
||||||
peer.next_sync_attempt = 0
|
peer.next_sync_attempt = 0
|
||||||
|
peer.peering_timebase = timestamp
|
||||||
peer.peering_timebase = timestamp
|
peer.last_heard = time.time()
|
||||||
peer.last_heard = time.time()
|
peer.propagation_transfer_limit = propagation_transfer_limit
|
||||||
|
|
||||||
else:
|
else:
|
||||||
peer = LXMPeer(self, destination_hash)
|
peer = LXMPeer(self, destination_hash)
|
||||||
peer.alive = True
|
peer.alive = True
|
||||||
peer.last_heard = time.time()
|
peer.last_heard = time.time()
|
||||||
|
peer.propagation_transfer_limit = propagation_transfer_limit
|
||||||
self.peers[destination_hash] = peer
|
self.peers[destination_hash] = peer
|
||||||
RNS.log("Peered with "+str(peer.destination))
|
RNS.log("Peered with "+str(peer.destination))
|
||||||
|
|
||||||
@@ -1034,9 +1114,20 @@ class LXMRouter:
|
|||||||
|
|
||||||
def propagation_link_established(self, link):
|
def propagation_link_established(self, link):
|
||||||
link.set_packet_callback(self.propagation_packet)
|
link.set_packet_callback(self.propagation_packet)
|
||||||
link.set_resource_strategy(RNS.Link.ACCEPT_ALL)
|
link.set_resource_strategy(RNS.Link.ACCEPT_APP)
|
||||||
|
link.set_resource_callback(self.propagation_resource_advertised)
|
||||||
link.set_resource_started_callback(self.resource_transfer_began)
|
link.set_resource_started_callback(self.resource_transfer_began)
|
||||||
link.set_resource_concluded_callback(self.propagation_resource_concluded)
|
link.set_resource_concluded_callback(self.propagation_resource_concluded)
|
||||||
|
self.active_propagation_links.append(link)
|
||||||
|
|
||||||
|
def propagation_resource_advertised(self, resource):
|
||||||
|
size = resource.get_data_size()
|
||||||
|
limit = self.propagation_per_transfer_limit*1000
|
||||||
|
if limit != None and size > limit:
|
||||||
|
RNS.log("Rejecting "+RNS.prettysize(size)+" incoming LXMF propagation resource, since it exceeds the limit of "+RNS.prettysize(limit), RNS.LOG_DEBUG)
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
def propagation_packet(self, data, packet):
|
def propagation_packet(self, data, packet):
|
||||||
try:
|
try:
|
||||||
@@ -1056,7 +1147,7 @@ class LXMRouter:
|
|||||||
RNS.log("Exception occurred while parsing incoming LXMF propagation data.", RNS.LOG_ERROR)
|
RNS.log("Exception occurred while parsing incoming LXMF propagation data.", RNS.LOG_ERROR)
|
||||||
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
|
||||||
def offer_request(self, path, data, request_id, remote_identity, requested_at):
|
def offer_request(self, path, data, request_id, link_id, remote_identity, requested_at):
|
||||||
if remote_identity == None:
|
if remote_identity == None:
|
||||||
return LXMPeer.ERROR_NO_IDENTITY
|
return LXMPeer.ERROR_NO_IDENTITY
|
||||||
else:
|
else:
|
||||||
@@ -1085,7 +1176,7 @@ class LXMRouter:
|
|||||||
RNS.log("Transfer concluded for incoming propagation resource "+str(resource), RNS.LOG_DEBUG)
|
RNS.log("Transfer concluded for incoming propagation resource "+str(resource), RNS.LOG_DEBUG)
|
||||||
if resource.status == RNS.Resource.COMPLETE:
|
if resource.status == RNS.Resource.COMPLETE:
|
||||||
# TODO: The peer this was received from should
|
# TODO: The peer this was received from should
|
||||||
# have the transient id added to it's list of
|
# have the transient id added to its list of
|
||||||
# already handled messages.
|
# already handled messages.
|
||||||
try:
|
try:
|
||||||
data = msgpack.unpackb(resource.data.read())
|
data = msgpack.unpackb(resource.data.read())
|
||||||
@@ -1325,7 +1416,7 @@ class LXMRouter:
|
|||||||
else:
|
else:
|
||||||
# Simply wait for the link to become
|
# Simply wait for the link to become
|
||||||
# active or close
|
# active or close
|
||||||
RNS.log("The propagation link to "+RNS.prettyhexrep(self.outbound_propagation_node)+" is pending, waiting for link to become active: "+str(self.outbound_propagation_link.status), RNS.LOG_DEBUG)
|
RNS.log("The propagation link to "+RNS.prettyhexrep(self.outbound_propagation_node)+" is pending, waiting for link to become active", RNS.LOG_DEBUG)
|
||||||
else:
|
else:
|
||||||
# No link exists, so we'll try to establish one, but
|
# No link exists, so we'll try to establish one, but
|
||||||
# only if we've never tried before, or the retry wait
|
# only if we've never tried before, or the retry wait
|
||||||
|
|||||||
@@ -78,6 +78,13 @@ def apply_config():
|
|||||||
else:
|
else:
|
||||||
active_configuration["peer_announce_interval"] = None
|
active_configuration["peer_announce_interval"] = None
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
if "lxmf" in lxmd_config and "on_inbound" in lxmd_config["lxmf"]:
|
if "lxmf" in lxmd_config and "on_inbound" in lxmd_config["lxmf"]:
|
||||||
active_configuration["on_inbound"] = lxmd_config["lxmf"]["on_inbound"]
|
active_configuration["on_inbound"] = lxmd_config["lxmf"]["on_inbound"]
|
||||||
else:
|
else:
|
||||||
@@ -121,6 +128,13 @@ def apply_config():
|
|||||||
else:
|
else:
|
||||||
active_configuration["message_storage_limit"] = 2000
|
active_configuration["message_storage_limit"] = 2000
|
||||||
|
|
||||||
|
if "propagation" in lxmd_config and "propagation_transfer_max_accepted_size" in lxmd_config["propagation"]:
|
||||||
|
active_configuration["propagation_transfer_max_accepted_size"] = lxmd_config["propagation"].as_float("propagation_transfer_max_accepted_size")
|
||||||
|
if active_configuration["propagation_transfer_max_accepted_size"] < 0.38:
|
||||||
|
active_configuration["propagation_transfer_max_accepted_size"] = 0.38
|
||||||
|
else:
|
||||||
|
active_configuration["propagation_transfer_max_accepted_size"] = 256
|
||||||
|
|
||||||
if "propagation" in lxmd_config and "prioritise_destinations" in lxmd_config["propagation"]:
|
if "propagation" in lxmd_config and "prioritise_destinations" in lxmd_config["propagation"]:
|
||||||
active_configuration["prioritised_lxmf_destinations"] = lxmd_config["propagation"].as_list("prioritise_destinations")
|
active_configuration["prioritised_lxmf_destinations"] = lxmd_config["propagation"].as_list("prioritise_destinations")
|
||||||
else:
|
else:
|
||||||
@@ -289,6 +303,8 @@ def program_setup(configdir = None, rnsconfigdir = None, run_pn = False, on_inbo
|
|||||||
storagepath = storagedir,
|
storagepath = storagedir,
|
||||||
autopeer = active_configuration["autopeer"],
|
autopeer = active_configuration["autopeer"],
|
||||||
autopeer_maxdepth = active_configuration["autopeer_maxdepth"],
|
autopeer_maxdepth = active_configuration["autopeer_maxdepth"],
|
||||||
|
propagation_limit = active_configuration["propagation_transfer_max_accepted_size"],
|
||||||
|
delivery_limit = active_configuration["delivery_transfer_max_accepted_size"],
|
||||||
)
|
)
|
||||||
message_router.register_delivery_callback(lxmf_delivery)
|
message_router.register_delivery_callback(lxmf_delivery)
|
||||||
|
|
||||||
@@ -418,23 +434,41 @@ __default_lxmd_config__ = """# This is an example LXM Daemon config file.
|
|||||||
[propagation]
|
[propagation]
|
||||||
|
|
||||||
# Whether to enable propagation node
|
# Whether to enable propagation node
|
||||||
|
|
||||||
enable_node = no
|
enable_node = no
|
||||||
|
|
||||||
# Automatic announce interval in minutes.
|
# Automatic announce interval in minutes.
|
||||||
# 6 hours by default.
|
# 6 hours by default.
|
||||||
|
|
||||||
announce_interval = 360
|
announce_interval = 360
|
||||||
|
|
||||||
# Whether to announce when the node starts.
|
# Whether to announce when the node starts.
|
||||||
|
|
||||||
announce_at_start = yes
|
announce_at_start = yes
|
||||||
|
|
||||||
# Wheter to automatically peer with other
|
# Wheter to automatically peer with other
|
||||||
# propagation nodes on the network.
|
# propagation nodes on the network.
|
||||||
|
|
||||||
autopeer = yes
|
autopeer = yes
|
||||||
|
|
||||||
# The maximum peering depth (in hops) for
|
# The maximum peering depth (in hops) for
|
||||||
# automatically peered nodes.
|
# automatically peered nodes.
|
||||||
|
|
||||||
autopeer_maxdepth = 4
|
autopeer_maxdepth = 4
|
||||||
|
|
||||||
|
# The maximum accepted transfer size per in-
|
||||||
|
# coming propagation transfer, in kilobytes.
|
||||||
|
# This also sets the upper limit for the size
|
||||||
|
# of single messages accepted onto this node.
|
||||||
|
#
|
||||||
|
# If a node wants to propagate a larger number
|
||||||
|
# of messages to this node, than what can fit
|
||||||
|
# within this limit, it will prioritise sending
|
||||||
|
# the smallest messages first, and try again
|
||||||
|
# with any remaining messages at a later point.
|
||||||
|
|
||||||
|
propagation_transfer_max_accepted_size = 256
|
||||||
|
|
||||||
# The maximum amount of storage to use for
|
# The maximum amount of storage to use for
|
||||||
# the LXMF Propagation Node message store,
|
# the LXMF Propagation Node message store,
|
||||||
# specified in megabytes. When this limit
|
# specified in megabytes. When this limit
|
||||||
@@ -444,6 +478,7 @@ autopeer_maxdepth = 4
|
|||||||
# new and small. Large and old messages will
|
# new and small. Large and old messages will
|
||||||
# be removed first. This setting is optional
|
# be removed first. This setting is optional
|
||||||
# and defaults to 2 gigabytes.
|
# and defaults to 2 gigabytes.
|
||||||
|
|
||||||
# message_storage_limit = 2000
|
# message_storage_limit = 2000
|
||||||
|
|
||||||
# You can tell the LXMF message router to
|
# You can tell the LXMF message router to
|
||||||
@@ -453,6 +488,7 @@ autopeer_maxdepth = 4
|
|||||||
# keeping messages for destinations specified
|
# keeping messages for destinations specified
|
||||||
# with this option. This setting is optional,
|
# with this option. This setting is optional,
|
||||||
# and generally you do not need to use it.
|
# and generally you do not need to use it.
|
||||||
|
|
||||||
# prioritise_destinations = 41d20c727598a3fbbdf9106133a3a0ed, d924b81822ca24e68e2effea99bcb8cf
|
# prioritise_destinations = 41d20c727598a3fbbdf9106133a3a0ed, d924b81822ca24e68e2effea99bcb8cf
|
||||||
|
|
||||||
# By default, any destination is allowed to
|
# By default, any destination is allowed to
|
||||||
@@ -461,6 +497,7 @@ autopeer_maxdepth = 4
|
|||||||
# authentication, you must provide a list of
|
# authentication, you must provide a list of
|
||||||
# allowed identity hashes in the a file named
|
# allowed identity hashes in the a file named
|
||||||
# "allowed" in the lxmd config directory.
|
# "allowed" in the lxmd config directory.
|
||||||
|
|
||||||
auth_required = no
|
auth_required = no
|
||||||
|
|
||||||
|
|
||||||
@@ -469,23 +506,35 @@ auth_required = no
|
|||||||
# The LXM Daemon will create an LXMF destination
|
# The LXM Daemon will create an LXMF destination
|
||||||
# that it can receive messages on. This option sets
|
# that it can receive messages on. This option sets
|
||||||
# the announced display name for this destination.
|
# the announced display name for this destination.
|
||||||
|
|
||||||
display_name = Anonymous Peer
|
display_name = Anonymous Peer
|
||||||
|
|
||||||
# It is possible to announce the internal LXMF
|
# It is possible to announce the internal LXMF
|
||||||
# destination when the LXM Daemon starts up.
|
# destination when the LXM Daemon starts up.
|
||||||
|
|
||||||
announce_at_start = no
|
announce_at_start = no
|
||||||
|
|
||||||
# You can also announce the delivery destination
|
# You can also announce the delivery destination
|
||||||
# at a specified interval. This is not enabled by
|
# at a specified interval. This is not enabled by
|
||||||
# default.
|
# default.
|
||||||
|
|
||||||
# announce_interval = 360
|
# announce_interval = 360
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
# You can configure an external program to be run
|
# You can configure an external program to be run
|
||||||
# every time a message is received. The program
|
# every time a message is received. The program
|
||||||
# will receive as an argument the full path to the
|
# will receive as an argument the full path to the
|
||||||
# message saved as a file. The example below will
|
# message saved as a file. The example below will
|
||||||
# simply result in the message getting deleted as
|
# simply result in the message getting deleted as
|
||||||
# soon as it has been received.
|
# soon as it has been received.
|
||||||
|
|
||||||
# on_inbound = rm
|
# on_inbound = rm
|
||||||
|
|
||||||
|
|
||||||
@@ -499,6 +548,7 @@ announce_at_start = no
|
|||||||
# 5: Verbose logging
|
# 5: Verbose logging
|
||||||
# 6: Debug logging
|
# 6: Debug logging
|
||||||
# 7: Extreme logging
|
# 7: Extreme logging
|
||||||
|
|
||||||
loglevel = 4
|
loglevel = 4
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
__version__ = "0.3.9"
|
__version__ = "0.4.1"
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
qrcode==7.4.2
|
||||||
|
rns==0.5.7
|
||||||
|
setuptools==68.0.0
|
||||||
Reference in new issue
Block a user