-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlxmf.patch
More file actions
388 lines (366 loc) · 27.4 KB
/
Copy pathlxmf.patch
File metadata and controls
388 lines (366 loc) · 27.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
diff --git a/LXMF/Handlers.py b/LXMF/Handlers.py
index 6239b18..e586b1e 100644
--- a/LXMF/Handlers.py
+++ b/LXMF/Handlers.py
@@ -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():
diff --git a/LXMF/LXMPeer.py b/LXMF/LXMPeer.py
index ca2138e..e5c1a7f 100644
--- a/LXMF/LXMPeer.py
+++ b/LXMF/LXMPeer.py
@@ -294,7 +294,7 @@ 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):
diff --git a/LXMF/LXMRouter.py b/LXMF/LXMRouter.py
index 7e354f7..1864ce7 100644
--- a/LXMF/LXMRouter.py
+++ b/LXMF/LXMRouter.py
@@ -31,6 +31,8 @@ class LXMRouter:
PROCESSING_INTERVAL = 4
DELIVERY_RETRY_WAIT = 10
PATH_REQUEST_WAIT = 7
+ PATH_REQUEST_DEBOUNCE = 60
+ SLOW_INTERFACE_BITRATE = 2000
MAX_PATHLESS_TRIES = 1
LINK_MAX_INACTIVITY = 10*60
P_LINK_MAX_INACTIVITY = 3*60
@@ -108,6 +110,8 @@ class LXMRouter:
self.pending_outbound = []
self.direct_links = {}
self.backchannel_links = {}
+ self.path_request_times = {}
+ self.path_request_lock = threading.Lock()
self.delivery_destinations = {}
self.prioritised_list = []
@@ -428,8 +432,8 @@ class LXMRouter:
if not target_propagation_cost:
RNS.log(f"Could not retrieve cached propagation node config. Requesting path to propagation node to get target propagation cost...", RNS.LOG_DEBUG)
- RNS.Transport.request_path(pn_destination_hash)
- timeout = time.time() + LXMRouter.PATH_REQUEST_WAIT
+ self.request_path(pn_destination_hash)
+ timeout = time.time() + self.path_request_wait()
while not RNS.Identity.recall_app_data(pn_destination_hash) and time.time() < timeout:
time.sleep(0.5)
@@ -532,10 +536,10 @@ class LXMRouter:
self.outbound_propagation_link = RNS.Link(propagation_node_destination, established_callback=msg_request_established_callback)
else:
RNS.log("No path known for message download from propagation node "+RNS.prettyhexrep(self.outbound_propagation_node)+". Requesting path...", RNS.LOG_DEBUG)
- RNS.Transport.request_path(self.outbound_propagation_node)
+ self.request_path(self.outbound_propagation_node)
self.wants_download_on_path_available_from = self.outbound_propagation_node
self.wants_download_on_path_available_to = identity
- self.wants_download_on_path_available_timeout = time.time() + LXMRouter.PR_PATH_TIMEOUT
+ self.wants_download_on_path_available_timeout = time.time() + max(LXMRouter.PR_PATH_TIMEOUT, self.path_request_wait())
self.propagation_transfer_state = LXMRouter.PR_PATH_REQUESTED
self.request_messages_path_job()
else:
@@ -617,7 +621,7 @@ class LXMRouter:
peer = LXMPeer.from_bytes(serialised_peer, self)
del serialised_peer
if peer.destination_hash in self.static_peers and peer.last_heard == 0:
- RNS.Transport.request_path(peer.destination_hash)
+ self.request_path(peer.destination_hash)
if peer.identity != None:
self.peers[peer.destination_hash] = peer
lim_str = ", no transfer limit"
@@ -639,7 +643,7 @@ class LXMRouter:
# TODO: Allow path request responses through announce handler
# momentarily here, so peering config can be updated even if
# the static peer is not available to directly send an announce.
- RNS.Transport.request_path(static_peer)
+ self.request_path(static_peer)
RNS.log(f"Rebuilt synchronisation state for {len(self.peers)} peers in {RNS.prettytime(time.time()-st)}", RNS.LOG_NOTICE)
@@ -1743,6 +1747,67 @@ class LXMRouter:
RNS.log(f"An error occurred while cancelling {lxmessage}: {e}", RNS.LOG_ERROR)
RNS.trace_exception(e)
+ def medium_path_timeout(self):
+ try: return RNS.Reticulum.get_instance().get_medium_path_timeout()
+ except Exception: return 0
+
+ def destination_round_trip(self, destination_hash):
+ if not RNS.Transport.has_path(destination_hash): return self.medium_path_timeout()
+ try:
+ mtu_time = RNS.Reticulum.get_instance().get_first_hop_timeout(destination_hash) - RNS.Reticulum.DEFAULT_PER_HOP_TIMEOUT
+ return 2 * max(mtu_time, 0) + RNS.Reticulum.DEFAULT_PER_HOP_TIMEOUT
+ except Exception: return 0
+
+ def path_request_wait(self):
+ return max(LXMRouter.PATH_REQUEST_WAIT, self.medium_path_timeout())
+
+ def slow_interface_online(self):
+ try: bitrate = RNS.Reticulum.get_instance().get_lowest_interface_bitrate()
+ except Exception: return False
+ return bitrate != None and bitrate < LXMRouter.SLOW_INTERFACE_BITRATE
+
+ def request_path(self, destination_hash):
+ if self.slow_interface_online(): window = LXMRouter.PATH_REQUEST_DEBOUNCE
+ else: window = self.path_request_wait()
+ with self.path_request_lock:
+ now = time.time()
+ if destination_hash in self.path_request_times and now - self.path_request_times[destination_hash] < window:
+ RNS.log(f"Path request for {RNS.prettyhexrep(destination_hash)} still pending, not repeating within {RNS.prettytime(window)}", RNS.LOG_DEBUG)
+ return False
+
+ self.path_request_times = {d: t for d, t in self.path_request_times.items() if now - t < window}
+ self.path_request_times[destination_hash] = now
+
+ RNS.Transport.request_path(destination_hash)
+ return True
+
+ def path_request_pending(self, destination_hash):
+ window = self.path_request_wait()
+ with self.path_request_lock:
+ if not destination_hash in self.path_request_times: return False
+ return time.time() - self.path_request_times[destination_hash] < window
+
+ def attempt_limit(self, lxmessage):
+ if lxmessage.max_delivery_attempts == None: return LXMRouter.MAX_DELIVERY_ATTEMPTS
+ else: return lxmessage.max_delivery_attempts
+
+ def attempt_due(self, lxmessage, destination_hash):
+ if not hasattr(lxmessage, "next_delivery_attempt"): return True
+ if time.time() > lxmessage.next_delivery_attempt: return True
+ return lxmessage.awaiting_path and RNS.Transport.has_path(destination_hash)
+
+ def schedule_attempt(self, lxmessage, destination_hash, path_request = False):
+ if path_request:
+ round_trip = self.medium_path_timeout()
+ lxmessage.next_delivery_attempt = time.time() + max(LXMRouter.PATH_REQUEST_WAIT, round_trip)
+ lxmessage.awaiting_path = True
+ else:
+ round_trip = self.destination_round_trip(destination_hash)
+ lxmessage.next_delivery_attempt = time.time() + max(LXMRouter.DELIVERY_RETRY_WAIT, round_trip)
+
+ if round_trip > LXMRouter.DELIVERY_RETRY_WAIT: lxmessage.max_delivery_attempts = max(3, round(LXMRouter.MAX_DELIVERY_ATTEMPTS * LXMRouter.DELIVERY_RETRY_WAIT / round_trip))
+ else: lxmessage.max_delivery_attempts = LXMRouter.MAX_DELIVERY_ATTEMPTS
+
def handle_outbound(self, lxmessage):
destination_hash = lxmessage.get_destination().hash
@@ -1776,8 +1841,8 @@ class LXMRouter:
unknown_path_requested = False
if not RNS.Transport.has_path(destination_hash) and lxmessage.method == LXMessage.OPPORTUNISTIC:
RNS.log(f"Pre-emptively requesting unknown path for opportunistic {lxmessage}", RNS.LOG_DEBUG)
- RNS.Transport.request_path(destination_hash)
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
+ self.request_path(destination_hash)
+ self.schedule_attempt(lxmessage, destination_hash, path_request=True)
unknown_path_requested = True
lxmessage.determine_transport_encryption()
@@ -2733,38 +2798,49 @@ class LXMRouter:
# Outbound handling for opportunistic messages
if lxmessage.method == LXMessage.OPPORTUNISTIC:
- if lxmessage.delivery_attempts <= LXMRouter.MAX_DELIVERY_ATTEMPTS:
- if lxmessage.delivery_attempts >= LXMRouter.MAX_PATHLESS_TRIES and not RNS.Transport.has_path(lxmessage.get_destination().hash):
- RNS.log(f"Requesting path to {RNS.prettyhexrep(lxmessage.get_destination().hash)} after {lxmessage.delivery_attempts} pathless tries for {lxmessage}", RNS.LOG_DEBUG)
- lxmessage.delivery_attempts += 1
- RNS.Transport.request_path(lxmessage.get_destination().hash)
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
- lxmessage.progress = 0.01
- elif lxmessage.delivery_attempts == LXMRouter.MAX_PATHLESS_TRIES+1 and RNS.Transport.has_path(lxmessage.get_destination().hash):
- RNS.log(f"Opportunistic delivery for {lxmessage} still unsuccessful after {lxmessage.delivery_attempts} attempts, trying to rediscover path to {RNS.prettyhexrep(lxmessage.get_destination().hash)}", RNS.LOG_DEBUG)
- lxmessage.delivery_attempts += 1
- RNS.Reticulum.get_instance().drop_path(lxmessage.get_destination().hash)
- def rediscover_job():
- time.sleep(0.5)
- RNS.Transport.request_path(lxmessage.get_destination().hash)
- threading.Thread(target=rediscover_job, daemon=True).start()
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
- lxmessage.progress = 0.01
- else:
- if not hasattr(lxmessage, "next_delivery_attempt") or time.time() > lxmessage.next_delivery_attempt:
+ if lxmessage.delivery_attempts <= self.attempt_limit(lxmessage):
+ destination_hash = lxmessage.get_destination().hash
+ if self.attempt_due(lxmessage, destination_hash):
+ path_known = RNS.Transport.has_path(destination_hash)
+ lxmessage.awaiting_path = False
+ if lxmessage.delivery_attempts >= LXMRouter.MAX_PATHLESS_TRIES and not path_known:
+ RNS.log(f"Requesting path to {RNS.prettyhexrep(destination_hash)} after {lxmessage.delivery_attempts} pathless tries for {lxmessage}", RNS.LOG_DEBUG)
+ lxmessage.delivery_attempts += 1
+ lxmessage.sent_on_path = False
+ self.request_path(destination_hash)
+ self.schedule_attempt(lxmessage, destination_hash, path_request=True)
+ lxmessage.progress = 0.01
+ elif lxmessage.delivery_attempts == LXMRouter.MAX_PATHLESS_TRIES+1 and path_known and lxmessage.sent_on_path:
+ # Only rediscover if the previous attempt was actually sent from same path
+ lxmessage.delivery_attempts += 1
+ lxmessage.sent_on_path = False
+ if self.path_request_pending(destination_hash):
+ RNS.log(f"Opportunistic delivery for {lxmessage} still unsuccessful after {lxmessage.delivery_attempts} attempts, path to {RNS.prettyhexrep(destination_hash)} is already being rediscovered, waiting for reply", RNS.LOG_DEBUG)
+ else:
+ RNS.log(f"Opportunistic delivery for {lxmessage} still unsuccessful after {lxmessage.delivery_attempts} attempts, trying to rediscover path to {RNS.prettyhexrep(destination_hash)}", RNS.LOG_DEBUG)
+ with self.path_request_lock: self.path_request_times[destination_hash] = time.time()
+ RNS.Reticulum.get_instance().drop_path(destination_hash)
+ def rediscover_job():
+ time.sleep(0.5)
+ RNS.Transport.request_path(destination_hash)
+ threading.Thread(target=rediscover_job, daemon=True).start()
+ lxmessage.next_delivery_attempt = time.time() + self.path_request_wait()
+ lxmessage.progress = 0.01
+ else:
lxmessage.delivery_attempts += 1
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.DELIVERY_RETRY_WAIT
- RNS.log("Opportunistic delivery attempt "+str(lxmessage.delivery_attempts)+" for "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
+ lxmessage.sent_on_path = path_known
+ self.schedule_attempt(lxmessage, destination_hash)
+ RNS.log("Opportunistic delivery attempt "+str(lxmessage.delivery_attempts) +" for "+str(lxmessage)+" to "+RNS.prettyhexrep(destination_hash), RNS.LOG_DEBUG)
lxmessage.send()
- else:
+ elif self.attempt_due(lxmessage, lxmessage.get_destination().hash):
RNS.log("Max delivery attempts reached for oppertunistic "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
self.fail_message(lxmessage)
# Outbound handling for messages transferred
# over a direct link to the final recipient
elif lxmessage.method == LXMessage.DIRECT:
- if lxmessage.delivery_attempts <= LXMRouter.MAX_DELIVERY_ATTEMPTS:
- delivery_destination_hash = lxmessage.get_destination().hash
+ delivery_destination_hash = lxmessage.get_destination().hash
+ if lxmessage.delivery_attempts <= self.attempt_limit(lxmessage):
direct_link = None
if delivery_destination_hash in self.direct_links:
@@ -2797,23 +2873,21 @@ class LXMRouter:
elif direct_link.status == RNS.Link.CLOSED:
if direct_link.activated_at != None:
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" was closed unexpectedly, retrying path request...", RNS.LOG_DEBUG)
- RNS.Transport.request_path(lxmessage.get_destination().hash)
+ self.request_path(lxmessage.get_destination().hash)
else:
if not hasattr(lxmessage, "path_request_retried"):
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" was never activated, retrying path request...", RNS.LOG_DEBUG)
- RNS.Transport.request_path(lxmessage.get_destination().hash)
+ self.request_path(lxmessage.get_destination().hash)
lxmessage.path_request_retried = True
else:
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" was never activated", RNS.LOG_DEBUG)
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
-
lxmessage.set_delivery_destination(None)
if delivery_destination_hash in self.direct_links:
self.direct_links.pop(delivery_destination_hash)
if delivery_destination_hash in self.backchannel_links:
self.backchannel_links.pop(delivery_destination_hash)
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.DELIVERY_RETRY_WAIT
+ if lxmessage.delivery_attempts+1 < self.attempt_limit(lxmessage): self.schedule_attempt(lxmessage, delivery_destination_hash)
else:
# Simply wait for the link to become active or close
RNS.log("The link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" is pending, waiting for link to become active", RNS.LOG_DEBUG)
@@ -2821,11 +2895,12 @@ class LXMRouter:
# No link exists, so we'll try to establish one, but
# only if we've never tried before, or the retry wait
# period has elapsed.
- if not hasattr(lxmessage, "next_delivery_attempt") or time.time() > lxmessage.next_delivery_attempt:
+ if self.attempt_due(lxmessage, delivery_destination_hash):
lxmessage.delivery_attempts += 1
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.DELIVERY_RETRY_WAIT
+ lxmessage.awaiting_path = False
+ self.schedule_attempt(lxmessage, delivery_destination_hash)
- if lxmessage.delivery_attempts < LXMRouter.MAX_DELIVERY_ATTEMPTS:
+ if lxmessage.delivery_attempts < self.attempt_limit(lxmessage):
if RNS.Transport.has_path(lxmessage.get_destination().hash):
RNS.log("Establishing link to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+" for delivery attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
delivery_link = RNS.Link(lxmessage.get_destination())
@@ -2834,10 +2909,13 @@ class LXMRouter:
lxmessage.progress = 0.03
else:
RNS.log("No path known for delivery attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash)+". Requesting path...", RNS.LOG_DEBUG)
- RNS.Transport.request_path(lxmessage.get_destination().hash)
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
+ self.request_path(lxmessage.get_destination().hash)
+ self.schedule_attempt(lxmessage, delivery_destination_hash, path_request=True)
lxmessage.progress = 0.01
- else:
+ else:
+ RNS.log("Max delivery attempts reached for direct "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
+ self.fail_message(lxmessage)
+ elif self.attempt_due(lxmessage, delivery_destination_hash):
RNS.log("Max delivery attempts reached for direct "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
self.fail_message(lxmessage)
@@ -2850,7 +2928,7 @@ class LXMRouter:
RNS.log("No outbound propagation node specified for propagated "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_ERROR)
self.fail_message(lxmessage)
else:
- if lxmessage.delivery_attempts <= LXMRouter.MAX_DELIVERY_ATTEMPTS:
+ if lxmessage.delivery_attempts <= self.attempt_limit(lxmessage):
if self.outbound_propagation_link != None:
# A link already exists, so we'll try to use it
@@ -2868,7 +2946,7 @@ class LXMRouter:
elif self.outbound_propagation_link.status == RNS.Link.CLOSED:
RNS.log("The link to "+RNS.prettyhexrep(self.outbound_propagation_node)+" was closed", RNS.LOG_DEBUG)
self.outbound_propagation_link = None
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.DELIVERY_RETRY_WAIT
+ if lxmessage.delivery_attempts+1 < self.attempt_limit(lxmessage): self.schedule_attempt(lxmessage, self.outbound_propagation_node)
else:
# Simply wait for the link to become
# active or close
@@ -2877,11 +2955,12 @@ class LXMRouter:
# No link exists, so we'll try to establish one, but
# only if we've never tried before, or the retry wait
# period has elapsed.
- if not hasattr(lxmessage, "next_delivery_attempt") or time.time() > lxmessage.next_delivery_attempt:
+ if self.attempt_due(lxmessage, self.outbound_propagation_node):
lxmessage.delivery_attempts += 1
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.DELIVERY_RETRY_WAIT
+ lxmessage.awaiting_path = False
+ self.schedule_attempt(lxmessage, self.outbound_propagation_node)
- if lxmessage.delivery_attempts < LXMRouter.MAX_DELIVERY_ATTEMPTS:
+ if lxmessage.delivery_attempts < self.attempt_limit(lxmessage):
if RNS.Transport.has_path(self.outbound_propagation_node):
RNS.log("Establishing link to "+RNS.prettyhexrep(self.outbound_propagation_node)+" for propagation attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
propagation_node_identity = RNS.Identity.recall(self.outbound_propagation_node)
@@ -2891,9 +2970,12 @@ class LXMRouter:
self.outbound_propagation_link.for_lxmessage = lxmessage
else:
RNS.log("No path known for propagation attempt "+str(lxmessage.delivery_attempts)+" to "+RNS.prettyhexrep(self.outbound_propagation_node)+". Requesting path...", RNS.LOG_DEBUG)
- RNS.Transport.request_path(self.outbound_propagation_node)
- lxmessage.next_delivery_attempt = time.time() + LXMRouter.PATH_REQUEST_WAIT
+ self.request_path(self.outbound_propagation_node)
+ self.schedule_attempt(lxmessage, self.outbound_propagation_node, path_request=True)
+ else:
+ RNS.log("Max delivery attempts reached for propagated "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
+ self.fail_message(lxmessage)
- else:
+ elif self.attempt_due(lxmessage, self.outbound_propagation_node):
RNS.log("Max delivery attempts reached for propagated "+str(lxmessage)+" to "+RNS.prettyhexrep(lxmessage.get_destination().hash), RNS.LOG_DEBUG)
self.fail_message(lxmessage)
diff --git a/LXMF/LXMessage.py b/LXMF/LXMessage.py
index 95d2310..47a49d2 100644
--- a/LXMF/LXMessage.py
+++ b/LXMF/LXMessage.py
@@ -177,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
@@ -466,7 +471,8 @@ 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()
+ if receipt: receipt.set_delivery_callback(self.__mark_delivered)
self.progress = 0.50
self.ratchet_id = lxm_packet.ratchet_id
self.state = LXMessage.SENT