mirror of
https://github.com/markqvist/Reticulum
synced 2026-11-22 23:10:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f55c0c6ea6 | ||
|
|
840eb3699b | ||
|
|
cff4d03fdb | ||
|
|
528986836b | ||
|
|
01ffb98ee5 | ||
|
|
eb00622fef | ||
|
|
e8b3b14b73 | ||
|
|
ef3e80868e | ||
|
|
48ba76df9c | ||
|
|
41260ea163 | ||
|
|
1f7cd14513 | ||
|
|
b9903c53a8 | ||
|
|
1a71073cc0 | ||
|
|
f7b54ccc11 | ||
|
|
3f55e9ebeb | ||
|
|
c90a5d5887 | ||
|
|
9568b70458 | ||
|
|
8e7dc8b776 | ||
|
|
4a058544a5 | ||
|
|
8c73e203b1 | ||
|
|
70eb417d90 | ||
|
|
5bd93ad979 | ||
|
|
d72cfdd7f0 | ||
|
|
833f6cf2aa | ||
|
|
05ac4bba8e | ||
|
|
0123133e71 | ||
|
|
f876ed8dd9 | ||
|
|
48c7706188 | ||
|
|
4916017aee | ||
|
|
12b2b8c013 | ||
|
|
cc5d6dd065 | ||
|
|
25cce0a847 | ||
|
|
2b1a984c91 | ||
|
|
338df09607 | ||
|
|
aecc1547da | ||
|
|
da368e05e7 | ||
|
|
884f109b2b | ||
|
|
fd36a97220 | ||
|
|
51fa841327 | ||
|
|
b7a93b9b6b | ||
|
|
13b98a6bc2 | ||
|
|
e35bd08f18 | ||
|
|
715707b1bf | ||
|
|
d077d1ab00 | ||
|
|
bb63dd4406 | ||
|
|
e96c81c3f2 | ||
|
|
29ce7ca568 | ||
|
|
ad6c709e80 | ||
|
|
f361a354ba | ||
|
|
096e6726b4 | ||
|
|
a450be5d7e | ||
|
|
85d3697938 | ||
|
|
29dc449af8 | ||
|
|
c850cdac6c | ||
|
|
350b7e2614 | ||
|
|
56b23c4810 | ||
|
|
464e75986e | ||
|
|
3281e28315 | ||
|
|
daec67a116 | ||
|
|
819076c378 | ||
|
|
d183791956 | ||
|
|
01e7ed8443 | ||
|
|
d5f1e014db | ||
|
|
6852971d3c | ||
|
|
04585ff2a8 | ||
|
|
54159d1d93 | ||
|
|
134dc6777c | ||
|
|
20e25a9f0c | ||
|
|
9b6b724b08 | ||
|
|
f96cef7ed9 | ||
|
|
db67adea0a | ||
|
|
3c4b271f41 | ||
|
|
5f2dbc169d | ||
|
|
9ef6c90ea6 | ||
|
|
0bc5c37c39 | ||
|
|
1855f9927f | ||
|
|
70b9d58f15 | ||
|
|
7852f53a4c | ||
|
|
3ac3236b2f | ||
|
|
023849ed29 | ||
|
|
50b6733a1c | ||
|
|
16621a78e3 | ||
|
|
132ec70f75 | ||
|
|
aaf08e6107 | ||
|
|
2c7cf8272b | ||
|
|
c5d205ffea | ||
|
|
e0da9c381e | ||
|
|
d4af18fd6f | ||
|
|
cb1260891d | ||
|
|
2960e6a41d | ||
|
|
baccc6d8a2 | ||
|
|
1fee7af7f2 | ||
|
|
dad1302b1e | ||
|
|
9d67be9acb | ||
|
|
50e939ab0e | ||
|
|
29e5a997ac | ||
|
|
01aef5bc2a | ||
|
|
65a7208a9d | ||
|
|
acb38a8a1c | ||
|
|
c97e2158f5 | ||
|
|
426673e974 | ||
|
|
f15b34870a | ||
|
|
eb826cde90 | ||
|
|
e9d82e698d | ||
|
|
3305fc1cbd | ||
|
|
53dc223a03 | ||
|
|
9b6678b317 | ||
|
|
ceac4a28bd | ||
|
|
8a09c9b550 | ||
|
|
e49fafecce | ||
|
|
ecd677ba7f | ||
|
|
cda4d72bb8 | ||
|
|
d5891fde14 | ||
|
|
fa683e6c21 | ||
|
|
d3874ddedb | ||
|
|
825c2e1993 | ||
|
|
ade030ada9 | ||
|
|
0cc6f5aef3 | ||
|
|
263dc6bae5 | ||
|
|
6927c3c589 | ||
|
|
22bf35d59d | ||
|
|
e64ce99565 | ||
|
|
af4504d675 | ||
|
|
2117087710 | ||
|
|
c4ed59be2c | ||
|
|
1d9067c3bd | ||
|
|
f1fc51ba09 | ||
|
|
fe2fe94dd8 | ||
|
|
d45a5860fd | ||
|
|
eab2983b95 | ||
|
|
1ee89ad8d6 | ||
|
|
2ef855c892 | ||
|
|
81b6ba364c | ||
|
|
9152bc1319 | ||
|
|
c147201470 | ||
|
|
5b2b8afbdf | ||
|
|
1a6e26ac2b | ||
|
|
9b46438233 | ||
|
|
2e6963c388 | ||
|
|
da027e9c0f | ||
|
|
f57fa2655c | ||
|
|
796ef2d44b | ||
|
|
75465efad8 | ||
|
|
34bb4ac88c | ||
|
|
2c142973bf | ||
|
|
a8cc6cb239 | ||
|
|
5f46fc6b48 | ||
|
|
78fb90ea6f | ||
|
|
c0fe08c08d | ||
|
|
d7749b0b06 | ||
|
|
5d38ce3072 | ||
|
|
025f6d609f | ||
|
|
ba3c42459b | ||
|
|
134db17c81 | ||
|
|
4867e889e2 | ||
|
|
ca6451a02a | ||
|
|
ba8c2d76db | ||
|
|
c37b5f7f44 | ||
|
|
9955e1bf67 | ||
|
|
30c6428e0b | ||
|
|
c3af19893f | ||
|
|
8d5871915a | ||
|
|
7c1b648607 | ||
|
|
c68066edff | ||
|
|
51be88fbd8 | ||
|
|
7ec975fc88 | ||
|
|
156c7323a5 | ||
|
|
d3ec00cd51 | ||
|
|
d2dd730801 | ||
|
|
d1da5c3d67 | ||
|
|
9a01a20ce6 | ||
|
|
4ebd4dcc5b | ||
|
|
3e83fcc18b | ||
|
|
156290733e | ||
|
|
044d4c9adc | ||
|
|
af8d05819d | ||
|
|
e24d207312 | ||
|
|
f3ebec9cb1 | ||
|
|
ee82fa75a7 | ||
|
|
ae67448e88 | ||
|
|
a29bfb51c4 | ||
|
|
318b78b416 | ||
|
|
2578750bf7 | ||
|
|
cadee01f9e | ||
|
|
f0875ac44e | ||
|
|
49ae71e06c | ||
|
|
1e6ebd3fa0 | ||
|
|
2bae9ff0dc | ||
|
|
d1a7e0c8a0 | ||
|
|
fca509ff04 | ||
|
|
e40191b3d1 |
No files matched your search
+153
-20
@@ -1,27 +1,44 @@
|
||||
### 2026-09-29: RNS 1.5.5
|
||||
### RNS 1.6.1
|
||||
|
||||
This release adds live interface attach, detach and reload, as well as significant improvements to interface discovery. Auto-connecting interfaces is now also supported on Windows and macOS.
|
||||
This release brings yet another round of major efficiency, performance and filtering improvements to RNS, and continues the transition towards full network stamp functionality.
|
||||
|
||||
It also brings improvements to `rngit` and fixes discovered `I2PInterface` configuration snippets, along with a number of other bugs.
|
||||
All network stamp types will now be generated and emitted by default. Expect some CPU load once your applications start up for the first time on `1.6.1`, as destination stamps are generated.
|
||||
|
||||
**Changes**
|
||||
- Added ability to `--attach`, `--detach` and `--reload` interfaces to the `rnstatus` utility
|
||||
- Added interface discovery auto-connect support on Windows and macOS
|
||||
- Added ability to download micron-converted versions of markdown files to the `rngit` page node
|
||||
- Added workdoc counts to filter scope links to the `rngit` page node
|
||||
- Added version info to `rnstatus` discovered interfaces output
|
||||
- Added `--show-stale` and `--show-unknown` options to `rnstatus`
|
||||
- Added sequential naming of auto-connected interfaces on announced name collisions
|
||||
- Added auto-connect implementation and version criteria filtering
|
||||
- Added configuration option for allowing auto-connects to discovered interfaces with missing version info
|
||||
- Improved sanitization of nonsensical interface discovery IFAC announce data
|
||||
- Fixed `I2PInterface` discovery config snippets not including `.b32.i2p`
|
||||
- Fixed timeout and response rejects not being processed for single-packet requests, by **JRG**
|
||||
- Fixed missing configurable property propagations on spawned interfaces, by **JRG**
|
||||
- Fixed ingress control producer comprehension at mid-watermark using incorrect variable name for interface type check, by **JRG**
|
||||
- Fixed instances of `announce_cap` property ensurance logic not storing announce cap value as a fraction, by **JRG**
|
||||
- Fixed a potential race condition in `LocalInterface` initialization.
|
||||
- Updated documentation and manual
|
||||
- Enabled network stamp generation by default
|
||||
- Added ability to filter destination types by hash
|
||||
- Added hop limiter options both globally and per-interface
|
||||
- Added super fast announce ingress pre-filtering
|
||||
- Added filtered traffic stats to `rnstatus`
|
||||
- Added link traffic stats to `rnstatus`
|
||||
- Added display of remote transport IDs per client interface in `rnstatus`.
|
||||
- Ability to inspect filtered traffic, announces, et cetera in `rnstatus` per interface
|
||||
- Ability to inspect tunnel properties, stamp costs, remote implementation info and more in `rnstatus`
|
||||
- Added ability to set `client_limit` on `BackboneInterface`, defaults to 500
|
||||
- Added ability to configure the maximum amount of stamp workers and worker niceness
|
||||
- Added ability to place a `blocked_ips` file in your config directory to permanently block IPs
|
||||
- Added ability to directly blackhole remote transport nodes
|
||||
- Added ability to configure stamp values and costs for `rngit`
|
||||
- Added asynchronous, interleaved held announce queue cleaning across all interfaces based on potential announce usability
|
||||
- Added bidirectional tunnel synthesis on non shared-medium interfaces, with stamp cost and version signalling
|
||||
- Added announce rate table persistence between instance restarts
|
||||
- Added default caps for configured auto-connect interface counts
|
||||
- Added path state info to API path table getters
|
||||
- Significantly optimized and improved inbound announce filtering and deduplication
|
||||
- Significantly optimized and reworked the filtering subsystem for scalability across hundreds of interfaces
|
||||
- Improved `rnpath` display and filtering options
|
||||
- Improved traffic counting
|
||||
- Improved path responsiveness tracking
|
||||
- Improved protocol violation tracking and logging
|
||||
- Improved path pool and tunnel table culling
|
||||
- Tuned announce validation caches and other parameters
|
||||
- Fixed a regression introduced in `1.6.0`, that could cause path table culling to temporarily remove an instance's own local destination paths
|
||||
- Fixed dataplane egress control state not resetting on `BackboneInterface` client connection recovery
|
||||
- Fixed a potential logging deadlock
|
||||
- Fixed a potential exit handler deadlock if a signal arrives mid RPC call
|
||||
- Fixed missing wanted destination type for interface discovery when local announce filtering was enabled
|
||||
- Fixed split-instance initial known-destinations load not being available on Android
|
||||
- Added mitigation for a CPython process fork deadlock dug in stdin handling
|
||||
|
||||
**Verified Retrieval**
|
||||
You can retrieve and verify this release over Reticulum using the built-in `rngit release` utility. To retrieve only the installation `.whl` package, and the release manifest for future updates, you can use:
|
||||
@@ -51,6 +68,122 @@ rnid -i bc7291552be7a58f361522990465165c -V rns_*.rsm *.rsg
|
||||
|
||||
The `rnid` utility will then verify the signatures, and display whether they are valid. If the signature cannot be verified, the release has been tampered with and should be discarded.
|
||||
|
||||
### RNS 1.6.0
|
||||
|
||||
This major release of Reticulum brings significant improvements to resource consumption, performance, stability and resilience, especially for constrained devices and nodes.
|
||||
|
||||
**Memory & Performance Improvements**
|
||||
|
||||
A new, SQLite based storage backend has been implemented, and is now the default. All legacy file-based storage will be auto-migrated to the database-backed store on the first start. If you are using an esoteric system that does not support the `sqlite3` module, Reticulum will automatically fall back to using the file-based storage system.
|
||||
|
||||
The memory management system has been completely reworked, and significantly improved. For long-running transport nodes, this cuts memory consumption by approximately 50%, and for non-transport instances, standalone applications and appliance devices by up to 80%.
|
||||
|
||||
**Path Table Sharding**
|
||||
|
||||
This release implements the initial transport awareness and mechanisms for emergent path table sharding. Transport instances will no longer attempt to hold full inter-network path tables in memory, but keep only paths relevant to the nodes they are transporting traffic for. Unused paths are now kept for much shorter periods of time, and used as a rolling pool that potential new traffic corridors can form into. The system is entirely passive, and adds no inter-node coordination or additional protocol mechanics. The current release brings the foundation, and the upcoming 1.6.x releases will tune, improve it and add the remaining pieces of the functionality.
|
||||
|
||||
**Network Stamps**
|
||||
|
||||
The stamp system, first introduced in LXMF, where it was tested and refined over the last two years, has now been brought into the core of Reticulum to help protect against spam and network abuse. All the relevant core primtives now support stamp generation and verification:
|
||||
|
||||
- Identities can be created with an embedded stamp value. This adds no additional bytes or identity format changes. Generation and verification is completely transparent, and carried within the Reticulum Identity keyset.
|
||||
- Destinations can now be stamped, and will embed stamps and required link request cost in their announces. The change is backwards-compatible, so even older versions of Reticulum carry stamped announces transparently. Destination stamps are one-time generations, stored and persisted on success, so these have relatively high default target values. Expect some CPU usage when an unstamped destination has its stamp generated for the first time on 1.6.0+.
|
||||
- Path requests can now be stamped, and are also backwards-compatible. A stamped path request will be carried transparently by non stamp-aware transport nodes.
|
||||
- Link requests are stamped according to the announced link request cost of the destination. As with all the other primitives, these are also completely transparent and backwards-compatible. The stamp is carried embedded in the ephemeral link request keyset.
|
||||
|
||||
The stamp functionality and requirements will be deployed in a phased transition, so both network operators and application developers have time to update their systems, and any potential bugs and issues can be worked out before the full deployment:
|
||||
|
||||
- Version `1.6.0` implements all the core functionality and primitives, and starts excercising the verification mechanics. By default, no destination and path request stamps are generated yet in this release, and while stamps are checked and verified, they are not *enforced*. However, both stamp emission and enforcement can be enabled in the configuration for testing or early opt-in. Link request stamps *will* be generated, if the destination has announced a cost.
|
||||
- Version `1.6.1` will enable stamp emission for all network primitives by default. Old, unstamped destinations will have their stamps generated automatically on their first announce, and will start announcing link request costs as configured. Enforcement in this phase will still be disabled by default, but can be enabled by configuration.
|
||||
- Version `1.6.2` will complete the transition to network stamps. All functionality will now be enabled by default, including enforcement. Destination announces, path requests and link requests that do not meet stamp requirements will be dropped. Any old transport nodes that have not updated to `1.6.x` will not be able to communicate with stamp-enforcing nodes, but will still *carry traffic for* stamp-capable systems.
|
||||
|
||||
The `1.6.0` and `1.6.1` releases will be an important time for observing the on-network behaviour, functionality and stability of the system, and to make any potential adjustments or fix problems before the final transition to `1.6.2`. If you're operating a transport node, please help out by reporting any problems or issues you discover.
|
||||
|
||||
**For application developers**, there is no immediate refactoring or changes required application-side. Simply updating RNS to `1.6.0` is sufficient to transparently enable all the new functionality and improvements. It is very much recommended, however, to familiarize yourself with the new API methods for specifying link request costs and destination values, as these are configurable on a per-destination basis, and might warrant specific configuration for your intended use-case.
|
||||
|
||||
**Changes**
|
||||
- Added `Identity` stamps
|
||||
- Added destination and announce stamps
|
||||
- Added path request stamps
|
||||
- Added link request stamps
|
||||
- Added link request cost signalling to announces
|
||||
- Added fractional stamp value support
|
||||
- Added path usage tracking
|
||||
- Added automatic path table culling based on traffic and usage
|
||||
- Added path retainment prioritization for slow interfaces
|
||||
- Added unused path pool monitoring and handling
|
||||
- Added managed storage backend using SQLite
|
||||
- Added fallback to legacy file-based storage if SQLite is unavailable
|
||||
- Added managed storage for known destinations and ratchets
|
||||
- Added managed storage for cached announces
|
||||
- Added memory-density optimized announce rate table implementation
|
||||
- Added memory-density optimized packet hashlist implementation
|
||||
- Added heap-tracking memory management
|
||||
- Added more comprehensive metrics to status output structure
|
||||
- Added improved filtering backend capabilities
|
||||
- Added new `[filter]` configuration section
|
||||
- Added `hop_limiter` configuration option
|
||||
- Added allow and ignore lists for destination types
|
||||
- Added ability for applications to receive required announces only
|
||||
- Added cost-aware interface discovery and auto-connects
|
||||
- Added cost and value display to `rnstatus` and `rnpath` utilities
|
||||
- Added `app_flag` signalling to resource advertisements
|
||||
- Added link MTU aware resource advertisements
|
||||
- Significantly improved inbound announce handling performance
|
||||
- Significantly improved stamper performance on Android
|
||||
- Significantly improved announce handler callback performance
|
||||
- Optimized and improved stamper implementation
|
||||
- Optimized announce rate table handling
|
||||
- Optimized packet filter hashlist handling
|
||||
- Improved early filtering and malformed packet detection
|
||||
- Improved path request protocol violation handling
|
||||
- Fixed `RNodeInterface` phy stats regression on Android
|
||||
- Fixed missing interface parameter inheritances
|
||||
- Fixed `rngit` default config path typo for `~/.config/rngit` case
|
||||
- Fixed invalid RPC error handling in some cases
|
||||
- Fixed various minor bugs and inconsistencies
|
||||
- Updated documentation
|
||||
|
||||
### 2026-10-05: RNS 1.5.7
|
||||
|
||||
This maintenance release fixes a bug in the dataplane egress control handling.
|
||||
|
||||
**Changes**
|
||||
- Fixed egress control TX stall state deadlock on BackboneInterface initiator instances
|
||||
|
||||
### 2026-10-02: RNS 1.5.6
|
||||
|
||||
This maintenance release improves interface discovery handling.
|
||||
|
||||
**Changes**
|
||||
- Fixed ephemeral transport identity being possible when discoverable interfaces are present on non-transport instances
|
||||
- Ensure only transport-enabled interfaces are autoconnected at discovery time
|
||||
|
||||
### 2026-09-29: RNS 1.5.5
|
||||
|
||||
This release adds live interface attach, detach and reload, as well as significant improvements to interface discovery. Auto-connecting interfaces is now also supported on Windows and macOS.
|
||||
|
||||
It also brings improvements to `rngit` and fixes discovered `I2PInterface` configuration snippets, along with a number of other bugs.
|
||||
|
||||
**Changes**
|
||||
- Added ability to `--attach`, `--detach` and `--reload` interfaces to the `rnstatus` utility
|
||||
- Added interface discovery auto-connect support on Windows and macOS
|
||||
- Added ability to download micron-converted versions of markdown files to the `rngit` page node
|
||||
- Added workdoc counts to filter scope links to the `rngit` page node
|
||||
- Added version info to `rnstatus` discovered interfaces output
|
||||
- Added `--show-stale` and `--show-unknown` options to `rnstatus`
|
||||
- Added sequential naming of auto-connected interfaces on announced name collisions
|
||||
- Added auto-connect implementation and version criteria filtering
|
||||
- Added configuration option for allowing auto-connects to discovered interfaces with missing version info
|
||||
- Improved sanitization of nonsensical interface discovery IFAC announce data
|
||||
- Fixed `I2PInterface` discovery config snippets not including `.b32.i2p`
|
||||
- Fixed timeout and response rejects not being processed for single-packet requests, by **JRG**
|
||||
- Fixed missing configurable property propagations on spawned interfaces, by **JRG**
|
||||
- Fixed ingress control producer comprehension at mid-watermark using incorrect variable name for interface type check, by **JRG**
|
||||
- Fixed instances of `announce_cap` property ensurance logic not storing announce cap value as a fraction, by **JRG**
|
||||
- Fixed a potential race condition in `LocalInterface` initialization.
|
||||
- Updated documentation and manual
|
||||
|
||||
### 2026-09-11: RNS 1.5.4
|
||||
|
||||
This release improves RNode BLE connectivity reliability on desktop operating systems.
|
||||
|
||||
@@ -42,6 +42,9 @@ def server(configpath):
|
||||
"linkexample"
|
||||
)
|
||||
|
||||
# We can optionally configure a link request stamp cost
|
||||
server_destination.set_link_cost(14.2)
|
||||
|
||||
# We configure a function that will get called every time
|
||||
# a new client creates a link to this destination.
|
||||
server_destination.set_link_established_callback(client_connected)
|
||||
|
||||
+10
-3
@@ -92,6 +92,7 @@ def resource_concluded(resource):
|
||||
if resource.status == RNS.Resource.COMPLETE:
|
||||
RNS.log(f"Resource {resource} received")
|
||||
RNS.log(f"Metadata: {resource.metadata}")
|
||||
RNS.log(f"Application flag is {'set' if resource.app_flag else 'not set'}")
|
||||
RNS.log(f"Data length: {os.stat(resource.data.name).st_size}")
|
||||
RNS.log(f"Data can be read directly from: {resource.data}")
|
||||
RNS.log(f"Data can be moved or copied from: {resource.data.name}")
|
||||
@@ -192,16 +193,22 @@ def client_loop():
|
||||
RNS.log(f"First 32 bytes of data: {RNS.hexrep(data[:32])}")
|
||||
|
||||
# Generate some metadata
|
||||
metadata = {"text": random_text_generator(), "numbers": [1,2,3,4], "blob": os.urandom(16)}
|
||||
metadata = {"text": random_text_generator(),
|
||||
"numbers": [1,2,3,4], "blob": os.urandom(16)}
|
||||
|
||||
# An optional application-specific flag can be set
|
||||
flag_set = True
|
||||
|
||||
# Send the resource
|
||||
resource = RNS.Resource(data, server_link, metadata=metadata, callback=resource_concluded_sending, auto_compress=False)
|
||||
resource = RNS.Resource(data, server_link, metadata=metadata, app_flag=flag_set,
|
||||
callback=resource_concluded_sending, auto_compress=False)
|
||||
|
||||
# Alternatively, you can stream data
|
||||
# directly from an open file descriptor
|
||||
|
||||
# with open("/path/to/file", "rb") as data_file:
|
||||
# resource = RNS.Resource(data_file, server_link, metadata=metadata, callback=resource_concluded_sending, auto_compress=False)
|
||||
# resource = RNS.Resource(data_file, server_link, metadata=metadata,
|
||||
# callback=resource_concluded_sending, auto_compress=False)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error while sending resource over the link: "+str(e))
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+106
-8
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -35,6 +35,8 @@ import threading
|
||||
import RNS
|
||||
|
||||
from RNS.Cryptography import Token
|
||||
from RNS.Stamps import generate_stamp, store_destination_stamp, load_destination_stamp
|
||||
from RNS.Stamps import cost_to_bytes, quantize_cost
|
||||
from .vendor import umsgpack as umsgpack
|
||||
|
||||
class Callbacks:
|
||||
@@ -146,6 +148,14 @@ class Destination:
|
||||
|
||||
return Destination.hash(identity, app_name, *aspects)
|
||||
|
||||
@staticmethod
|
||||
def name_hash(full_name):
|
||||
components = Destination.app_and_aspects_from_name(full_name)
|
||||
app_name = str(components[0])
|
||||
aspects = f".{'.'.join(components[1])}" if components[1] else ""
|
||||
name = f"{app_name}{aspects}".encode("utf-8")
|
||||
return RNS.Identity.full_hash(name)[:(RNS.Identity.NAME_HASH_LENGTH//8)]
|
||||
|
||||
def __init__(self, identity, direction, type, app_name, *aspects):
|
||||
# Check input values and build name string
|
||||
if "." in app_name: raise ValueError("Dots can't be used in app names")
|
||||
@@ -159,6 +169,11 @@ class Destination:
|
||||
self.type = type
|
||||
self.direction = direction
|
||||
self.proof_strategy = Destination.PROVE_NONE
|
||||
self.stamp = None
|
||||
self.stamp_value = None
|
||||
self.stamp_generation_lock = threading.Lock()
|
||||
self._target_value = RNS.Transport.DESTINATION_VALUE
|
||||
self._link_cost = None
|
||||
self.ratchets = None
|
||||
self.ratchets_path = None
|
||||
self.ratchet_interval = Destination.RATCHET_INTERVAL
|
||||
@@ -190,6 +205,13 @@ class Destination:
|
||||
self.name_hash = RNS.Identity.full_hash(self.expand_name(None, app_name, *aspects).encode("utf-8"))[:(RNS.Identity.NAME_HASH_LENGTH//8)]
|
||||
self.hexhash = self.hash.hex()
|
||||
|
||||
# Load existing stamp if available
|
||||
if self.direction == Destination.IN and self.identity != None and self.identity.prv != None and RNS.Transport.STAMP_DESTINATIONS:
|
||||
stamp_entry = load_destination_stamp(self.hash, self.stamp_material(), RNS.Transport.DESTINATION_COST)
|
||||
if stamp_entry != None:
|
||||
self.stamp, self.stamp_value = stamp_entry
|
||||
RNS.log(f"Loaded stamp with value {RNS.prettycost(self.stamp_value)} for {self}", RNS.LOG_DEBUG)
|
||||
|
||||
self.default_app_data = None
|
||||
self.callback = None
|
||||
self.proofcallback = None
|
||||
@@ -241,6 +263,26 @@ class Destination:
|
||||
|
||||
return False
|
||||
|
||||
def _await_stamp(self):
|
||||
with self.stamp_generation_lock:
|
||||
if self.stamp == None or self.stamp_value == None or self.stamp_value < quantize_cost(self.target_value):
|
||||
stamp_entry = load_destination_stamp(self.hash, self.stamp_material(), self.target_value)
|
||||
if stamp_entry != None: self.stamp, self.stamp_value = stamp_entry
|
||||
else:
|
||||
stamp, stamp_value = generate_stamp(self.stamp_material(), stamp_cost=self.target_value,
|
||||
expand_rounds=0, size=RNS.Identity.STAMPLENGTH)
|
||||
if stamp == None:
|
||||
RNS.log(f"Destination stamp generation for {RNS.prettyhexrep(self.hash)} failed or was aborted", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
self.stamp = stamp
|
||||
self.stamp_value = stamp_value
|
||||
store_destination_stamp(self.hash, stamp, stamp_value)
|
||||
RNS.log(f"Generated and persisted stamp with value {self.stamp_value} for {self}", RNS.LOG_DEBUG)
|
||||
|
||||
if self.stamp == None: return False
|
||||
else: return True
|
||||
|
||||
def announce(self, app_data=None, path_response=False, attached_interface=None, tag=None, send=True):
|
||||
"""
|
||||
Creates an announce packet for this destination and broadcasts it on all
|
||||
@@ -249,12 +291,20 @@ class Destination:
|
||||
:param app_data: *bytes* containing the app_data.
|
||||
:param path_response: Internal flag used by :ref:`RNS.Transport<api-transport>`. Ignore.
|
||||
"""
|
||||
if self.type != Destination.SINGLE:
|
||||
raise TypeError("Only SINGLE destination types can be announced")
|
||||
if self.type != Destination.SINGLE: raise TypeError("Only SINGLE destination types can be announced")
|
||||
if self.direction != Destination.IN: raise TypeError("Only IN destination types can be announced")
|
||||
|
||||
if self.direction != Destination.IN:
|
||||
raise TypeError("Only IN destination types can be announced")
|
||||
|
||||
if send and RNS.Transport.STAMP_DESTINATIONS and self.stamp == None:
|
||||
# If no stamp is available, queue for background generation
|
||||
# and announce emission once ready.
|
||||
RNS.Transport.enqueue_stamped_announce(self, app_data=app_data, path_response=path_response,
|
||||
attached_interface=attached_interface, tag=tag)
|
||||
else:
|
||||
# Otherwise, dispatch immediately.
|
||||
return self._announce(app_data=app_data, path_response=path_response,
|
||||
attached_interface=attached_interface, tag=tag, send=send)
|
||||
|
||||
def _announce(self, app_data=None, path_response=False, attached_interface=None, tag=None, send=True):
|
||||
ratchet = b""
|
||||
now = time.time()
|
||||
stale_responses = []
|
||||
@@ -294,6 +344,17 @@ class Destination:
|
||||
returned_app_data = self.default_app_data()
|
||||
if isinstance(returned_app_data, bytes):
|
||||
app_data = returned_app_data
|
||||
|
||||
if RNS.Transport.STAMP_DESTINATIONS:
|
||||
if not self._await_stamp():
|
||||
RNS.log(f"Could not generate destination stamp for {RNS.prettyhexrep(self.hash)}, announce emission cancelled", RNS.LOG_WARNING)
|
||||
return None
|
||||
|
||||
cost_bytes = cost_to_bytes(self.get_link_cost())
|
||||
ext_payload = bytes([RNS.Identity.EXTPAYLOADMARKER, self.get_ext_flags()])+self.stamp+bytes([cost_bytes[1], cost_bytes[0]])
|
||||
|
||||
if app_data == None: app_data = ext_payload
|
||||
else: app_data = app_data+ext_payload
|
||||
|
||||
signed_data = self.hash+self.identity.get_public_key()+self.name_hash+random_hash+ratchet
|
||||
if app_data != None: signed_data += app_data
|
||||
@@ -317,6 +378,44 @@ class Destination:
|
||||
if send: announce_packet.send()
|
||||
else: return announce_packet
|
||||
|
||||
def stamp_material(self):
|
||||
return self.hash+self.identity.get_public_key()+self.name_hash
|
||||
|
||||
def get_ext_flags(self):
|
||||
return 0x00
|
||||
|
||||
@property
|
||||
def target_value(self):
|
||||
return min(RNS.Transport.STAMP_COST_CAP, max(float(self._target_value), RNS.Transport.DESTINATION_VALUE))
|
||||
|
||||
def set_value(self, value):
|
||||
"""
|
||||
Sets the target stamp value for this destination.
|
||||
|
||||
:param value: The target value as a *float*.
|
||||
"""
|
||||
self._target_value = min(RNS.Transport.STAMP_COST_CAP, max(float(value), RNS.Transport.DESTINATION_VALUE))
|
||||
|
||||
def set_link_cost(self, cost):
|
||||
"""
|
||||
Sets the required link establishment stamp cost for this destination. Set to 0 to disable.
|
||||
|
||||
:param cost: The required cost as a *float*.
|
||||
"""
|
||||
self._link_cost = max(0, min(float(cost), RNS.Transport.LINK_COST_CAP))
|
||||
|
||||
def get_link_cost(self):
|
||||
"""
|
||||
Returns the link request stamp cost to be announced for this
|
||||
destination, as a float. If no destination-specific cost has
|
||||
been set, the default link request cost is returned.
|
||||
|
||||
:returns: The announced link request cost as a *float*.
|
||||
"""
|
||||
cost = self._link_cost
|
||||
if cost == None: cost = RNS.Transport.LR_COST
|
||||
return max(0.0, min(float(cost), RNS.Transport.STAMP_COST_CAP))
|
||||
|
||||
def accepts_links(self, accepts = None):
|
||||
"""
|
||||
Set or query whether the destination accepts incoming link requests.
|
||||
@@ -431,8 +530,7 @@ class Destination:
|
||||
def incoming_link_request(self, data, packet):
|
||||
if self.accept_link_requests:
|
||||
link = RNS.Link.validate_request(self, data, packet)
|
||||
if link != None:
|
||||
self.links.append(link)
|
||||
if link != None: self.links.append(link)
|
||||
|
||||
def _reload_ratchets(self, ratchets_path):
|
||||
if os.path.isfile(ratchets_path):
|
||||
|
||||
+53
-28
@@ -45,11 +45,14 @@ from collections import deque
|
||||
# version tag in announced discovery information.
|
||||
IMPLEMENTATION_NAME = "RNS"
|
||||
from RNS._version import __version__ as RNS_VERSION
|
||||
import RNS.Stamps
|
||||
|
||||
NAME = 0xFF
|
||||
TRANSPORT_ID = 0xFE
|
||||
TRANSPORT_IMPL = 0xFD
|
||||
TRANSPORT_VERS = 0xFC
|
||||
DST_COST = 0xFB
|
||||
PR_COST = 0xFA
|
||||
INTERFACE_TYPE = 0x00
|
||||
TRANSPORT = 0x01
|
||||
REACHABLE_ON = 0x02
|
||||
@@ -78,17 +81,10 @@ class InterfaceAnnouncer():
|
||||
"RNodeInterface", "WeaveInterface", "I2PInterface", "KISSInterface"]
|
||||
|
||||
def __init__(self, owner):
|
||||
import importlib.util
|
||||
if importlib.util.find_spec('LXMF') != None: from LXMF import LXStamper
|
||||
else:
|
||||
RNS.log("Using on-network interface discovery requires the LXMF module to be installed.", RNS.LOG_CRITICAL)
|
||||
RNS.log("You can install it with the command: pip install lxmf", RNS.LOG_CRITICAL)
|
||||
RNS.panic()
|
||||
|
||||
self.owner = owner
|
||||
self.should_run = False
|
||||
self.job_interval = self.JOB_INTERVAL
|
||||
self.stamper = LXStamper
|
||||
self.stamper = RNS.Stamps
|
||||
self.stamp_cache = {}
|
||||
|
||||
if self.owner.has_network_identity(): identity = self.owner.network_identity
|
||||
@@ -172,6 +168,8 @@ class InterfaceAnnouncer():
|
||||
TRANSPORT_ID: RNS.Transport.identity.hash,
|
||||
TRANSPORT_IMPL: IMPLEMENTATION_NAME,
|
||||
TRANSPORT_VERS: RNS_VERSION,
|
||||
DST_COST: RNS.Stamps.quantize_cost(interface.destination_cost),
|
||||
PR_COST: RNS.Stamps.quantize_cost(interface.pr_cost),
|
||||
NAME: self.sanitize(interface.discovery_name),
|
||||
LATITUDE: interface.discovery_latitude,
|
||||
LONGITUDE: interface.discovery_longitude,
|
||||
@@ -262,17 +260,10 @@ class InterfaceAnnounceHandler:
|
||||
FLAG_ENCRYPTED = 0b00000010
|
||||
|
||||
def __init__(self, required_value=InterfaceAnnouncer.DEFAULT_STAMP_VALUE, callback=None):
|
||||
import importlib.util
|
||||
if importlib.util.find_spec('LXMF') != None: from LXMF import LXStamper
|
||||
else:
|
||||
RNS.log("Using on-network interface discovery requires the LXMF module to be installed.", RNS.LOG_CRITICAL)
|
||||
RNS.log("You can install it with the command: pip install lxmf", RNS.LOG_CRITICAL)
|
||||
RNS.panic()
|
||||
|
||||
self.aspect_filter = APP_NAME+".discovery.interface"
|
||||
self.required_value = required_value
|
||||
self.callback = callback
|
||||
self.stamper = LXStamper
|
||||
self.stamper = RNS.Stamps
|
||||
self.valid_cache = {}
|
||||
self.valid_cache_max = 2048
|
||||
self.invalid_cache = deque(maxlen=2048)
|
||||
@@ -300,6 +291,11 @@ class InterfaceAnnounceHandler:
|
||||
signed = flags & self.FLAG_SIGNED
|
||||
encrypted = flags & self.FLAG_ENCRYPTED
|
||||
fullhash = RNS.Identity.full_hash(app_data)
|
||||
hops = RNS.Transport.hops_to(destination_hash)
|
||||
|
||||
if hops > RNS.Transport.PATHFINDER_M-1:
|
||||
RNS.log(f"Ignored discovered interface with invalid hop count", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
return
|
||||
|
||||
if fullhash in self.invalid_cache:
|
||||
RNS.log(f"Ignored previously discovered interface with insufficient stamp value", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
@@ -327,18 +323,27 @@ class InterfaceAnnounceHandler:
|
||||
stamp = app_data[-self.stamper.STAMP_SIZE:]
|
||||
packed = app_data[:-self.stamper.STAMP_SIZE]
|
||||
infohash = RNS.Identity.full_hash(packed)
|
||||
workblock = self.stamper.stamp_workblock(infohash, expand_rounds=InterfaceAnnouncer.WORKBLOCK_EXPAND_ROUNDS)
|
||||
value = self.stamper.stamp_value(workblock, stamp)
|
||||
valid = self.stamper.stamp_valid(stamp, self.required_value, workblock)
|
||||
|
||||
# Transitory mechanism, check non-expanded workblock validity first.
|
||||
workblock_ne = self.stamper.stamp_workblock(infohash, expand_rounds=0)
|
||||
valid_ne = self.stamper.stamp_valid(stamp, self.required_value, workblock_ne)
|
||||
if valid_ne:
|
||||
value = self.stamper.stamp_value(workblock_ne, stamp)
|
||||
valid = valid_ne
|
||||
|
||||
else:
|
||||
workblock = self.stamper.stamp_workblock(infohash, expand_rounds=InterfaceAnnouncer.WORKBLOCK_EXPAND_ROUNDS)
|
||||
value = self.stamper.stamp_value(workblock, stamp)
|
||||
valid = self.stamper.stamp_valid(stamp, self.required_value, workblock)
|
||||
|
||||
self.valid_cache[fullhash] = {"valid": valid, "value": value, "packed": packed, "stamp": stamp}
|
||||
while len(self.valid_cache) > self.valid_cache_max: self.valid_cache.pop(next(iter(self.valid_cache)))
|
||||
|
||||
if not valid:
|
||||
RNS.log(f"Ignored discovered interface with insufficient stamp value {value}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
RNS.log(f"Ignored discovered interface with insufficient stamp value {RNS.prettycost(value)}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
self.invalid_cache.append(fullhash)
|
||||
return
|
||||
|
||||
if value < self.required_value: RNS.log(f"Ignored discovered interface with stamp value {value}", RNS.LOG_DEBUG)
|
||||
else:
|
||||
info = None
|
||||
unpacked = msgpack.unpackb(packed)
|
||||
@@ -347,6 +352,8 @@ class InterfaceAnnounceHandler:
|
||||
name = self.sanitize_name(unpacked[NAME])
|
||||
impl_name = unpacked[TRANSPORT_IMPL] if TRANSPORT_IMPL in unpacked else None
|
||||
impl_version = unpacked[TRANSPORT_VERS] if TRANSPORT_VERS in unpacked else None
|
||||
dst_cost = RNS.Stamps.quantize_cost(unpacked[DST_COST]) if DST_COST in unpacked else None
|
||||
pr_cost = RNS.Stamps.quantize_cost(unpacked[PR_COST]) if PR_COST in unpacked else None
|
||||
|
||||
if type(unpacked[TRANSPORT]) != bool: raise ValueError("Invalid data in transport field of announce")
|
||||
if type(unpacked[LATITUDE]) not in [type(None), float]: raise ValueError("Invalid data in latitude field of announce")
|
||||
@@ -370,7 +377,9 @@ class InterfaceAnnounceHandler:
|
||||
"value": value,
|
||||
"transport_id": RNS.hexrep(unpacked[TRANSPORT_ID], delimit=False),
|
||||
"network_id": RNS.hexrep(announced_identity.hash, delimit=False),
|
||||
"hops": RNS.Transport.hops_to(destination_hash),
|
||||
"dst_cost": dst_cost,
|
||||
"pr_cost": pr_cost,
|
||||
"hops": hops,
|
||||
"latitude": unpacked[LATITUDE],
|
||||
"longitude": unpacked[LONGITUDE],
|
||||
"height": unpacked[HEIGHT]}
|
||||
@@ -466,7 +475,7 @@ class InterfaceAnnounceHandler:
|
||||
if self.callback and callable(self.callback): self.callback(info)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"An error occurred while trying to decode discovered interface. The contained exception was: {e}", RNS.LOG_DEBUG)
|
||||
RNS.log(f"Could not decode discovered interface. The contained exception was: {e}", RNS.LOG_DEBUG)
|
||||
|
||||
class InterfaceDiscovery():
|
||||
THRESHOLD_UNKNOWN = 24*60*60
|
||||
@@ -484,7 +493,7 @@ class InterfaceDiscovery():
|
||||
DISCOVERABLE_TYPES = ["BackboneInterface", "TCPServerInterface", "I2PInterface", "RNodeInterface", "WeaveInterface", "KISSInterface"]
|
||||
|
||||
AUTOCONNECT_IMPLS = ["RNS"]
|
||||
AUTOCONNECT_MIN_V = "1.5.2"
|
||||
AUTOCONNECT_MIN_V = "1.5.7"
|
||||
|
||||
AC_TRANSPORT_MODE = RNS.Interfaces.Interface.Interface.MODE_GATEWAY
|
||||
AC_GRAVITY = 0
|
||||
@@ -511,6 +520,7 @@ class InterfaceDiscovery():
|
||||
if not os.path.isdir(self.storagepath): os.makedirs(self.storagepath)
|
||||
|
||||
if discover_interfaces:
|
||||
RNS.Reticulum.get_instance().wants_destination_type("rnstransport.discovery.interface")
|
||||
self.handler = InterfaceAnnounceHandler(callback=self.interface_discovered, required_value=self.required_value)
|
||||
RNS.Transport.register_announce_handler(self.handler)
|
||||
threading.Thread(target=self.connect_discovered, daemon=True).start()
|
||||
@@ -597,7 +607,7 @@ class InterfaceDiscovery():
|
||||
hops = info["hops"]; ms = "" if hops == 1 else "s"
|
||||
filename = RNS.hexrep(discovery_hash, delimit=False)
|
||||
filepath = os.path.join(self.storagepath, filename)
|
||||
RNS.log(f"Discovered {interface_type}{version_str} {hops} hop{ms} away with stamp value {value}: {name}", RNS.LOG_DEBUG)
|
||||
RNS.log(f"Discovered {interface_type}{version_str} {hops} hop{ms} away with stamp value {RNS.prettycost(value)}: {name}", RNS.LOG_DEBUG)
|
||||
with self.discovery_lock:
|
||||
if not os.path.isfile(filepath):
|
||||
try:
|
||||
@@ -780,6 +790,7 @@ class InterfaceDiscovery():
|
||||
return seq_name
|
||||
|
||||
def autoconnect_qualified(self, info):
|
||||
if not "transport" in info or info["transport"] != True: return False
|
||||
if RNS.Reticulum.should_autoconnect_unverified_implementations(): return True
|
||||
if not "impl_name" in info: return False
|
||||
if not info["impl_name"] in self.AUTOCONNECT_IMPLS: return False
|
||||
@@ -795,12 +806,24 @@ class InterfaceDiscovery():
|
||||
autoconnected_count = self.autoconnect_count()
|
||||
if autoconnected_count < RNS.Reticulum.max_autoconnected_interfaces():
|
||||
interface_type = info["type"]
|
||||
has_cost_info = "dst_cost" in info and "pr_cost" in info
|
||||
if interface_type in self.AUTOCONNECT_TYPES:
|
||||
impl = f"{info['impl_name']} {info['version']}" if ("impl_name" in info and "version" in info and info["impl_name"] and info["version"]) else "unknown implementation"
|
||||
if not self.autoconnect_qualified(info):
|
||||
impl = f"{info['impl_name']} {info['version']}" if ("impl_name" in info and "version" in info and info["impl_name"] and info["version"]) else "unknown implementation"
|
||||
RNS.log(f"Not auto-connecting discovered {interface_type} {info['name']} ({impl}), auto-connect criteria not satisfied", RNS.LOG_DEBUG)
|
||||
return
|
||||
|
||||
if has_cost_info:
|
||||
dst_value = RNS.Stamps.quantize_cost(RNS.Transport.DESTINATION_VALUE)
|
||||
pr_value = RNS.Stamps.quantize_cost(RNS.Transport.PR_VALUE)
|
||||
dst_cost = RNS.Stamps.quantize_cost(info["dst_cost"] or 0)
|
||||
pr_cost = RNS.Stamps.quantize_cost(info["pr_cost"] or 0)
|
||||
dst_cost_ok = dst_cost <= dst_value
|
||||
pr_cost_ok = pr_cost <= pr_value
|
||||
if not dst_cost_ok: RNS.log(f"Destination cost {dst_cost} higher than configured value {dst_value} for {interface_type} {info['name']} ({impl}), not auto-connecting", RNS.LOG_DEBUG)
|
||||
if not pr_cost_ok: RNS.log(f"Path request cost {pr_cost} higher than configured value {pr_value} for {interface_type} {info['name']} ({impl}), not auto-connecting", RNS.LOG_DEBUG)
|
||||
if not dst_cost_ok or not pr_cost_ok: return
|
||||
|
||||
endpoint_hash = self.endpoint_hash(info)
|
||||
exists = self.interface_exists(info)
|
||||
|
||||
@@ -893,6 +916,7 @@ class BlackholeUpdater():
|
||||
|
||||
def start(self):
|
||||
if not self.should_run:
|
||||
RNS.Reticulum.get_instance().wants_destination_type("rnstransport.info.blackhole")
|
||||
source_count = len(RNS.Reticulum.blackhole_sources())
|
||||
ms = "" if source_count == 1 else "s"
|
||||
RNS.log(f"Starting blackhole updater with {source_count} source{ms}", RNS.LOG_DEBUG)
|
||||
@@ -931,8 +955,9 @@ class BlackholeUpdater():
|
||||
if os.path.isfile(sourcelistpath): os.unlink(sourcelistpath)
|
||||
os.rename(tmppath, sourcelistpath)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Error while persisting blackhole list from {RNS.prettyhexrep(remote_identity.hash)}: {e}", RNS.LOG_ERROR)
|
||||
except Exception as e: RNS.log(f"Error while persisting blackhole list from {RNS.prettyhexrep(remote_identity.hash)}: {e}", RNS.LOG_ERROR)
|
||||
|
||||
RNS.Identity._reset_validation_caches()
|
||||
|
||||
RNS.log(f"Blackhole list update from {RNS.prettyhexrep(remote_identity.hash)} completed", RNS.LOG_DEBUG)
|
||||
|
||||
|
||||
+466
-87
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -40,6 +40,9 @@ from .vendor import umsgpack as umsgpack
|
||||
|
||||
from RNS.Cryptography import X25519PrivateKey, X25519PublicKey, Ed25519PrivateKey, Ed25519PublicKey
|
||||
from RNS.Cryptography import Token
|
||||
from RNS.Storage import KnownDestinationsStore
|
||||
from RNS.Stamps import stamp_workblock, stamp_valid, stamp_value, generate_stamped_key
|
||||
from RNS.Stamps import cost_from_bytes, quantize_cost
|
||||
|
||||
|
||||
class Identity:
|
||||
@@ -78,9 +81,14 @@ class Identity:
|
||||
AES128_BLOCKSIZE = 16 # In bytes
|
||||
AES256_BLOCKSIZE = 16 # In bytes
|
||||
HASHLENGTH = 256 # In bits
|
||||
NAME_HASH_LENGTH = 80 # In bits
|
||||
SIGLENGTH = KEYSIZE # In bits
|
||||
STAMPLENGTH = 14 # In bytes
|
||||
EXTHEADERLENGTH = 2 # In bytes
|
||||
LRCOSTLENGTH = 2 # In bytes
|
||||
EXTPAYLOADLENGTH = EXTHEADERLENGTH+STAMPLENGTH+LRCOSTLENGTH
|
||||
EXTPAYLOADMARKER = 0xC1 # Never used at msgpack object boundaries
|
||||
|
||||
NAME_HASH_LENGTH = 80
|
||||
TRUNCATED_HASHLENGTH = RNS.Reticulum.TRUNCATED_HASHLENGTH
|
||||
"""
|
||||
Constant specifying the truncated hash length (in bits) used by Reticulum
|
||||
@@ -88,29 +96,34 @@ class Identity:
|
||||
"""
|
||||
|
||||
DERIVED_KEY_LENGTH = 512//8
|
||||
DERIVED_KEY_LENGTH_LEGACY = 256//8
|
||||
|
||||
# Storage
|
||||
known_destinations = {}
|
||||
known_destinations_store = None
|
||||
known_ratchets = {}
|
||||
|
||||
ratchet_persist_lock = threading.Lock()
|
||||
known_destinations_lock = threading.Lock()
|
||||
|
||||
@staticmethod
|
||||
def remember(packet_hash, destination_hash, public_key, app_data = None):
|
||||
if len(public_key) != Identity.KEYSIZE//8:
|
||||
raise TypeError("Can't remember "+RNS.prettyhexrep(destination_hash)+", the public key size of "+str(len(public_key))+" is not valid.", RNS.LOG_ERROR)
|
||||
def remember(packet_hash, destination_hash, public_key, app_data=None, stamp=None, stamp_value=0, lr_cost=None):
|
||||
if stamp_value == None: stamp_value = 0
|
||||
if len(public_key) != Identity.KEYSIZE//8: raise TypeError(f"Can't remember {RNS.prettyhexrep(destination_hash)}, the public key size of {len(public_key)} is not valid.", RNS.LOG_ERROR)
|
||||
else:
|
||||
with Identity.known_destinations_lock:
|
||||
if not destination_hash in Identity.known_destinations:
|
||||
Identity.known_destinations[destination_hash] = [time.time(), packet_hash, public_key, app_data, 0]
|
||||
Identity.known_destinations[destination_hash] = [time.time(), packet_hash, public_key, app_data, 0, stamp, stamp_value, lr_cost]
|
||||
else:
|
||||
entry = Identity.known_destinations[destination_hash]
|
||||
entry[0] = time.time()
|
||||
entry[1] = packet_hash
|
||||
entry[2] = public_key
|
||||
entry[3] = app_data
|
||||
entry[5] = stamp
|
||||
entry[6] = stamp_value
|
||||
entry[7] = lr_cost
|
||||
|
||||
Identity._kd_mark_dirty(destination_hash)
|
||||
|
||||
@staticmethod
|
||||
def recall(target_hash, from_identity_hash=False, _no_use=False):
|
||||
@@ -173,11 +186,40 @@ class Identity:
|
||||
|
||||
else: return None
|
||||
|
||||
@staticmethod
|
||||
def recall_stamp_value(destination_hash):
|
||||
"""
|
||||
Recall last heard announce stamp value for a destination hash.
|
||||
|
||||
:param destination_hash: Destination hash as *bytes*.
|
||||
:returns: *Float*, or *None* if the destination is unknown.
|
||||
"""
|
||||
known_destination = Identity.known_destinations.get(destination_hash)
|
||||
if not known_destination: return None
|
||||
else: return known_destination[6]
|
||||
|
||||
@staticmethod
|
||||
def recall_link_cost(destination_hash):
|
||||
"""
|
||||
Recall the link request stamp cost announced by a destination.
|
||||
|
||||
:param destination_hash: Destination hash as *bytes*.
|
||||
:returns: *Float*, or *None* if the destination is unknown or has not announced a cost.
|
||||
"""
|
||||
known_destination = Identity.known_destinations.get(destination_hash)
|
||||
if not known_destination: return None
|
||||
else: return known_destination[7]
|
||||
|
||||
@staticmethod
|
||||
def save_known_destinations(background=False, recombine=False):
|
||||
if recombine: RNS.log(f"Recombining known destinations from disk cache on persist is deprecated, argument ignored", RNS.LOG_WARNING)
|
||||
if RNS.Transport.owner.is_connected_to_shared_instance: return
|
||||
|
||||
|
||||
if Identity.known_destinations_store != None: Identity.flush_known_destinations()
|
||||
else: Identity.save_known_destinations_legacy(background=background)
|
||||
|
||||
@staticmethod
|
||||
def save_known_destinations_legacy(background=False):
|
||||
try:
|
||||
if hasattr(Identity, "saving_known_destinations"):
|
||||
wait_interval = 0.2
|
||||
@@ -214,6 +256,80 @@ class Identity:
|
||||
|
||||
@staticmethod
|
||||
def load_known_destinations():
|
||||
if RNS.Reticulum.get_instance().is_connected_to_shared_instance:
|
||||
try:
|
||||
store = KnownDestinationsStore(RNS.Reticulum.storagepath+"/known_destinations.db", hash_width=RNS.Reticulum.TRUNCATED_HASHLENGTH//8, read_only=True)
|
||||
count = 0
|
||||
with Identity.known_destinations_lock:
|
||||
for destination_hash, entry in store.load_all():
|
||||
Identity.known_destinations[destination_hash] = entry
|
||||
count += 1
|
||||
|
||||
store.close()
|
||||
RNS.log(f"Loaded {count} known destinations from shared instance", RNS.LOG_VERBOSE)
|
||||
|
||||
except Exception as e:
|
||||
try:
|
||||
RNS.log(f"Could not load known destinations from shared instance database: {e}", RNS.LOG_DEBUG)
|
||||
RNS.log(f"Potentially running in split mode, attempting to load known destinations over RPC...", RNS.LOG_DEBUG)
|
||||
known_destinations = RNS.Reticulum.get_instance().get_known_destinations() or {}
|
||||
with Identity.known_destinations_lock: Identity.known_destinations = known_destinations
|
||||
RNS.log(f"Loaded {len(Identity.known_destinations)} known destinations from shared instance", RNS.LOG_VERBOSE)
|
||||
|
||||
except Exception as e:
|
||||
with Identity.known_destinations_lock: Identity.known_destinations = {}
|
||||
RNS.log(f"Could not load known destinations from shared instance: {e}", RNS.LOG_ERROR)
|
||||
|
||||
return
|
||||
|
||||
store = None
|
||||
try: store = KnownDestinationsStore(RNS.Reticulum.storagepath+"/known_destinations.db", hash_width=RNS.Reticulum.TRUNCATED_HASHLENGTH//8)
|
||||
except Exception as e:
|
||||
RNS.log("Could not initialise known destinations database, falling back to legacy snapshot persistence. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
Identity.known_destinations_store = None
|
||||
|
||||
if store != None:
|
||||
Identity.known_destinations_store = store
|
||||
|
||||
legacy_path = RNS.Reticulum.storagepath+"/known_destinations"
|
||||
if os.path.isfile(legacy_path):
|
||||
try:
|
||||
imported = store.import_legacy(legacy_path)
|
||||
os.rename(legacy_path, legacy_path+".imported")
|
||||
RNS.log(f"Imported {imported} known destinations from legacy storage into the known destinations database", RNS.LOG_VERBOSE)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Could not import legacy known destinations file into the known destinations database. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
RNS.trace_exception(e)
|
||||
|
||||
st = time.time()
|
||||
try:
|
||||
count = 0
|
||||
with Identity.known_destinations_lock:
|
||||
for destination_hash, entry in store.load_all():
|
||||
Identity.known_destinations[destination_hash] = entry
|
||||
count += 1
|
||||
|
||||
RNS.log(f"Loaded {count} known destinations from storage in {RNS.prettyshorttime(time.time()-st)}", RNS.LOG_VERBOSE)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error loading known destinations from storage, continuing with an empty table", RNS.LOG_ERROR)
|
||||
RNS.trace_exception(e)
|
||||
|
||||
ratchetdir = RNS.Reticulum.storagepath+"/ratchets"
|
||||
if os.path.isdir(ratchetdir) and len(os.listdir(ratchetdir)) > 0:
|
||||
try:
|
||||
imported = store.import_legacy_ratchets(ratchetdir, time.time()-Identity.RATCHET_EXPIRY, Identity.known_destinations)
|
||||
RNS.log(f"Imported {imported} ratchets from legacy file storage", RNS.LOG_VERBOSE)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Could not import legacy ratchet files into the known destinations database. The contained exception was: {e}", RNS.LOG_ERROR)
|
||||
RNS.trace_exception(e)
|
||||
|
||||
else: Identity.load_known_destinations_legacy()
|
||||
|
||||
@staticmethod
|
||||
def load_known_destinations_legacy():
|
||||
if os.path.isfile(RNS.Reticulum.storagepath+"/known_destinations"):
|
||||
st = time.time()
|
||||
try:
|
||||
@@ -225,7 +341,11 @@ class Identity:
|
||||
if len(known_destination) == RNS.Reticulum.TRUNCATED_HASHLENGTH//8:
|
||||
if len(loaded_known_destinations[known_destination]) < 5:
|
||||
e = loaded_known_destinations[known_destination]
|
||||
loaded_known_destinations[known_destination] = [e[0], e[1], e[2], e[3], 0]
|
||||
loaded_known_destinations[known_destination] = [e[0], e[1], e[2], e[3], 0, None, 0, None]
|
||||
elif len(loaded_known_destinations[known_destination]) < 8:
|
||||
e = loaded_known_destinations[known_destination]
|
||||
while len(e) < 8: e.append(None if len(e) in (5, 7) else 0)
|
||||
loaded_known_destinations[known_destination] = e
|
||||
|
||||
with Identity.known_destinations_lock:
|
||||
Identity.known_destinations[known_destination] = loaded_known_destinations[known_destination]
|
||||
@@ -244,6 +364,7 @@ class Identity:
|
||||
if destination_hash in Identity.known_destinations:
|
||||
if not Identity.known_destinations[destination_hash][4] < 0:
|
||||
Identity.known_destinations[destination_hash][4] = time.time()
|
||||
Identity._kd_mark_dirty(destination_hash)
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -253,6 +374,7 @@ class Identity:
|
||||
with Identity.known_destinations_lock:
|
||||
if destination_hash in Identity.known_destinations:
|
||||
Identity.known_destinations[destination_hash][4] = -1
|
||||
Identity._kd_mark_dirty(destination_hash)
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -262,6 +384,7 @@ class Identity:
|
||||
with Identity.known_destinations_lock:
|
||||
if destination_hash in Identity.known_destinations:
|
||||
Identity.known_destinations[destination_hash][4] = time.time()
|
||||
Identity._kd_mark_dirty(destination_hash)
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -327,7 +450,7 @@ class Identity:
|
||||
|
||||
if not is_retained and not has_path:
|
||||
if not was_used and now - last_announce > RNS.Transport.UNUSED_DESTINATION_LINGER: stale.append(destination_hash)
|
||||
elif unused_for > RNS.Transport.DESTINATION_TIMEOUT*1.25: stale.append(destination_hash)
|
||||
elif unused_for > RNS.Transport.PATH_TIMEOUT*1.25: stale.append(destination_hash)
|
||||
|
||||
except Exception as e: RNS.log(f"Faulty entry for {RNS.prettyhexrep(destination_hash)} while cleaning known destinations: {e}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
|
||||
@@ -336,13 +459,23 @@ class Identity:
|
||||
with Identity.known_destinations_lock:
|
||||
if destination_hash in Identity.known_destinations:
|
||||
Identity.known_destinations.pop(destination_hash)
|
||||
Identity._kd_mark_deleted(destination_hash)
|
||||
if destination_hash in Identity.known_ratchets: Identity.known_ratchets.pop(destination_hash)
|
||||
removed += 1
|
||||
|
||||
try:
|
||||
hexhash = RNS.hexrep(destination_hash, delimit=False)
|
||||
ratchet_path = f"{ratchetdir}/{hexhash}"
|
||||
if os.path.isfile(ratchet_path): os.unlink(ratchet_path)
|
||||
except Exception as e: RNS.log(f"Could not clean stale ratchets for {RNS.prettyhexrep(destination_hash)}: {e}", RNS.LOG_WARNING)
|
||||
if not Identity.known_destinations_store:
|
||||
try:
|
||||
hexhash = RNS.hexrep(destination_hash, delimit=False)
|
||||
ratchet_path = f"{ratchetdir}/{hexhash}"
|
||||
if os.path.isfile(ratchet_path): os.unlink(ratchet_path)
|
||||
except Exception as e: RNS.log(f"Could not clean stale ratchets for {RNS.prettyhexrep(destination_hash)}: {e}", RNS.LOG_WARNING)
|
||||
|
||||
if Identity.known_destinations_store != None:
|
||||
expired_ratchets = Identity.known_destinations_store.expire_ratchets(time.time()-Identity.RATCHET_EXPIRY)
|
||||
if len(expired_ratchets) > 0:
|
||||
for destination_hash in expired_ratchets:
|
||||
with Identity.known_destinations_lock:
|
||||
if destination_hash in Identity.known_ratchets: Identity.known_ratchets.pop(destination_hash)
|
||||
|
||||
RNS.log(f"Cleaned known destinations in {RNS.prettyshorttime(time.time()-st)}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
RNS.log(f"Total: {total}, stale: {len(stale)}, removed: {removed}, no path: {no_path}, never used: {never_used}, with path: {total-no_path}, used: {total-never_used}, retained: {retained}", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
@@ -409,33 +542,40 @@ class Identity:
|
||||
@staticmethod
|
||||
def _remember_ratchet(destination_hash, ratchet):
|
||||
try:
|
||||
if destination_hash in Identity.known_ratchets and Identity.known_ratchets[destination_hash] == ratchet:
|
||||
ratchet_exists = True
|
||||
# Don't re-insert existing ratchet
|
||||
if Identity.known_ratchets.get(destination_hash) == ratchet: return
|
||||
|
||||
store = Identity.known_destinations_store
|
||||
if store != None:
|
||||
# Persist to store, only update in-memory cache if this
|
||||
# destination already exists there.
|
||||
store.remember_ratchet(destination_hash, ratchet, time.time())
|
||||
if destination_hash in Identity.known_ratchets:
|
||||
Identity.known_ratchets[destination_hash] = ratchet
|
||||
|
||||
# Legacy store: Use file system
|
||||
# Shared instance client: Just keep in memory cache
|
||||
else:
|
||||
ratchet_exists = False
|
||||
ratchet_exists = destination_hash in Identity.known_ratchets and Identity.known_ratchets[destination_hash] == ratchet
|
||||
if not ratchet_exists:
|
||||
RNS.log(f"Remembering ratchet {RNS.prettyhexrep(Identity._get_ratchet_id(ratchet))} for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
Identity.known_ratchets[destination_hash] = ratchet
|
||||
if not RNS.Transport.owner.is_connected_to_shared_instance:
|
||||
def persist_job():
|
||||
with Identity.ratchet_persist_lock:
|
||||
hexhash = RNS.hexrep(destination_hash, delimit=False)
|
||||
ratchet_data = {"ratchet": ratchet, "received": time.time()}
|
||||
|
||||
if not ratchet_exists:
|
||||
RNS.log(f"Remembering ratchet {RNS.prettyhexrep(Identity._get_ratchet_id(ratchet))} for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
Identity.known_ratchets[destination_hash] = ratchet
|
||||
if not RNS.Transport.owner.is_connected_to_shared_instance:
|
||||
def persist_job():
|
||||
with Identity.ratchet_persist_lock:
|
||||
hexhash = RNS.hexrep(destination_hash, delimit=False)
|
||||
ratchet_data = {"ratchet": ratchet, "received": time.time()}
|
||||
ratchetdir = RNS.Reticulum.storagepath+"/ratchets"
|
||||
|
||||
ratchetdir = RNS.Reticulum.storagepath+"/ratchets"
|
||||
|
||||
if not os.path.isdir(ratchetdir):
|
||||
os.makedirs(ratchetdir)
|
||||
if not os.path.isdir(ratchetdir): os.makedirs(ratchetdir)
|
||||
|
||||
outpath = f"{ratchetdir}/{hexhash}.out"
|
||||
finalpath = f"{ratchetdir}/{hexhash}"
|
||||
with open(outpath, "wb") as ratchet_file:
|
||||
ratchet_file.write(umsgpack.packb(ratchet_data))
|
||||
os.replace(outpath, finalpath)
|
||||
outpath = f"{ratchetdir}/{hexhash}.out"
|
||||
finalpath = f"{ratchetdir}/{hexhash}"
|
||||
with open(outpath, "wb") as ratchet_file: ratchet_file.write(umsgpack.packb(ratchet_data))
|
||||
os.replace(outpath, finalpath)
|
||||
|
||||
|
||||
threading.Thread(target=persist_job, daemon=True).start()
|
||||
threading.Thread(target=persist_job, daemon=True).start()
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Could not persist ratchet for {RNS.prettyhexrep(destination_hash)} to storage.", RNS.LOG_ERROR)
|
||||
@@ -444,6 +584,7 @@ class Identity:
|
||||
|
||||
@staticmethod
|
||||
def _clean_ratchets():
|
||||
if Identity.known_destinations_store != None: return
|
||||
RNS.log("Cleaning ratchets...", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
try:
|
||||
count = 0
|
||||
@@ -483,7 +624,43 @@ class Identity:
|
||||
|
||||
@staticmethod
|
||||
def get_ratchet(destination_hash):
|
||||
if not destination_hash in Identity.known_ratchets:
|
||||
if destination_hash in Identity.known_ratchets: return Identity.known_ratchets[destination_hash]
|
||||
|
||||
store = Identity.known_destinations_store
|
||||
if store != None:
|
||||
ratchet_data = store.fetch_ratchet(destination_hash)
|
||||
if ratchet_data != None:
|
||||
ratchet, received = ratchet_data
|
||||
if time.time() < received+Identity.RATCHET_EXPIRY:
|
||||
Identity.known_ratchets[destination_hash] = ratchet
|
||||
return ratchet
|
||||
|
||||
else: return None
|
||||
|
||||
else:
|
||||
RNS.log(f"Could not load ratchet for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
return None
|
||||
|
||||
elif RNS.Reticulum.get_instance().is_connected_to_shared_instance:
|
||||
try:
|
||||
# TODO: Ideally, refactor this to an RPC method instead
|
||||
store = KnownDestinationsStore(RNS.Reticulum.storagepath+"/known_destinations.db", hash_width=RNS.Reticulum.TRUNCATED_HASHLENGTH//8, read_only=True)
|
||||
ratchet_data = store.fetch_ratchet(destination_hash)
|
||||
store.close()
|
||||
|
||||
if ratchet_data != None:
|
||||
ratchet, received = ratchet_data
|
||||
if time.time() < received+Identity.RATCHET_EXPIRY:
|
||||
Identity.known_ratchets[destination_hash] = ratchet
|
||||
return ratchet
|
||||
|
||||
except Exception as e: RNS.log(f"Could not fetch ratchet for {RNS.prettyhexrep(destination_hash)} from shared instance database. The contained exception was: {e}", RNS.LOG_ERROR)
|
||||
|
||||
return None
|
||||
|
||||
else:
|
||||
if not os.path.isfile(RNS.Reticulum.storagepath+"/ratchets/"+RNS.hexrep(destination_hash, delimit=False)): return None
|
||||
|
||||
ratchetdir = RNS.Reticulum.storagepath+"/ratchets"
|
||||
hexhash = RNS.hexrep(destination_hash, delimit=False)
|
||||
ratchet_path = f"{ratchetdir}/{hexhash}"
|
||||
@@ -493,22 +670,138 @@ class Identity:
|
||||
ratchet_data = umsgpack.unpackb(ratchet_file.read())
|
||||
if time.time() < ratchet_data["received"]+Identity.RATCHET_EXPIRY and len(ratchet_data["ratchet"]) == Identity.RATCHETSIZE//8:
|
||||
Identity.known_ratchets[destination_hash] = ratchet_data["ratchet"]
|
||||
else:
|
||||
return None
|
||||
|
||||
else: return None
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"An error occurred while loading ratchet data for {RNS.prettyhexrep(destination_hash)} from storage.", RNS.LOG_ERROR)
|
||||
RNS.log(f"The contained exception was: {e}", RNS.LOG_ERROR)
|
||||
return None
|
||||
|
||||
if destination_hash in Identity.known_ratchets:
|
||||
return Identity.known_ratchets[destination_hash]
|
||||
if destination_hash in Identity.known_ratchets: return Identity.known_ratchets[destination_hash]
|
||||
else:
|
||||
RNS.log(f"Could not load ratchet for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def validate_announce(packet, only_validate_signature=False, signal_blackholed=False):
|
||||
def _reset_validation_caches():
|
||||
Identity.announce_valid_cache = {}
|
||||
Identity.announce_invalid_cache = {}
|
||||
|
||||
__valid_cache_count = 0
|
||||
__valid_cache_max = 384
|
||||
@staticmethod
|
||||
def __cache_valid_announce(result):
|
||||
Identity.__valid_cache_count += 1
|
||||
result["id"] = Identity.__valid_cache_count
|
||||
packet_hash = result["packet_hash"]
|
||||
if packet_hash and not packet_hash in Identity.announce_valid_cache:
|
||||
Identity.announce_valid_cache[packet_hash] = result
|
||||
|
||||
Identity.announce_invalid_cache.pop(packet_hash, None)
|
||||
|
||||
try:
|
||||
while len(Identity.announce_valid_cache) > Identity.__valid_cache_max:
|
||||
Identity.announce_valid_cache.pop(next(iter(Identity.announce_valid_cache)))
|
||||
except Exception as e: RNS.log(f"Error while culling announce validation cache: {e}", RNS.LOG_DEBUG)
|
||||
|
||||
return True
|
||||
|
||||
__invalid_cache_count = 0
|
||||
__invalid_cache_max = 384
|
||||
@staticmethod
|
||||
def __cache_invalid_announce(packet, signal=None, stamp_value=None):
|
||||
Identity.__invalid_cache_count += 1
|
||||
result = (signal or False, stamp_value)
|
||||
if packet.packet_hash: Identity.announce_invalid_cache[packet.packet_hash] = result
|
||||
|
||||
try:
|
||||
while len(Identity.announce_invalid_cache) > Identity.__invalid_cache_max:
|
||||
Identity.announce_invalid_cache.pop(next(iter(Identity.announce_invalid_cache)))
|
||||
except Exception as e: RNS.log(f"Error while culling announce invalidation cache: {e}", RNS.LOG_DEBUG)
|
||||
|
||||
return result[0]
|
||||
|
||||
@staticmethod
|
||||
def __finalize_av(r, cache_hit=False):
|
||||
# We are also re-persisting here on cache hit in the edge (but very possible) case
|
||||
# that a path was culled (for example because of interface teardown), and its
|
||||
# associated destination data was removed. Known destinations must always cover
|
||||
# what is in the path table, anything else is state inconsintency.
|
||||
if not cache_hit or not r["destination_hash"] in Identity.known_destinations:
|
||||
RNS.Identity.remember(r["packet_hash"], r["destination_hash"], r["public_key"], app_data=r["app_data"],
|
||||
stamp=r["stamp"], stamp_value=r["stamp_value"], lr_cost=r["lr_cost"])
|
||||
|
||||
if r["ratchet"]: Identity._remember_ratchet(r["destination_hash"], r["ratchet"])
|
||||
|
||||
valid_announce_loglevel = RNS.LOG_EXTREME
|
||||
if RNS.sl(valid_announce_loglevel):
|
||||
if r["rssi"] != None or r["snr"] != None:
|
||||
signal_str = " ["
|
||||
if r["rssi"] != None:
|
||||
signal_str += "RSSI "+str(r["rssi"])+"dBm"
|
||||
if r["snr"] != None: signal_str += ", "
|
||||
if r["snr"] != None: signal_str += "SNR "+str(r["snr"])+"dB"
|
||||
signal_str += "]"
|
||||
else: signal_str = ""
|
||||
|
||||
via_str = f" via {RNS.prettyhexrep(r['transport_id'])}" if r["transport_id"] else ""
|
||||
val_str = f" (v:{RNS.prettycost(r['stamp_value'])})"
|
||||
RNS.log(f"Valid announce for {RNS.prettyhexrep(r['destination_hash'])}{val_str} {r['hops']} hops away, received{via_str} on {r['receiving_interface']}{signal_str}", valid_announce_loglevel)
|
||||
|
||||
return True
|
||||
|
||||
announce_valid_cache = {}
|
||||
announce_invalid_cache = {}
|
||||
|
||||
@staticmethod
|
||||
def validate_announce(packet, only_validate_signature=False, signal_blackholed=False, signal_stamp=False, required_value=None):
|
||||
# Check cached announce invalidations
|
||||
cached_invalidation = Identity.announce_invalid_cache.get(packet.packet_hash, None)
|
||||
if cached_invalidation:
|
||||
try:
|
||||
if cached_invalidation[0] != "invalid_stamp":
|
||||
if cached_invalidation[0] == "no_stamp": return cached_invalidation[0] if signal_stamp else False
|
||||
elif cached_invalidation[0] == "blackholed": return cached_invalidation[0] if signal_blackholed else False
|
||||
else: return False
|
||||
elif cached_invalidation[1] != None:
|
||||
rcvd_value = quantize_cost(cached_invalidation[1])
|
||||
if packet.receiving_interface: cost_target = packet.receiving_interface.destination_cost
|
||||
else: cost_target = RNS.Transport.DESTINATION_COST
|
||||
if quantize_cost(cost_target) > quantize_cost(rcvd_value): return "invalid_stamp" if signal_stamp else False
|
||||
else: pass # Stamp value above target for this interface, allow re-validation
|
||||
else:
|
||||
RNS.log(f"Incoherent state in cached announce invalidation, rejecting announce", RNS.LOG_WARNING)
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Error while processing cached invalid announce: {e}", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
# Check cached announce validations
|
||||
cached_validation = Identity.announce_valid_cache.get(packet.packet_hash, None)
|
||||
if cached_validation:
|
||||
try:
|
||||
if RNS.Transport.STAMPS_ENABLED and RNS.Transport.STAMPS_ENFORCED:
|
||||
if required_value == None:
|
||||
if packet.receiving_interface: cost_target = packet.receiving_interface.destination_cost
|
||||
else: cost_target = RNS.Transport.DESTINATION_COST
|
||||
else: cost_target = required_value
|
||||
|
||||
cached_stamp_value = cached_validation.get("stamp_value", None)
|
||||
if cached_stamp_value == None: return "no_stamp" if signal_stamp else False
|
||||
elif quantize_cost(cost_target) > quantize_cost(cached_stamp_value):
|
||||
return "invalid_stamp" if signal_stamp else False
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Error while processing cached valid announce: {e}", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
return Identity.__finalize_av(cached_validation, cache_hit=True)
|
||||
|
||||
if required_value == None:
|
||||
if packet.receiving_interface: required_value = packet.receiving_interface.destination_cost
|
||||
else: required_value = RNS.Transport.DESTINATION_COST
|
||||
|
||||
try:
|
||||
if packet.packet_type == RNS.Packet.ANNOUNCE:
|
||||
keysize = Identity.KEYSIZE//8
|
||||
@@ -520,11 +813,14 @@ class Identity:
|
||||
# Get public key bytes from announce
|
||||
public_key = packet.data[:keysize]
|
||||
|
||||
# Shared format structure
|
||||
ratchet = b""
|
||||
name_hash = packet.data[keysize:keysize+name_hash_len]
|
||||
random_hash = packet.data[keysize+name_hash_len:keysize+name_hash_len+10]
|
||||
|
||||
# If the packet context flag is set,
|
||||
# this announce contains a new ratchet
|
||||
if packet.context_flag == RNS.Packet.FLAG_SET:
|
||||
name_hash = packet.data[keysize:keysize+name_hash_len ]
|
||||
random_hash = packet.data[keysize+name_hash_len:keysize+name_hash_len+10]
|
||||
ratchet = packet.data[keysize+name_hash_len+10:keysize+name_hash_len+10+ratchetsize]
|
||||
signature = packet.data[keysize+name_hash_len+10+ratchetsize:keysize+name_hash_len+10+ratchetsize+sig_len]
|
||||
app_data = b""
|
||||
@@ -534,9 +830,6 @@ class Identity:
|
||||
# If the packet context flag is not set,
|
||||
# this announce does not contain a ratchet
|
||||
else:
|
||||
ratchet = b""
|
||||
name_hash = packet.data[keysize:keysize+name_hash_len]
|
||||
random_hash = packet.data[keysize+name_hash_len:keysize+name_hash_len+10]
|
||||
signature = packet.data[keysize+name_hash_len+10:keysize+name_hash_len+10+sig_len]
|
||||
app_data = b""
|
||||
if len(packet.data) > keysize+name_hash_len+10+sig_len:
|
||||
@@ -547,14 +840,70 @@ class Identity:
|
||||
if not len(packet.data) > Identity.KEYSIZE//8+Identity.NAME_HASH_LENGTH//8+10+Identity.SIGLENGTH//8:
|
||||
app_data = None
|
||||
|
||||
stamp = None
|
||||
dst_stamped = None
|
||||
dst_value = None
|
||||
stamp_validated = None
|
||||
dst_lr_cost = None
|
||||
if RNS.Transport.STAMPS_ENABLED and app_data and len(app_data) >= Identity.EXTPAYLOADLENGTH:
|
||||
ext_payload = app_data[-Identity.EXTPAYLOADLENGTH:]
|
||||
ext_header = ext_payload[:Identity.EXTHEADERLENGTH]
|
||||
ext_flags = ext_header[1] # Reserved for future extensions
|
||||
ext_anchor = ext_payload[-1]
|
||||
|
||||
# The ext_anchor carries the lr_cost integer part, and a
|
||||
# reserved flag in the MSB. The fractional part of the
|
||||
# lr_cost is stored in the immediately preceding byte.
|
||||
ext_extended = (ext_anchor & 0x80) != 0
|
||||
ext_lr_cost_i = ext_anchor & 0x7F
|
||||
ext_lr_cost_m = ext_payload[-2]
|
||||
cost_bytes = bytes([ext_lr_cost_i, ext_lr_cost_m])
|
||||
ext_lr_cost = cost_from_bytes(cost_bytes)
|
||||
known_format = (not ext_extended) and (ext_lr_cost <= RNS.Transport.STAMP_COST_CAP)
|
||||
|
||||
if (not ext_header[0] == Identity.EXTPAYLOADMARKER) or (not known_format): dst_stamped = False
|
||||
else:
|
||||
# RNS.log(f"Checking potential stamp in announce with app_data len {len(app_data)} for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_DEBUG) # TODO: Remove after 1.6.1
|
||||
dst_stamped = True
|
||||
try:
|
||||
stamp = ext_payload[Identity.EXTHEADERLENGTH:Identity.EXTHEADERLENGTH+Identity.STAMPLENGTH]
|
||||
material = destination_hash+public_key+name_hash
|
||||
wb = stamp_workblock(material, expand_rounds=0)
|
||||
valid = stamp_valid(stamp, required_value, wb)
|
||||
dst_value = stamp_value(wb, stamp)
|
||||
|
||||
if valid:
|
||||
app_data = app_data[:-Identity.EXTPAYLOADLENGTH]
|
||||
if not len(app_data): app_data = None
|
||||
stamp_validated = True
|
||||
dst_lr_cost = ext_lr_cost
|
||||
|
||||
except Exception as e: RNS.log(f"Announce stamp parsing failed: {e}", RNS.LOG_ERROR)
|
||||
|
||||
# TODO: Initial debug only, remove ######
|
||||
# if RNS.sl(RNS.LOG_DEBUG):
|
||||
# if not dst_stamped: RNS.log(f"No stamp on announce from {RNS.prettyhexrep(destination_hash)}", RNS.LOG_DEBUG)
|
||||
# else:
|
||||
# if not stamp_validated: RNS.log(f"Invalid or insufficient-value stamp for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_DEBUG)
|
||||
# else: RNS.log(f"Valid stamp with value {dst_value} for {RNS.prettyhexrep(destination_hash)}", RNS.LOG_DEBUG)
|
||||
#########################################
|
||||
|
||||
if RNS.Transport.STAMPS_ENABLED and RNS.Transport.STAMPS_ENFORCED:
|
||||
if not dst_stamped:
|
||||
if signal_stamp: return Identity.__cache_invalid_announce(packet, "no_stamp")
|
||||
else: return Identity.__cache_invalid_announce(packet)
|
||||
elif not stamp_validated:
|
||||
if signal_stamp: return Identity.__cache_invalid_announce(packet, "invalid_stamp", dst_value)
|
||||
else: return Identity.__cache_invalid_announce(packet)
|
||||
|
||||
announced_identity = Identity(create_keys=False)
|
||||
announced_identity.load_public_key(public_key)
|
||||
|
||||
if len(RNS.Transport.blackholed_identities) > 0:
|
||||
if announced_identity.hash in RNS.Transport.blackholed_identities:
|
||||
RNS.log(f"Invalidated and dropped announce from blackholed identity {RNS.prettyhexrep(announced_identity.hash)}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
if signal_blackholed: return "blackholed"
|
||||
else: return False
|
||||
if signal_blackholed: return Identity.__cache_invalid_announce(packet, "blackholed")
|
||||
else: return Identity.__cache_invalid_announce(packet)
|
||||
|
||||
if announced_identity.pub != None and (packet.announce_signature_validated or announced_identity.validate(signature, signed_data)):
|
||||
packet.announce_signature_validated = True
|
||||
@@ -564,6 +913,7 @@ class Identity:
|
||||
|
||||
hash_material = name_hash+announced_identity.hash
|
||||
expected_hash = RNS.Identity.full_hash(hash_material)[:RNS.Reticulum.TRUNCATED_HASHLENGTH//8]
|
||||
del announced_identity
|
||||
|
||||
if destination_hash == expected_hash:
|
||||
# Check if we already have a public key for this destination
|
||||
@@ -574,52 +924,63 @@ class Identity:
|
||||
# that someone manages a hash collision, we reject the announce.
|
||||
RNS.log("Received announce with valid signature and destination hash, but announced public key does not match already known public key.", RNS.LOG_CRITICAL)
|
||||
RNS.log("This may indicate an attempt to modify network paths, or a random hash collision. The announce was rejected.", RNS.LOG_CRITICAL)
|
||||
return False
|
||||
return Identity.__cache_invalid_announce(packet)
|
||||
|
||||
RNS.Identity.remember(packet.get_hash(), destination_hash, public_key, app_data)
|
||||
del announced_identity
|
||||
validation_result = { "packet_hash": packet.packet_hash, "destination_hash": destination_hash,
|
||||
"public_key": public_key, "ratchet": ratchet, "app_data": app_data, "stamp": stamp,
|
||||
"stamp_value": dst_value, "lr_cost": dst_lr_cost, "transport_id": packet.transport_id,
|
||||
"hops": packet.hops, "receiving_interface": str(packet.receiving_interface),
|
||||
"rssi": packet.rssi, "snr": packet.snr, "q": packet.q }
|
||||
|
||||
if packet.rssi != None or packet.snr != None:
|
||||
signal_str = " ["
|
||||
if packet.rssi != None:
|
||||
signal_str += "RSSI "+str(packet.rssi)+"dBm"
|
||||
if packet.snr != None: signal_str += ", "
|
||||
if packet.snr != None: signal_str += "SNR "+str(packet.snr)+"dB"
|
||||
signal_str += "]"
|
||||
|
||||
else: signal_str = ""
|
||||
|
||||
if hasattr(packet, "transport_id") and packet.transport_id != None:
|
||||
RNS.log("Valid announce for "+RNS.prettyhexrep(destination_hash)+" "+str(packet.hops)+" hops away, received via "+RNS.prettyhexrep(packet.transport_id)+" on "+str(packet.receiving_interface)+signal_str, RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
else:
|
||||
RNS.log("Valid announce for "+RNS.prettyhexrep(destination_hash)+" "+str(packet.hops)+" hops away, received on "+str(packet.receiving_interface)+signal_str, RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
|
||||
if ratchet: Identity._remember_ratchet(destination_hash, ratchet)
|
||||
|
||||
return True
|
||||
Identity.__finalize_av(validation_result)
|
||||
return Identity.__cache_valid_announce(validation_result)
|
||||
|
||||
else:
|
||||
RNS.log("Received invalid announce for "+RNS.prettyhexrep(destination_hash)+": Destination mismatch.", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
return False
|
||||
return Identity.__cache_invalid_announce(packet)
|
||||
|
||||
else:
|
||||
RNS.log("Received invalid announce for "+RNS.prettyhexrep(destination_hash)+": Invalid signature.", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
del announced_identity
|
||||
return False
|
||||
return Identity.__cache_invalid_announce(packet)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Error occurred while validating announce. The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||
RNS.trace_exception(e) # TODO: Remove debug
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def persist_data(background=False):
|
||||
if not RNS.Transport.owner.is_connected_to_shared_instance:
|
||||
Identity.save_known_destinations(background=background)
|
||||
if hasattr(RNS.Transport, "owner") and not RNS.Transport.owner.is_connected_to_shared_instance:
|
||||
if Identity.known_destinations_store != None: Identity.flush_known_destinations()
|
||||
else: Identity.save_known_destinations_legacy(background=background)
|
||||
|
||||
@staticmethod
|
||||
def exit_handler():
|
||||
Identity.persist_data()
|
||||
def flush_known_destinations():
|
||||
store = Identity.known_destinations_store
|
||||
if store == None: return False
|
||||
|
||||
with Identity.known_destinations_lock: upserts, deletes, ratchet_upserts, ratchet_deletes = store.take_pending()
|
||||
|
||||
try: return store.apply(upserts, deletes, ratchet_upserts, ratchet_deletes, Identity.known_destinations)
|
||||
except Exception as e:
|
||||
RNS.log(f"Could not flush known destinations to storage. The contained exception was: {e}", RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _kd_mark_dirty(destination_hash):
|
||||
store = Identity.known_destinations_store
|
||||
if store != None: store.mark_dirty(destination_hash)
|
||||
|
||||
@staticmethod
|
||||
def _kd_mark_deleted(destination_hash):
|
||||
store = Identity.known_destinations_store
|
||||
if store != None:
|
||||
store.mark_deleted(destination_hash)
|
||||
store.mark_ratchet_deleted(destination_hash)
|
||||
|
||||
@staticmethod
|
||||
def exit_handler(): Identity.persist_data()
|
||||
|
||||
@staticmethod
|
||||
def from_bytes(prv_bytes):
|
||||
@@ -686,7 +1047,7 @@ class Identity:
|
||||
RNS.log("Error while saving identity to "+str(path), RNS.LOG_ERROR)
|
||||
RNS.log("The contained exception was: "+str(e))
|
||||
|
||||
def __init__(self,create_keys=True):
|
||||
def __init__(self, create_keys=True, value=None):
|
||||
# Initialize keys to none
|
||||
self.prv = None
|
||||
self.prv_bytes = None
|
||||
@@ -702,25 +1063,43 @@ class Identity:
|
||||
self.hexhash = None
|
||||
|
||||
if create_keys:
|
||||
self.create_keys()
|
||||
|
||||
def create_keys(self):
|
||||
self.prv = X25519PrivateKey.generate()
|
||||
self.prv_bytes = self.prv.private_bytes()
|
||||
self.create_keys(value=value)
|
||||
|
||||
def create_keys(self, value=None):
|
||||
self.sig_prv = Ed25519PrivateKey.generate()
|
||||
self.sig_pub = self.sig_prv.public_key()
|
||||
self.sig_prv_bytes = self.sig_prv.private_bytes()
|
||||
self.sig_pub_bytes = self.sig_pub.public_bytes()
|
||||
|
||||
if not value:
|
||||
self.prv = X25519PrivateKey.generate()
|
||||
self.prv_bytes = self.prv.private_bytes()
|
||||
|
||||
else:
|
||||
stamped_key, v = generate_stamped_key(material=self.sig_pub_bytes, stamp_cost=value)
|
||||
if not stamped_key: raise RuntimeError("Stamped identity key generation failed or was cancelled")
|
||||
|
||||
stamped_prv = stamped_key[0]
|
||||
self.prv = X25519PrivateKey.from_private_bytes(stamped_prv)
|
||||
self.prv_bytes = self.prv.private_bytes()
|
||||
|
||||
assert self.prv_bytes == stamped_prv
|
||||
assert self.prv.public_key().public_bytes() == stamped_key[1]
|
||||
|
||||
self.pub = self.prv.public_key()
|
||||
self.pub_bytes = self.pub.public_bytes()
|
||||
|
||||
self.sig_pub = self.sig_prv.public_key()
|
||||
self.sig_pub_bytes = self.sig_pub.public_bytes()
|
||||
|
||||
self.update_hashes()
|
||||
|
||||
RNS.log("Identity keys created for "+RNS.prettyhexrep(self.hash), RNS.LOG_VERBOSE)
|
||||
|
||||
def get_value(self):
|
||||
"""
|
||||
:returns: The stamp value of this identity as a *float*
|
||||
"""
|
||||
if not self.get_public_key(): return None
|
||||
else: return stamp_value(self.sig_pub_bytes, self.pub_bytes)
|
||||
|
||||
def get_private_key(self):
|
||||
"""
|
||||
:returns: The private key as *bytes*
|
||||
|
||||
@@ -266,9 +266,7 @@ class AX25KISSInterface(Interface):
|
||||
|
||||
|
||||
def process_incoming(self, data):
|
||||
if (len(data) > AX25.HEADER_SIZE):
|
||||
self.rxb += len(data)
|
||||
self.owner.inbound(data[AX25.HEADER_SIZE:], self)
|
||||
if (len(data) > AX25.HEADER_SIZE): self.owner.inbound(data[AX25.HEADER_SIZE:], self)
|
||||
|
||||
|
||||
def process_outgoing(self,data):
|
||||
|
||||
@@ -500,6 +500,7 @@ class RNodeInterface(Interface):
|
||||
self.r_interference = None
|
||||
self.r_interference_l = None
|
||||
self.r_temperature = None
|
||||
self.reports_phy_stats = True
|
||||
|
||||
self.r_battery_state = RNodeInterface.BATTERY_STATE_UNKNOWN
|
||||
self.r_battery_percent = 0
|
||||
|
||||
@@ -557,6 +557,9 @@ class AutoInterface(Interface):
|
||||
spawned_interface.ec_pr_freq = self.ec_pr_freq
|
||||
spawned_interface.ic_pr_burst_freq_new = self.ic_pr_burst_freq_new
|
||||
spawned_interface.ic_pr_burst_freq = self.ic_pr_burst_freq
|
||||
|
||||
spawned_interface._destination_cost = self._destination_cost
|
||||
spawned_interface._pr_cost = self._pr_cost
|
||||
|
||||
spawned_interface.parent_interface = self
|
||||
spawned_interface.bitrate = self.bitrate
|
||||
@@ -660,8 +663,6 @@ class AutoInterfacePeer(Interface):
|
||||
self.owner.refresh_peer(self.addr)
|
||||
self.owner.mif_deque.append(data_hash)
|
||||
self.owner.mif_deque_times.append([data_hash, time.time()])
|
||||
self.rxb += len(data)
|
||||
self.owner.rxb += len(data)
|
||||
self.owner.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self, data):
|
||||
|
||||
@@ -52,6 +52,8 @@ class BackboneInterface(Interface):
|
||||
fast_flapping_lock = threading.Lock()
|
||||
fast_flapping = {}
|
||||
|
||||
CLIENT_LIMIT = 500
|
||||
|
||||
DP_IC_HIGH_WM_PCT = 90
|
||||
DP_IC_MID_WM_PCT = 68
|
||||
DP_IC_LOW_WM_PCT = 10
|
||||
@@ -135,6 +137,7 @@ class BackboneInterface(Interface):
|
||||
port = int(c["port"]) if "port" in c else None
|
||||
bindip = c["listen_ip"] if "listen_ip" in c else None
|
||||
bindport = int(c["listen_port"]) if "listen_port" in c else None
|
||||
client_limit = int(c["client_limit"]) if "client_limit" in c else None
|
||||
prefer_ipv6 = c.as_bool("prefer_ipv6") if "prefer_ipv6" in c else False
|
||||
flap_block = c.as_bool("block_fast_flapping") if "block_fast_flapping" in c else BackboneInterface.BLOCK_FAST_FLAPPING
|
||||
flap_threshold = c.as_float("fast_flapping_threshold") if "fast_flapping_threshold" in c else BackboneInterface.FAST_FLAP_THRESHOLD
|
||||
@@ -152,6 +155,9 @@ class BackboneInterface(Interface):
|
||||
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
||||
self.spawned_interfaces = []
|
||||
self.supports_discovery = True
|
||||
self.tunnels_allowed = True
|
||||
self.lossless_medium = True
|
||||
self.client_limit = client_limit or self.CLIENT_LIMIT
|
||||
self.block_fast_flapping = flap_block
|
||||
self.fast_flap_threshold = flap_threshold
|
||||
self.fast_flap_grace = flap_grace
|
||||
@@ -284,7 +290,7 @@ class BackboneInterface(Interface):
|
||||
server_socket.bind(bind_address)
|
||||
else: raise TypeError(f"Invalid socket type {socket_type} for {interface}")
|
||||
|
||||
server_socket.listen(1)
|
||||
server_socket.listen(16)
|
||||
server_socket.setblocking(0)
|
||||
BackboneInterface.listener_filenos[server_socket.fileno()] = (interface, server_socket)
|
||||
BackboneInterface.epoll.register(server_socket.fileno(), select.EPOLLIN)
|
||||
@@ -408,6 +414,14 @@ class BackboneInterface(Interface):
|
||||
RNS.log(f"Available ingress budget {RNS.prettyspeed(avail*8)}, hard-allocated {round(alloc*100.0, 2)}% ({RNS.prettyspeed(avail*alloc*8)}), handled in {RNS.prettyshorttime(taken, compact=True, tight=True)}", RNS.LOG_DEBUG)
|
||||
RNS.log(f"Holding for {RNS.prettyshorttime(hold, compact=True, tight=True)}, throttling handled in {RNS.prettyshorttime(taken, compact=True, tight=True)} at depth {q_depth}", RNS.LOG_DEBUG)
|
||||
|
||||
@staticmethod
|
||||
def _dp_ec_reset(interface):
|
||||
interface._dp_ec_prev_sent = 0
|
||||
interface._dp_ec_zero_ticks = 0
|
||||
interface._dp_ec_last_drain = time.time()
|
||||
interface.transmit_buffer = TransmitBuffer()
|
||||
interface.tx_stalled = False
|
||||
|
||||
@staticmethod
|
||||
def _dp_ec_evaluate(interface, now):
|
||||
tb = interface.transmit_buffer
|
||||
@@ -434,6 +448,7 @@ class BackboneInterface(Interface):
|
||||
except Exception as e: RNS.log(f"Egress control could not close socket for {interface}: {e}", RNS.LOG_ERROR)
|
||||
except Exception as e: RNS.log(f"Egress control cleanup error for {interface}: {e}", RNS.LOG_ERROR)
|
||||
|
||||
BackboneInterface._dp_ec_reset(interface)
|
||||
interface.receive(b"")
|
||||
return True
|
||||
|
||||
@@ -678,6 +693,8 @@ class BackboneInterface(Interface):
|
||||
|
||||
def incoming_connection(self, socket):
|
||||
try:
|
||||
if len(self.spawned_interfaces) >= self.client_limit: return False
|
||||
|
||||
remote_ip = socket.getpeername()[0]
|
||||
remote_port = str(socket.getpeername()[1])
|
||||
if self.blocked_ip_count > 0:
|
||||
@@ -712,6 +729,9 @@ class BackboneInterface(Interface):
|
||||
spawned_interface.ic_pr_burst_freq_new = self.ic_pr_burst_freq_new
|
||||
spawned_interface.ic_pr_burst_freq = self.ic_pr_burst_freq
|
||||
|
||||
spawned_interface._destination_cost = self._destination_cost
|
||||
spawned_interface._pr_cost = self._pr_cost
|
||||
|
||||
spawned_interface.socket = socket
|
||||
spawned_interface.target_ip = remote_ip
|
||||
spawned_interface.target_port = remote_port
|
||||
@@ -738,6 +758,7 @@ class BackboneInterface(Interface):
|
||||
spawned_interface.announce_rate_penalty = self.announce_rate_penalty
|
||||
spawned_interface.mode = self.mode
|
||||
spawned_interface.gravity = self.gravity
|
||||
spawned_interface.hop_limiter = self.hop_limiter
|
||||
spawned_interface.recursive_prs = self.recursive_prs
|
||||
spawned_interface.announces_from_internal = self.announces_from_internal
|
||||
spawned_interface.announces_to_internal = self.announces_to_internal
|
||||
@@ -865,6 +886,7 @@ class BackboneClientInterface(Interface):
|
||||
self.OUT = False
|
||||
self.socket = None
|
||||
self.parent_interface = None
|
||||
self.tunnels_allowed = True
|
||||
self.name = name
|
||||
self.initiator = False
|
||||
self.reconnecting = False
|
||||
@@ -872,6 +894,7 @@ class BackboneClientInterface(Interface):
|
||||
self.owner = owner
|
||||
self.online = False
|
||||
self.detached = False
|
||||
self.lossless_medium = True
|
||||
self.prefer_ipv6 = prefer_ipv6
|
||||
self.i2p_tunneled = i2p_tunneled
|
||||
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
||||
@@ -901,25 +924,21 @@ class BackboneClientInterface(Interface):
|
||||
self.target_port = target_port
|
||||
self.initiator = True
|
||||
|
||||
if connect_timeout != None:
|
||||
self.connect_timeout = connect_timeout
|
||||
else:
|
||||
self.connect_timeout = BackboneClientInterface.INITIAL_CONNECT_TIMEOUT
|
||||
|
||||
if BackboneClientInterface.SYNCHRONOUS_START:
|
||||
self.initial_connect()
|
||||
else:
|
||||
thread = threading.Thread(target=self.initial_connect)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
if connect_timeout != None: self.connect_timeout = connect_timeout
|
||||
else: self.connect_timeout = BackboneClientInterface.INITIAL_CONNECT_TIMEOUT
|
||||
|
||||
def final_init(self):
|
||||
if BackboneClientInterface.SYNCHRONOUS_START: self.initial_connect()
|
||||
else:
|
||||
thread = threading.Thread(target=self.initial_connect)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def initial_connect(self):
|
||||
if not self.connect(initial=True):
|
||||
thread = threading.Thread(target=self.reconnect)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
else:
|
||||
self.wants_tunnel = True
|
||||
|
||||
def set_timeouts_linux(self):
|
||||
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, int(BackboneClientInterface.TCP_USER_TIMEOUT * 1000))
|
||||
@@ -947,6 +966,17 @@ class BackboneClientInterface(Interface):
|
||||
|
||||
self.socket = None
|
||||
|
||||
def early_synthesis(self, packet):
|
||||
if not self.detached:
|
||||
if not packet.packed: packet.pack()
|
||||
if self.ifac_identity: raw = RNS.Transport.handle_outgoing_ifac(self, packet.raw);
|
||||
else: raw = packet.raw
|
||||
frame = HDLC.frame(raw)
|
||||
if not self.transmit_buffer.append(frame, self.tx_hwm):
|
||||
raise IOError("Transmit buffer overflow at early tunnel synthesis")
|
||||
|
||||
BackboneInterface.tx_ready(self)
|
||||
|
||||
def connect(self, initial=False):
|
||||
try:
|
||||
if initial:
|
||||
@@ -970,7 +1000,11 @@ class BackboneClientInterface(Interface):
|
||||
# TODO: Check missing setblocking(0)
|
||||
self.socket.settimeout(None)
|
||||
|
||||
self.wants_tunnel = True
|
||||
self.remote_transport = None
|
||||
self.synthesis_received = False
|
||||
BackboneInterface.add_client_socket(self.socket, self)
|
||||
RNS.Transport.synthesize_tunnel(self)
|
||||
self.online = True
|
||||
|
||||
if initial:
|
||||
@@ -995,6 +1029,7 @@ class BackboneClientInterface(Interface):
|
||||
def reconnect(self):
|
||||
if self.initiator:
|
||||
if not self.reconnecting:
|
||||
BackboneInterface._dp_ec_reset(self)
|
||||
self.reconnecting = True
|
||||
attempts = 0
|
||||
while not self.online and not self.detached:
|
||||
@@ -1016,7 +1051,6 @@ class BackboneClientInterface(Interface):
|
||||
RNS.log("Reconnected socket for "+str(self)+".", RNS.LOG_INFO)
|
||||
|
||||
self.reconnecting = False
|
||||
RNS.Transport.synthesize_tunnel(self)
|
||||
|
||||
else:
|
||||
RNS.log("Attempt to reconnect on a non-initiator TCP interface. This should not happen.", RNS.LOG_ERROR)
|
||||
@@ -1024,10 +1058,6 @@ class BackboneClientInterface(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if self.online and not self.detached:
|
||||
self.rxb += len(data)
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
self.parent_interface.rxb += len(data)
|
||||
|
||||
self.dp_ingress_packets += 1
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
|
||||
@@ -353,9 +353,11 @@ class I2PInterfacePeer(Interface):
|
||||
self.online = False
|
||||
self.detached = False
|
||||
self.kiss_framing = False
|
||||
self.tunnels_allowed = True
|
||||
self.i2p_tunneled = True
|
||||
self.i2p_dest = None
|
||||
self.i2p_tunnel_ready = False
|
||||
self.lossless_medium = True
|
||||
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
||||
self.bitrate = I2PInterface.BITRATE_GUESS
|
||||
self.last_read = 0
|
||||
@@ -425,8 +427,6 @@ class I2PInterfacePeer(Interface):
|
||||
while self.awaiting_i2p_tunnel: time.sleep(0.25)
|
||||
time.sleep(2)
|
||||
|
||||
if not self.kiss_framing: self.wants_tunnel = True
|
||||
|
||||
if not self.connect(initial=True):
|
||||
thread = threading.Thread(target=self.reconnect)
|
||||
thread.daemon = True
|
||||
@@ -479,10 +479,31 @@ class I2PInterfacePeer(Interface):
|
||||
|
||||
self.socket = None
|
||||
|
||||
def early_synthesis(self, packet):
|
||||
if not self.detached:
|
||||
if not packet.packed: packet.pack()
|
||||
if self.ifac_identity: raw = RNS.Transport.handle_outgoing_ifac(self, packet.raw);
|
||||
else: raw = packet.raw
|
||||
|
||||
if self.kiss_framing: frame = bytes([KISS.FEND])+bytes([KISS.CMD_DATA])+KISS.escape(raw)+bytes([KISS.FEND])
|
||||
else: frame = bytes([HDLC.FLAG])+HDLC.escape(raw)+bytes([HDLC.FLAG])
|
||||
|
||||
self.socket.sendall(frame)
|
||||
self.txb += len(frame)
|
||||
self.last_write = time.time()
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None and self.parent_count: self.parent_interface.txb += len(frame)
|
||||
|
||||
def connect(self, initial=False):
|
||||
try:
|
||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.socket.connect((self.target_ip, self.target_port))
|
||||
|
||||
if not self.kiss_framing:
|
||||
self.wants_tunnel = True
|
||||
self.remote_transport = None
|
||||
self.synthesis_received = False
|
||||
RNS.Transport.synthesize_tunnel(self)
|
||||
|
||||
self.online = True
|
||||
|
||||
except Exception as e:
|
||||
@@ -500,8 +521,6 @@ class I2PInterfacePeer(Interface):
|
||||
self.writing = False
|
||||
self.never_connected = False
|
||||
|
||||
if not self.kiss_framing and self.wants_tunnel: RNS.Transport.synthesize_tunnel(self)
|
||||
|
||||
return True
|
||||
|
||||
def reconnect(self):
|
||||
@@ -530,7 +549,6 @@ class I2PInterfacePeer(Interface):
|
||||
thread = threading.Thread(target=self.read_loop)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
if not self.kiss_framing: RNS.Transport.synthesize_tunnel(self)
|
||||
|
||||
else:
|
||||
RNS.log("Attempt to reconnect on a non-initiator I2P interface. This should not happen.", RNS.LOG_ERROR)
|
||||
@@ -538,9 +556,6 @@ class I2PInterfacePeer(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
self.rxb += len(data)
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None and self.parent_count:
|
||||
self.parent_interface.rxb += len(data)
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self, data):
|
||||
@@ -741,6 +756,8 @@ class I2PInterface(Interface):
|
||||
self.owner = owner
|
||||
self.connectable = connectable
|
||||
self.i2p_tunneled = True
|
||||
self.tunnels_allowed = True
|
||||
self.peers = peers
|
||||
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
||||
|
||||
self.b32 = None
|
||||
@@ -750,7 +767,6 @@ class I2PInterface(Interface):
|
||||
self.OUT = False
|
||||
self.name = name
|
||||
|
||||
|
||||
self.receives = True
|
||||
self.bind_ip = "127.0.0.1"
|
||||
self.bind_port = self.i2p.get_free_port()
|
||||
@@ -760,6 +776,7 @@ class I2PInterface(Interface):
|
||||
self.ifac_netname = ifac_netname
|
||||
self.ifac_netkey = ifac_netkey
|
||||
self.supports_discovery = True
|
||||
self.lossless_medium = True
|
||||
|
||||
self.online = False
|
||||
|
||||
@@ -790,6 +807,7 @@ class I2PInterface(Interface):
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def final_init(self):
|
||||
if self.connectable:
|
||||
def tunnel_job():
|
||||
while True:
|
||||
@@ -809,22 +827,61 @@ class I2PInterface(Interface):
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
if peers != None:
|
||||
for peer_addr in peers:
|
||||
interface_name = self.name+" to "+peer_addr
|
||||
peer_interface = I2PInterfacePeer(self, self.owner, interface_name, peer_addr)
|
||||
peer_interface.OUT = True
|
||||
peer_interface.IN = True
|
||||
peer_interface.parent_interface = self
|
||||
peer_interface.parent_count = False
|
||||
RNS.Transport.add_interface(peer_interface)
|
||||
threading.Thread(target=self._spawn_peers, daemon=True).start()
|
||||
|
||||
def _spawn_peers(self):
|
||||
time.sleep(1.5)
|
||||
if self.peers != None:
|
||||
for peer_addr in self.peers:
|
||||
try:
|
||||
interface_name = self.name+" to "+peer_addr
|
||||
peer_interface = I2PInterfacePeer(self, self.owner, interface_name, peer_addr)
|
||||
peer_interface.OUT = self.OUT
|
||||
peer_interface.IN = self.IN
|
||||
peer_interface.parent_interface = self
|
||||
peer_interface.parent_count = False
|
||||
|
||||
peer_interface.mode = self.mode
|
||||
peer_interface.bitrate = self.bitrate
|
||||
peer_interface.recursive_prs = self.recursive_prs
|
||||
peer_interface.gravity = self.gravity
|
||||
peer_interface.HW_MTU = self.HW_MTU
|
||||
|
||||
peer_interface.announces_to_internal = self.announces_to_internal
|
||||
peer_interface.announces_from_internal = self.announces_from_internal
|
||||
peer_interface.announce_cap = self.announce_cap
|
||||
|
||||
peer_interface.ingress_control = self.ingress_control
|
||||
peer_interface.ic_max_held_announces = self.ic_max_held_announces
|
||||
peer_interface.ic_burst_hold = self.ic_burst_hold
|
||||
peer_interface.ic_burst_freq = self.ic_burst_freq
|
||||
peer_interface.ic_burst_freq_new = self.ic_burst_freq_new
|
||||
peer_interface.ic_new_time = self.ic_new_time
|
||||
peer_interface.ic_burst_penalty = self.ic_burst_penalty
|
||||
peer_interface.ic_held_release_interval = self.ic_held_release_interval
|
||||
|
||||
peer_interface.egress_control = self.egress_control
|
||||
peer_interface.ec_pr_freq = self.ec_pr_freq
|
||||
peer_interface.ic_pr_burst_freq_new = self.ic_pr_burst_freq_new
|
||||
peer_interface.ic_pr_burst_freq = self.ic_pr_burst_freq
|
||||
|
||||
peer_interface.announce_rate_target = self.announce_rate_target
|
||||
peer_interface.announce_rate_grace = self.announce_rate_grace
|
||||
peer_interface.announce_rate_penalty = self.announce_rate_penalty
|
||||
|
||||
peer_interface._destination_cost = self._destination_cost
|
||||
peer_interface._pr_cost = self._pr_cost
|
||||
|
||||
RNS.Transport.add_interface(peer_interface)
|
||||
|
||||
except Exception as e: RNS.log(f"Could not create interface for {self} to {peer_addr}: {e}", RNS.LOG_ERROR)
|
||||
|
||||
def incoming_connection(self, handler):
|
||||
RNS.log("Accepting incoming I2P connection", RNS.LOG_VERBOSE)
|
||||
interface_name = "Connected peer on "+self.name
|
||||
spawned_interface = I2PInterfacePeer(self, self.owner, interface_name, connected_socket=handler.request)
|
||||
spawned_interface.OUT = True
|
||||
spawned_interface.IN = True
|
||||
spawned_interface.OUT = self.OUT
|
||||
spawned_interface.IN = self.IN
|
||||
|
||||
spawned_interface.ingress_control = self.ingress_control
|
||||
spawned_interface.ic_max_held_announces = self.ic_max_held_announces
|
||||
@@ -835,10 +892,17 @@ class I2PInterface(Interface):
|
||||
spawned_interface.ic_burst_penalty = self.ic_burst_penalty
|
||||
spawned_interface.ic_held_release_interval = self.ic_held_release_interval
|
||||
|
||||
spawned_interface.announces_to_internal = self.announces_to_internal
|
||||
spawned_interface.announces_from_internal = self.announces_from_internal
|
||||
spawned_interface.announce_cap = self.announce_cap
|
||||
|
||||
spawned_interface.egress_control = self.egress_control
|
||||
spawned_interface.ec_pr_freq = self.ec_pr_freq
|
||||
spawned_interface.ic_pr_burst_freq_new = self.ic_pr_burst_freq_new
|
||||
spawned_interface.ic_pr_burst_freq = self.ic_pr_burst_freq
|
||||
|
||||
spawned_interface._destination_cost = self._destination_cost
|
||||
spawned_interface._pr_cost = self._pr_cost
|
||||
|
||||
spawned_interface.parent_interface = self
|
||||
spawned_interface.online = True
|
||||
@@ -861,7 +925,9 @@ class I2PInterface(Interface):
|
||||
spawned_interface.announce_rate_grace = self.announce_rate_grace
|
||||
spawned_interface.announce_rate_penalty = self.announce_rate_penalty
|
||||
spawned_interface.mode = self.mode
|
||||
spawned_interface.recursive_prs = self.recursive_prs
|
||||
spawned_interface.gravity = self.gravity
|
||||
spawned_interface.hop_limiter = self.hop_limiter
|
||||
spawned_interface.HW_MTU = self.HW_MTU
|
||||
RNS.log("Spawned new I2PInterface Peer: "+str(spawned_interface), RNS.LOG_VERBOSE)
|
||||
RNS.Transport.add_interface(spawned_interface)
|
||||
|
||||
+82
-15
@@ -39,7 +39,6 @@ class Interface:
|
||||
OUT = False
|
||||
FWD = False
|
||||
RPT = False
|
||||
name = None
|
||||
|
||||
# Interface mode definitions
|
||||
MODE_FULL = 0x01
|
||||
@@ -69,7 +68,7 @@ class Interface:
|
||||
|
||||
# Maximum amount of ingress limited announces
|
||||
# to hold at any given time.
|
||||
MAX_HELD_ANNOUNCES = 256
|
||||
MAX_HELD_ANNOUNCES = 64
|
||||
|
||||
# Control parameters
|
||||
DEFAULT_GRAVITY = 0
|
||||
@@ -96,12 +95,16 @@ class Interface:
|
||||
DEFAULT_IFAC_SIZE = 16
|
||||
|
||||
def __init__(self):
|
||||
self.name = None
|
||||
self.rxb = 0
|
||||
self.txb = 0
|
||||
self.frxb = 0
|
||||
self.ftxb = 0
|
||||
self.arxb = 0
|
||||
self.atxb = 0
|
||||
self.arxc = 0
|
||||
self.atxc = 0
|
||||
self.afrxc = 0
|
||||
self.prxb = 0
|
||||
self.ptxb = 0
|
||||
self.prxc = 0
|
||||
@@ -115,6 +118,7 @@ class Interface:
|
||||
self.__hash = None
|
||||
|
||||
self.announce_cap = RNS.Reticulum.ANNOUNCE_CAP/100.0
|
||||
self.announce_allowed_at = 0
|
||||
self.supports_discovery = False
|
||||
self.discoverable = False
|
||||
self.last_discovery_announce = 0
|
||||
@@ -122,12 +126,27 @@ class Interface:
|
||||
self.recursive_prs = False
|
||||
self.announces_from_internal = True
|
||||
self.announces_to_internal = None
|
||||
self.is_local_shared_instance = False
|
||||
self.parent_interface = None
|
||||
self.spawned_interfaces = None
|
||||
self.tunnel_id = None
|
||||
self.local_tunnel_id = None
|
||||
self.tunnels_allowed = False
|
||||
self.synthesis_received = False
|
||||
self.synthesis_emitted = False
|
||||
self.wants_tunnel = False
|
||||
self.remote_transport = None
|
||||
self.ingress_control = True
|
||||
self.hop_limiter = None
|
||||
self.phy_keepalive = False
|
||||
self.shared_medium = False
|
||||
self.lossless_medium = False
|
||||
|
||||
self.remote_impl = None
|
||||
self.remote_vers = None
|
||||
self.remote_dst_cost = None
|
||||
self.remote_pr_cost = None
|
||||
self.remote_is_tn = None
|
||||
|
||||
self.ic_burst_active = False
|
||||
self.ic_burst_activated = 0
|
||||
@@ -148,7 +167,9 @@ class Interface:
|
||||
self.ic_held_release_interval = RNS.Reticulum.get_instance()._default_ic_held_release_interval()
|
||||
self.ec_pr_freq = RNS.Reticulum.get_instance()._default_ec_pr_freq()
|
||||
self.egress_control = RNS.Reticulum.get_instance()._default_egress_control()
|
||||
self.announce_queue = []
|
||||
self.held_announces = {}
|
||||
self.ifac_identity = None
|
||||
self.transmit_buffer = None
|
||||
|
||||
self.ia_freq_deque = deque(maxlen=Interface.IA_FREQ_SAMPLES)
|
||||
@@ -159,6 +180,7 @@ class Interface:
|
||||
self.protocol_violations = 0
|
||||
self.ifac_violations = 0
|
||||
self.packet_filter_hits = 0
|
||||
self.hop_limiter_hits = 0
|
||||
self.dp_ingress_tcount = 0
|
||||
self.dp_ingress_bytes = 0
|
||||
self.dp_ingress_packets = 0
|
||||
@@ -173,11 +195,16 @@ class Interface:
|
||||
self._dp_ec_zero_ticks = 0
|
||||
self._dp_ec_last_drain = time.time()
|
||||
|
||||
self._destination_cost = None
|
||||
self._pr_cost = None
|
||||
|
||||
self.reports_phy_stats = False
|
||||
self.r_stat_rssi = None
|
||||
self.r_stat_snr = None
|
||||
self.r_stat_q = None
|
||||
|
||||
self.is_connected_to_shared_instance = False
|
||||
|
||||
def get_hash(self):
|
||||
if not self.__hash: self.__hash = RNS.Identity.full_hash(str(self).encode("utf-8"))
|
||||
return self.__hash
|
||||
@@ -269,11 +296,14 @@ class Interface:
|
||||
|
||||
def hold_announce(self, announce_packet):
|
||||
if announce_packet.hops >= RNS.Transport.PATHFINDER_M-1:
|
||||
return
|
||||
return self.filtered_announce()
|
||||
elif announce_packet.destination_hash in self.held_announces:
|
||||
self.held_announces[announce_packet.destination_hash] = announce_packet
|
||||
return self.filtered_announce()
|
||||
elif not len(self.held_announces) >= self.ic_max_held_announces:
|
||||
self.held_announces[announce_packet.destination_hash] = announce_packet
|
||||
return True
|
||||
else: return self.filtered_announce()
|
||||
|
||||
def process_held_announces(self):
|
||||
try:
|
||||
@@ -283,18 +313,32 @@ class Interface:
|
||||
if ia_freq < freq_threshold:
|
||||
selected_announce_packet = None
|
||||
min_hops = RNS.Transport.PATHFINDER_M
|
||||
for destination_hash in self.held_announces:
|
||||
announce_packet = self.held_announces[destination_hash]
|
||||
cull_entries = []
|
||||
for destination_hash in self.held_announces.copy():
|
||||
announce_packet = self.held_announces.get(destination_hash)
|
||||
if not announce_packet: continue
|
||||
|
||||
# If we can determine that a held announce has become
|
||||
# useless for any potential path table updates, we'll
|
||||
# remove it immediately instead of waiting for it to
|
||||
# eventually get released, freeing up other held queue
|
||||
# slots for potentially useful new announces.
|
||||
path_entry = RNS.Transport.path_table.get(destination_hash)
|
||||
if path_entry and not RNS.Transport.announce_prefilter(announce_packet, path_entry):
|
||||
cull_entries.append(destination_hash)
|
||||
continue
|
||||
|
||||
if announce_packet.hops < min_hops:
|
||||
min_hops = announce_packet.hops
|
||||
selected_announce_packet = announce_packet
|
||||
|
||||
for destination_hash in cull_entries: self.held_announces.pop(destination_hash, None)
|
||||
|
||||
if selected_announce_packet != None:
|
||||
RNS.log("Releasing held announce packet "+str(selected_announce_packet)+" from "+str(self), RNS.LOG_EXTREME)
|
||||
self.ic_held_release = time.time() + self.ic_held_release_interval
|
||||
self.held_announces.pop(selected_announce_packet.destination_hash)
|
||||
def release(): RNS.Transport.inbound(selected_announce_packet.raw, selected_announce_packet.receiving_interface, tc=RNS.Transport.TC_INGRESS_LIMITED, ifac_handled=True)
|
||||
threading.Thread(target=release, daemon=True).start()
|
||||
self.held_announces.pop(selected_announce_packet.destination_hash, None)
|
||||
RNS.Transport.inbound(selected_announce_packet.raw, selected_announce_packet.receiving_interface, tc=RNS.Transport.TC_INGRESS_LIMITED, ifac_handled=True)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("An error occurred while processing held announces for "+str(self), RNS.LOG_ERROR)
|
||||
@@ -303,30 +347,37 @@ class Interface:
|
||||
def received_announce(self, size=0, from_spawned=False):
|
||||
self.arxc += 1; self.arxb += size
|
||||
self.ia_freq_deque.append(time.time())
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
if self.parent_interface != None:
|
||||
self.parent_interface.received_announce(size=size, from_spawned=True)
|
||||
|
||||
def sent_announce(self, size=0, from_spawned=False):
|
||||
self.atxc += 1; self.atxb += size
|
||||
self.oa_freq_deque.append(time.time())
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
if self.parent_interface != None:
|
||||
self.parent_interface.sent_announce(size=size, from_spawned=True)
|
||||
|
||||
def filtered_announce(self, size=0, from_spawned=False):
|
||||
self.afrxc += 1
|
||||
RNS.Transport.filtered_arxc += 1
|
||||
if self.parent_interface != None: self.parent_interface.afrxc += 1
|
||||
return None
|
||||
|
||||
def received_path_request(self, size=0, from_spawned=False):
|
||||
self.prxc += 1; self.prxb += size
|
||||
self.ip_freq_deque.append(time.time())
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
if self.parent_interface != None:
|
||||
self.parent_interface.received_path_request(size=size, from_spawned=True)
|
||||
|
||||
def sent_path_request(self, size=0, from_spawned=False):
|
||||
self.ptxc += 1; self.ptxb += size
|
||||
self.op_freq_deque.append(time.time())
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
if self.parent_interface != None:
|
||||
self.parent_interface.sent_path_request(size=size, from_spawned=True)
|
||||
|
||||
def protocol_violation(self, description=None):
|
||||
def protocol_violation(self, description=None, level=None):
|
||||
if level == None: level = RNS.LOG_DEBUG
|
||||
self.protocol_violations += 1
|
||||
RNS.log(f"Protocol violation on {self}: {description}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
RNS.log(f"Protocol violation on {self}: {description}", level) if RNS.sl(level) else None
|
||||
return None
|
||||
|
||||
def ifac_violation(self, description=None):
|
||||
@@ -338,6 +389,20 @@ class Interface:
|
||||
self.packet_filter_hits += 1
|
||||
return None
|
||||
|
||||
def hop_limiter_hit(self):
|
||||
self.hop_limiter_hits += 1
|
||||
return None
|
||||
|
||||
@property
|
||||
def destination_cost(self):
|
||||
if not self._destination_cost == None: return self._destination_cost
|
||||
else: return RNS.Transport.DESTINATION_COST
|
||||
|
||||
@property
|
||||
def pr_cost(self):
|
||||
if not self._pr_cost == None: return self._pr_cost
|
||||
else: return RNS.Transport.PR_COST
|
||||
|
||||
@property
|
||||
def ic_burst_count(self): return None
|
||||
|
||||
@@ -389,10 +454,12 @@ class Interface:
|
||||
return hz
|
||||
|
||||
def process_announce_queue(self):
|
||||
if not self.announce_queue: return
|
||||
|
||||
if not hasattr(self, "announce_cap"):
|
||||
self.announce_cap = RNS.Reticulum.ANNOUNCE_CAP/100.0
|
||||
|
||||
if hasattr(self, "announce_queue"):
|
||||
if self.announce_queue:
|
||||
try:
|
||||
now = time.time()
|
||||
stale = []
|
||||
|
||||
@@ -255,7 +255,6 @@ class KISSInterface(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
self.rxb += len(data)
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
|
||||
|
||||
@@ -202,9 +202,6 @@ class LocalClientInterface(Interface):
|
||||
except Exception as e: RNS.log(f"Exception occurred while sending keepalive on {self}: {e}", RNS.LOG_ERROR)
|
||||
|
||||
def process_incoming(self, data):
|
||||
self.rxb += len(data)
|
||||
if self.parent_interface != None: self.parent_interface.rxb += len(data)
|
||||
|
||||
try: self.owner.inbound(data, self)
|
||||
except Exception as e:
|
||||
RNS.log(f"An error occurred in the processing of an incoming frame for {self}: {e}", RNS.LOG_ERROR)
|
||||
|
||||
@@ -121,7 +121,6 @@ class PipeInterface(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
self.rxb += len(data)
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
|
||||
|
||||
@@ -262,6 +262,7 @@ class RNodeInterface(Interface):
|
||||
self.r_st_alock = None
|
||||
self.r_lt_alock = None
|
||||
self.r_random = None
|
||||
self.r_modulation = "LoRa"
|
||||
self.r_airtime_short = 0.0
|
||||
self.r_airtime_long = 0.0
|
||||
self.r_channel_load_short = 0.0
|
||||
@@ -705,7 +706,6 @@ class RNodeInterface(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
self.rxb += len(data)
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self,data):
|
||||
|
||||
@@ -278,7 +278,7 @@ class RNodeMultiInterface(Interface):
|
||||
self.interface_ready = False
|
||||
self.announce_rate_target = None
|
||||
self.reports_phy_stats = True
|
||||
|
||||
self.r_modulation = "LoRa"
|
||||
|
||||
self.validcfg = True
|
||||
if id_interval != None and id_callsign != None:
|
||||
@@ -1130,7 +1130,6 @@ class RNodeSubInterface(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
self.rxb += len(data)
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self,data):
|
||||
|
||||
@@ -151,7 +151,6 @@ class SerialInterface(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
self.rxb += len(data)
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self,data):
|
||||
|
||||
@@ -126,6 +126,8 @@ class TCPClientInterface(Interface):
|
||||
self.writing = False
|
||||
self.online = False
|
||||
self.detached = False
|
||||
self.tunnels_allowed = True
|
||||
self.lossless_medium = True
|
||||
self.kiss_framing = kiss_framing
|
||||
self.i2p_tunneled = i2p_tunneled
|
||||
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
||||
@@ -158,13 +160,13 @@ class TCPClientInterface(Interface):
|
||||
self.connect_timeout = connect_timeout
|
||||
else:
|
||||
self.connect_timeout = TCPClientInterface.INITIAL_CONNECT_TIMEOUT
|
||||
|
||||
if TCPClientInterface.SYNCHRONOUS_START:
|
||||
self.initial_connect()
|
||||
else:
|
||||
thread = threading.Thread(target=self.initial_connect)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def final_init(self):
|
||||
if TCPClientInterface.SYNCHRONOUS_START: self.initial_connect()
|
||||
else:
|
||||
thread = threading.Thread(target=self.initial_connect)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def initial_connect(self):
|
||||
if not self.connect(initial=True):
|
||||
@@ -175,8 +177,6 @@ class TCPClientInterface(Interface):
|
||||
thread = threading.Thread(target=self.read_loop)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
if not self.kiss_framing:
|
||||
self.wants_tunnel = True
|
||||
|
||||
def set_timeouts_linux(self):
|
||||
if not self.i2p_tunneled:
|
||||
@@ -228,6 +228,20 @@ class TCPClientInterface(Interface):
|
||||
|
||||
self.socket = None
|
||||
|
||||
def early_synthesis(self, packet):
|
||||
if not self.detached:
|
||||
if not packet.packed: packet.pack()
|
||||
if self.ifac_identity: raw = RNS.Transport.handle_outgoing_ifac(self, packet.raw);
|
||||
else: raw = packet.raw
|
||||
|
||||
if self.kiss_framing: frame = bytes([KISS.FEND])+bytes([KISS.CMD_DATA])+KISS.escape(raw)+bytes([KISS.FEND])
|
||||
else: frame = bytes([HDLC.FLAG])+HDLC.escape(raw)+bytes([HDLC.FLAG])
|
||||
|
||||
self.socket.sendall(frame)
|
||||
self.txb += len(frame)
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
self.parent_interface.txb += len(frame)
|
||||
|
||||
def connect(self, initial=False):
|
||||
try:
|
||||
if initial:
|
||||
@@ -242,6 +256,13 @@ class TCPClientInterface(Interface):
|
||||
self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
self.socket.connect(target_address)
|
||||
self.socket.settimeout(None)
|
||||
|
||||
if not self.kiss_framing:
|
||||
self.wants_tunnel = True
|
||||
self.remote_transport = None
|
||||
self.synthesis_received = False
|
||||
RNS.Transport.synthesize_tunnel(self)
|
||||
|
||||
self.online = True
|
||||
|
||||
if initial:
|
||||
@@ -282,9 +303,7 @@ class TCPClientInterface(Interface):
|
||||
self.teardown()
|
||||
break
|
||||
|
||||
try:
|
||||
self.connect()
|
||||
|
||||
try: self.connect()
|
||||
except Exception as e:
|
||||
RNS.log("Connection attempt for "+str(self)+" failed: "+str(e), RNS.LOG_DEBUG)
|
||||
|
||||
@@ -295,8 +314,6 @@ class TCPClientInterface(Interface):
|
||||
thread = threading.Thread(target=self.read_loop)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
if not self.kiss_framing:
|
||||
RNS.Transport.synthesize_tunnel(self)
|
||||
|
||||
else:
|
||||
RNS.log("Attempt to reconnect on a non-initiator TCP interface. This should not happen.", RNS.LOG_ERROR)
|
||||
@@ -305,10 +322,6 @@ class TCPClientInterface(Interface):
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
if self.online and not self.detached:
|
||||
self.rxb += len(data)
|
||||
if hasattr(self, "parent_interface") and self.parent_interface != None:
|
||||
self.parent_interface.rxb += len(data)
|
||||
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self, data):
|
||||
@@ -533,6 +546,8 @@ class TCPServerInterface(Interface):
|
||||
self.OUT = False
|
||||
self.name = name
|
||||
self.detached = False
|
||||
self.tunnels_allowed = True
|
||||
self.lossless_medium = True
|
||||
|
||||
self.i2p_tunneled = i2p_tunneled
|
||||
self.mode = RNS.Interfaces.Interface.Interface.MODE_FULL
|
||||
@@ -605,6 +620,9 @@ class TCPServerInterface(Interface):
|
||||
spawned_interface.ic_pr_burst_freq_new = self.ic_pr_burst_freq_new
|
||||
spawned_interface.ic_pr_burst_freq = self.ic_pr_burst_freq
|
||||
|
||||
spawned_interface._destination_cost = self._destination_cost
|
||||
spawned_interface._pr_cost = self._pr_cost
|
||||
|
||||
spawned_interface.target_ip = handler.client_address[0]
|
||||
spawned_interface.target_port = str(handler.client_address[1])
|
||||
spawned_interface.parent_interface = self
|
||||
@@ -636,6 +654,7 @@ class TCPServerInterface(Interface):
|
||||
spawned_interface.announce_rate_penalty = self.announce_rate_penalty
|
||||
spawned_interface.mode = self.mode
|
||||
spawned_interface.gravity = self.gravity
|
||||
spawned_interface.hop_limiter = self.hop_limiter
|
||||
spawned_interface.recursive_prs = self.recursive_prs
|
||||
spawned_interface.announces_from_internal = self.announces_from_internal
|
||||
spawned_interface.announces_to_internal = self.announces_to_internal
|
||||
|
||||
@@ -124,7 +124,6 @@ class UDPInterface(Interface):
|
||||
|
||||
def process_incoming(self, data):
|
||||
if not data: return
|
||||
self.rxb += len(data)
|
||||
self.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self,data):
|
||||
|
||||
@@ -249,7 +249,6 @@ class WDCL():
|
||||
self.online = True
|
||||
|
||||
def process_incoming(self, data):
|
||||
self.rxb += len(data)
|
||||
if self.device:
|
||||
while len(self.frame_queue): self.device.incoming_frame(self.frame_queue.pop())
|
||||
self.device.incoming_frame(data)
|
||||
@@ -933,9 +932,17 @@ class WeaveInterface(Interface):
|
||||
spawned_interface.ic_new_time = self.ic_new_time
|
||||
spawned_interface.ic_burst_penalty = self.ic_burst_penalty
|
||||
spawned_interface.ic_held_release_interval = self.ic_held_release_interval
|
||||
|
||||
spawned_interface.announces_to_internal = self.announces_to_internal
|
||||
spawned_interface.announces_from_internal = self.announces_from_internal
|
||||
spawned_interface.announce_cap = self.announce_cap
|
||||
|
||||
spawned_interface._destination_cost = self._destination_cost
|
||||
spawned_interface._pr_cost = self._pr_cost
|
||||
|
||||
spawned_interface.parent_interface = self
|
||||
spawned_interface.bitrate = self.bitrate
|
||||
spawned_interface.recursive_prs = self.recursive_prs
|
||||
|
||||
spawned_interface.ifac_size = self.ifac_size
|
||||
spawned_interface.ifac_netname = self.ifac_netname
|
||||
@@ -960,10 +967,18 @@ class WeaveInterface(Interface):
|
||||
spawned_interface.announce_rate_target = self.announce_rate_target
|
||||
spawned_interface.announce_rate_grace = self.announce_rate_grace
|
||||
spawned_interface.announce_rate_penalty = self.announce_rate_penalty
|
||||
|
||||
spawned_interface.egress_control = self.egress_control
|
||||
spawned_interface.ec_pr_freq = self.ec_pr_freq
|
||||
spawned_interface.ic_pr_burst_freq_new = self.ic_pr_burst_freq_new
|
||||
spawned_interface.ic_pr_burst_freq = self.ic_pr_burst_freq
|
||||
|
||||
spawned_interface.mode = self.mode
|
||||
spawned_interface.gravity = self.gravity
|
||||
spawned_interface.hop_limiter = self.hop_limiter
|
||||
spawned_interface.HW_MTU = self.HW_MTU
|
||||
spawned_interface._online = True
|
||||
|
||||
RNS.Transport.add_interface(spawned_interface)
|
||||
if endpoint_addr in self.spawned_interfaces:
|
||||
self.spawned_interfaces[endpoint_addr].detach()
|
||||
@@ -1045,8 +1060,6 @@ class WeaveInterfacePeer(Interface):
|
||||
self.owner.refresh_peer(self.endpoint_addr)
|
||||
self.owner.mif_deque.append(data_hash)
|
||||
self.owner.mif_deque_times.append([data_hash, time.time()])
|
||||
self.rxb += len(data)
|
||||
self.owner.rxb += len(data)
|
||||
self.owner.owner.inbound(data, self)
|
||||
|
||||
def process_outgoing(self, data):
|
||||
|
||||
+128
-39
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,8 +28,8 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
from RNS.Cryptography import X25519PrivateKey, X25519PublicKey, Ed25519PrivateKey, Ed25519PublicKey
|
||||
from RNS.Cryptography import Token
|
||||
from RNS.Cryptography import X25519PrivateKey, X25519PublicKey, Ed25519PrivateKey, Ed25519PublicKey, Token
|
||||
from RNS.Stamps import stamp_valid, stamp_value, generate_stamped_key, cancel_work
|
||||
from RNS.Channel import Channel, LinkChannelOutlet
|
||||
|
||||
from time import sleep
|
||||
@@ -70,7 +70,7 @@ class Link:
|
||||
ECPUBSIZE = 32+32
|
||||
KEYSIZE = 32
|
||||
|
||||
MDU = math.floor((RNS.Reticulum.MTU-RNS.Reticulum.IFAC_MIN_SIZE-RNS.Reticulum.HEADER_MINSIZE-RNS.Identity.TOKEN_OVERHEAD)/RNS.Identity.AES128_BLOCKSIZE)*RNS.Identity.AES128_BLOCKSIZE - 1
|
||||
MDU = math.floor((RNS.Reticulum.MTU-RNS.Reticulum.IFAC_MIN_SIZE-RNS.Reticulum.HEADER_MINSIZE-RNS.Identity.TOKEN_OVERHEAD)/RNS.Identity.AES256_BLOCKSIZE)*RNS.Identity.AES256_BLOCKSIZE - 1
|
||||
|
||||
ESTABLISHMENT_TIMEOUT_PER_HOP = RNS.Reticulum.DEFAULT_PER_HOP_TIMEOUT
|
||||
"""
|
||||
@@ -116,6 +116,7 @@ class Link:
|
||||
TIMEOUT = 0x01
|
||||
INITIATOR_CLOSED = 0x02
|
||||
DESTINATION_CLOSED = 0x03
|
||||
STAMP_FAILURE = 0x04
|
||||
|
||||
ACCEPT_NONE = 0x00
|
||||
ACCEPT_APP = 0x01
|
||||
@@ -186,8 +187,17 @@ class Link:
|
||||
def validate_request(owner, data, packet):
|
||||
if len(data) == Link.ECPUBSIZE or len(data) == Link.ECPUBSIZE+Link.LINK_MTU_SIZE:
|
||||
try:
|
||||
link = Link(owner = owner, peer_pub_bytes=data[:Link.ECPUBSIZE//2], peer_sig_pub_bytes=data[Link.ECPUBSIZE//2:Link.ECPUBSIZE])
|
||||
peer_pub_bytes = data[:Link.ECPUBSIZE//2]
|
||||
peer_sig_pub_bytes = data[Link.ECPUBSIZE//2:Link.ECPUBSIZE]
|
||||
stamp_material = owner.hash + peer_sig_pub_bytes
|
||||
value = stamp_value(stamp_material, peer_pub_bytes)
|
||||
|
||||
if RNS.Transport.LR_STAMPS_ENFORCED and not stamp_valid(peer_pub_bytes, owner.get_link_cost(), stamp_material): raise ValueError(f"Insufficient link request stamp value {value}")
|
||||
|
||||
link = Link(owner=owner, peer_pub_bytes=peer_pub_bytes, peer_sig_pub_bytes=peer_sig_pub_bytes)
|
||||
link.set_link_id(packet)
|
||||
link.stamp_cost = value
|
||||
link.stamp_status = True
|
||||
|
||||
if len(data) == Link.ECPUBSIZE+Link.LINK_MTU_SIZE:
|
||||
RNS.log("Link request includes MTU signalling", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
@@ -203,7 +213,7 @@ class Link:
|
||||
link.destination = packet.destination
|
||||
link.establishment_timeout = Link.ESTABLISHMENT_TIMEOUT_PER_HOP * max(1, packet.hops) + Link.KEEPALIVE
|
||||
link.establishment_cost += len(packet.raw)
|
||||
RNS.log(f"Validating link request {RNS.prettyhexrep(link.link_id)}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
RNS.log(f"Validating link request {RNS.prettyhexrep(link.link_id)} with value {value}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
RNS.log(f"Link MTU configured to {RNS.prettysize(link.mtu)}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
RNS.log(f"Establishment timeout is {RNS.prettytime(link.establishment_timeout)} for incoming link request {RNS.prettyhexrep(link.link_id)}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
link.handshake()
|
||||
@@ -219,7 +229,7 @@ class Link:
|
||||
return link
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Validating link request failed: {e}", RNS.LOG_VERBOSE) if RNS.sl(RNS.LOG_VERBOSE) else None
|
||||
RNS.log(f"Validating incoming link request failed: {e}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
return None
|
||||
|
||||
else:
|
||||
@@ -229,7 +239,9 @@ class Link:
|
||||
|
||||
def __init__(self, destination=None, established_callback=None, closed_callback=None, owner=None, peer_pub_bytes=None, peer_sig_pub_bytes=None, mode=MODE_DEFAULT):
|
||||
if destination != None and destination.type != RNS.Destination.SINGLE: raise TypeError("Links can only be established to the \"single\" destination type")
|
||||
if not mode in Link.ENABLED_MODES: raise TypeError(f"Requested link mode {Link.MODE_DESCRIPTIONS[mode]} not enabled")
|
||||
self.mode = mode
|
||||
self.link_id = None
|
||||
self.rtt = None
|
||||
self.mtu = RNS.Reticulum.MTU
|
||||
self.establishment_cost = 0
|
||||
@@ -260,6 +272,8 @@ class Link:
|
||||
self.stale_time = Link.STALE_TIME
|
||||
self.watchdog_lock = False
|
||||
self.status = Link.PENDING
|
||||
self.stamp_status = None
|
||||
self.stamp_job_id = None
|
||||
self.activated_at = None
|
||||
self.type = RNS.Destination.LINK
|
||||
self.owner = owner
|
||||
@@ -267,6 +281,19 @@ class Link:
|
||||
self.expected_hops = None
|
||||
self.rebalanced = None
|
||||
self.attached_interface = None
|
||||
self.stamp_cost = None
|
||||
self.stamp_material = None
|
||||
self.packet = None
|
||||
self.token = None
|
||||
self.hash = None
|
||||
self.prv = None
|
||||
self.prv_bytes = None
|
||||
self.sig_prv = None
|
||||
self.pub = None
|
||||
self.pub_bytes = None
|
||||
self.sig_pub = None
|
||||
self.sig_pub_bytes = None
|
||||
self.__defer_keys = False
|
||||
self.__remote_identity = None
|
||||
self.__track_phy_stats = False
|
||||
self._channel = None
|
||||
@@ -279,21 +306,24 @@ class Link:
|
||||
else:
|
||||
self.initiator = True
|
||||
self.expected_hops = RNS.Transport.hops_to(self.destination.hash)
|
||||
self.establishment_timeout = RNS.Reticulum.get_instance().get_first_hop_timeout(destination.hash)
|
||||
self.establishment_timeout += Link.ESTABLISHMENT_TIMEOUT_PER_HOP * max(1, RNS.Transport.hops_to(destination.hash))
|
||||
self.prv = X25519PrivateKey.generate()
|
||||
self.sig_prv = Ed25519PrivateKey.generate()
|
||||
self.establishment_timeout = RNS.Reticulum.get_instance().get_first_hop_timeout(self.destination.hash)
|
||||
self.establishment_timeout += Link.ESTABLISHMENT_TIMEOUT_PER_HOP * max(1, RNS.Transport.hops_to(self.destination.hash))
|
||||
self.stamp_cost = RNS.Identity.recall_link_cost(self.destination.hash)
|
||||
if self.stamp_cost == None and RNS.Transport.ALWAYS_STAMP_LRS: self.stamp_cost = RNS.Transport.LR_COST
|
||||
|
||||
self.token = None
|
||||
|
||||
self.pub = self.prv.public_key()
|
||||
self.pub_bytes = self.pub.public_bytes()
|
||||
if self.stamp_cost and RNS.Transport.STAMP_LRS: self.__defer_keys = True
|
||||
else:
|
||||
self.prv = X25519PrivateKey.generate()
|
||||
self.sig_prv = Ed25519PrivateKey.generate()
|
||||
|
||||
self.sig_pub = self.sig_prv.public_key()
|
||||
self.sig_pub_bytes = self.sig_pub.public_bytes()
|
||||
if not self.__defer_keys:
|
||||
self.pub = self.prv.public_key()
|
||||
self.pub_bytes = self.pub.public_bytes()
|
||||
self.sig_pub = self.sig_prv.public_key()
|
||||
self.sig_pub_bytes = self.sig_pub.public_bytes()
|
||||
|
||||
if peer_pub_bytes == None:
|
||||
self.peer_pub = None
|
||||
self.peer_pub = None
|
||||
self.peer_pub_bytes = None
|
||||
|
||||
else: self.load_peer(peer_pub_bytes, peer_sig_pub_bytes)
|
||||
@@ -302,26 +332,82 @@ class Link:
|
||||
if closed_callback != None: self.set_link_closed_callback(closed_callback)
|
||||
|
||||
if self.initiator:
|
||||
signalling_bytes = b""
|
||||
nh_hw_mtu = RNS.Transport.next_hop_interface_hw_mtu(destination.hash)
|
||||
if RNS.Reticulum.link_mtu_discovery() and nh_hw_mtu:
|
||||
signalling_bytes = Link.signalling_bytes(nh_hw_mtu, self.mode)
|
||||
RNS.log(f"Signalling link MTU of {RNS.prettysize(nh_hw_mtu)} for link", RNS.LOG_DEBUG) # TODO: Remove debug
|
||||
else: signalling_bytes = Link.signalling_bytes(RNS.Reticulum.MTU, self.mode)
|
||||
RNS.log(f"Establishing link with mode {Link.MODE_DESCRIPTIONS[self.mode]}", RNS.LOG_DEBUG) # TODO: Remove debug
|
||||
self.request_data = self.pub_bytes+self.sig_pub_bytes+signalling_bytes
|
||||
self.packet = RNS.Packet(destination, self.request_data, packet_type=RNS.Packet.LINKREQUEST)
|
||||
self.packet.pack()
|
||||
self.establishment_cost += len(self.packet.raw)
|
||||
self.set_link_id(self.packet)
|
||||
RNS.Transport.register_link(self)
|
||||
self.request_time = time.time()
|
||||
self.start_watchdog()
|
||||
self.packet.send()
|
||||
self.had_outbound()
|
||||
RNS.log("Link request "+RNS.prettyhexrep(self.link_id)+" sent to "+str(self.destination), RNS.LOG_DEBUG)
|
||||
RNS.log(f"Establishment timeout is {RNS.prettytime(self.establishment_timeout)} for link request "+RNS.prettyhexrep(self.link_id), RNS.LOG_EXTREME)
|
||||
if not self.__defer_keys: self.__initiate()
|
||||
else: threading.Thread(target=self.__initiate, daemon=True).start()
|
||||
|
||||
def __stamp_failed(self):
|
||||
if self.status != Link.CLOSED:
|
||||
self.teardown_reason = Link.STAMP_FAILURE
|
||||
self.stamp_status = False
|
||||
self.status = Link.CLOSED
|
||||
self.link_closed()
|
||||
|
||||
def __initiate(self):
|
||||
if self.status != Link.PENDING: return
|
||||
if self.__defer_keys:
|
||||
try:
|
||||
def stamp_watchdog():
|
||||
deadline = time.time() + RNS.Transport.LINK_STAMP_TIMEOUT
|
||||
while self.stamp_status == None and time.time() <= deadline: time.sleep(1)
|
||||
if time.time() > deadline and self.stamp_job_id and not self.stamp_status:
|
||||
cancel_work(self.stamp_job_id)
|
||||
RNS.log(f"Stamp generation timed out for link request to {RNS.prettyhexrep(self.destination.hash)}", RNS.LOG_NOTICE)
|
||||
|
||||
self.sig_prv = Ed25519PrivateKey.generate()
|
||||
self.sig_pub = self.sig_prv.public_key()
|
||||
self.sig_pub_bytes = self.sig_pub.public_bytes()
|
||||
self.stamp_material = self.destination.hash + self.sig_pub_bytes
|
||||
|
||||
RNS.log(f"Starting stamp generation for link request to {self.destination}", RNS.LOG_DEBUG)
|
||||
self.stamp_job_id = self.stamp_material
|
||||
threading.Thread(target=stamp_watchdog, daemon=True).start()
|
||||
stamped_key, v = generate_stamped_key(material=self.stamp_material, stamp_cost=self.stamp_cost)
|
||||
self.stamp_job_id = None
|
||||
|
||||
if stamped_key:
|
||||
stamped_prv = stamped_key[0]
|
||||
self.prv = X25519PrivateKey.from_private_bytes(stamped_prv)
|
||||
self.prv_bytes = self.prv.private_bytes()
|
||||
self.pub = self.prv.public_key()
|
||||
self.pub_bytes = self.pub.public_bytes()
|
||||
|
||||
if self.prv_bytes != stamped_prv or self.prv.public_key().public_bytes() != stamped_key[1]:
|
||||
RNS.log(f"Stamped link request key generation mismatch, aborting link establishment", RNS.LOG_WARNING)
|
||||
self.__stamp_failed()
|
||||
return
|
||||
|
||||
self.stamp_status = True
|
||||
|
||||
else:
|
||||
self.__stamp_failed()
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Error while generating link request stamp: {e}", RNS.LOG_ERROR)
|
||||
RNS.trace_exception(e)
|
||||
self.__stamp_failed()
|
||||
return
|
||||
|
||||
if self.status != Link.PENDING: return
|
||||
|
||||
signalling_bytes = b""
|
||||
nh_hw_mtu = RNS.Transport.next_hop_interface_hw_mtu(self.destination.hash)
|
||||
if RNS.Reticulum.link_mtu_discovery() and nh_hw_mtu:
|
||||
signalling_bytes = Link.signalling_bytes(nh_hw_mtu, self.mode)
|
||||
RNS.log(f"Signalling link MTU of {RNS.prettysize(nh_hw_mtu)} for link", RNS.LOG_PATHING) if RNS.sl(RNS.LOG_PATHING) else None
|
||||
else: signalling_bytes = Link.signalling_bytes(RNS.Reticulum.MTU, self.mode)
|
||||
request_data = self.pub_bytes+self.sig_pub_bytes+signalling_bytes
|
||||
self.packet = RNS.Packet(self.destination, request_data, packet_type=RNS.Packet.LINKREQUEST)
|
||||
self.packet.pack()
|
||||
self.establishment_cost += len(self.packet.raw)
|
||||
self.set_link_id(self.packet)
|
||||
RNS.Transport.register_link(self)
|
||||
self.request_time = time.time()
|
||||
self.start_watchdog()
|
||||
self.packet.send()
|
||||
self.had_outbound()
|
||||
RNS.log(f"Link request {RNS.prettyhexrep(self.link_id)} sent to {self.destination}", RNS.LOG_DEBUG)
|
||||
RNS.log(f"Establishment timeout is {RNS.prettytime(self.establishment_timeout)} for link request {RNS.prettyhexrep(self.link_id)}", RNS.LOG_EXTREME)
|
||||
|
||||
def load_peer(self, peer_pub_bytes, peer_sig_pub_bytes):
|
||||
self.peer_pub_bytes = peer_pub_bytes
|
||||
@@ -425,6 +511,7 @@ class Link:
|
||||
self.activated_at = time.time()
|
||||
self.last_proof = self.activated_at
|
||||
RNS.Transport.activate_link(self)
|
||||
RNS.Transport.mark_path_responsive(self.destination.hash)
|
||||
RNS.log(f"Link {self} established with {self.destination}, RTT is {RNS.prettyshorttime(self.rtt)}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
|
||||
if self.rtt != None and self.establishment_cost != None and self.rtt > 0 and self.establishment_cost > 0:
|
||||
@@ -511,7 +598,7 @@ class Link:
|
||||
|
||||
def update_mdu(self):
|
||||
self.mdu = self.mtu - RNS.Reticulum.HEADER_MAXSIZE - RNS.Reticulum.IFAC_MIN_SIZE
|
||||
self.mdu = math.floor((self.mtu-RNS.Reticulum.IFAC_MIN_SIZE-RNS.Reticulum.HEADER_MINSIZE-RNS.Identity.TOKEN_OVERHEAD)/RNS.Identity.AES128_BLOCKSIZE)*RNS.Identity.AES128_BLOCKSIZE - 1
|
||||
self.mdu = math.floor((self.mtu-RNS.Reticulum.IFAC_MIN_SIZE-RNS.Reticulum.HEADER_MINSIZE-RNS.Identity.TOKEN_OVERHEAD)/RNS.Identity.AES256_BLOCKSIZE)*RNS.Identity.AES256_BLOCKSIZE - 1
|
||||
|
||||
def rtt_packet(self, packet):
|
||||
try:
|
||||
@@ -669,6 +756,7 @@ class Link:
|
||||
self.status = Link.CLOSED
|
||||
if self.initiator: self.teardown_reason = Link.INITIATOR_CLOSED
|
||||
else: self.teardown_reason = Link.DESTINATION_CLOSED
|
||||
if self.stamp_job_id: cancel_work(self.stamp_job_id); self.stamp_status = False
|
||||
self.link_closed()
|
||||
|
||||
def teardown_packet(self, packet):
|
||||
@@ -943,6 +1031,7 @@ class Link:
|
||||
if packet.context != RNS.Packet.KEEPALIVE: self.last_data = self.last_inbound
|
||||
self.rx += 1
|
||||
self.rxbytes += len(packet.data)
|
||||
RNS.Transport.link_rxb += len(packet.raw)
|
||||
if self.status == Link.STALE: self.status = Link.ACTIVE
|
||||
|
||||
if packet.packet_type == RNS.Packet.DATA:
|
||||
@@ -1305,7 +1394,7 @@ class Link:
|
||||
if len(self.outgoing_resources) > 0: return False
|
||||
else: return True
|
||||
|
||||
def __str__(self): return RNS.prettyhexrep(self.link_id)
|
||||
def __str__(self): return RNS.prettyhexrep(self.link_id) if self.link_id else "<pending link>"
|
||||
|
||||
|
||||
class RequestReceipt():
|
||||
|
||||
+17
-9
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -103,7 +103,7 @@ class Packet:
|
||||
# With an MTU of 500, the maximum of data we can
|
||||
# send in a single encrypted packet is given by
|
||||
# the below calculation; 383 bytes.
|
||||
ENCRYPTED_MDU = math.floor((RNS.Reticulum.MDU-RNS.Identity.TOKEN_OVERHEAD-RNS.Identity.KEYSIZE//16)/RNS.Identity.AES128_BLOCKSIZE)*RNS.Identity.AES128_BLOCKSIZE - 1
|
||||
ENCRYPTED_MDU = math.floor((RNS.Reticulum.MDU-RNS.Identity.TOKEN_OVERHEAD-RNS.Identity.KEYSIZE//16)/RNS.Identity.AES256_BLOCKSIZE)*RNS.Identity.AES256_BLOCKSIZE - 1
|
||||
"""
|
||||
The maximum size of the payload data in a single encrypted packet
|
||||
"""
|
||||
@@ -116,12 +116,13 @@ class Packet:
|
||||
|
||||
__slots__ = "hops", "header", "header_type", "packet_type", "transport_type", "context", "context_flag", "destination"
|
||||
__slots__ += "transport_id", "data", "flags", "raw", "packed", "sent", "create_receipt", "receipt", "fromPacked", "MTU"
|
||||
__slots__ += "sent_at", "packet_hash", "ratchet_id", "attached_interface", "receiving_interface", "rssi", "snr", "q"
|
||||
__slots__ += "ciphertext", "plaintext", "destination_hash", "destination_type", "link", "map_hash", "is_outbound_pr"
|
||||
__slots__ += "traffic_class", "announce_signature_validated"
|
||||
__slots__ += "sent_at", "packet_hash", "ratchet_id", "receiving_interface", "attached_interface", "blocked_interfaces"
|
||||
__slots__ += "rssi", "snr", "q", "ciphertext", "plaintext", "destination_hash", "destination_type", "link", "map_hash"
|
||||
__slots__ += "is_outbound_pr", "traffic_class", "announce_signature_validated"
|
||||
|
||||
def __init__(self, destination, data, packet_type = DATA, context = NONE, transport_type = RNS.Transport.BROADCAST,
|
||||
header_type = HEADER_1, transport_id = None, attached_interface = None, create_receipt = True, context_flag=FLAG_UNSET):
|
||||
def __init__(self, destination, data, packet_type=DATA, context=NONE, transport_type=RNS.Transport.BROADCAST,
|
||||
header_type=HEADER_1, transport_id=None, attached_interface=None, blocked_interfaces=None,
|
||||
create_receipt=True, context_flag=FLAG_UNSET):
|
||||
|
||||
if destination != None:
|
||||
if transport_type == None:
|
||||
@@ -163,6 +164,7 @@ class Packet:
|
||||
self.traffic_class = None
|
||||
self.announce_signature_validated = None
|
||||
self.attached_interface = attached_interface
|
||||
self.blocked_interfaces = blocked_interfaces
|
||||
self.receiving_interface = None
|
||||
self.is_outbound_pr = False
|
||||
self.rssi = None
|
||||
@@ -235,8 +237,13 @@ class Packet:
|
||||
self.header += bytes([self.context])
|
||||
self.raw = self.header + self.ciphertext
|
||||
|
||||
if self.packet_type == Packet.ANNOUNCE and self.header_type == Packet.HEADER_1:
|
||||
transport_id_length = RNS.Reticulum.TRUNCATED_HASHLENGTH//8
|
||||
if len(self.raw)+transport_id_length > self.MTU:
|
||||
raise IOError(f"Transport-inserted announce packet size of {len(self.raw)+transport_id_length} exceeds MTU of {self.MTU} bytes")
|
||||
|
||||
if len(self.raw) > self.MTU:
|
||||
raise IOError("Packet size of "+str(len(self.raw))+" exceeds MTU of "+str(self.MTU)+" bytes")
|
||||
raise IOError(f"Packet size of {len(self.raw)} exceeds MTU of {self.MTU} bytes")
|
||||
|
||||
self.packed = True
|
||||
self.update_hash()
|
||||
@@ -279,7 +286,7 @@ class Packet:
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Received malformed packet, dropping it. The contained exception was: {e}", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
RNS.log(f"Dropping malformed packet. The contained exception was: {e}", RNS.LOG_EXTREME) if RNS.sl(RNS.LOG_EXTREME) else None
|
||||
return False
|
||||
|
||||
def send(self):
|
||||
@@ -302,6 +309,7 @@ class Packet:
|
||||
self.destination.last_outbound = time.time()
|
||||
self.destination.tx += 1
|
||||
self.destination.txbytes += len(self.ciphertext)
|
||||
RNS.Transport.link_txb += len(self.raw)
|
||||
|
||||
if RNS.Transport.outbound(self): return self.receipt
|
||||
else:
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+62
-29
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -139,6 +139,7 @@ class Resource:
|
||||
|
||||
HASHMAP_IS_NOT_EXHAUSTED = 0x00
|
||||
HASHMAP_IS_EXHAUSTED = 0xFF
|
||||
HASHMAP_IS_EMPTY = 0xFE
|
||||
|
||||
# Status constants
|
||||
NONE = 0x00
|
||||
@@ -182,6 +183,7 @@ class Resource:
|
||||
resource.hashmap_raw = adv.m
|
||||
resource.encrypted = True if resource.flags & 0x01 else False
|
||||
resource.compressed = True if resource.flags >> 1 & 0x01 else False
|
||||
resource.app_flag = True if resource.flags >> 6 & 0x01 else False
|
||||
resource.initiator = False
|
||||
resource.callback = callback
|
||||
resource.__progress_callback = progress_callback
|
||||
@@ -247,7 +249,7 @@ class Resource:
|
||||
# The data passed can be either a bytes-array or a file opened
|
||||
# in binary read mode.
|
||||
def __init__(self, data, link, metadata=None, advertise=True, auto_compress=True, callback=None, progress_callback=None,
|
||||
timeout = None, segment_index = 1, original_hash = None, request_id = None, is_response = False, sent_metadata_size=0):
|
||||
timeout=None, segment_index = 1, original_hash=None, request_id=None, is_response=False, app_flag=False, sent_metadata_size=0):
|
||||
|
||||
data_size = None
|
||||
resource_data = None
|
||||
@@ -257,6 +259,7 @@ class Resource:
|
||||
self.metadata = None
|
||||
self.has_metadata = False
|
||||
self.metadata_size = sent_metadata_size
|
||||
self.app_flag = app_flag
|
||||
|
||||
if metadata != None:
|
||||
packed_metadata = umsgpack.packb(metadata)
|
||||
@@ -503,11 +506,12 @@ class Resource:
|
||||
if self.hashmap[i+segment*seg_len] == None: self.hashmap_height += 1
|
||||
self.hashmap[i+segment*seg_len] = hashmap[i*Resource.MAPHASH_LEN:(i+1)*Resource.MAPHASH_LEN]
|
||||
|
||||
if hashes < 1:
|
||||
if hashes < 1 and segment != 0:
|
||||
RNS.log("Invalid HMU received, cancelling transfer", RNS.LOG_ERROR)
|
||||
self.cancel()
|
||||
|
||||
else:
|
||||
if hashes == 0 and segment == 0: RNS.log(f"Received HMU-less resource advertisement, requesting initial hashmap", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
self.waiting_for_hmu = False
|
||||
self.request_next()
|
||||
|
||||
@@ -535,7 +539,7 @@ class Resource:
|
||||
else: return True
|
||||
|
||||
def __advertise_job(self):
|
||||
self.advertisement_packet = RNS.Packet(self.link, ResourceAdvertisement(self).pack(), context=RNS.Packet.RESOURCE_ADV)
|
||||
self.advertisement_packet = RNS.Packet(self.link, ResourceAdvertisement(self, mdu=self.link.mdu).pack(), context=RNS.Packet.RESOURCE_ADV)
|
||||
while not self.link.ready_for_new_resource():
|
||||
self.status = Resource.QUEUED
|
||||
sleep(0.25)
|
||||
@@ -594,7 +598,7 @@ class Resource:
|
||||
RNS.log("No part requests received, retrying resource advertisement...", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
self.retries_left -= 1
|
||||
if not self.ensure_link(): return
|
||||
self.advertisement_packet = RNS.Packet(self.link, ResourceAdvertisement(self).pack(), context=RNS.Packet.RESOURCE_ADV)
|
||||
self.advertisement_packet = RNS.Packet(self.link, ResourceAdvertisement(self, mdu=self.link.mdu).pack(), context=RNS.Packet.RESOURCE_ADV)
|
||||
self.advertisement_packet.send()
|
||||
self.last_activity = time.time()
|
||||
self.adv_sent = self.last_activity
|
||||
@@ -789,6 +793,7 @@ class Resource:
|
||||
is_response = self.is_response,
|
||||
advertise = False,
|
||||
auto_compress = self.auto_compress_option,
|
||||
app_flag = self.app_flag,
|
||||
sent_metadata_size = self.metadata_size)
|
||||
|
||||
if self.__progress_callback: self.next_segment.progress_callback(self.__progress_callback)
|
||||
@@ -949,23 +954,30 @@ class Resource:
|
||||
hashmap_exhausted = Resource.HASHMAP_IS_NOT_EXHAUSTED
|
||||
requested_hashes = b""
|
||||
|
||||
i = 0; pn = self.consecutive_completed_height+1
|
||||
search_start = pn
|
||||
search_size = self.window
|
||||
|
||||
for part in self.parts[search_start:search_start+search_size]:
|
||||
if part == None:
|
||||
part_hash = self.hashmap[pn]
|
||||
if part_hash != None:
|
||||
requested_hashes += part_hash
|
||||
self.outstanding_parts += 1
|
||||
i += 1
|
||||
else:
|
||||
hashmap_exhausted = Resource.HASHMAP_IS_EXHAUSTED
|
||||
# Initial advertisement-carried hashmap was empty,
|
||||
# we can't request any real parts, and need an
|
||||
# actual hashmap update first
|
||||
if self.hashmap[0] == None:
|
||||
hashmap_exhausted = Resource.HASHMAP_IS_EMPTY
|
||||
|
||||
pn += 1
|
||||
if i >= self.window or hashmap_exhausted == Resource.HASHMAP_IS_EXHAUSTED:
|
||||
break
|
||||
else:
|
||||
i = 0; pn = self.consecutive_completed_height+1
|
||||
search_start = pn
|
||||
search_size = self.window
|
||||
|
||||
for part in self.parts[search_start:search_start+search_size]:
|
||||
if part == None:
|
||||
part_hash = self.hashmap[pn]
|
||||
if part_hash != None:
|
||||
requested_hashes += part_hash
|
||||
self.outstanding_parts += 1
|
||||
i += 1
|
||||
else:
|
||||
hashmap_exhausted = Resource.HASHMAP_IS_EXHAUSTED
|
||||
|
||||
pn += 1
|
||||
if i >= self.window or hashmap_exhausted == Resource.HASHMAP_IS_EXHAUSTED:
|
||||
break
|
||||
|
||||
hmu_part = bytes([hashmap_exhausted])
|
||||
if hashmap_exhausted == Resource.HASHMAP_IS_EXHAUSTED:
|
||||
@@ -973,6 +985,9 @@ class Resource:
|
||||
hmu_part += last_map_hash
|
||||
self.waiting_for_hmu = True
|
||||
|
||||
if hashmap_exhausted == Resource.HASHMAP_IS_EMPTY:
|
||||
self.waiting_for_hmu = True
|
||||
|
||||
request_data = hmu_part + self.hash + requested_hashes
|
||||
request_packet = RNS.Packet(self.link, request_data, context = RNS.Packet.RESOURCE_REQ)
|
||||
|
||||
@@ -1003,8 +1018,16 @@ class Resource:
|
||||
|
||||
self.retries_left = self.max_retries
|
||||
|
||||
wants_more_hashmap = True if request_data[0] == Resource.HASHMAP_IS_EXHAUSTED else False
|
||||
pad = 1+Resource.MAPHASH_LEN if wants_more_hashmap else 1
|
||||
pad = 1
|
||||
hashmap_is_empty = False
|
||||
wants_more_hashmap = False
|
||||
if request_data[0] == Resource.HASHMAP_IS_EMPTY:
|
||||
wants_more_hashmap = True
|
||||
hashmap_is_empty = True
|
||||
|
||||
if request_data[0] == Resource.HASHMAP_IS_EXHAUSTED:
|
||||
wants_more_hashmap = True
|
||||
pad += Resource.MAPHASH_LEN
|
||||
|
||||
requested_hashes = request_data[pad+RNS.Identity.HASHLENGTH//8:]
|
||||
|
||||
@@ -1040,15 +1063,15 @@ class Resource:
|
||||
last_map_hash = request_data[1:Resource.MAPHASH_LEN+1]
|
||||
|
||||
part_index = self.receiver_min_consecutive_height
|
||||
search_start = part_index
|
||||
search_end = self.receiver_min_consecutive_height+ResourceAdvertisement.COLLISION_GUARD_SIZE
|
||||
search_start = part_index if not hashmap_is_empty else 0
|
||||
search_end = self.receiver_min_consecutive_height+ResourceAdvertisement.COLLISION_GUARD_SIZE if not hashmap_is_empty else 0
|
||||
for part in self.parts[search_start:search_end]:
|
||||
part_index += 1
|
||||
if part.map_hash == last_map_hash: break
|
||||
|
||||
self.receiver_min_consecutive_height = max(part_index-1-Resource.WINDOW_MAX, 0)
|
||||
|
||||
if part_index % ResourceAdvertisement.HASHMAP_MAX_LEN != 0:
|
||||
if not hashmap_is_empty and part_index % ResourceAdvertisement.HASHMAP_MAX_LEN != 0:
|
||||
RNS.log("Resource sequencing error, cancelling transfer!", RNS.LOG_ERROR)
|
||||
self.cancel()
|
||||
return
|
||||
@@ -1286,8 +1309,9 @@ class ResourceAdvertisement:
|
||||
adv = ResourceAdvertisement.unpack(advertisement_packet.plaintext)
|
||||
return adv.d
|
||||
|
||||
def __init__(self, resource=None, request_id=None, is_response=False):
|
||||
def __init__(self, resource=None, request_id=None, is_response=False, mdu=None):
|
||||
self.link = None
|
||||
self.mdu = mdu or RNS.Link.MDU
|
||||
if resource != None:
|
||||
self.t = resource.size # Transfer size
|
||||
self.d = resource.total_size # Total uncompressed data size
|
||||
@@ -1298,6 +1322,7 @@ class ResourceAdvertisement:
|
||||
self.m = resource.hashmap # Resource hashmap
|
||||
self.c = resource.compressed # Compression flag
|
||||
self.e = resource.encrypted # Encryption flag
|
||||
self.a = resource.app_flag # Application flag
|
||||
self.s = resource.split # Split flag
|
||||
self.x = resource.has_metadata # Metadata flag
|
||||
self.i = resource.segment_index # Segment index
|
||||
@@ -1315,7 +1340,7 @@ class ResourceAdvertisement:
|
||||
self.p = True
|
||||
|
||||
# Flags
|
||||
self.f = 0x00 | self.x << 5 | self.p << 4 | self.u << 3 | self.s << 2 | self.c << 1 | self.e
|
||||
self.f = 0x00 | self.a << 6 | self.x << 5 | self.p << 4 | self.u << 3 | self.s << 2 | self.c << 1 | self.e
|
||||
|
||||
def get_transfer_size(self): return self.t
|
||||
def get_data_size(self): return self.d
|
||||
@@ -1325,6 +1350,7 @@ class ResourceAdvertisement:
|
||||
def is_compressed(self): return self.c
|
||||
def has_metadata(self): return self.x
|
||||
def get_link(self): return self.link
|
||||
def app_flag_set(self): return self.f >> 6 & 0x01
|
||||
|
||||
def pack(self, segment=0):
|
||||
hashmap_start = segment*ResourceAdvertisement.HASHMAP_MAX_LEN
|
||||
@@ -1346,7 +1372,13 @@ class ResourceAdvertisement:
|
||||
"f": self.f, # Resource flags
|
||||
"m": hashmap }
|
||||
|
||||
return umsgpack.packb(dictionary)
|
||||
packed_adv = umsgpack.packb(dictionary)
|
||||
if len(packed_adv) > self.mdu:
|
||||
RNS.log(f"Resource advertisement ({RNS.prettysize(len(packed_adv))}) exceeds link MDU, deferring initial HMU", RNS.LOG_DEBUG) if RNS.sl(RNS.LOG_DEBUG) else None
|
||||
dictionary["m"] = b""
|
||||
packed_adv = umsgpack.packb(dictionary)
|
||||
|
||||
return packed_adv
|
||||
|
||||
@staticmethod
|
||||
def unpack(data):
|
||||
@@ -1370,6 +1402,7 @@ class ResourceAdvertisement:
|
||||
adv.u = True if ((adv.f >> 3) & 0x01) == 0x01 else False
|
||||
adv.p = True if ((adv.f >> 4) & 0x01) == 0x01 else False
|
||||
adv.x = True if ((adv.f >> 5) & 0x01) == 0x01 else False
|
||||
adv.a = True if ((adv.f >> 6) & 0x01) == 0x01 else False
|
||||
|
||||
if adv.t > Resource.MAX_EFFICIENT_SIZE*3: raise ValueError("Invalid transfer size")
|
||||
|
||||
|
||||
+492
-66
@@ -53,6 +53,7 @@ import configparser
|
||||
import multiprocessing.connection
|
||||
import importlib.util
|
||||
import threading
|
||||
import weakref
|
||||
import signal
|
||||
import atexit
|
||||
import struct
|
||||
@@ -175,17 +176,35 @@ class Reticulum:
|
||||
gracious_persist_lock = Lock()
|
||||
|
||||
__instance = None
|
||||
__pid = os.getpid()
|
||||
|
||||
__interface_detach_ran = False
|
||||
__exit_handler_ran = False
|
||||
RPC_EXIT_TIMEOUT = 0.5
|
||||
@staticmethod
|
||||
def exit_handler():
|
||||
# This exit handler is called whenever Reticulum is asked to
|
||||
# shut down, and will in turn call exit handlers in other
|
||||
# classes, saving necessary information to disk and carrying
|
||||
# out cleanup operations.
|
||||
if not os.getpid() == Reticulum.__pid:
|
||||
Reticulum.__exit_handler_ran = True
|
||||
|
||||
if not Reticulum.__exit_handler_ran:
|
||||
Reticulum.__exit_handler_ran = True
|
||||
|
||||
for conn in list(Reticulum.__open_rpc_conns):
|
||||
try: conn.close()
|
||||
except Exception: pass
|
||||
|
||||
try:
|
||||
if Reticulum.__instance.is_connected_to_shared_instance:
|
||||
deregister_job = threading.Thread(target=Reticulum.__instance.unwants_all_destination_types, daemon=True)
|
||||
deregister_job.start()
|
||||
deregister_job.join(timeout=Reticulum.RPC_EXIT_TIMEOUT)
|
||||
if deregister_job.is_alive(): RNS.log("Shared instance RPC timed out during exit", RNS.LOG_DEBUG)
|
||||
except Exception as e: RNS.log(f"Could not deregister destination types at exit: {e}", RNS.LOG_DEBUG)
|
||||
|
||||
if not Reticulum.__interface_detach_ran: RNS.Transport.detach_interfaces()
|
||||
RNS.Transport.exit_handler()
|
||||
RNS.Identity.exit_handler()
|
||||
@@ -195,13 +214,13 @@ class Reticulum:
|
||||
|
||||
@staticmethod
|
||||
def sigint_handler(signal, frame):
|
||||
RNS.Transport.detach_interfaces()
|
||||
if os.getpid() == Reticulum.__pid: RNS.Transport.detach_interfaces()
|
||||
Reticulum.__interface_detach_ran = True
|
||||
RNS.exit()
|
||||
|
||||
@staticmethod
|
||||
def sigterm_handler(signal, frame):
|
||||
RNS.Transport.detach_interfaces()
|
||||
if os.getpid() == Reticulum.__pid: RNS.Transport.detach_interfaces()
|
||||
Reticulum.__interface_detach_ran = True
|
||||
RNS.exit()
|
||||
|
||||
@@ -212,8 +231,16 @@ class Reticulum:
|
||||
"""
|
||||
return Reticulum.__instance
|
||||
|
||||
@staticmethod
|
||||
def get_instance_pid():
|
||||
"""
|
||||
Returns the main process ID of the currently running Reticulum instance.
|
||||
"""
|
||||
return Reticulum.__pid
|
||||
|
||||
def __init__(self,configdir=None, loglevel=None, logdest=None, verbosity=None,
|
||||
require_shared_instance=False, shared_instance_type=None):
|
||||
require_shared_instance=False, shared_instance_type=None,
|
||||
enable_stamping=False, enforce_stamps=False):
|
||||
"""
|
||||
Initialises and starts a Reticulum instance. This must be
|
||||
done before any other operations, and Reticulum will not
|
||||
@@ -264,6 +291,9 @@ class Reticulum:
|
||||
Reticulum.__discover_interfaces = False
|
||||
Reticulum.__autoconnect_discovered_interfaces = False
|
||||
Reticulum.__autoconnect_unverified = False
|
||||
Reticulum.__autoconnect_warn = 6
|
||||
Reticulum.__autoconnect_cap = 12
|
||||
Reticulum.__autoconnect_caps_disabled = False
|
||||
Reticulum.__autoconnect_interface_mode = None
|
||||
Reticulum.__autoconnect_interface_gravity = None
|
||||
Reticulum.__autoconnect_announces_to_internal = None
|
||||
@@ -348,9 +378,16 @@ class Reticulum:
|
||||
RNS.log(f"Utilising cryptography backend \"{RNS.Cryptography.Provider.backend()}\"", RNS.LOG_DEBUG)
|
||||
RNS.log(f"Configuration loaded from {self.configpath}", RNS.LOG_VERBOSE)
|
||||
|
||||
RNS.Identity.load_known_destinations()
|
||||
if not self.is_connected_to_shared_instance: RNS.Identity._clean_ratchets()
|
||||
RNS.Transport.start(self)
|
||||
if enable_stamping:
|
||||
RNS.log(f"Network stamp generation activated", RNS.LOG_VERBOSE)
|
||||
RNS.Transport.STAMP_DESTINATIONS = True
|
||||
RNS.Transport.STAMP_PRS = True
|
||||
RNS.Transport.STAMP_LRS = True
|
||||
|
||||
if enforce_stamps:
|
||||
RNS.log(f"Network stamp enforcement activated", RNS.LOG_VERBOSE)
|
||||
RNS.Transport.STAMPS_ENFORCED = True
|
||||
RNS.Transport.LR_STAMPS_ENFORCED = True
|
||||
|
||||
if self.use_af_unix:
|
||||
self.rpc_addr = f"\0rns/{self.local_socket_path}/rpc"
|
||||
@@ -362,8 +399,12 @@ class Reticulum:
|
||||
if self.rpc_key == None:
|
||||
self.rpc_key = RNS.Identity.full_hash(RNS.Transport.internal_identity().get_private_key())
|
||||
|
||||
RNS.Identity.load_known_destinations()
|
||||
if not self.is_connected_to_shared_instance: RNS.Identity._clean_ratchets()
|
||||
RNS.Transport.start(self)
|
||||
|
||||
if self.is_shared_instance:
|
||||
self.rpc_listener = multiprocessing.connection.Listener(self.rpc_addr, family=self.rpc_type, authkey=self.rpc_key)
|
||||
self.rpc_listener = multiprocessing.connection.Listener(self.rpc_addr, family=self.rpc_type, backlog=128, authkey=self.rpc_key)
|
||||
thread = threading.Thread(target=self.rpc_loop)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
@@ -471,6 +512,80 @@ class Reticulum:
|
||||
value = self.config["logging"].as_bool(option)
|
||||
RNS.logtimestamps = bool(value)
|
||||
|
||||
if "filter" in self.config:
|
||||
for option in self.config["filter"]:
|
||||
if option == "required_only":
|
||||
v = self.config["filter"].as_bool(option)
|
||||
RNS.Transport.required_destinations_only = v
|
||||
|
||||
if option == "ignored_types":
|
||||
entries = self.config["filter"].as_list(option)
|
||||
for entry in entries: RNS.Transport.block_destination_type(entry)
|
||||
|
||||
if option == "allowed_types":
|
||||
entries = self.config["filter"].as_list(option)
|
||||
for entry in entries: RNS.Transport.allow_destination_type(entry)
|
||||
|
||||
if option == "hop_limiter":
|
||||
v = self.config["filter"].as_int(option)
|
||||
RNS.Transport.HOP_LIMITER = max(0, min(v, RNS.Transport.PATHFINDER_M))
|
||||
|
||||
if "stamps" in self.config:
|
||||
for option in self.config["stamps"]:
|
||||
if option == "enforce_stamps":
|
||||
value = self.config["stamps"].as_bool(option)
|
||||
if value == True:
|
||||
RNS.Transport.STAMPS_ENFORCED = True
|
||||
RNS.Transport.LR_STAMPS_ENFORCED = True
|
||||
|
||||
if option == "stamp_destinations":
|
||||
value = self.config["stamps"].as_bool(option)
|
||||
if value == True: RNS.Transport.STAMP_DESTINATIONS = True
|
||||
|
||||
if option == "stamp_prs":
|
||||
value = self.config["stamps"].as_bool(option)
|
||||
if value == True: RNS.Transport.STAMP_PRS = True
|
||||
|
||||
if option == "always_stamp_lrs":
|
||||
value = self.config["stamps"].as_bool(option)
|
||||
if value == True: RNS.Transport.ALWAYS_STAMP_LRS = True
|
||||
|
||||
if option == "destination_cost":
|
||||
v = self.config["stamps"].as_float(option)
|
||||
RNS.Transport.DESTINATION_COST = max(0, min(v, RNS.Transport.STAMP_COST_CAP))
|
||||
|
||||
if option == "destination_value":
|
||||
v = self.config["stamps"].as_float(option)
|
||||
RNS.Transport.DESTINATION_VALUE = max(0, min(v, RNS.Transport.STAMP_COST_CAP))
|
||||
|
||||
if option == "pr_cost":
|
||||
v = self.config["stamps"].as_float(option)
|
||||
RNS.Transport.PR_COST = max(0, min(v, RNS.Transport.STAMP_COST_CAP))
|
||||
|
||||
if option == "pr_value":
|
||||
v = self.config["stamps"].as_float(option)
|
||||
RNS.Transport.PR_VALUE = max(0, min(v, RNS.Transport.STAMP_COST_CAP))
|
||||
|
||||
if option == "lr_cost":
|
||||
v = self.config["stamps"].as_float(option)
|
||||
RNS.Transport.LR_COST = max(0, min(v, RNS.Transport.LINK_COST_CAP))
|
||||
|
||||
if option == "lr_stamp_timeout":
|
||||
v = self.config["stamps"].as_float(option)
|
||||
RNS.Transport.LINK_STAMP_TIMEOUT = max(0.020, v)
|
||||
|
||||
if option == "pr_stamp_timeout":
|
||||
v = self.config["stamps"].as_float(option)
|
||||
RNS.Transport.PR_STAMP_TIMEOUT = max(0.020, v)
|
||||
|
||||
if option == "max_workers":
|
||||
v = self.config["stamps"].as_int(option)
|
||||
RNS.Stamps.MAX_WORKERS = max(1, v)
|
||||
|
||||
if option == "worker_niceness":
|
||||
v = self.config["stamps"].as_int(option)
|
||||
RNS.Stamps.NICENESS = min(20, max(0, v))
|
||||
|
||||
if "reticulum" in self.config:
|
||||
for option in self.config["reticulum"]:
|
||||
value = self.config["reticulum"][option]
|
||||
@@ -509,7 +624,7 @@ class Reticulum:
|
||||
if option == "enable_transport":
|
||||
v = self.config["reticulum"].as_bool(option)
|
||||
if v == True: Reticulum.__transport_enabled = True
|
||||
|
||||
|
||||
if option == "static_transport_identity":
|
||||
v = self.config["reticulum"].as_bool(option)
|
||||
if v == True: Reticulum.__static_transport_identity = True
|
||||
@@ -593,7 +708,7 @@ class Reticulum:
|
||||
if v == False: Reticulum.__discover_interfaces = False
|
||||
|
||||
if option == "required_discovery_value":
|
||||
v = self.config["reticulum"].as_int(option)
|
||||
v = self.config["reticulum"].as_float(option)
|
||||
if v > 0: Reticulum.__required_discovery_value = v
|
||||
else: Reticulum.__required_discovery_value = None
|
||||
|
||||
@@ -625,9 +740,32 @@ class Reticulum:
|
||||
except Exception as e: raise ValueError(f"Invalid identity hash for interface discovery source: {hexhash}")
|
||||
if not source_identity_hash in Reticulum.__interface_sources: Reticulum.__interface_sources.append(source_identity_hash)
|
||||
|
||||
if option == "autoconnect_discovered_interfaces_disable_caps":
|
||||
v = self.config["reticulum"].as_bool(option)
|
||||
if v: Reticulum.__autoconnect_caps_disabled = True
|
||||
|
||||
if option == "autoconnect_discovered_interfaces":
|
||||
v = self.config["reticulum"].as_int(option)
|
||||
if v > 0: Reticulum.__autoconnect_discovered_interfaces = v
|
||||
if not Reticulum.__autoconnect_caps_disabled:
|
||||
if Reticulum.__autoconnect_discovered_interfaces > Reticulum.__autoconnect_cap:
|
||||
Reticulum.__autoconnect_discovered_interfaces = Reticulum.__autoconnect_cap
|
||||
RNS.log(f"", RNS.LOG_WARNING)
|
||||
RNS.log(f"Auto-connect interface target was capped to {Reticulum.__autoconnect_discovered_interfaces}", RNS.LOG_WARNING)
|
||||
RNS.log(f"Using large numbers of auto-connected interfaces will not lead to better", RNS.LOG_WARNING)
|
||||
RNS.log(f"connectivity or redundancy. If you really know what you're doing, and are", RNS.LOG_WARNING)
|
||||
RNS.log(f"certain that you need this, you will also know how to get around this check.", RNS.LOG_WARNING)
|
||||
if Reticulum.__autoconnect_discovered_interfaces > Reticulum.__autoconnect_warn:
|
||||
RNS.log(f"", RNS.LOG_WARNING)
|
||||
RNS.log(f"You have configured more than {Reticulum.__autoconnect_warn} auto-connect interfaces.", RNS.LOG_WARNING)
|
||||
RNS.log(f"In almost all situations, this is excessive, and should be avoided.", RNS.LOG_WARNING)
|
||||
RNS.log(f"For a normal home or office node, 2-3 autoconnects will be sufficient.", RNS.LOG_WARNING)
|
||||
RNS.log(f"", RNS.LOG_WARNING)
|
||||
RNS.log(f"If you're running a fast, well-connected transport node that can actually", RNS.LOG_WARNING)
|
||||
RNS.log(f"provide additional capacity and transport to the network, you can consider", RNS.LOG_WARNING)
|
||||
RNS.log(f"raising this number to {Reticulum.__autoconnect_warn}-{Reticulum.__autoconnect_warn+3}. Only in the rarest of cases will going beyond", RNS.LOG_WARNING)
|
||||
RNS.log(f"this actually provide any benefit.", RNS.LOG_WARNING)
|
||||
RNS.log(f"", RNS.LOG_WARNING)
|
||||
|
||||
if option == "autoconnect_unverified_implementations":
|
||||
v = self.config["reticulum"].as_bool(option)
|
||||
@@ -746,11 +884,50 @@ class Reticulum:
|
||||
if self.local_socket_path == None and self.use_af_unix:
|
||||
self.local_socket_path = "default"
|
||||
|
||||
if os.path.isfile(Reticulum.configdir+"/blocked_ips"):
|
||||
try:
|
||||
with open(Reticulum.configdir+"/blocked_ips", "r") as f:
|
||||
expire = time.time()+(60*60*24*365.25*1000)
|
||||
blocked_ips = f.read().strip().splitlines()
|
||||
blocked_count = 0
|
||||
for line in blocked_ips:
|
||||
blocked_ip = line.strip()
|
||||
if blocked_ip.startswith("#"): continue
|
||||
if RNS.Discovery.is_ip_address(blocked_ip):
|
||||
BackboneInterface.BackboneInterface.fast_flapping[blocked_ip] = [expire, expire, 0xFFFF]
|
||||
blocked_count += 1
|
||||
RNS.log(f"Loaded {blocked_count} blocked IPs", RNS.LOG_VERBOSE)
|
||||
|
||||
except Exception as e: RNS.log(f"Error while loading blocked IP list: {e}", RNS.LOG_ERROR)
|
||||
|
||||
if os.path.isfile(Reticulum.configdir+"/known_destination_types"):
|
||||
try:
|
||||
with open(Reticulum.configdir+"/known_destination_types", "r") as f:
|
||||
dst_types = f.read().strip().splitlines()
|
||||
for line in dst_types:
|
||||
dst_type = line.strip()
|
||||
if dst_type.startswith("#"): continue
|
||||
RNS.Transport.destination_type_map[RNS.Destination.name_hash(dst_type)] = dst_type
|
||||
|
||||
except Exception as e: RNS.log(f"Error while loading known destination types list: {e}", RNS.LOG_ERROR)
|
||||
|
||||
if os.path.isfile(Reticulum.configdir+"/flagged_destination_types"):
|
||||
try:
|
||||
with open(Reticulum.configdir+"/flagged_destination_types", "r") as f:
|
||||
dst_types = f.read().strip().splitlines()
|
||||
for line in dst_types:
|
||||
dst_type = line.strip()
|
||||
if dst_type.startswith("#"): continue
|
||||
RNS.Transport.flagged_type_map[RNS.Destination.name_hash(dst_type)] = dst_type
|
||||
|
||||
except Exception as e: RNS.log(f"Error while loading flagged destination types list: {e}", RNS.LOG_ERROR)
|
||||
|
||||
dql = RNS.Reticulum.default_data_queue_length() or RNS.Transport.INBOUND_DA_QUEUE_LENGTH
|
||||
BackboneInterface.BackboneInterface.DP_IC_HIGH_WM = max(4, int((BackboneInterface.BackboneInterface.DP_IC_HIGH_WM_PCT/100.0) * dql))
|
||||
BackboneInterface.BackboneInterface.DP_IC_MID_WM = max(2, int((BackboneInterface.BackboneInterface.DP_IC_MID_WM_PCT/100.0) * dql))
|
||||
BackboneInterface.BackboneInterface.DP_IC_LOW_WM = max(0, int((BackboneInterface.BackboneInterface.DP_IC_LOW_WM_PCT/100.0) * dql))
|
||||
|
||||
RNS.Transport.ensure_identity()
|
||||
self.__start_local_interface()
|
||||
|
||||
if self.is_shared_instance or self.is_standalone_instance:
|
||||
@@ -796,16 +973,25 @@ class Reticulum:
|
||||
except Exception as e: RNS.log(f"Error while detaching interface \"{name}\": {e}", RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
def _detach_interface(self, name, internal_forced=False):
|
||||
def _detach_interface(self, name, internal_forced=False, interface_instance=None):
|
||||
if not internal_forced and not Reticulum.__interface_management_enabled: return False
|
||||
try:
|
||||
interfaces = { iface.name: iface for iface in RNS.Transport.interfaces }
|
||||
if not name in interfaces:
|
||||
RNS.log(f"Attempt to detach non-existing interface \"{name}\"", RNS.LOG_WARNING)
|
||||
if interface_instance: interface = interface_instance
|
||||
else:
|
||||
interfaces = { iface.name: iface for iface in RNS.Transport.interfaces }
|
||||
interface = interfaces.get(name, None)
|
||||
if not interface:
|
||||
try: tunnel_id = bytes.fromhex(name)
|
||||
except: return None
|
||||
tunnel_ids = { iface.tunnel_id: iface for iface in RNS.Transport.interfaces if iface.tunnel_id }
|
||||
local_tunnel_ids = { iface.local_tunnel_id: iface for iface in RNS.Transport.interfaces if iface.local_tunnel_id }
|
||||
interface = tunnel_ids.get(tunnel_id, None) or local_tunnel_ids.get(tunnel_id, None)
|
||||
|
||||
if not interface:
|
||||
RNS.log(f"Attempt to detach non-existing interface \"{name or interface}\"", RNS.LOG_WARNING)
|
||||
return None
|
||||
|
||||
else:
|
||||
interface = interfaces[name]
|
||||
if isinstance(interface, I2PInterface.I2PInterface): return False
|
||||
if isinstance(interface, LocalInterface.LocalClientInterface): return False
|
||||
if isinstance(interface, LocalInterface.LocalServerInterface): return False
|
||||
@@ -818,8 +1004,12 @@ class Reticulum:
|
||||
RNS.Transport.remove_interface(s)
|
||||
|
||||
interface.detach()
|
||||
if interface.parent_interface and interface.parent_interface.spawned_interfaces:
|
||||
if interface in interface.parent_interface.spawned_interfaces:
|
||||
interface.teardown()
|
||||
|
||||
RNS.Transport.remove_interface(interface)
|
||||
RNS.log(f"Interface \"{name}\" was detached", RNS.LOG_NOTICE)
|
||||
RNS.log(f"Interface {interface} was detached", RNS.LOG_NOTICE)
|
||||
return True
|
||||
|
||||
except Exception as e: RNS.log(f"Error while detaching interface \"{name}\": {e}", RNS.LOG_ERROR); RNS.trace_exception(e)
|
||||
@@ -881,10 +1071,25 @@ class Reticulum:
|
||||
gravity = self._default_gravity()
|
||||
if "gravity" in c: gravity = c.as_int("gravity")
|
||||
|
||||
hop_limiter = None
|
||||
if "hop_limiter" in c:
|
||||
v = c.as_int("hop_limiter")
|
||||
hop_limiter = max(0, min(v, RNS.Transport.PATHFINDER_M))
|
||||
|
||||
destination_cost = None
|
||||
if "destination_cost" in c:
|
||||
v = c.as_float("destination_cost")
|
||||
destination_cost = max(0, min(v, RNS.Transport.STAMP_COST_CAP))
|
||||
|
||||
pr_cost = None
|
||||
if "pr_cost" in c:
|
||||
v = c.as_float("pr_cost")
|
||||
pr_cost = max(0, min(v, RNS.Transport.STAMP_COST_CAP))
|
||||
|
||||
ifac_size = None
|
||||
if "ifac_size" in c:
|
||||
if c.as_int("ifac_size") >= Reticulum.IFAC_MIN_SIZE*8: ifac_size = c.as_int("ifac_size")//8
|
||||
|
||||
|
||||
ifac_netname = None
|
||||
if "networkname" in c:
|
||||
if c["networkname"] == "None": RNS.log("Ambiguous IFAC network name \"None\", this value is ignored and an IFAC network name has NOT been set", RNS.LOG_WARNING)
|
||||
@@ -989,12 +1194,16 @@ class Reticulum:
|
||||
discoverable = c.as_bool("discoverable")
|
||||
if discoverable:
|
||||
Reticulum.__discovery_enabled = True
|
||||
if not Reticulum.__static_transport_identity and not Reticulum.__transport_enabled:
|
||||
RNS.log(f"Discoverable interface was configured, enabling static transport identity on non-transport instance", RNS.LOG_WARNING)
|
||||
Reticulum.__static_transport_identity = True
|
||||
|
||||
if "announce_interval" in c:
|
||||
discovery_announce_interval = c.as_int("announce_interval")*60
|
||||
if discovery_announce_interval < 5*60: discovery_announce_interval = 5*60
|
||||
|
||||
if discovery_announce_interval == None: discovery_announce_interval = 6*60*60
|
||||
if "discovery_stamp_value" in c: discovery_stamp_value = c.as_int("discovery_stamp_value")
|
||||
if "discovery_stamp_value" in c: discovery_stamp_value = c.as_float("discovery_stamp_value")
|
||||
if "discovery_name" in c: discovery_name = c["discovery_name"]
|
||||
if "discovery_encrypt" in c: discovery_encrypt = c.as_bool("discovery_encrypt")
|
||||
if "reachable_on" in c: reachable_on = c["reachable_on"]
|
||||
@@ -1027,11 +1236,12 @@ class Reticulum:
|
||||
if "outgoing" in c and c.as_bool("outgoing") == False: interface.OUT = False
|
||||
else: interface.OUT = True
|
||||
|
||||
interface.mode = interface_mode
|
||||
interface.gravity = gravity
|
||||
interface.announce_cap = announce_cap
|
||||
interface.bootstrap_only = bootstrap_only
|
||||
if configured_bitrate: interface.bitrate = configured_bitrate
|
||||
interface.mode = interface_mode
|
||||
interface.gravity = gravity
|
||||
interface.hop_limiter = hop_limiter
|
||||
interface.announce_cap = announce_cap
|
||||
interface.bootstrap_only = bootstrap_only
|
||||
if configured_bitrate: interface.bitrate = configured_bitrate
|
||||
interface.optimise_mtu()
|
||||
|
||||
if ifac_size != None: interface.ifac_size = ifac_size
|
||||
@@ -1061,6 +1271,9 @@ class Reticulum:
|
||||
interface.announce_rate_penalty = announce_rate_penalty
|
||||
interface.ingress_control = ingress_control
|
||||
|
||||
interface._destination_cost = destination_cost
|
||||
interface._pr_cost = pr_cost
|
||||
|
||||
if egress_control != None: interface.egress_control = egress_control
|
||||
if ic_max_held_announces != None: interface.ic_max_held_announces = ic_max_held_announces
|
||||
if ic_burst_hold != None: interface.ic_burst_hold = ic_burst_hold
|
||||
@@ -1346,7 +1559,7 @@ class Reticulum:
|
||||
filepath = self.cachepath + "/" + filename
|
||||
mtime = os.path.getmtime(filepath)
|
||||
age = now - mtime
|
||||
if age > RNS.Transport.DESTINATION_TIMEOUT: os.unlink(filepath)
|
||||
if age > RNS.Transport.PATH_TIMEOUT: os.unlink(filepath)
|
||||
if background: time.sleep(0.001)
|
||||
|
||||
except Exception as e:
|
||||
@@ -1364,6 +1577,7 @@ class Reticulum:
|
||||
|
||||
def rpc_loop(self):
|
||||
while RNS.Transport._should_run:
|
||||
conn = None
|
||||
try:
|
||||
conn = self.rpc_listener.accept()
|
||||
call = mp.unpackb(conn.recv_bytes())
|
||||
@@ -1377,12 +1591,14 @@ class Reticulum:
|
||||
|
||||
if path == "interface_stats": self.rpc_return(conn, self.get_interface_stats())
|
||||
if path == "rate_table": self.rpc_return(conn, self.get_rate_table())
|
||||
if path == "known_destinations": self.rpc_return(conn, self.get_known_destinations())
|
||||
if path == "next_hop_if_name": self.rpc_return(conn, self.get_next_hop_if_name(call["destination_hash"]))
|
||||
if path == "next_hop": self.rpc_return(conn, self.get_next_hop(call["destination_hash"]))
|
||||
if path == "first_hop_timeout": self.rpc_return(conn, self.get_first_hop_timeout(call["destination_hash"]))
|
||||
if path == "lowest_interface_bitrate": self.rpc_return(conn, self.get_lowest_interface_bitrate())
|
||||
if path == "medium_path_timeout": self.rpc_return(conn, self.get_medium_path_timeout())
|
||||
if path == "link_count": self.rpc_return(conn, self.get_link_count())
|
||||
if path == "link_distribution": self.rpc_return(conn, self.get_link_distribution())
|
||||
if path == "active_link_count": self.rpc_return(conn, self.get_active_link_count())
|
||||
if path == "packet_rssi": self.rpc_return(conn, self.get_packet_rssi(call["packet_hash"]))
|
||||
if path == "packet_snr": self.rpc_return(conn, self.get_packet_snr(call["packet_hash"]))
|
||||
@@ -1413,6 +1629,23 @@ class Reticulum:
|
||||
identity_hash = call["unblackhole_identity"]
|
||||
self.rpc_return(conn, self.unblackhole_identity(identity_hash))
|
||||
|
||||
if "wants_destination_type" in call:
|
||||
full_name = call["wants_destination_type"]
|
||||
requester = call["requester"]
|
||||
signature = call["signature"]
|
||||
self.rpc_return(conn, self.wants_destination_type(full_name, requester, signature))
|
||||
|
||||
if "unwants_destination_type" in call:
|
||||
full_name = call["unwants_destination_type"]
|
||||
requester = call["requester"]
|
||||
signature = call["signature"]
|
||||
self.rpc_return(conn, self.unwants_destination_type(full_name, requester, signature))
|
||||
|
||||
if "unwants_all_destination_types" in call:
|
||||
requester = call["requester"]
|
||||
signature = call["signature"]
|
||||
self.rpc_return(conn, self.unwants_all_destination_types(requester, signature))
|
||||
|
||||
if "destination_data" in call:
|
||||
operation = call["destination_data"]
|
||||
destination_hash = call["destination_hash"]
|
||||
@@ -1425,12 +1658,14 @@ class Reticulum:
|
||||
identity_hash = call["identity_hash"]
|
||||
if operation == "retain": self.rpc_return(conn, self._retain_identity(identity_hash))
|
||||
|
||||
conn.close()
|
||||
except Exception as e: RNS.log("An error ocurred while handling RPC call from local client: "+str(e), RNS.LOG_ERROR)
|
||||
finally: conn.close() if conn else None
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("An error ocurred while handling RPC call from local client: "+str(e), RNS.LOG_ERROR)
|
||||
|
||||
def get_rpc_client(self): return multiprocessing.connection.Client(self.rpc_addr, family=self.rpc_type, authkey=self.rpc_key)
|
||||
__open_rpc_conns = weakref.WeakSet()
|
||||
def get_rpc_client(self):
|
||||
conn = multiprocessing.connection.Client(self.rpc_addr, family=self.rpc_type, authkey=self.rpc_key)
|
||||
Reticulum.__open_rpc_conns.add(conn)
|
||||
return conn
|
||||
|
||||
def _used_destination_data(self, destination_hash):
|
||||
if self.is_connected_to_shared_instance:
|
||||
@@ -1493,10 +1728,15 @@ class Reticulum:
|
||||
|
||||
def get_interface_stats(self):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "interface_stats"}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "interface_stats"}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting interface stats: {e}", RNS.LOG_ERROR)
|
||||
return None
|
||||
|
||||
else:
|
||||
interfaces = []
|
||||
@@ -1531,6 +1771,16 @@ class Reticulum:
|
||||
else:
|
||||
ifstats["tunnelstate"] = None
|
||||
|
||||
if hasattr(interface, "r_stat_rssi"): ifstats["rssi"] = interface.r_stat_rssi
|
||||
if hasattr(interface, "r_stat_snr"): ifstats["snr"] = interface.r_stat_snr
|
||||
if hasattr(interface, "r_stat_q"): ifstats["signal_quality"] = interface.r_stat_q
|
||||
if hasattr(interface, "r_frequency"): ifstats["frequency"] = interface.r_frequency
|
||||
if hasattr(interface, "r_bandwidth"): ifstats["bandwidth"] = interface.r_bandwidth
|
||||
if hasattr(interface, "r_txpower"): ifstats["txpower"] = interface.r_txpower
|
||||
if hasattr(interface, "r_sf"): ifstats["sf"] = interface.r_sf
|
||||
if hasattr(interface, "r_cr"): ifstats["cr"] = interface.r_cr
|
||||
if hasattr(interface, "r_channel"): ifstats["channel"] = interface.r_channel
|
||||
if hasattr(interface, "modulation"): ifstats["modulation"] = interface.modulation
|
||||
if hasattr(interface, "r_airtime_short"): ifstats["airtime_short"] = interface.r_airtime_short
|
||||
if hasattr(interface, "r_airtime_long"): ifstats["airtime_long"] = interface.r_airtime_long
|
||||
if hasattr(interface, "r_channel_load_short"): ifstats["channel_load_short"] = interface.r_channel_load_short
|
||||
@@ -1575,6 +1825,16 @@ class Reticulum:
|
||||
else: ifstats["txs"] = 0
|
||||
else: ifstats["txs"] = 0
|
||||
|
||||
if hasattr(interface, "current_frx_speed"):
|
||||
if interface.current_frx_speed != None: ifstats["frxs"] = interface.current_frx_speed
|
||||
else: ifstats["frxs"] = 0
|
||||
else: ifstats["frxs"] = 0
|
||||
|
||||
if hasattr(interface, "current_ftx_speed"):
|
||||
if interface.current_ftx_speed != None: ifstats["ftxs"] = interface.current_ftx_speed
|
||||
else: ifstats["ftxs"] = 0
|
||||
else: ifstats["ftxs"] = 0
|
||||
|
||||
if hasattr(interface, "current_arx_speed"):
|
||||
if interface.current_arx_speed != None: ifstats["arxs"] = interface.current_arx_speed
|
||||
else: ifstats["arxs"] = 0
|
||||
@@ -1628,10 +1888,13 @@ class Reticulum:
|
||||
ifstats["mtu"] = interface.HW_MTU
|
||||
ifstats["rxb"] = interface.rxb
|
||||
ifstats["txb"] = interface.txb
|
||||
ifstats["frxb"] = interface.frxb
|
||||
ifstats["ftxb"] = interface.ftxb
|
||||
ifstats["arxb"] = interface.arxb
|
||||
ifstats["atxb"] = interface.atxb
|
||||
ifstats["arxc"] = interface.arxc
|
||||
ifstats["atxc"] = interface.atxc
|
||||
ifstats["afrxc"] = interface.afrxc
|
||||
ifstats["prxb"] = interface.prxb
|
||||
ifstats["ptxb"] = interface.ptxb
|
||||
ifstats["prxc"] = interface.prxc
|
||||
@@ -1661,6 +1924,21 @@ class Reticulum:
|
||||
ifstats["protocol_violations"] = interface.protocol_violations
|
||||
ifstats["ifac_violations"] = interface.ifac_violations
|
||||
ifstats["packet_filter_hits"] = interface.packet_filter_hits
|
||||
ifstats["tunnel_id"] = interface.tunnel_id or interface.local_tunnel_id
|
||||
ifstats["remote_transport_id"] = interface.remote_transport.hash if interface.remote_transport else None
|
||||
|
||||
if interface.shared_medium:
|
||||
ifstats["rem_impl"] = None
|
||||
ifstats["rem_vers"] = None
|
||||
ifstats["rem_is_tn"] = None
|
||||
ifstats["rem_dst_cost"] = None
|
||||
ifstats["rem_pr_cost"] = None
|
||||
else:
|
||||
ifstats["rem_impl"] = interface.remote_impl
|
||||
ifstats["rem_vers"] = interface.remote_vers
|
||||
ifstats["rem_is_tn"] = interface.remote_is_tn
|
||||
ifstats["rem_dst_cost"] = interface.remote_dst_cost
|
||||
ifstats["rem_pr_cost"] = interface.remote_pr_cost
|
||||
|
||||
interfaces.append(ifstats)
|
||||
|
||||
@@ -1670,6 +1948,7 @@ class Reticulum:
|
||||
pql = RNS.Transport.INBOUND_PR_QUEUE_LENGTH
|
||||
ilql = RNS.Transport.INBOUND_IL_QUEUE_LENGTH
|
||||
tql = dql+aql+pql+ilql
|
||||
ppcs = RNS.Transport.path_pool_counts()
|
||||
|
||||
stats = {}
|
||||
stats["interfaces"] = interfaces
|
||||
@@ -1677,6 +1956,14 @@ class Reticulum:
|
||||
stats["txb"] = RNS.Transport.traffic_txb
|
||||
stats["rxs"] = RNS.Transport.speed_rx
|
||||
stats["txs"] = RNS.Transport.speed_tx
|
||||
stats["lrxb"] = RNS.Transport.link_rxb
|
||||
stats["ltxb"] = RNS.Transport.link_txb
|
||||
stats["lrxs"] = RNS.Transport.link_speed_rx
|
||||
stats["ltxs"] = RNS.Transport.link_speed_tx
|
||||
stats["frxb"] = RNS.Transport.filtered_rxb
|
||||
stats["ftxb"] = RNS.Transport.filtered_txb
|
||||
stats["frxs"] = RNS.Transport.filtered_speed_rx
|
||||
stats["ftxs"] = RNS.Transport.filtered_speed_tx
|
||||
stats["arxb"] = RNS.Transport.announce_rxb
|
||||
stats["atxb"] = RNS.Transport.announce_txb
|
||||
stats["arxs"] = RNS.Transport.announce_speed_rx
|
||||
@@ -1691,6 +1978,12 @@ class Reticulum:
|
||||
stats["ptxf"] = RNS.Transport.pr_freq_tx
|
||||
stats["rxpps"] = RNS.Transport.rx_pps
|
||||
stats["txpps"] = RNS.Transport.tx_pps
|
||||
stats["rxpkts"] = RNS.Transport.rx_packets
|
||||
stats["txpkts"] = RNS.Transport.tx_packets
|
||||
stats["arxpkts"] = RNS.Transport.announce_rxc
|
||||
stats["atxpkts"] = RNS.Transport.announce_txc
|
||||
stats["prxpkts"] = RNS.Transport.pr_rxc
|
||||
stats["ptxpkts"] = RNS.Transport.pr_txc
|
||||
stats["rxqt"] = qsnapshot[0]
|
||||
stats["rxqd"] = qsnapshot[1][0]
|
||||
stats["rxqa"] = qsnapshot[1][1]
|
||||
@@ -1707,6 +2000,12 @@ class Reticulum:
|
||||
stats["pqpressure"] = qsnapshot[1][2]/pql if qsnapshot[1][2] else 0
|
||||
stats["ilqpressure"] = qsnapshot[1][3]/ilql if qsnapshot[1][3] else 0
|
||||
stats["txq"] = None
|
||||
stats["tlinks"] = RNS.Transport.link_count()
|
||||
stats["alinks"] = RNS.Transport.active_link_count()
|
||||
stats["plinks"] = stats["tlinks"]-stats["alinks"]
|
||||
stats["tpcount"] = ppcs[0]
|
||||
stats["unupcount"] = ppcs[1]
|
||||
stats["actpcount"] = stats["tpcount"] - stats["unupcount"]
|
||||
|
||||
if Reticulum.transport_enabled():
|
||||
stats["transport_id"] = RNS.Transport.identity.hash
|
||||
@@ -1726,45 +2025,73 @@ class Reticulum:
|
||||
|
||||
def get_path_table(self, max_hops=None):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "path_table", "max_hops": max_hops}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "path_table", "max_hops": max_hops}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting path table: {e}", RNS.LOG_ERROR)
|
||||
return []
|
||||
|
||||
else:
|
||||
path_table = []
|
||||
for dst_hash in RNS.Transport.path_table:
|
||||
path_hops = RNS.Transport.path_table[dst_hash][2]
|
||||
if max_hops == None or path_hops <= max_hops:
|
||||
known_destination = RNS.Identity.known_destinations.get(dst_hash, None)
|
||||
dst_value = known_destination[6] if known_destination else None
|
||||
lr_cost = known_destination[7] if known_destination else None
|
||||
entry = { "hash": dst_hash, "timestamp": RNS.Transport.path_table[dst_hash][0],
|
||||
"via": RNS.Transport.path_table[dst_hash][1], "hops": path_hops,
|
||||
"expires": RNS.Transport.path_table[dst_hash][3],
|
||||
"interface": str(RNS.Transport.path_table[dst_hash][5]) }
|
||||
"expires": RNS.Transport.path_table[dst_hash][3], "value": dst_value,
|
||||
"used": RNS.Transport.path_table[dst_hash][7], "lr_cost": lr_cost,
|
||||
"interface": str(RNS.Transport.path_table[dst_hash][5]),
|
||||
"interface_hash": RNS.Transport.path_table[dst_hash][5].get_hash(),
|
||||
"state": RNS.Transport.get_path_state(dst_hash) }
|
||||
path_table.append(entry)
|
||||
|
||||
return path_table
|
||||
|
||||
def get_rate_table(self):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "rate_table"}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "rate_table"}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting rate table: {e}", RNS.LOG_ERROR)
|
||||
return []
|
||||
|
||||
else:
|
||||
rate_table = []
|
||||
for dst_hash in RNS.Transport.announce_rate_table:
|
||||
entry = {
|
||||
"hash": dst_hash,
|
||||
"last": RNS.Transport.announce_rate_table[dst_hash]["last"],
|
||||
"rate_violations": RNS.Transport.announce_rate_table[dst_hash]["rate_violations"],
|
||||
"blocked_until": RNS.Transport.announce_rate_table[dst_hash]["blocked_until"],
|
||||
"timestamps": RNS.Transport.announce_rate_table[dst_hash]["timestamps"],
|
||||
}
|
||||
rate_table.append(entry)
|
||||
with RNS.Transport.announce_rate_table_lock:
|
||||
for dst_hash, entry in RNS.Transport.announce_rate_table.items():
|
||||
entry["hash"] = dst_hash
|
||||
rate_table.append(entry)
|
||||
|
||||
return rate_table
|
||||
|
||||
def get_known_destinations(self):
|
||||
if self.is_connected_to_shared_instance:
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "known_destinations"}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting known destinations: {e}", RNS.LOG_ERROR)
|
||||
return {}
|
||||
|
||||
else:
|
||||
known_destinations = {}
|
||||
with RNS.Identity.known_destinations_lock:
|
||||
for dst_hash in RNS.Identity.known_destinations:
|
||||
known_destinations[dst_hash] = RNS.Identity.known_destinations[dst_hash]
|
||||
|
||||
return known_destinations
|
||||
|
||||
def drop_path(self, destination):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
@@ -1911,12 +2238,30 @@ class Reticulum:
|
||||
else:
|
||||
return RNS.Transport.active_link_count()
|
||||
|
||||
def get_link_distribution(self):
|
||||
if self.is_connected_to_shared_instance:
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "link_distribution"}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting link distribution: {e}", RNS.LOG_ERROR)
|
||||
return None
|
||||
|
||||
else:
|
||||
return RNS.Transport.link_distribution()
|
||||
|
||||
def get_packet_rssi(self, packet_hash):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "packet_rssi", "packet_hash": packet_hash}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "packet_rssi", "packet_hash": packet_hash}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting packet RSSI: {e}", RNS.LOG_ERROR)
|
||||
return None
|
||||
|
||||
else:
|
||||
for entry in RNS.Transport.local_client_rssi_cache:
|
||||
@@ -1927,10 +2272,14 @@ class Reticulum:
|
||||
|
||||
def get_packet_snr(self, packet_hash):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "packet_snr", "packet_hash": packet_hash}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "packet_snr", "packet_hash": packet_hash}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting packet SNR: {e}", RNS.LOG_ERROR)
|
||||
return None
|
||||
|
||||
else:
|
||||
for entry in RNS.Transport.local_client_snr_cache:
|
||||
@@ -1941,10 +2290,14 @@ class Reticulum:
|
||||
|
||||
def get_packet_q(self, packet_hash):
|
||||
if self.is_connected_to_shared_instance:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "packet_q", "packet_hash": packet_hash}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
try:
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"get": "packet_q", "packet_hash": packet_hash}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while getting packet link quality: {e}", RNS.LOG_ERROR)
|
||||
return None
|
||||
|
||||
else:
|
||||
for entry in RNS.Transport.local_client_q_cache:
|
||||
@@ -2036,6 +2389,62 @@ class Reticulum:
|
||||
|
||||
else: return RNS.Transport.unblackhole_identity(identity_hash)
|
||||
|
||||
# For now, this is available on shared instance clients
|
||||
# only, so an application cannot squelch announce ingress
|
||||
# for other applications and the node as a whole.
|
||||
def required_announces_only(self, enabled=True):
|
||||
if not enabled in [True, False]: return False
|
||||
if not self.is_connected_to_shared_instance: return False
|
||||
else: RNS.Transport.required_destinations_only = enabled
|
||||
if enabled: RNS.log(f"Setting announce filtering to required only", RNS.LOG_DEBUG)
|
||||
else: RNS.log(f"Setting announce filtering to all", RNS.LOG_DEBUG)
|
||||
return True
|
||||
|
||||
def wants_destination_type(self, full_name, requester=None, signature=None):
|
||||
if not requester: requester = RNS.Transport.application_identity.hash
|
||||
if self.is_connected_to_shared_instance:
|
||||
try:
|
||||
RNS.Transport._wants_destination_type(full_name, requester, signature)
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"wants_destination_type": full_name, "requester": requester, "signature": signature}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while setting destination type filters: {e}", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
else: return RNS.Transport._wants_destination_type(full_name, requester, signature)
|
||||
|
||||
def unwants_destination_type(self, full_name, requester=None, signature=None):
|
||||
if not requester: requester = RNS.Transport.application_identity.hash
|
||||
if self.is_connected_to_shared_instance:
|
||||
try:
|
||||
RNS.Transport._unwants_destination_type(full_name, requester, signature)
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"unwants_destination_type": full_name, "requester": requester, "signature": signature}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while setting destination type filters: {e}", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
else: return RNS.Transport._unwants_destination_type(full_name, requester, signature)
|
||||
|
||||
def unwants_all_destination_types(self, requester=None, signature=None):
|
||||
if not requester: requester = RNS.Transport.application_identity.hash
|
||||
if self.is_connected_to_shared_instance:
|
||||
try:
|
||||
RNS.Transport._unwants_all_destination_types(requester, signature)
|
||||
rpc_connection = self.get_rpc_client()
|
||||
rpc_connection.send_bytes(mp.packb({"unwants_all_destination_types": True, "requester": requester, "signature": signature}))
|
||||
response = mp.unpackb(rpc_connection.recv_bytes())
|
||||
return response
|
||||
except Exception as e:
|
||||
RNS.log(f"Shared instance RPC failed while setting destination type filters: {e}", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
else: return RNS.Transport._unwants_all_destination_types(requester, signature)
|
||||
|
||||
@staticmethod
|
||||
def should_use_implicit_proof():
|
||||
"""
|
||||
@@ -2096,7 +2505,7 @@ class Reticulum:
|
||||
Returns the required stamp value for a discovered interface
|
||||
to be considered valid and remembered.
|
||||
|
||||
:returns: The required stamp value as an integer.
|
||||
:returns: The required stamp value as a float.
|
||||
"""
|
||||
return Reticulum.__required_discovery_value
|
||||
|
||||
@@ -2192,7 +2601,8 @@ class Reticulum:
|
||||
return Reticulum.__inbound_il_queue_length
|
||||
|
||||
# Default configuration file:
|
||||
__default_rns_config__ = '''# This is the default Reticulum config file.
|
||||
__default_rns_config__ = '''##########################################################
|
||||
# This is the default Reticulum config file.
|
||||
# You should probably edit it to include any additional,
|
||||
# interfaces and settings you might need.
|
||||
|
||||
@@ -2276,6 +2686,22 @@ instance_name = default
|
||||
|
||||
# blackhole_sources = 521c87a83afb8f29e4455e77930b973b
|
||||
|
||||
##########################################################
|
||||
# This section configures stamping behaviour and defaults.
|
||||
# In most cases, you do not need to change this, but on
|
||||
# constrained systems especially, tuning these parameters
|
||||
# can be very beneficial. See "rnsd --exampleconfig" or
|
||||
# the manual for a full explanation of these parameters.
|
||||
|
||||
[stamps]
|
||||
|
||||
# destination_cost = 23.5
|
||||
# destination_value = 25.0
|
||||
# pr_cost = 15.8
|
||||
# pr_value = 15.8
|
||||
# lr_cost = 12.5
|
||||
# lr_stamp_timeout = 15
|
||||
# pr_stamp_timeout = 15
|
||||
|
||||
[logging]
|
||||
# Valid log levels are 0 through 8:
|
||||
@@ -2291,7 +2717,7 @@ instance_name = default
|
||||
|
||||
loglevel = 4
|
||||
|
||||
|
||||
##########################################################
|
||||
# The interfaces section defines the physical and virtual
|
||||
# interfaces Reticulum will use to communicate on. This
|
||||
# section will contain examples for a variety of interface
|
||||
|
||||
+1093
File diff suppressed because it is too large.
Load diff
+851
@@ -0,0 +1,851 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# - The Software shall not be used in any kind of system which includes amongst
|
||||
# its functions the ability to purposefully do harm to human beings.
|
||||
#
|
||||
# - The Software shall not be used, directly or indirectly, in the creation of
|
||||
# an artificial intelligence, machine learning or language model training
|
||||
# dataset, including but not limited to any use that contributes to the
|
||||
# training or development of such a model or algorithm.
|
||||
#
|
||||
# - The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
import RNS
|
||||
import hashlib
|
||||
import struct
|
||||
import sys
|
||||
import threading
|
||||
import os
|
||||
import time
|
||||
from array import array
|
||||
|
||||
class AnnounceRateTable:
|
||||
# Columnar store for announce rate tracking. Layout:
|
||||
# _index : dict[destination_hash -> slot]
|
||||
# _keys : list[slot] -> destination_hash (for swap-remove bookkeeping)
|
||||
# _last : array('d') last non-violating announce time
|
||||
# _blocked: array('d') blocked_until
|
||||
# _viol : array('i') rate_violations
|
||||
# _ts : array('d') flat ring of max_timestamps doubles per slot
|
||||
# _ts_len : array('B') valid timestamp count per slot
|
||||
# _ts_head: array('B') ring write cursor per slot
|
||||
|
||||
def __init__(self, max_timestamps=16):
|
||||
assert max_timestamps <= 255, "Timestamp ring size must fit in a single byte"
|
||||
self.max_ts = max_timestamps
|
||||
self._index = {}
|
||||
self._keys = []
|
||||
self._last = array('d')
|
||||
self._blocked = array('d')
|
||||
self._viol = array('i')
|
||||
self._ts = array('d')
|
||||
self._ts_len = array('B')
|
||||
self._ts_head = array('B')
|
||||
self._cursor = 0
|
||||
|
||||
def __len__(self): return len(self._keys)
|
||||
def __contains__(self, destination_hash): return destination_hash in self._index
|
||||
|
||||
# Perform the announce-rate check-and-update for one announce.
|
||||
# Caller must hold the announce_rate_table_lock.
|
||||
def check_and_update(self, destination_hash, now, target, grace, penalty):
|
||||
slot = self._index.get(destination_hash)
|
||||
|
||||
if slot is None:
|
||||
slot = len(self._keys)
|
||||
self._index[destination_hash] = slot
|
||||
self._keys.append(destination_hash)
|
||||
self._last.append(now)
|
||||
self._blocked.append(0.0)
|
||||
self._viol.append(0)
|
||||
self._ts.extend([0.0]*self.max_ts)
|
||||
self._ts[slot*self.max_ts] = now
|
||||
self._ts_len.append(1)
|
||||
self._ts_head.append(1 % self.max_ts)
|
||||
return False
|
||||
|
||||
base = slot*self.max_ts
|
||||
head = self._ts_head[slot]
|
||||
self._ts[base+head] = now
|
||||
self._ts_head[slot] = (head+1) % self.max_ts
|
||||
if self._ts_len[slot] < self.max_ts: self._ts_len[slot] += 1
|
||||
|
||||
current_rate = now - self._last[slot]
|
||||
rate_blocked = False
|
||||
|
||||
if now > self._blocked[slot]:
|
||||
if current_rate < target: self._viol[slot] += 1
|
||||
else:
|
||||
v = self._viol[slot] - 1
|
||||
self._viol[slot] = v if v > 0 else 0
|
||||
|
||||
if self._viol[slot] > grace:
|
||||
self._blocked[slot] = self._last[slot] + target + penalty
|
||||
rate_blocked = True
|
||||
else: self._last[slot] = now
|
||||
|
||||
else: rate_blocked = True
|
||||
|
||||
return rate_blocked
|
||||
|
||||
# Caller must hold the table lock
|
||||
def cull(self, now, ttl, max_scan=1024, max_cull=None):
|
||||
if max_cull is None: max_cull = max_scan
|
||||
horizon = now - ttl
|
||||
culled = 0
|
||||
scanned = 0
|
||||
n = len(self._keys)
|
||||
|
||||
while scanned < max_scan and culled < max_cull and n > 0:
|
||||
if self._cursor >= n: self._cursor = 0
|
||||
slot = self._cursor
|
||||
|
||||
if self._last[slot] < horizon and self._blocked[slot] <= now:
|
||||
last_i = n - 1
|
||||
stale_key = self._keys[slot]
|
||||
|
||||
if slot != last_i:
|
||||
moved_key = self._keys[last_i]
|
||||
self._keys[slot] = moved_key
|
||||
self._index[moved_key] = slot
|
||||
self._last[slot] = self._last[last_i]
|
||||
self._blocked[slot] = self._blocked[last_i]
|
||||
self._viol[slot] = self._viol[last_i]
|
||||
self._ts_len[slot] = self._ts_len[last_i]
|
||||
self._ts_head[slot] = self._ts_head[last_i]
|
||||
|
||||
f = last_i*self.max_ts; t = slot*self.max_ts
|
||||
self._ts[t:t+self.max_ts] = self._ts[f:f+self.max_ts]
|
||||
|
||||
self._keys.pop()
|
||||
self._last.pop(); self._blocked.pop(); self._viol.pop()
|
||||
self._ts_len.pop(); self._ts_head.pop()
|
||||
del self._ts[len(self._ts)-self.max_ts:] # drop tail block of removed slot
|
||||
del self._index[stale_key]
|
||||
|
||||
n -= 1
|
||||
culled += 1
|
||||
# Do not advance cursor, re-examine the slot a moved entry landed in
|
||||
|
||||
else:
|
||||
self._cursor = slot + 1
|
||||
scanned += 1
|
||||
|
||||
if self._cursor >= n: self._cursor = 0
|
||||
|
||||
return culled
|
||||
|
||||
# Hold table lock, or accept a possibly inconsistent snapshot
|
||||
def items(self):
|
||||
for slot, key in enumerate(self._keys):
|
||||
n = self._ts_len[slot]
|
||||
head = self._ts_head[slot]
|
||||
base = slot*self.max_ts
|
||||
if n < self.max_ts: ts = list(self._ts[base:base+n])
|
||||
else: ts = list(self._ts[base+head:base+self.max_ts]) + list(self._ts[base:base+head])
|
||||
yield key, { "last": self._last[slot], "rate_violations": self._viol[slot],
|
||||
"blocked_until": self._blocked[slot], "timestamps": ts }
|
||||
|
||||
# Persists the announce rate table to a file, in
|
||||
# compacted, little-endian binary format:
|
||||
#
|
||||
# Header (16 bytes)
|
||||
# 0x00 6 Magic bytes
|
||||
# 0x06 1 Format version
|
||||
# 0x07 1 Flags, reserved, must be zero
|
||||
# 0x08 1 Timestamp ring size (max_ts)
|
||||
# 0x09 1 Destination hash length in bytes (keylen)
|
||||
# 0x0A 2 Reserved, zero
|
||||
# 0x0C 4 Entry count, uint32, little-endian
|
||||
#
|
||||
# Entries (columnar, in native slot order)
|
||||
# Destination hash keys, followed by the _last, _blocked,
|
||||
# _viol, _ts_len, _ts_head and _ts columns, all encoded as
|
||||
# little-endian fixed-width values.
|
||||
#
|
||||
# Caller must hold the announce rate table lock
|
||||
|
||||
PERSIST_MAGIC = b"RNSART"
|
||||
PERSIST_VERSION = 0x01
|
||||
def persist(self, path, retain=None):
|
||||
try:
|
||||
count = len(self._keys)
|
||||
|
||||
if count > 0:
|
||||
keylen = len(self._keys[0])
|
||||
for key in self._keys:
|
||||
if len(key) != keylen: raise ValueError("Inconsistent destination hash lengths in table")
|
||||
else:
|
||||
keylen = RNS.Identity.TRUNCATED_HASHLENGTH//8
|
||||
|
||||
if retain != None and count > 0:
|
||||
now = time.time()
|
||||
horizon = now - retain
|
||||
keep = [slot for slot in range(count) if not (self._last[slot] < horizon and self._blocked[slot] <= now)]
|
||||
else:
|
||||
keep = None
|
||||
|
||||
if keep != None and len(keep) != count:
|
||||
count = len(keep)
|
||||
keys = [self._keys[slot] for slot in keep]
|
||||
last = array("d", [self._last[slot] for slot in keep])
|
||||
blocked = array("d", [self._blocked[slot] for slot in keep])
|
||||
viol = array("i", [self._viol[slot] for slot in keep])
|
||||
ts_len = array("B", [self._ts_len[slot] for slot in keep])
|
||||
ts_head = array("B", [self._ts_head[slot] for slot in keep])
|
||||
ts = array("d")
|
||||
for slot in keep: ts.extend(self._ts[slot*self.max_ts:(slot+1)*self.max_ts])
|
||||
else:
|
||||
keys = self._keys
|
||||
last = self._last
|
||||
blocked = self._blocked
|
||||
viol = self._viol
|
||||
ts_len = self._ts_len
|
||||
ts_head = self._ts_head
|
||||
ts = self._ts
|
||||
|
||||
if last.itemsize != 8 or viol.itemsize != 4:
|
||||
raise ValueError(f"Unsupported array itemsize at persist: d={last.itemsize}, i={viol.itemsize}")
|
||||
|
||||
header = self.PERSIST_MAGIC
|
||||
header += bytes([self.PERSIST_VERSION, 0x00, self.max_ts & 0xFF, keylen & 0xFF])
|
||||
header += struct.pack("<H", 0)
|
||||
header += struct.pack("<I", count)
|
||||
|
||||
blob = header
|
||||
blob += b"".join(keys)
|
||||
blob += self._column_le(last)
|
||||
blob += self._column_le(blocked)
|
||||
blob += self._column_le(viol)
|
||||
blob += ts_len.tobytes()
|
||||
blob += ts_head.tobytes()
|
||||
blob += self._column_le(ts)
|
||||
|
||||
tmp_path = path+".tmp"
|
||||
with open(tmp_path, "wb") as file: file.write(blob)
|
||||
os.replace(tmp_path, path)
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Could not persist announce rate table to {path}: {e}", RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
# Caller must hold the announce rate table lock
|
||||
def load(self, path):
|
||||
try:
|
||||
with open(path, "rb") as file: blob = file.read()
|
||||
except Exception: return False
|
||||
|
||||
try:
|
||||
if len(blob) < 16: return False
|
||||
if blob[0:6] != self.PERSIST_MAGIC: return False
|
||||
if blob[6] != self.PERSIST_VERSION: return False
|
||||
if blob[7] != 0x00: return False
|
||||
|
||||
file_max_ts = blob[8]
|
||||
keylen = blob[9]
|
||||
count = struct.unpack_from("<I", blob, 12)[0]
|
||||
|
||||
if file_max_ts < 1 or file_max_ts > 255: return False
|
||||
if keylen < 1: return False
|
||||
|
||||
entry_size = keylen+22+file_max_ts*8
|
||||
if len(blob) != 16+count*entry_size: return False
|
||||
|
||||
if file_max_ts == self.max_ts:
|
||||
# Ring size matches, load directly
|
||||
keys = [blob[16+slot*keylen : 16+(slot+1)*keylen] for slot in range(count)]
|
||||
index = {}
|
||||
for slot in range(count):
|
||||
if keys[slot] in index: return False
|
||||
index[keys[slot]] = slot
|
||||
|
||||
offset = 16+count*keylen
|
||||
last = self._column_from_le("d", blob[offset:offset+count*8]); offset += count*8
|
||||
blocked = self._column_from_le("d", blob[offset:offset+count*8]); offset += count*8
|
||||
viol = self._column_from_le("i", blob[offset:offset+count*4]); offset += count*4
|
||||
ts_len = array("B", blob[offset:offset+count]); offset += count
|
||||
ts_head = array("B", blob[offset:offset+count]); offset += count
|
||||
ts = self._column_from_le("d", blob[offset:offset+count*self.max_ts*8]); offset += count*self.max_ts*8
|
||||
|
||||
for slot in range(count):
|
||||
if ts_len[slot] > self.max_ts or ts_head[slot] >= self.max_ts: return False
|
||||
|
||||
else:
|
||||
# Different ring sizes from current running config,
|
||||
# rebuild entries best effort.
|
||||
keys = [blob[16+slot*keylen : 16+(slot+1)*keylen] for slot in range(count)]
|
||||
index = {}
|
||||
for slot in range(count):
|
||||
if keys[slot] in index: return False
|
||||
index[keys[slot]] = slot
|
||||
|
||||
offset = 16+count*keylen
|
||||
last = self._column_from_le("d", blob[offset:offset+count*8]); offset += count*8
|
||||
blocked = self._column_from_le("d", blob[offset:offset+count*8]); offset += count*8
|
||||
viol = self._column_from_le("i", blob[offset:offset+count*4]); offset += count*4
|
||||
f_ts_len = array("B", blob[offset:offset+count]); offset += count
|
||||
f_ts_head = array("B", blob[offset:offset+count]); offset += count
|
||||
f_ts = self._column_from_le("d", blob[offset:offset+count*file_max_ts*8]); offset += count*file_max_ts*8
|
||||
|
||||
for slot in range(count):
|
||||
if f_ts_len[slot] > file_max_ts or f_ts_head[slot] >= file_max_ts: return False
|
||||
|
||||
ts_len = array("B"); ts_head = array("B"); ts = array("d")
|
||||
for slot in range(count):
|
||||
base = slot*file_max_ts
|
||||
if f_ts_len[slot] < file_max_ts: chronological = list(f_ts[base:base+f_ts_len[slot]])
|
||||
else: chronological = list(f_ts[base+f_ts_head[slot]:base+file_max_ts])+list(f_ts[base:base+f_ts_head[slot]])
|
||||
chronological = chronological[-self.max_ts:]
|
||||
ts_count = len(chronological)
|
||||
|
||||
ts_len.append(ts_count)
|
||||
ts.extend(chronological)
|
||||
if ts_count < self.max_ts: ts.extend([0.0]*(self.max_ts-ts_count))
|
||||
ts_head.append(ts_count % self.max_ts)
|
||||
|
||||
self._index = index
|
||||
self._keys = keys
|
||||
self._last = last
|
||||
self._blocked = blocked
|
||||
self._viol = viol
|
||||
self._ts = ts
|
||||
self._ts_len = ts_len
|
||||
self._ts_head = ts_head
|
||||
self._cursor = 0
|
||||
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Could not load announce rate table from {path}: {e}", RNS.LOG_ERROR)
|
||||
return False
|
||||
|
||||
def _column_le(self, column):
|
||||
if sys.byteorder == "big": swapped = array(column.typecode, column); swapped.byteswap(); return swapped.tobytes()
|
||||
else: return column.tobytes()
|
||||
|
||||
def _column_from_le(self, typecode, data):
|
||||
column = array(typecode); column.frombytes(data)
|
||||
if sys.byteorder == "big": column.byteswap()
|
||||
return column
|
||||
|
||||
class PacketHashlist:
|
||||
# Bucketed byte-blob packet filter hashlist, with the primary
|
||||
# design goal of memory coherence and density. All operations
|
||||
# are safe to call without holding a lock.
|
||||
|
||||
def __init__(self, hash_width=32, bucket_count=16384):
|
||||
assert bucket_count > 0 and bucket_count & (bucket_count-1) == 0, "Bucket count must be a power of two"
|
||||
self.width = hash_width
|
||||
self._nb = bucket_count
|
||||
self._mask = bucket_count - 1
|
||||
self._cur = [bytearray() for _ in range(bucket_count)]
|
||||
self._prv = [bytearray() for _ in range(bucket_count)]
|
||||
self._count = 0
|
||||
|
||||
def __len__(self):
|
||||
return self._count
|
||||
|
||||
def __contains__(self, packet_hash):
|
||||
bucket = (packet_hash[0] | (packet_hash[1] << 8)) & self._mask
|
||||
return packet_hash in self._cur[bucket] or packet_hash in self._prv[bucket]
|
||||
|
||||
def add(self, packet_hash):
|
||||
assert len(packet_hash) == self.width, "Packet hash width mismatch"
|
||||
bucket = (packet_hash[0] | (packet_hash[1] << 8)) & self._mask
|
||||
if packet_hash not in self._cur[bucket]:
|
||||
self._cur[bucket].extend(packet_hash)
|
||||
self._count += 1
|
||||
|
||||
def discard(self, packet_hash):
|
||||
w = self.width
|
||||
bucket = (packet_hash[0] | (packet_hash[1] << 8)) & self._mask
|
||||
for generation in (self._cur, self._prv):
|
||||
entries = generation[bucket]
|
||||
pos = entries.find(packet_hash)
|
||||
while pos != -1:
|
||||
if pos % w == 0:
|
||||
del entries[pos:pos+w]
|
||||
if generation is self._cur: self._count -= 1
|
||||
pos = entries.find(packet_hash, pos)
|
||||
else:
|
||||
pos = entries.find(packet_hash, pos+1)
|
||||
|
||||
def swap(self):
|
||||
self._prv = self._cur
|
||||
self._cur = [bytearray() for _ in range(self._nb)]
|
||||
self._count = 0
|
||||
|
||||
# Current-generation buckets for persist operations
|
||||
def buckets(self): return tuple(self._cur)
|
||||
|
||||
class KnownDestinationsStore:
|
||||
# Write-behind SQLite storage backend for known destinations.
|
||||
# The actual in-memory table is used directly for all transport
|
||||
# operations; this serves purely as the store, and no read operations
|
||||
# utilize the database directly.
|
||||
|
||||
def __init__(self, db_path, hash_width=16, read_only=False):
|
||||
import sqlite3
|
||||
self.sqlite3 = sqlite3
|
||||
self.db_path = db_path
|
||||
self.hash_width = hash_width
|
||||
self.read_only = read_only
|
||||
self._dirty_upsert = set()
|
||||
self._dirty_delete = set()
|
||||
self._ratchet_upserts = {}
|
||||
self._ratchet_deletes = set()
|
||||
self._kd_quarantine = {}
|
||||
self._ratchet_quarantine = {}
|
||||
self._flush_lock = threading.Lock()
|
||||
|
||||
if read_only: self._conn = sqlite3.connect(f"file:{db_path}?mode=ro", uri=True, check_same_thread=False, isolation_level=None, cached_statements=0)
|
||||
else:
|
||||
self._conn = sqlite3.connect(db_path, check_same_thread=False, isolation_level=None, cached_statements=0)
|
||||
self._conn.execute("PRAGMA journal_mode=WAL")
|
||||
self._conn.execute("PRAGMA synchronous=NORMAL")
|
||||
self._conn.execute("PRAGMA journal_size_limit=8388608")
|
||||
self.__create_schema()
|
||||
|
||||
def close(self):
|
||||
if self._conn != None:
|
||||
self._conn.close()
|
||||
self._conn = None
|
||||
|
||||
def __create_schema(self):
|
||||
db_version = self._conn.execute("PRAGMA user_version").fetchone()[0]
|
||||
|
||||
# Pre-release database cleanup
|
||||
# TODO: Remove this in 1.6.1
|
||||
if db_version > 0:
|
||||
RNS.log(f"Pre-release database detected, rebuilding known destinations DB to release format", RNS.LOG_WARNING)
|
||||
self._conn.execute("DROP TABLE IF EXISTS known_destinations")
|
||||
|
||||
self._conn.execute("""CREATE TABLE IF NOT EXISTS known_destinations (
|
||||
destination_hash BLOB PRIMARY KEY,
|
||||
last_heard REAL NOT NULL,
|
||||
packet_hash BLOB,
|
||||
public_key BLOB NOT NULL,
|
||||
app_data BLOB,
|
||||
used REAL NOT NULL DEFAULT 0,
|
||||
stamp BLOB,
|
||||
stamp_value REAL,
|
||||
lr_cost REAL,
|
||||
identity_hash BLOB NOT NULL)""")
|
||||
|
||||
self._conn.execute("""CREATE TABLE IF NOT EXISTS ratchets (
|
||||
destination_hash BLOB PRIMARY KEY,
|
||||
ratchet BLOB NOT NULL,
|
||||
received REAL NOT NULL)""")
|
||||
|
||||
# Schema migrations
|
||||
try:
|
||||
self._conn.execute("BEGIN")
|
||||
# No migrations yet
|
||||
self._conn.execute("PRAGMA user_version = 0")
|
||||
self._conn.execute("COMMIT")
|
||||
self._conn.commit()
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Known destinations database version migration failed: {e}", RNS.LOG_CRITICAL)
|
||||
RNS.log(f"You will need to remove the known_destinations.db* files from your storage directory so it can be rebuilt", RNS.LOG_CRITICAL)
|
||||
|
||||
def __entry_row(self, destination_hash, entry):
|
||||
stamp = entry[5] if len(entry) > 5 else None
|
||||
stamp_value = entry[6] if len(entry) > 6 else 0
|
||||
lr_cost = entry[7] if len(entry) > 7 else None
|
||||
identity_hash = hashlib.sha256(entry[2]).digest()[:self.hash_width]
|
||||
return (destination_hash, entry[0], entry[1], entry[2], entry[3], entry[4], stamp, stamp_value, lr_cost, identity_hash)
|
||||
|
||||
# Caller must hold Identity.known_destinations_lock
|
||||
def mark_dirty(self, destination_hash):
|
||||
if self.read_only: return
|
||||
self._dirty_delete.discard(destination_hash)
|
||||
self._kd_quarantine.pop(destination_hash, None)
|
||||
self._dirty_upsert.add(destination_hash)
|
||||
|
||||
# Caller must hold Identity.known_destinations_lock
|
||||
def mark_deleted(self, destination_hash):
|
||||
if self.read_only: return
|
||||
self._dirty_upsert.discard(destination_hash)
|
||||
self._dirty_delete.add(destination_hash)
|
||||
self._kd_quarantine.pop(destination_hash, None)
|
||||
self._ratchet_quarantine.pop(destination_hash, None)
|
||||
|
||||
# Caller must hold Identity.known_destinations_lock
|
||||
def take_pending(self):
|
||||
if self.read_only: return set(), set(), {}, set()
|
||||
upserts = self._dirty_upsert
|
||||
deletes = self._dirty_delete
|
||||
ratchet_upserts = self._ratchet_upserts
|
||||
ratchet_deletes = self._ratchet_deletes
|
||||
self._dirty_upsert = set()
|
||||
self._dirty_delete = set()
|
||||
self._ratchet_upserts = {}
|
||||
self._ratchet_deletes = set()
|
||||
return upserts, deletes, ratchet_upserts, ratchet_deletes
|
||||
|
||||
# Caller must hold the flush lock and have an already open transaction
|
||||
def __wrap_exec(self, sql, rows):
|
||||
rejects = []
|
||||
|
||||
# By default, run batched queries in chunks.
|
||||
for i in range(0, len(rows), 4096):
|
||||
chunk = rows[i:i+4096]
|
||||
try:
|
||||
self._conn.execute("SAVEPOINT chunk")
|
||||
self._conn.executemany(sql, chunk)
|
||||
self._conn.execute("RELEASE chunk")
|
||||
|
||||
# But on integrity and data errors, roll back the chunk
|
||||
# and iterate per-row, so we can catch any violating
|
||||
# entries and quarantine them. A later, sane update
|
||||
# will then unquarantine and heal upon arrival.
|
||||
#
|
||||
# Other exceptions are intentionally not caught here,
|
||||
# so they can propagate directly.
|
||||
except (self.sqlite3.IntegrityError, self.sqlite3.DataError):
|
||||
self._conn.execute("ROLLBACK TO chunk")
|
||||
for row in chunk:
|
||||
try:
|
||||
self._conn.execute("SAVEPOINT row")
|
||||
self._conn.execute(sql, row)
|
||||
self._conn.execute("RELEASE row")
|
||||
|
||||
except (self.sqlite3.IntegrityError, self.sqlite3.DataError) as e:
|
||||
self._conn.execute("ROLLBACK TO row")
|
||||
rejects.append((row[0], str(e)))
|
||||
|
||||
self._conn.execute("RELEASE chunk")
|
||||
|
||||
return rejects
|
||||
|
||||
# May be called without any locks held
|
||||
def apply(self, upserts, deletes, ratchet_upserts, ratchet_deletes, known_destinations):
|
||||
if self.read_only: return 0
|
||||
if len(upserts) == 0 and len(deletes) == 0 and len(ratchet_upserts) == 0 and len(ratchet_deletes) == 0: return 0
|
||||
|
||||
with self._flush_lock:
|
||||
rows = []
|
||||
removables = []
|
||||
ratchet_rows = []
|
||||
ratchet_removables = []
|
||||
|
||||
for destination_hash in upserts:
|
||||
if destination_hash in self._kd_quarantine: continue
|
||||
entry = known_destinations.get(destination_hash)
|
||||
if entry != None: rows.append(self.__entry_row(destination_hash, entry))
|
||||
|
||||
for destination_hash in deletes:
|
||||
if destination_hash not in known_destinations: removables.append((destination_hash,))
|
||||
|
||||
for destination_hash, ratchet_entry in ratchet_upserts.items():
|
||||
# Ratchets of purged destinations must be removed as well
|
||||
if destination_hash not in known_destinations: ratchet_removables.append((destination_hash,))
|
||||
elif destination_hash not in self._ratchet_quarantine: ratchet_rows.append((destination_hash, *ratchet_entry))
|
||||
|
||||
for destination_hash in ratchet_deletes:
|
||||
if destination_hash not in known_destinations: ratchet_removables.append((destination_hash,))
|
||||
|
||||
kd_rejects = []
|
||||
ratchet_rejects = []
|
||||
try:
|
||||
self._conn.execute("BEGIN")
|
||||
kd_rejects += self.__wrap_exec("INSERT INTO known_destinations (destination_hash, last_heard, packet_hash, public_key, app_data, used, stamp, stamp_value, lr_cost, identity_hash) VALUES (?,?,?,?,?,?,?,?,?,?) ON CONFLICT(destination_hash) DO UPDATE SET last_heard=excluded.last_heard, packet_hash=excluded.packet_hash, public_key=excluded.public_key, app_data=excluded.app_data, used=excluded.used, stamp=excluded.stamp, stamp_value=excluded.stamp_value, lr_cost=excluded.lr_cost, identity_hash=excluded.identity_hash", rows)
|
||||
kd_rejects += self.__wrap_exec("DELETE FROM known_destinations WHERE destination_hash=?", removables)
|
||||
ratchet_rejects += self.__wrap_exec("INSERT INTO ratchets VALUES (?,?,?) ON CONFLICT(destination_hash) DO UPDATE SET ratchet=excluded.ratchet, received=excluded.received", ratchet_rows)
|
||||
ratchet_rejects += self.__wrap_exec("DELETE FROM ratchets WHERE destination_hash=?", ratchet_removables)
|
||||
self._conn.commit()
|
||||
|
||||
except Exception:
|
||||
# If an exception is not handled in the batch query wrapper,
|
||||
# we will have to roll back the transaction, and mark all
|
||||
# attempted entries as dirty. A failure state like such
|
||||
# should not happen, and this is a last resort; at this
|
||||
# point, writes may stall until an updated entry for
|
||||
# the violating row(s) arrive and heal the invalid
|
||||
# dirty entries, so this is raised for logging.
|
||||
self._dirty_upsert |= {row[0] for row in rows}
|
||||
self._dirty_delete |= {row[0] for row in removables}
|
||||
self._ratchet_upserts |= {row[0]: row[1:] for row in ratchet_rows}
|
||||
self._ratchet_deletes |= {row[0] for row in ratchet_removables}
|
||||
self._conn.rollback()
|
||||
raise
|
||||
|
||||
# Track failed persists and one-time log per failure. A later
|
||||
# update of the destination clears the quarantine state and
|
||||
# allows persist to retry with the (hopefully) valid data.
|
||||
if len(kd_rejects) > 0 or len(ratchet_rejects) > 0:
|
||||
for destination_hash, error in kd_rejects:
|
||||
self._kd_quarantine[destination_hash] = (error, time.time())
|
||||
RNS.log(f"Invalid known destination data for {RNS.prettyhexrep(destination_hash)} at persist. The contained exception was: {error}", RNS.LOG_ERROR)
|
||||
|
||||
for destination_hash, error in ratchet_rejects:
|
||||
self._ratchet_quarantine[destination_hash] = (error, time.time())
|
||||
RNS.log(f"Invalid ratchet data for {RNS.prettyhexrep(destination_hash)} at persist. The contained exception was: {error}", RNS.LOG_ERROR)
|
||||
|
||||
return len(rows)+len(removables)+len(ratchet_rows)+len(ratchet_removables)-len(kd_rejects)-len(ratchet_rejects)
|
||||
|
||||
def load_all(self):
|
||||
cursor = self._conn.execute("SELECT destination_hash, last_heard, packet_hash, public_key, app_data, used, stamp, stamp_value, lr_cost FROM known_destinations")
|
||||
while True:
|
||||
rows = cursor.fetchmany(4096)
|
||||
if not rows: break
|
||||
for row in rows: yield row[0], [row[1], row[2], row[3], row[4], row[5], row[6], row[7], row[8]]
|
||||
|
||||
def remember_ratchet(self, destination_hash, ratchet, now):
|
||||
if self.read_only: return False
|
||||
self._ratchet_quarantine.pop(destination_hash, None)
|
||||
|
||||
pending = self._ratchet_upserts.get(destination_hash)
|
||||
if pending != None:
|
||||
if pending[0] == ratchet:
|
||||
self._ratchet_deletes.discard(destination_hash)
|
||||
return False
|
||||
|
||||
else:
|
||||
with self._flush_lock:
|
||||
row = self._conn.execute("SELECT ratchet FROM ratchets WHERE destination_hash=?", (destination_hash,)).fetchone()
|
||||
|
||||
if row != None and row[0] == ratchet:
|
||||
# Discard any pending delete mark queued
|
||||
# before this ratchet arrived
|
||||
self._ratchet_deletes.discard(destination_hash)
|
||||
return False
|
||||
|
||||
self._ratchet_upserts[destination_hash] = (ratchet, now)
|
||||
self._ratchet_deletes.discard(destination_hash)
|
||||
return True
|
||||
|
||||
def fetch_ratchet(self, destination_hash):
|
||||
pending = self._ratchet_upserts.get(destination_hash)
|
||||
if pending != None: return pending[0], pending[1]
|
||||
if destination_hash in self._ratchet_deletes: return None
|
||||
|
||||
with self._flush_lock:
|
||||
row = self._conn.execute("SELECT ratchet, received FROM ratchets WHERE destination_hash=?", (destination_hash,)).fetchone()
|
||||
|
||||
if row != None: return row[0], row[1]
|
||||
|
||||
return None
|
||||
|
||||
# Caller must hold Identity.known_destinations_lock
|
||||
def mark_ratchet_deleted(self, destination_hash):
|
||||
if self.read_only: return
|
||||
self._ratchet_upserts.pop(destination_hash, None)
|
||||
self._ratchet_deletes.add(destination_hash)
|
||||
self._ratchet_quarantine.pop(destination_hash, None)
|
||||
|
||||
def expire_ratchets(self, cutoff):
|
||||
if self.read_only: return []
|
||||
|
||||
with self._flush_lock:
|
||||
# Drop expired entries in pending as well
|
||||
expired = set(row[0] for row in self._conn.execute("SELECT destination_hash FROM ratchets WHERE received<?", (cutoff,)))
|
||||
for destination_hash, entry in list(self._ratchet_upserts.items()):
|
||||
if entry[1] < cutoff:
|
||||
expired.add(destination_hash)
|
||||
self._ratchet_upserts.pop(destination_hash, None)
|
||||
|
||||
expired.difference_update(self._ratchet_deletes)
|
||||
if len(expired) > 0:
|
||||
self._conn.execute("BEGIN")
|
||||
for i in range(0, len(expired), 4096):
|
||||
self._conn.executemany("DELETE FROM ratchets WHERE destination_hash=?", [(h,) for h in list(expired)[i:i+4096]])
|
||||
self._conn.commit()
|
||||
|
||||
return list(expired)
|
||||
|
||||
def load_ratchets(self):
|
||||
cursor = self._conn.execute("SELECT destination_hash, ratchet, received FROM ratchets")
|
||||
while True:
|
||||
rows = cursor.fetchmany(4096)
|
||||
if not rows: break
|
||||
for row in rows: yield row[0], row[1], row[2]
|
||||
|
||||
def import_legacy_ratchets(self, dir_path, expiry_cutoff, known_destinations, ratchet_width=32):
|
||||
from .vendor import umsgpack
|
||||
imported = 0
|
||||
for filename in os.listdir(dir_path):
|
||||
file_path = os.path.join(dir_path, filename)
|
||||
try:
|
||||
if not os.path.isfile(file_path): continue
|
||||
with open(file_path, "rb") as rf:
|
||||
ratchet_data = umsgpack.unpackb(rf.read())
|
||||
|
||||
destination_hash = bytes.fromhex(filename)
|
||||
ratchet = ratchet_data["ratchet"]; received = ratchet_data["received"]
|
||||
if len(ratchet) != ratchet_width: raise ValueError("Invalid ratchet width")
|
||||
if received < expiry_cutoff: raise ValueError("Ratchet expired")
|
||||
if destination_hash not in known_destinations: raise ValueError("Destination unknown")
|
||||
|
||||
self._ratchet_upserts[destination_hash] = (ratchet, received)
|
||||
imported += 1
|
||||
os.unlink(file_path)
|
||||
|
||||
except Exception as e:
|
||||
RNS.log(f"Could not import ratchet for {filename}: {e}", RNS.LOG_WARNING)
|
||||
try: os.unlink(file_path)
|
||||
except: pass
|
||||
|
||||
pending = self._ratchet_upserts
|
||||
self._ratchet_upserts = {}
|
||||
self.apply(set(), set(), pending, set(), known_destinations)
|
||||
|
||||
return imported
|
||||
|
||||
def import_legacy(self, path):
|
||||
from .vendor import umsgpack
|
||||
with open(path, "rb") as file: legacy = umsgpack.load(file)
|
||||
|
||||
rows = []
|
||||
now = time.time()
|
||||
for destination_hash, entry in legacy.items():
|
||||
if len(entry) < 5: continue
|
||||
entry = list(entry)
|
||||
while len(entry) < 8: entry.append(None if len(entry) in (5, 7) else 0)
|
||||
if entry[0] == None or entry[0] <= 0: entry[0] = now
|
||||
rows.append(self.__entry_row(destination_hash, entry))
|
||||
|
||||
self._conn.execute("BEGIN")
|
||||
for i in range(0, len(rows), 4096): self._conn.executemany("INSERT OR REPLACE INTO known_destinations (destination_hash, last_heard, packet_hash, public_key, app_data, used, stamp, stamp_value, lr_cost, identity_hash) VALUES (?,?,?,?,?,?,?,?,?,?)", rows[i:i+4096])
|
||||
self._conn.commit()
|
||||
|
||||
return len(rows)
|
||||
|
||||
class AnnounceCache:
|
||||
|
||||
def __init__(self, db_path):
|
||||
import sqlite3
|
||||
self.db_path = db_path
|
||||
self._pending = {}
|
||||
self._flush_lock = threading.Lock()
|
||||
self._conn = sqlite3.connect(db_path, check_same_thread=False, isolation_level=None, cached_statements=0)
|
||||
|
||||
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.__create_schema()
|
||||
|
||||
def __create_schema(self):
|
||||
self._conn.execute("""CREATE TABLE IF NOT EXISTS cached_announces (
|
||||
packet_hash BLOB PRIMARY KEY,
|
||||
received REAL NOT NULL,
|
||||
raw BLOB NOT NULL,
|
||||
interface_reference TEXT)""")
|
||||
|
||||
self._conn.execute("PRAGMA user_version = 1")
|
||||
|
||||
def store(self, packet_hash, raw, interface_reference):
|
||||
self._pending[packet_hash] = (time.time(), raw, interface_reference)
|
||||
|
||||
def pending_count(self):
|
||||
return len(self._pending)
|
||||
|
||||
def fetch(self, packet_hash):
|
||||
pending = self._pending.get(packet_hash)
|
||||
if pending != None: return pending[1], pending[2]
|
||||
|
||||
with self._flush_lock:
|
||||
row = self._conn.execute("SELECT raw, interface_reference FROM cached_announces WHERE packet_hash=?", (packet_hash,)).fetchone()
|
||||
|
||||
if row != None: return row[0], row[1]
|
||||
|
||||
return None
|
||||
|
||||
def flush(self):
|
||||
with self._flush_lock: return self.__apply_pending()
|
||||
|
||||
def __apply_pending(self):
|
||||
pending = self._pending
|
||||
self._pending = {}
|
||||
if len(pending) == 0: return 0
|
||||
|
||||
try:
|
||||
self._conn.execute("BEGIN")
|
||||
items = list(pending.items())
|
||||
for i in range(0, len(items), 4096):
|
||||
self._conn.executemany("INSERT INTO cached_announces VALUES (?,?,?,?) ON CONFLICT(packet_hash) DO UPDATE SET received=excluded.received, raw=excluded.raw, interface_reference=excluded.interface_reference",
|
||||
[(packet_hash, *entry) for packet_hash, entry in items[i:i+4096]])
|
||||
self._conn.commit()
|
||||
|
||||
except Exception:
|
||||
# Re-mark everything as pending, so the changes
|
||||
# are retried on the next flush, then propagate.
|
||||
self._pending.update(pending)
|
||||
self._conn.rollback()
|
||||
raise
|
||||
|
||||
return len(pending)
|
||||
|
||||
def clean(self, active_hashes):
|
||||
with self._flush_lock:
|
||||
self.__apply_pending()
|
||||
|
||||
try:
|
||||
self._conn.execute("BEGIN")
|
||||
self._conn.execute("DROP TABLE IF EXISTS temp.active_announces")
|
||||
self._conn.execute("CREATE TEMP TABLE active_announces (packet_hash BLOB PRIMARY KEY)")
|
||||
active_list = list(active_hashes)
|
||||
for i in range(0, len(active_list), 4096):
|
||||
self._conn.executemany("INSERT OR IGNORE INTO active_announces VALUES (?)", [(h,) for h in active_list[i:i+4096]])
|
||||
|
||||
changes_before = self._conn.total_changes
|
||||
self._conn.execute("DELETE FROM cached_announces WHERE packet_hash NOT IN (SELECT packet_hash FROM active_announces)")
|
||||
removed = self._conn.total_changes - changes_before
|
||||
self._conn.commit()
|
||||
|
||||
except Exception:
|
||||
self._conn.rollback()
|
||||
raise
|
||||
|
||||
if removed > 0: self._conn.execute("PRAGMA incremental_vacuum")
|
||||
|
||||
return removed
|
||||
|
||||
def import_legacy(self, dir_path):
|
||||
from .vendor import umsgpack
|
||||
imported = 0
|
||||
for filename in os.listdir(dir_path):
|
||||
file_path = os.path.join(dir_path, filename)
|
||||
try:
|
||||
if not os.path.isfile(file_path): continue
|
||||
with open(file_path, "rb") as file:
|
||||
cached_data = umsgpack.unpackb(file.read())
|
||||
|
||||
packet_hash = bytes.fromhex(filename)
|
||||
interface_reference = cached_data[1] if len(cached_data) > 1 else None
|
||||
self.store(packet_hash, cached_data[0], interface_reference)
|
||||
imported += 1
|
||||
os.unlink(file_path)
|
||||
|
||||
except Exception:
|
||||
try: os.unlink(file_path)
|
||||
except Exception: pass
|
||||
|
||||
self.flush()
|
||||
return imported
|
||||
|
||||
def close(self):
|
||||
if self._conn != None:
|
||||
self._conn.close()
|
||||
self._conn = None
|
||||
+1533
-515
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -387,6 +387,7 @@ def fetch(configdir, identitypath = None, verbosity = 0, quietness = 0, destinat
|
||||
RNS.exit(1)
|
||||
|
||||
reticulum = RNS.Reticulum(configdir=configdir, loglevel=targetloglevel)
|
||||
reticulum.wants_destination_type(f"{APP_NAME}.receive")
|
||||
|
||||
if identity == None:
|
||||
prepare_identity(identitypath)
|
||||
@@ -643,6 +644,7 @@ def send(configdir, identitypath = None, verbosity = 0, quietness = 0, destinati
|
||||
print(f"{erase_str}", end="")
|
||||
|
||||
reticulum = RNS.Reticulum(configdir=configdir, loglevel=targetloglevel)
|
||||
reticulum.wants_destination_type(f"{APP_NAME}.receive")
|
||||
|
||||
if identity == None:
|
||||
prepare_identity(identitypath)
|
||||
|
||||
@@ -154,6 +154,8 @@ class ReticulumGitClient():
|
||||
print(f"Failed to initialize Reticulum: {e}", file=sys.stderr)
|
||||
return
|
||||
|
||||
self.reticulum.wants_destination_type(f"{APP_NAME}.repositories")
|
||||
|
||||
self.__apply_config()
|
||||
self.ready = True
|
||||
|
||||
|
||||
+150
-12
@@ -31,6 +31,7 @@
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import selectors
|
||||
import subprocess
|
||||
import tempfile
|
||||
import RNS
|
||||
@@ -50,6 +51,11 @@ BACKENDS = ( ("magick", ["magick", "-", "webp:-"]),
|
||||
("ffmpeg", ["ffmpeg", "-y", "-loglevel", "error", "-i", "-", "-f", "webp", "pipe:1"]),
|
||||
("avconv", ["avconv", "-y", "-loglevel", "error", "-i", "-", "-f", "webp", "pipe:1"]) )
|
||||
|
||||
SUPPORTED_IMAGE_EXTS = [".webp", ".png", ".jpg", ".jpeg", ".gif", ".tiff", ".tif", ".bmp"]
|
||||
CONV_SIZE_MAX = 32*1024*1024
|
||||
SNIFF_BYTES = 64
|
||||
RELAY_CHUNK = 256*1024
|
||||
|
||||
_ENV_BACKEND = os.environ.get("RNGIT_MEDIA_BACKEND")
|
||||
_winner = None
|
||||
_no_backend_logged = False
|
||||
@@ -106,6 +112,24 @@ def _webp_info(data):
|
||||
if width > 0 and height > 0: return (width, height)
|
||||
return None
|
||||
|
||||
def _is_bmp_header(data):
|
||||
if len(data) < 18 or data[:2] != b"BM": return False
|
||||
try: dib_size = int.from_bytes(data[14:18], "little")
|
||||
except Exception: return False
|
||||
return dib_size in (12, 40, 52, 56, 64, 108, 124)
|
||||
|
||||
_IMAGE_SIGNATURES = ( ("png", lambda data: len(data) >= 8 and data[:8] == b"\x89PNG\r\n\x1a\n"),
|
||||
("jpeg", lambda data: len(data) >= 3 and data[:3] == b"\xff\xd8\xff"),
|
||||
("gif", lambda data: len(data) >= 6 and data[:6] in (b"GIF87a", b"GIF89a")),
|
||||
("tiff", lambda data: len(data) >= 4 and data[:4] in (b"II*\x00", b"MM\x00*")),
|
||||
("webp", lambda data: _webp_info(data) is not None),
|
||||
("bmp", lambda data: _is_bmp_header(data)) )
|
||||
|
||||
def _classify_image(data):
|
||||
for format_name, signature_matches in _IMAGE_SIGNATURES:
|
||||
if signature_matches(data): return format_name
|
||||
return None
|
||||
|
||||
def _valid_webp(path):
|
||||
try:
|
||||
with open(path, "rb") as fh: return _webp_info(fh.read(30)) is not None
|
||||
@@ -115,7 +139,7 @@ def _unlink_output(path):
|
||||
try: os.unlink(path)
|
||||
except Exception: pass
|
||||
|
||||
def _configured_backend(quality=None, max_dimension=None):
|
||||
def _configured_backend(quality=None, max_dimension=None, input_spec=None):
|
||||
global _no_backend_logged
|
||||
backend = _selected_backend()
|
||||
if backend is None:
|
||||
@@ -139,10 +163,15 @@ def _configured_backend(quality=None, max_dimension=None):
|
||||
|
||||
encoder_argv = list(encoder_argv)
|
||||
if backend_name in ("magick", "convert", "gm"):
|
||||
if input_spec is not None:
|
||||
try: input_index = encoder_argv.index("-")
|
||||
except ValueError: input_index = None
|
||||
if input_index is not None: encoder_argv[input_index] = input_spec
|
||||
options = []
|
||||
if quality_arg is not None: options += ["-quality", str(quality_arg)]
|
||||
if dimension_arg is not None: options += ["-resize", f"{dimension_arg}x{dimension_arg}>"]
|
||||
encoder_argv = encoder_argv[:-1] + options + encoder_argv[-1:]
|
||||
|
||||
elif backend_name in ("ffmpeg", "avconv"):
|
||||
options = []
|
||||
if quality_arg is not None: options += ["-quality", str(quality_arg)]
|
||||
@@ -163,13 +192,13 @@ def _await(backend_name, encoder_proc, input_proc=None, timeout=None):
|
||||
except subprocess.TimeoutExpired:
|
||||
_terminate(input_proc)
|
||||
_terminate(encoder_proc)
|
||||
RNS.log(f"Media conversion via {backend_name} timed out after {timeout} seconds", RNS.LOG_WARNING)
|
||||
RNS.log(f"Media conversion via {backend_name} timed out after {RNS.prettytime(timeout)}", RNS.LOG_WARNING)
|
||||
return False
|
||||
|
||||
if encoder_proc.returncode != 0:
|
||||
detail = ""
|
||||
encoder_tail = _stderr_tail(encoder_proc)
|
||||
input_tail = _stderr_tail(input_proc) if input_proc is not None else ""
|
||||
input_tail = _stderr_tail(input_proc) if input_proc is not None else ""
|
||||
if encoder_tail: detail += f" Encoder: {encoder_tail}"
|
||||
if input_tail: detail += f" Input: {input_tail}"
|
||||
RNS.log(f"Media conversion via {backend_name} failed.{detail}", RNS.LOG_WARNING)
|
||||
@@ -177,21 +206,107 @@ def _await(backend_name, encoder_proc, input_proc=None, timeout=None):
|
||||
|
||||
return True
|
||||
|
||||
def _await_readable(fd, timeout, selector):
|
||||
try: return bool(selector.select(max(0.0, timeout)))
|
||||
except Exception: return False
|
||||
|
||||
def _read_prefix(fd, amount, deadline):
|
||||
data = bytearray()
|
||||
selector = selectors.DefaultSelector()
|
||||
try:
|
||||
selector.register(fd, selectors.EVENT_READ)
|
||||
while len(data) < amount:
|
||||
if not _await_readable(fd, deadline - time.time(), selector): return None
|
||||
chunk = os.read(fd, amount - len(data))
|
||||
if not chunk: break
|
||||
data += chunk
|
||||
return bytes(data)
|
||||
finally: selector.close()
|
||||
|
||||
def _pump(fd, encoder_stdin, prefix, deadline):
|
||||
written = len(prefix)
|
||||
if written > CONV_SIZE_MAX: return None
|
||||
encoder_stdin.write(prefix)
|
||||
|
||||
selector = selectors.DefaultSelector()
|
||||
try:
|
||||
selector.register(fd, selectors.EVENT_READ)
|
||||
while True:
|
||||
if not _await_readable(fd, deadline - time.time(), selector):
|
||||
raise subprocess.TimeoutExpired("input relay", max(0.0, deadline - time.time()))
|
||||
chunk = os.read(fd, RELAY_CHUNK)
|
||||
if not chunk: break
|
||||
|
||||
written += len(chunk)
|
||||
if written > CONV_SIZE_MAX: return None
|
||||
encoder_stdin.write(chunk)
|
||||
|
||||
return written
|
||||
|
||||
finally: selector.close()
|
||||
|
||||
def detect_image_format(data):
|
||||
return _classify_image(data)
|
||||
|
||||
def convert_to_webp(input_argv, output_path, cwd=None, timeout=None, quality=None, max_dimension=None):
|
||||
configured = _configured_backend(quality=quality, max_dimension=max_dimension)
|
||||
if configured is None: return False
|
||||
backend_name = configured[0]
|
||||
|
||||
backend_name, encoder_argv = configured
|
||||
if timeout is None: timeout = CONVERSION_TIMEOUT
|
||||
deadline = time.time() + timeout
|
||||
|
||||
try:
|
||||
with open(output_path, "wb") as output_fh:
|
||||
input_proc = subprocess.Popen(input_argv, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
encoder_proc = subprocess.Popen(encoder_argv, stdin=input_proc.stdout, stdout=output_fh, stderr=subprocess.PIPE)
|
||||
input_fd = input_proc.stdout.fileno()
|
||||
|
||||
# The parent must not retain a copy of the input pipe's write
|
||||
# end, or the input process would never see EOF.
|
||||
input_proc.stdout.close()
|
||||
if not _await(backend_name, encoder_proc, input_proc=input_proc, timeout=timeout): return False
|
||||
prefix = _read_prefix(input_fd, SNIFF_BYTES, deadline)
|
||||
if prefix is None:
|
||||
RNS.log(f"Media conversion via {backend_name} timed out after {RNS.prettytime(timeout)}", RNS.LOG_WARNING)
|
||||
_terminate(input_proc)
|
||||
return False
|
||||
|
||||
detected = _classify_image(prefix)
|
||||
if detected is None:
|
||||
RNS.log("Media conversion failed: Input format is not supported", RNS.LOG_DEBUG)
|
||||
_terminate(input_proc)
|
||||
return False
|
||||
|
||||
configured = _configured_backend(quality=quality, max_dimension=max_dimension, input_spec=detected+":-")
|
||||
if configured is None:
|
||||
_terminate(input_proc)
|
||||
return False
|
||||
backend_name, encoder_argv = configured
|
||||
|
||||
encoder_proc = subprocess.Popen(encoder_argv, stdin=subprocess.PIPE, stdout=output_fh, stderr=subprocess.PIPE)
|
||||
|
||||
aborted = False
|
||||
try:
|
||||
if _pump(input_fd, encoder_proc.stdin, prefix, deadline) is None:
|
||||
RNS.log(f"Media conversion failed: Streaming input exceeded maximum size of {RNS.prettysize(CONV_SIZE_MAX)}", RNS.LOG_DEBUG)
|
||||
aborted = True
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
RNS.log(f"Media conversion via {backend_name} timed out after {RNS.prettytime(timeout)}", RNS.LOG_WARNING)
|
||||
aborted = True
|
||||
|
||||
except (BrokenPipeError, OSError):
|
||||
RNS.log(f"Media conversion via {backend_name} failed: Encoder exited before input was consumed", RNS.LOG_DEBUG)
|
||||
aborted = True
|
||||
|
||||
if aborted:
|
||||
_terminate(input_proc)
|
||||
_terminate(encoder_proc)
|
||||
return False
|
||||
|
||||
try: encoder_proc.stdin.close()
|
||||
except (BrokenPipeError, OSError): pass
|
||||
|
||||
try: input_proc.stdout.close()
|
||||
except Exception: pass
|
||||
|
||||
if not _await(backend_name, encoder_proc, input_proc=input_proc, timeout=max(0.0, deadline - time.time())): return False
|
||||
|
||||
if not _valid_webp(output_path):
|
||||
RNS.log(f"Media conversion via {backend_name} produced invalid WebP output", RNS.LOG_WARNING)
|
||||
@@ -207,19 +322,42 @@ def convert_to_webp(input_argv, output_path, cwd=None, timeout=None, quality=Non
|
||||
def convert_file_to_webp(source_path, quality=85, max_dimension=None, timeout=None):
|
||||
configured = _configured_backend(quality=quality, max_dimension=max_dimension)
|
||||
if configured is None: return False
|
||||
backend_name, encoder_argv = configured
|
||||
backend_name = configured[0]
|
||||
|
||||
tmp_path = None
|
||||
success = False
|
||||
try:
|
||||
if not os.path.isfile(source_path):
|
||||
RNS.log(f"Cannot convert media: source file does not exist: {source_path}", RNS.LOG_WARNING)
|
||||
RNS.log(f"Cannot convert media: Source file does not exist: {source_path}", RNS.LOG_WARNING)
|
||||
return False
|
||||
|
||||
try: source_size = os.path.getsize(source_path)
|
||||
except Exception: source_size = None
|
||||
if source_size is not None and source_size > CONV_SIZE_MAX:
|
||||
RNS.log(f"Cannot convert media: Source file exceeds maximum size of {RNS.prettysize(CONV_SIZE_MAX)}", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
fd, tmp_path = tempfile.mkstemp(prefix="rns_media_", suffix=".webp")
|
||||
os.close(fd)
|
||||
|
||||
with open(source_path, "rb") as input_fh, open(tmp_path, "wb") as output_fh:
|
||||
with open(source_path, "rb", buffering=0) as input_fh, open(tmp_path, "wb") as output_fh:
|
||||
prefix = b""
|
||||
while len(prefix) < SNIFF_BYTES:
|
||||
chunk = input_fh.read(SNIFF_BYTES - len(prefix))
|
||||
if not chunk: break
|
||||
prefix += chunk
|
||||
|
||||
detected = _classify_image(prefix)
|
||||
if detected is None:
|
||||
RNS.log("Cannot convert media: Source file is not a supported media format", RNS.LOG_DEBUG)
|
||||
return False
|
||||
|
||||
configured = _configured_backend(quality=quality, max_dimension=max_dimension, input_spec=detected+":-")
|
||||
if configured is None: return False
|
||||
backend_name, encoder_argv = configured
|
||||
|
||||
input_fh.seek(0)
|
||||
|
||||
encoder_proc = subprocess.Popen(encoder_argv, stdin=input_fh, stdout=output_fh, stderr=subprocess.PIPE)
|
||||
if not _await(backend_name, encoder_proc, timeout=timeout): return False
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ from RNS.vendor.configobj import ConfigObj
|
||||
from RNS.vendor import umsgpack as mp
|
||||
from RNS._version import __version__
|
||||
from RNS.Utilities.rnid import validate_rsg, extract_signed_rsg_data
|
||||
from RNS.Utilities.rngit.media import SUPPORTED_IMAGE_EXTS
|
||||
from RNS.Utilities.rngit.commitsigs import unarmor_ssh_signature, parse_ssh_signature, extract_commit_author
|
||||
|
||||
class NomadNetworkNode():
|
||||
@@ -71,6 +72,7 @@ class NomadNetworkNode():
|
||||
FILE_DOWNLOAD = "/file/download"
|
||||
FILE_WORKDOC = "/file/workdoc"
|
||||
|
||||
DEFAULT_LINK_COST = 18.0
|
||||
BLOB_SIZE_LIMIT = 256 * 1024
|
||||
TREE_ENTRIES_PER_PAGE = 1000
|
||||
COMMITS_PER_PAGE = 100
|
||||
@@ -126,7 +128,7 @@ class NomadNetworkNode():
|
||||
CONVERTABLE_EXTS = [".md"]
|
||||
RENDERABLE_EXTS = [".md", ".mu"]
|
||||
RENDER_DEFAULT = [".md", ".mu"]
|
||||
IMAGE_EXTS = [".webp", ".png", ".jpg", ".jpeg", ".gif", ".tiff", ".tif", ".bmp"]
|
||||
IMAGE_EXTS = SUPPORTED_IMAGE_EXTS
|
||||
|
||||
def __init__(self, owner=None):
|
||||
if not owner: raise TypeError(f"Invalid owner {owner} for {self}")
|
||||
@@ -138,6 +140,8 @@ class NomadNetworkNode():
|
||||
self.node_name = owner.node_name
|
||||
self.announce_interval = owner.announce_interval
|
||||
self.last_announce = 0
|
||||
self.stamp_value = None
|
||||
self.link_cost = self.DEFAULT_LINK_COST
|
||||
self.null_ident = RNS.Identity.from_bytes(bytes(64))
|
||||
|
||||
self.templates = {}
|
||||
@@ -175,8 +179,14 @@ class NomadNetworkNode():
|
||||
if self.owner.config["pages"].as_bool("unicode_icons"): self.use_nerdfonts = False
|
||||
if "media_conversion" in self.owner.config["pages"]:
|
||||
self.media_conversion = self.owner.config["pages"].as_bool("media_conversion")
|
||||
if "link_cost" in self.owner.config["pages"]:
|
||||
self.link_cost = RNS.Stamps.quantize_cost(self.owner.config["pages"].as_float("link_cost"))
|
||||
if "stamp_value" in self.owner.config["pages"]:
|
||||
self.stamp_value = RNS.Stamps.quantize_cost(self.owner.config["pages"].as_float("stamp_value"))
|
||||
|
||||
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, self.APP_NAME, "node")
|
||||
if self.stamp_value: self.destination.set_value(self.stamp_value)
|
||||
self.destination.set_link_cost(self.link_cost)
|
||||
self.destination.set_link_established_callback(self.remote_connected)
|
||||
self.destination.set_default_app_data(self.get_announce_app_data)
|
||||
self.register_request_handlers()
|
||||
|
||||
@@ -57,14 +57,15 @@ def program_setup(configdir, rnsconfigdir=None, verbosity=0, quietness=0, servic
|
||||
targetverbosity = verbosity-quietness
|
||||
|
||||
if service:
|
||||
targetlogdest = RNS.LOG_FILE
|
||||
targetlogdest = RNS.LOG_FILE
|
||||
targetverbosity = None
|
||||
else:
|
||||
targetlogdest = RNS.LOG_STDOUT
|
||||
targetlogdest = RNS.LOG_STDOUT
|
||||
|
||||
if print_identity: git_node = ReticulumGitNode(configdir=configdir, print_identity=True)
|
||||
|
||||
reticulum = RNS.Reticulum(configdir=rnsconfigdir, verbosity=targetverbosity, logdest=targetlogdest)
|
||||
reticulum = RNS.Reticulum(configdir=rnsconfigdir, verbosity=targetverbosity, logdest=targetlogdest)
|
||||
reticulum.wants_destination_type(f"{APP_NAME}.repositories")
|
||||
|
||||
if not task:
|
||||
RNS.log("Starting Reticulum Git Node...", RNS.LOG_NOTICE)
|
||||
@@ -1976,6 +1977,8 @@ class ReticulumGitNode():
|
||||
|
||||
CLONE_PROTOS = ["rns", "http", "https", "ssh"]
|
||||
|
||||
DEFAULT_LINK_COST = 18.0
|
||||
|
||||
def __init__(self, configdir=None, verbosity=None, print_identity=False):
|
||||
self.identity = None
|
||||
self.userdir = os.path.expanduser("~")
|
||||
@@ -1988,6 +1991,8 @@ class ReticulumGitNode():
|
||||
self.blocked_identities = {}
|
||||
self.last_announce = 0
|
||||
self.announce_interval = 0
|
||||
self.stamp_value = None
|
||||
self.link_cost = self.DEFAULT_LINK_COST
|
||||
self.stats_enabled = False
|
||||
self.stats_job_interval = 180
|
||||
self.last_stats_job = time.time()
|
||||
@@ -2017,7 +2022,7 @@ class ReticulumGitNode():
|
||||
if os.path.isdir("/etc/rngit") and os.path.isfile("/etc/rngit/config"):
|
||||
self.configdir = "/etc/rngit"
|
||||
elif os.path.isdir(self.userdir+"/.config/rngit") and os.path.isfile(self.userdir+"/.config/rngit/config"):
|
||||
self.configdir = self.userdir+"/.rngit/reticulum"
|
||||
self.configdir = self.userdir+"/.config/rngit"
|
||||
else:
|
||||
self.configdir = self.userdir+"/.rngit"
|
||||
|
||||
@@ -2058,6 +2063,8 @@ class ReticulumGitNode():
|
||||
exit(0)
|
||||
|
||||
self.destination = RNS.Destination(self.identity, RNS.Destination.IN, RNS.Destination.SINGLE, APP_NAME, "repositories")
|
||||
if self.stamp_value: self.destination.set_value(self.stamp_value)
|
||||
self.destination.set_link_cost(self.link_cost)
|
||||
self.destination.set_link_established_callback(self.remote_connected)
|
||||
self.register_request_handlers()
|
||||
RNS.log(f"Reticulum Git Node listening on {RNS.prettyhexrep(self.destination.hash)}", RNS.LOG_NOTICE)
|
||||
@@ -2204,6 +2211,8 @@ class ReticulumGitNode():
|
||||
section = self.config["rngit"]
|
||||
if "node_name" in section: self.node_name = section["node_name"]
|
||||
if "announce_interval" in section: self.announce_interval = section.as_int("announce_interval")*60
|
||||
if "stamp_value" in section: self.stamp_value = RNS.Stamps.quantize_cost(section.as_float("stamp_value"))
|
||||
if "link_cost" in section: self.link_cost = RNS.Stamps.quantize_cost(section.as_float("link_cost"))
|
||||
if "mirror_interval" in section: self.mirror_interval = max(section.as_int("mirror_interval")*60*60, 0)
|
||||
if "record_stats" in section: self.stats_enabled = section.as_bool("record_stats")
|
||||
if "stats_ignore_identities" in section:
|
||||
@@ -4925,6 +4934,16 @@ announce_interval = 360
|
||||
|
||||
# node_name = Anonymous Git Node
|
||||
|
||||
# You can configure the required link stamp cost for
|
||||
# connecting to the repository node.
|
||||
|
||||
# link_cost = 18.0
|
||||
|
||||
# The target stamp value for the repositories destination
|
||||
# can also be configured.
|
||||
|
||||
# stamp_value = 25.0
|
||||
|
||||
# You can enable collecting view, fetch and push statistics
|
||||
# which can be displayed on the stats pages of repositories.
|
||||
# Remember to set the "s" (stats) permission appropriately
|
||||
@@ -5043,6 +5062,16 @@ internal = rw:9710b86ba12c42d1d8f30f74fe509286
|
||||
|
||||
# serve_nomadnet = no
|
||||
|
||||
# You can configure the required link stamp cost for
|
||||
# connecting to the page node.
|
||||
|
||||
# link_cost = 18.0
|
||||
|
||||
# The target stamp value for the node destination can
|
||||
# also be configured.
|
||||
|
||||
# stamp_value = 25.0
|
||||
|
||||
# It is possible to disable Nerd Font icons and instead
|
||||
# use simpler (but more compatible) unicode icons.
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+134
-10
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -101,11 +101,13 @@ def parse_hash(input_str):
|
||||
|
||||
def program_setup(configdir, table, rates, drop, destination_hexhash, verbosity, timeout, drop_queues,
|
||||
drop_via, max_hops, remote=None, management_identity=None, remote_timeout=RNS.Transport.PATH_REQUEST_TIMEOUT,
|
||||
blackholed=False, blackhole=False, unblackhole=False, blackhole_duration=None, blackhole_reason=None,
|
||||
remote_blackhole_list=False, remote_blackhole_list_filter=None, no_output=False, json=False):
|
||||
blackholed=False, blackhole=False, unblackhole=False, blackhole_duration=None, blackhole_reason=None, remote_blackhole_list=False, remote_blackhole_list_filter=None,
|
||||
active=False, usage=False, vias=False, expinfo=False, min_value=None, no_output=False, analyze=False, capture=None, json=False):
|
||||
|
||||
global remote_link, reticulum
|
||||
reticulum = RNS.Reticulum(configdir = configdir, loglevel = 3+verbosity)
|
||||
reticulum.wants_destination_type("rnstransport.remote.management")
|
||||
reticulum.wants_destination_type("rnstransport.info.blackhole")
|
||||
if remote:
|
||||
try:
|
||||
dest_len = (RNS.Reticulum.TRUNCATED_HASHLENGTH//8)*2
|
||||
@@ -240,6 +242,10 @@ def program_setup(configdir, table, rates, drop, destination_hexhash, verbosity,
|
||||
print(f"Could not unblackhole identity: {e}")
|
||||
exit(20)
|
||||
|
||||
elif analyze:
|
||||
analyze_tables(path_table=reticulum.get_path_table(), rate_table=reticulum.get_rate_table(),
|
||||
link_distribution=reticulum.get_link_distribution(), capture=capture)
|
||||
|
||||
elif table:
|
||||
destination_hash = None
|
||||
if destination_hexhash != None:
|
||||
@@ -281,13 +287,35 @@ def program_setup(configdir, table, rates, drop, destination_hexhash, verbosity,
|
||||
exit()
|
||||
|
||||
else:
|
||||
now = time.time()
|
||||
if usage:
|
||||
try: table = sorted(table, key=lambda e: e["used"], reverse=True)
|
||||
except Exception as e: pass
|
||||
|
||||
now = time.time()
|
||||
for path in table:
|
||||
if destination_hash == None or destination_hash == path["hash"]:
|
||||
displayed += 1
|
||||
if min_value:
|
||||
if not path["value"]: continue
|
||||
if path["value"] < min_value: continue
|
||||
|
||||
if path["state"] == RNS.Transport.STATE_RESPONSIVE: state_str = " (R)"
|
||||
elif path["state"] == RNS.Transport.STATE_UNRESPONSIVE: state_str = " (u)"
|
||||
elif path["state"] == RNS.Transport.STATE_UNKNOWN: state_str = " (?)"
|
||||
else: state_str = " (?)"
|
||||
|
||||
exp_str = RNS.timestamp_str(path["expires"])
|
||||
if path["hops"] == 1: m_str = " "
|
||||
else: m_str = "s"
|
||||
print(RNS.prettyhexrep(path["hash"])+" is "+str(path["hops"])+" hop"+m_str+" away via "+RNS.prettyhexrep(path["via"])+" on "+path["interface"]+" expires "+RNS.timestamp_str(path["expires"]))
|
||||
if not "used" in path: u_str = ", no usage info"
|
||||
else:
|
||||
if active and not path["used"]: continue
|
||||
if usage: u_str = f", last used {RNS.prettytime(now-path['used'])} ago" if path["used"] else ", never used"
|
||||
else: u_str = ""
|
||||
via_str = f" via {RNS.prettyhexrep(path['via'])}" if vias else ""
|
||||
exp_str = f" expires in {RNS.prettytime(path['expires']-now, compact=True)}" if expinfo else ""
|
||||
print(f"{RNS.prettyhexrep(path['hash'])} {path['hops']:>3}h{state_str}{via_str} on {path['interface']}{exp_str} (dv:{RNS.prettycost(path['value'])}/lc:{RNS.prettycost(path['lr_cost'])}){u_str}")
|
||||
|
||||
if destination_hash != None and displayed == 0:
|
||||
print("No path known")
|
||||
@@ -484,7 +512,12 @@ def main():
|
||||
parser.add_argument("--config", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
|
||||
parser.add_argument("--version", action="version", version="rnpath {version}".format(version=__version__))
|
||||
parser.add_argument("-t", "--table", action="store_true", help="show all known paths", default=False)
|
||||
parser.add_argument("-a", "--active", action="store_true", help="show in-use paths only", default=False)
|
||||
parser.add_argument("-u", "--usage", action="store_true", help="show path usage time", default=False)
|
||||
parser.add_argument("-V", "--vias", action="store_true", help="show via transport IDs", default=False)
|
||||
parser.add_argument("-E", "--expiry", action="store_true", help="show path expiry times", default=False)
|
||||
parser.add_argument("-m", "--max", action="store", metavar="hops", type=int, help="maximum hops to filter path table by", default=None)
|
||||
parser.add_argument("-M", "--min-value", action="store", metavar="value", type=float, help="minimum value to filter path table by", default=None)
|
||||
parser.add_argument("-r", "--rates", action="store_true", help="show announce rate info", default=False)
|
||||
parser.add_argument("-d", "--drop", action="store_true", help="remove the path to a destination", default=False)
|
||||
parser.add_argument("-D", "--drop-announces", action="store_true", help="drop all queued announces", default=False)
|
||||
@@ -496,10 +529,12 @@ def main():
|
||||
parser.add_argument("-b", "--blackholed", action="store_true", help="list blackholed identities", default=False)
|
||||
parser.add_argument("-B", "--blackhole", action="store_true", help="blackhole identity", default=False)
|
||||
parser.add_argument("-U", "--unblackhole", action="store_true", help="unblackhole identity", default=False)
|
||||
parser.add_argument( "--duration", action="store", type=float, help="duration of blackhole enforcement in hours", default=None)
|
||||
parser.add_argument( "--reason", action="store", type=str, help="reason for blackholing identity", default=None)
|
||||
parser.add_argument( "--duration", action="store", metavar="hours", type=float, help="duration of blackhole enforcement in hours", default=None)
|
||||
parser.add_argument( "--reason", action="store", metavar="reason", type=str, help="reason for blackholing identity", default=None)
|
||||
parser.add_argument("-p", "--blackholed-list", action="store_true", help="view published blackhole list for remote transport instance", default=False)
|
||||
parser.add_argument("-j", "--json", action="store_true", help="output in JSON format", default=False)
|
||||
parser.add_argument("-A", "--analyze", action="store_true", help="Analyze tables", default=False)
|
||||
parser.add_argument("--capture", action="store", metavar="path", type=str, help="path to capture file for analyze mode", default=None)
|
||||
parser.add_argument("destination", nargs="?", default=None, help="hexadecimal hash of the destination", type=str)
|
||||
parser.add_argument("list_filter", nargs="?", default=None, help="filter for remote blackhole list view", type=str)
|
||||
parser.add_argument('-v', '--verbose', action='count', default=0)
|
||||
@@ -509,16 +544,17 @@ def main():
|
||||
if args.config: configarg = args.config
|
||||
else: configarg = None
|
||||
|
||||
if not args.drop_announces and not args.table and not args.rates and not args.destination and not args.drop_via and not args.blackholed:
|
||||
if not args.drop_announces and not args.table and not args.rates and not args.destination and not args.drop_via and not args.blackholed and not args.analyze:
|
||||
print("")
|
||||
parser.print_help()
|
||||
print("")
|
||||
else:
|
||||
program_setup(configdir = configarg, table = args.table, rates = args.rates, drop = args.drop, destination_hexhash = args.destination,
|
||||
verbosity = args.verbose, timeout = args.w, drop_queues = args.drop_announces, drop_via = args.drop_via, max_hops = args.max,
|
||||
program_setup(configdir=configarg, table=args.table, rates=args.rates, drop=args.drop, destination_hexhash=args.destination,
|
||||
verbosity=args.verbose, timeout=args.w, drop_queues=args.drop_announces, drop_via=args.drop_via, max_hops=args.max, min_value=args.min_value,
|
||||
remote=args.R, management_identity=args.i, remote_timeout=args.W, blackholed=args.blackholed, blackhole=args.blackhole,
|
||||
unblackhole=args.unblackhole, blackhole_duration=args.duration, blackhole_reason=args.reason, remote_blackhole_list=args.blackholed_list,
|
||||
remote_blackhole_list_filter=args.list_filter, json=args.json)
|
||||
remote_blackhole_list_filter=args.list_filter, usage=args.usage, vias=args.vias, active=args.active, expinfo=args.expiry,
|
||||
analyze=args.analyze, capture=args.capture, json=args.json)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
@@ -526,6 +562,94 @@ def main():
|
||||
print("")
|
||||
exit()
|
||||
|
||||
def analyze_tables(path_table=None, rate_table=None, link_distribution=None, capture=None):
|
||||
print("Not yet implemented")
|
||||
exit()
|
||||
|
||||
# if not path_table:
|
||||
# print("No path table to analyze")
|
||||
# exit()
|
||||
|
||||
# else:
|
||||
# print(f"Analyzing tables...")
|
||||
|
||||
# # TODO: If a `capture` path is specified, we save and (if existing) load from
|
||||
# # this file, so that `rnpath --analyze` can be run at intervals, and continuously
|
||||
# # collect data, instead of only providing an at-the-moment snapshot view.
|
||||
|
||||
# # Locally initialize announce cache to be able to
|
||||
# # fetch full announce packet data
|
||||
# if RNS.Transport.owner.is_connected_to_shared_instance: RNS.Transport.init_announce_cache()
|
||||
# tm = RNS.Transport.destination_type_map
|
||||
# total = len(path_table)
|
||||
# destinations = {}
|
||||
# unresolvable = 0
|
||||
# unknown_types = set()
|
||||
# known_types = set()
|
||||
# unknown_type_dsts = 0
|
||||
# known_type_dsts = 0
|
||||
# for path in path_table:
|
||||
# dst_hash = path["hash"]
|
||||
# dst_hops = path["hops"]
|
||||
# last_used = path["used"]
|
||||
# name_hash = None
|
||||
# kd_entry = RNS.Identity.known_destinations.get(dst_hash, None)
|
||||
|
||||
# # New destinations may have arrived after our initial known
|
||||
# # destinations snapshot, which is fine, we just count the few
|
||||
# # that miss here for now.
|
||||
# if not kd_entry: unresolvable += 1
|
||||
|
||||
# # Enrich data with information from cached announces
|
||||
# else:
|
||||
# dst_value = kd_entry[6]
|
||||
# dst_lr_cost = kd_entry[7]
|
||||
# announce_hash = kd_entry[1]
|
||||
# announce_packet = RNS.Transport.get_cached_packet(announce_hash, packet_type="announce")
|
||||
# if not announce_packet: unresolvable += 1; continue
|
||||
|
||||
# try: announce_packet.unpack()
|
||||
# except: unresolvable +=1; continue
|
||||
|
||||
# keysize = RNS.Identity.KEYSIZE//8
|
||||
# name_hash_len = RNS.Identity.NAME_HASH_LENGTH//8
|
||||
# name_hash = announce_packet.data[keysize:keysize+name_hash_len]
|
||||
# app_data = kd_entry[3] or RNS.Identity.recall_app_data(dst_hash, _no_use=True)
|
||||
# app_data_len = len(app_data) if app_data else None # No len counting if no app data
|
||||
|
||||
# if name_hash in tm: known_type_dsts += 1; known_types.add(name_hash)
|
||||
# else: unknown_type_dsts += 1; unknown_types.add(name_hash)
|
||||
|
||||
# # TODO: Create actual data structure for use in analysis
|
||||
# entry = {}
|
||||
|
||||
# destinations[dst_hash] = entry
|
||||
|
||||
# if rate_table:
|
||||
# # TODO: Incorporate and enrich with data from rate table
|
||||
# pass
|
||||
|
||||
# if link_distribution:
|
||||
# # TODO: Incorporate and enrich with link distribution data
|
||||
# pass
|
||||
|
||||
# # TODO: Actually analyze tables
|
||||
# pass
|
||||
|
||||
# # TODO: Actually print a comprehensive, beautifully formatted
|
||||
# # overview, charts and data. This is a stub.
|
||||
# print(f"Known types : {len(known_types)}")
|
||||
# print(f"Unknown types : {len(unknown_types)}")
|
||||
# print(f"Total types : {len(known_types)+len(unknown_types)}")
|
||||
# print(f"Known type dests : {known_type_dsts}")
|
||||
# print(f"Unknown type dests : {unknown_type_dsts}")
|
||||
# print(f"Total type dests : {known_type_dsts+unknown_type_dsts}")
|
||||
|
||||
# # TODO: Ensure we get the terminal width if possible, and fall back to
|
||||
# # a sensible default if not, so everything is rendered beautifully.
|
||||
|
||||
# exit()
|
||||
|
||||
def pretty_date(time=False):
|
||||
from datetime import datetime
|
||||
now = datetime.now()
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+77
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -122,6 +122,7 @@ share_instance = yes
|
||||
|
||||
instance_name = default
|
||||
|
||||
|
||||
# Some platforms don't support domain sockets, and if that
|
||||
# is the case, you can isolate different instances by
|
||||
# specifying a unique set of ports for each:
|
||||
@@ -289,6 +290,12 @@ instance_name = default
|
||||
# blackhole_update_interval = 60
|
||||
|
||||
|
||||
# You can enable a hop limiter, that will drop all packets
|
||||
# exceeding the specified maximum hop count.
|
||||
|
||||
# hop_limiter = 16
|
||||
|
||||
|
||||
# When not running as a transport node, it is possible to
|
||||
# force the use of the same, static transport identity
|
||||
# for every instance start. Defaults to using a new identity
|
||||
@@ -296,6 +303,75 @@ instance_name = default
|
||||
|
||||
# static_transport_identity = no
|
||||
|
||||
[stamps]
|
||||
# This section configures stamping behaviour and defaults.
|
||||
# In most cases, you do not need to change this, but on
|
||||
# constrained systems especially, tuning these parameters
|
||||
# can be very beneficial
|
||||
|
||||
# During the 1.6.x phased transition to network stamp usage,
|
||||
# it is possible to enable early opt-in on stamp generation
|
||||
# and enforcement. RNS 1.6.0 includes all the required stamp
|
||||
# generation and verification functionality, and actively
|
||||
# validates stamps, while leaving generation, emission and
|
||||
# enforcement disabled by default for destinations and PRs.
|
||||
# Link requests will be stamped already from 1.6.0 if a cost
|
||||
# has been announced by the destination. Version 1.6.1 will
|
||||
# enable generation and emission by default, and version
|
||||
# 1.6.2 will finally activate enforcement. Any of these
|
||||
# options can be enabled early by configuration:
|
||||
|
||||
# stamp_destinations = yes
|
||||
# stamp_prs = yes
|
||||
# enforce_stamps = yes
|
||||
|
||||
|
||||
# The default required stamp cost for an announce, and its
|
||||
# destination to be considered valid. This applies both to
|
||||
# announces received directly, and transported by this node,
|
||||
# if transport is enabled. Any announced destination not
|
||||
# meeting the cost will be ignored.
|
||||
|
||||
# destination_cost = 23.5
|
||||
|
||||
|
||||
# The default value this instance will target when generating
|
||||
# new destination stamps. An application may set a higher
|
||||
# target, but applications requesting a lower value than the
|
||||
# default will always generate at least the default value.
|
||||
# Destination stamps are cached and reused, so a one-time
|
||||
# high-value generation is usually a good idea.
|
||||
|
||||
# destination_value = 25.0
|
||||
|
||||
|
||||
# The default required path request stamp cost. Path requests
|
||||
# that do not meet the requirement are ignored.
|
||||
|
||||
# pr_cost = 15.8
|
||||
|
||||
|
||||
# The default target value of path request stamps generated
|
||||
# by this instance.
|
||||
|
||||
# pr_value = 15.8
|
||||
|
||||
|
||||
# The default link request stamp cost to use, if one has not
|
||||
# been announced by the destination the link is established
|
||||
# to, or if it is unknown. In practice, all destinations will
|
||||
# include their required link cost in each announce, and this
|
||||
# option is rarely necessary.
|
||||
|
||||
# lr_cost = 12.5
|
||||
|
||||
|
||||
# The maximum amount of time to spend attempting to generate
|
||||
# a link request and path request stamps, in seconds.
|
||||
|
||||
# lr_stamp_timeout = 15
|
||||
# pr_stamp_timeout = 15
|
||||
|
||||
|
||||
[logging]
|
||||
# Valid log levels are 0 through 8:
|
||||
|
||||
@@ -153,6 +153,8 @@ async def _initiate_link(configdir, rnsconfigdir, identitypath=None, logfile=Non
|
||||
RNS.logfile = logfile
|
||||
_reticulum = RNS.Reticulum(configdir=rnsconfigdir, loglevel=targetloglevel, logdest=RNS.LOG_FILE)
|
||||
|
||||
_reticulum.wants_destination_type(f"{rnsh.APP_NAME}")
|
||||
|
||||
if _identity is None:
|
||||
_identity = rnsh.prepare_identity(identity_path=identitypath, service_name=None, configdir=configdir)
|
||||
|
||||
@@ -167,14 +169,13 @@ async def _initiate_link(configdir, rnsconfigdir, identitypath=None, logfile=Non
|
||||
listener_identity = RNS.Identity.recall(destination_hash)
|
||||
_destination = RNS.Destination(listener_identity, RNS.Destination.OUT, RNS.Destination.SINGLE, rnsh.APP_NAME)
|
||||
|
||||
RNS.log(f"Establishing link with {RNS.prettyhexrep(destination_hash)}", RNS.LOG_INFO)
|
||||
if _link is None or _link.status == RNS.Link.PENDING:
|
||||
RNS.log("No link", RNS.LOG_DEBUG)
|
||||
_link = RNS.Link(_destination)
|
||||
_link.did_identify = False
|
||||
|
||||
_link.set_link_closed_callback(_client_link_closed)
|
||||
|
||||
RNS.log(f"Establishing link with {RNS.prettyhexrep(destination_hash)}", RNS.LOG_INFO)
|
||||
if not await _spin(until=lambda: _link.status == RNS.Link.ACTIVE, msg=f"Establishing link with {RNS.prettyhexrep(destination_hash)}",
|
||||
timeout=timeout, quiet=quietness > 0):
|
||||
raise RemoteExecutionError("Could not establish link with " + RNS.prettyhexrep(destination_hash))
|
||||
|
||||
+88
-10
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -160,7 +160,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
sorting=None, sort_reverse=False, remote=None, management_identity=None, must_exit=True, rns_instance=None,
|
||||
traffic_totals=False, discovered_interfaces=False, config_entries=False, burst_filter=False, blocked_ips=False,
|
||||
queue_stats=False, pps=False, profiling=False, remote_timeout=RNS.Transport.PATH_REQUEST_TIMEOUT,
|
||||
attach=None, detach=None, reload=None, show_stale=False, show_unknown=False):
|
||||
attach=None, detach=None, reload=None, show_stale=False, show_unknown=False, fstats=False, tstats=False):
|
||||
|
||||
if remote: require_shared = False
|
||||
else: require_shared = True
|
||||
@@ -171,6 +171,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
must_exit = False
|
||||
else:
|
||||
reticulum = RNS.Reticulum(configdir=configdir, loglevel=3+verbosity, require_shared_instance=require_shared)
|
||||
reticulum.wants_destination_type("rnstransport.remote.management")
|
||||
|
||||
except Exception as e:
|
||||
print("No shared RNS instance available to get status from")
|
||||
@@ -261,6 +262,14 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
last_heard_display = f"{RNS.prettytime(hago, compact=True)} ago"
|
||||
transport_str = "Enabled" if i["transport"] else "Disabled"
|
||||
|
||||
has_cost_info = "dst_cost" in i and "pr_cost" in i
|
||||
dst_cost = None; pr_cost = None
|
||||
if not has_cost_info: cost_str = "Unknown"
|
||||
else:
|
||||
dst_cost = i["dst_cost"]
|
||||
pr_cost = i["pr_cost"]
|
||||
cost_str = f"Dst {RNS.prettycost(dst_cost)}, PR {RNS.prettycost(pr_cost)}"
|
||||
|
||||
if i["latitude"] is not None and i["longitude"] is not None:
|
||||
lat = round(i["latitude"], 4)
|
||||
lon = round(i["longitude"], 4)
|
||||
@@ -287,6 +296,8 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
print(f"Stack : {impl_str}")
|
||||
print(f"Status : {status_display}")
|
||||
print(f"Transport : {transport_str}")
|
||||
print(f"Stamp Value : {RNS.prettycost(i['value'])}")
|
||||
print(f"Costs : {cost_str}") if has_cost_info else None
|
||||
print(f"Distance : {i['hops']} hop{'' if i['hops'] == 1 else 's'}")
|
||||
print(f"Discovered : {discovered_display}")
|
||||
print(f"Last Heard : {last_heard_display}")
|
||||
@@ -300,8 +311,6 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
if "reachable_on" in i: print(f"Address : {i['reachable_on']}")
|
||||
if "port" in i: print(f"Port : {i['port']}")
|
||||
|
||||
print(f"Stamp Value : {i['value']}")
|
||||
|
||||
print(f"\nConfiguration Entry:")
|
||||
config_lines = i["config_entry"].split('\n')
|
||||
for line in config_lines: print(f" {line}")
|
||||
@@ -345,7 +354,7 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
days = int(diff / 86400)
|
||||
last_heard_display = f"{days}d ago"
|
||||
|
||||
value = str(i["value"])
|
||||
value = RNS.prettycost(i["value"])
|
||||
|
||||
if i["latitude"] is not None and i["longitude"] is not None:
|
||||
lat = round(i["latitude"], 4)
|
||||
@@ -423,14 +432,19 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
if sorting == "rate" or sorting == "bitrate": interfaces.sort(key=lambda i: i["bitrate"], reverse=not sort_reverse)
|
||||
if sorting == "rx": interfaces.sort(key=lambda i: i["rxb"], reverse=not sort_reverse)
|
||||
if sorting == "tx": interfaces.sort(key=lambda i: i["txb"], reverse=not sort_reverse)
|
||||
if sorting == "frx": interfaces.sort(key=lambda i: i["frxb"], reverse=not sort_reverse)
|
||||
if sorting == "ftx": interfaces.sort(key=lambda i: i["ftxb"], reverse=not sort_reverse)
|
||||
if sorting == "rxs": interfaces.sort(key=lambda i: i["rxs"], reverse=not sort_reverse)
|
||||
if sorting == "txs": interfaces.sort(key=lambda i: i["txs"], reverse=not sort_reverse)
|
||||
if sorting == "frxs": interfaces.sort(key=lambda i: i["frxs"], reverse=not sort_reverse)
|
||||
if sorting == "ftxs": interfaces.sort(key=lambda i: i["ftxs"], reverse=not sort_reverse)
|
||||
if sorting == "traffic": interfaces.sort(key=lambda i: i["rxb"]+i["txb"], reverse=not sort_reverse)
|
||||
if sorting == "anns" or sorting == "announces": interfaces.sort(key=lambda i: i["incoming_announce_frequency"]+i["outgoing_announce_frequency"], reverse=not sort_reverse)
|
||||
if sorting == "arx": interfaces.sort(key=lambda i: i["incoming_announce_frequency"], reverse=not sort_reverse)
|
||||
if sorting == "atx": interfaces.sort(key=lambda i: i["outgoing_announce_frequency"], reverse=not sort_reverse)
|
||||
if sorting == "arxc": interfaces.sort(key=lambda i: i["arxc"], reverse=not sort_reverse)
|
||||
if sorting == "atxc": interfaces.sort(key=lambda i: i["atxc"], reverse=not sort_reverse)
|
||||
if sorting == "afrxc": interfaces.sort(key=lambda i: i["afrxc"], reverse=not sort_reverse)
|
||||
if sorting == "prx": interfaces.sort(key=lambda i: i["incoming_pr_frequency"], reverse=not sort_reverse)
|
||||
if sorting == "ptx": interfaces.sort(key=lambda i: i["outgoing_pr_frequency"], reverse=not sort_reverse)
|
||||
if sorting == "prxc": interfaces.sort(key=lambda i: i["prxc"], reverse=not sort_reverse)
|
||||
@@ -542,6 +556,21 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
if "bitrate" in ifstat and ifstat["bitrate"] != None:
|
||||
print(f" Rate : {speed_str(ifstat['bitrate'])}, MTU {ifstat['mtu']}")
|
||||
|
||||
if tstats and not clients:
|
||||
print(f" Tunnel ID : {RNS.hexrep(ifstat['tunnel_id'], delimit=False) if ifstat['tunnel_id'] else 'None'}")
|
||||
|
||||
if tstats and ifstat["tunnel_id"]:
|
||||
print(f" Rem.Tr.ID : {RNS.prettyhexrep(ifstat['remote_transport_id']) if ifstat['remote_transport_id'] else 'Unknown'}")
|
||||
|
||||
trns_str = ", transport enabled" if ifstat['rem_is_tn'] else ", no transport"
|
||||
impl_str = f"{ifstat['rem_impl']}" if ifstat['rem_impl'] else "Unknown implementation"
|
||||
vers_str = f" {'.'.join([str(v) for v in ifstat['rem_vers']])}{trns_str}" if ifstat['rem_vers'] else ", unknown version"
|
||||
print(f" Rem.Vers. : {impl_str}{vers_str}")
|
||||
|
||||
dst_cost_str = f"Dst {RNS.prettycost(ifstat['rem_dst_cost'])}" if ifstat["rem_dst_cost"] != None else "Dst ?"
|
||||
pr_cost_str = f"PR {RNS.prettycost(ifstat['rem_pr_cost'])}" if ifstat["rem_pr_cost"] != None else "PR ?"
|
||||
print(f" Rem.Csts. : {dst_cost_str}, {pr_cost_str}")
|
||||
|
||||
if "noise_floor" in ifstat:
|
||||
if not "interference" in ifstat: nstr = ""
|
||||
else:
|
||||
@@ -729,7 +758,8 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
|
||||
if asr:
|
||||
if ifstat["arxc"] and ifstat["atxc"]:
|
||||
print(f" Announces : {ifstat['arxc']}↓ {ifstat['atxc']}↑ total")
|
||||
f_str = f", {ifstat['afrxc']} filtered" if ifstat["afrxc"] else ""
|
||||
print(f" Announces : {ifstat['arxc']}↓ {ifstat['atxc']}↑ total{f_str}")
|
||||
print(f" {oaf} {pc_str}")
|
||||
else:
|
||||
print(f" Announces : {oaf} {pc_str}")
|
||||
@@ -748,6 +778,14 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
|
||||
print(f" Traffic : {txstat}\n {rxstat}")
|
||||
|
||||
if fstats:
|
||||
frxstat = "↓"+RNS.prettysize(ifstat["frxb"])
|
||||
ftxstat = "↑"+RNS.prettysize(ifstat["ftxb"])
|
||||
if "frxs" in ifstat and "ftxs" in ifstat:
|
||||
frxstat += " "+RNS.prettyspeed(ifstat["frxs"])
|
||||
ftxstat += " "+RNS.prettyspeed(ifstat["ftxs"])
|
||||
print(f" Filtered : {ftxstat}\n {frxstat}")
|
||||
|
||||
lstr = ""
|
||||
if link_count != None and lstats:
|
||||
ms = "y" if link_count == 1 else "ies"
|
||||
@@ -788,6 +826,41 @@ def program_setup(configdir, dispall=False, verbosity=0, name_filter=None, json=
|
||||
|
||||
print(f"\n Totals : {txstat}\n {rxstat}")
|
||||
|
||||
if fstats:
|
||||
frxstat = "↓"+RNS.prettysize(stats["frxb"])
|
||||
ftxstat = "↑"+RNS.prettysize(stats["ftxb"])
|
||||
|
||||
strdiff = len(frxstat)-len(ftxstat)
|
||||
if strdiff > 0: ftxstat += " "*strdiff
|
||||
elif strdiff < 0: frxstat += " "*-strdiff
|
||||
|
||||
if "frxs" in stats and "ftxs" in stats:
|
||||
frxstat += " "+RNS.prettyspeed(stats["frxs"])
|
||||
ftxstat += " "+RNS.prettyspeed(stats["ftxs"])
|
||||
print(f"\n Filtered : {ftxstat}\n {frxstat}")
|
||||
|
||||
if lstats:
|
||||
if "lrxb" in stats and "ltxb" in stats and "lrxs" in stats and "ltxs" in stats:
|
||||
lrxb_str = "↓"+RNS.prettysize(stats["lrxb"])
|
||||
ltxb_str = "↑"+RNS.prettysize(stats["ltxb"])
|
||||
strdiff = len(lrxb_str)-len(ltxb_str)
|
||||
if strdiff > 0: ltxb_str += " "*strdiff
|
||||
elif strdiff < 0: lrxb_str += " "*-strdiff
|
||||
|
||||
parxs = stats["prxs"]+stats["arxs"]
|
||||
patxs = stats["ptxs"]+stats["atxs"]
|
||||
drxpct = 100.0-min(100.0, (parxs / stats["rxs"])*100.0) if stats["rxs"] else 100.0
|
||||
dtxpct = 100.0-min(100.0, (patxs / stats["txs"])*100.0) if stats["txs"] else 100.0
|
||||
drxs = stats["rxs"]*(drxpct/100.0)
|
||||
dtxs = stats["txs"]*(dtxpct/100.0)
|
||||
|
||||
lrxspct = min(100.0, (stats["lrxs"] / drxs)*100.0) if drxs and stats["lrxs"] else 0.0
|
||||
ltxspct = min(100.0, (stats["ltxs"] / dtxs)*100.0) if dtxs and stats["ltxs"] else 0.0
|
||||
|
||||
lrxstat = lrxb_str+" "+RNS.prettyspeed(stats["lrxs"])+f", {int(lrxspct)}% of data flow"
|
||||
ltxstat = ltxb_str+" "+RNS.prettyspeed(stats["ltxs"])+f", {int(ltxspct)}% of data flow"
|
||||
print(f"\n Links : {ltxstat}\n {lrxstat}")
|
||||
|
||||
if pstats:
|
||||
if "prxb" in stats and "ptxb" in stats and "prxs" in stats and "ptxs" in stats:
|
||||
prxb_str = "↓"+RNS.prettysize(stats["prxb"])
|
||||
@@ -883,14 +956,16 @@ def main(must_exit=True, rns_instance=None):
|
||||
parser.add_argument("-a", "--all", action="store_true", help="show all interfaces", default=False)
|
||||
parser.add_argument("-A", "--announce-stats", action="store_true", help="show announce stats", default=False)
|
||||
parser.add_argument("-P", "--pr-stats", action="store_true", help="show path request stats", default=False)
|
||||
parser.add_argument("-F", "--filter-stats", action="store_true", help="show filtered traffic stats", default=False)
|
||||
parser.add_argument("-l", "--link-stats", action="store_true", help="show link stats", default=False)
|
||||
parser.add_argument("-B", "--burst", action="store_true", help="only show interfaces with active bursts", default=False)
|
||||
parser.add_argument("-b", "--blocked-ips", action="store_true", help="show blocked IPs per interface", default=False)
|
||||
parser.add_argument("-t", "--totals", action="store_true", help="display traffic totals", default=False)
|
||||
parser.add_argument("-T", "--tunnels", action="store_true", help="display tunnel information", default=False)
|
||||
parser.add_argument("-p", "--pps", action="store_true", help="display packets per second in totals", default=False)
|
||||
parser.add_argument("-q", "--queues", action="store_true", help="display queue stats", default=False)
|
||||
parser.add_argument("-z", "--profiling", action="store_true", help="display live profiling results", default=False)
|
||||
parser.add_argument("-s", "--sort", action="store", help="sort interfaces by [rate, traffic, rx, tx, rxs, txs, anns, arx, atx, arxc, atxc, held, prx, ptx, prxc, ptxc, pvs, ivs, flt, txdrp, txdrb, txbuf]", default=None, type=str)
|
||||
parser.add_argument("-s", "--sort", action="store", help="sort interfaces by [rate, traffic, rx, tx, rxs, txs, frx, ftx, anns, arx, atx, arxc, atxc, afrxc, held, prx, ptx, prxc, ptxc, pvs, ivs, flt, txdrp, txdrb, txbuf]", default=None, type=str)
|
||||
parser.add_argument("-r", "--reverse", action="store_true", help="reverse sorting", default=False)
|
||||
parser.add_argument("-j", "--json", action="store_true", help="output in JSON format", default=False)
|
||||
parser.add_argument("-R", action="store", metavar="hash", help="transport identity hash of remote instance to get status from", default=None, type=str)
|
||||
@@ -914,7 +989,9 @@ def main(must_exit=True, rns_instance=None):
|
||||
if args.R: require_shared = False
|
||||
else: require_shared = True
|
||||
|
||||
try: reticulum = RNS.Reticulum(configdir=configarg, loglevel=3+args.verbose, require_shared_instance=require_shared)
|
||||
try:
|
||||
reticulum = RNS.Reticulum(configdir=configarg, loglevel=3+args.verbose, require_shared_instance=require_shared)
|
||||
reticulum.wants_destination_type("rnstransport.remote.management")
|
||||
except Exception as e:
|
||||
print("No shared RNS instance available to get status from")
|
||||
exit(1)
|
||||
@@ -931,7 +1008,7 @@ def main(must_exit=True, rns_instance=None):
|
||||
remote=args.R, management_identity=args.i, remote_timeout=args.w, must_exit=False, rns_instance=reticulum,
|
||||
traffic_totals=args.totals, discovered_interfaces=args.discovered, config_entries=args.D, burst_filter=args.burst,
|
||||
blocked_ips=args.blocked_ips, queue_stats=args.queues, pps=args.pps, profiling=args.profiling,
|
||||
show_stale=args.show_stale, show_unknown=args.show_unknown)
|
||||
show_stale=args.show_stale, show_unknown=args.show_unknown, fstats=args.filter_stats, tstats=args.tunnels)
|
||||
|
||||
finally:
|
||||
sys.stdout = old_stdout
|
||||
@@ -950,7 +1027,8 @@ def main(must_exit=True, rns_instance=None):
|
||||
remote=args.R, management_identity=args.i, remote_timeout=args.w, must_exit=must_exit, rns_instance=rns_instance,
|
||||
traffic_totals=args.totals, discovered_interfaces=args.discovered, config_entries=args.D, burst_filter=args.burst,
|
||||
blocked_ips=args.blocked_ips, queue_stats=args.queues, pps=args.pps, profiling=args.profiling,
|
||||
attach=args.attach, detach=args.detach, reload=args.reload, show_stale=args.show_stale, show_unknown=args.show_unknown)
|
||||
attach=args.attach, detach=args.detach, reload=args.reload, show_stale=args.show_stale, tstats=args.tunnels,
|
||||
show_unknown=args.show_unknown, fstats=args.filter_stats)
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("")
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -342,6 +342,8 @@ def execute(configdir, identitypath = None, verbosity = 0, quietness = 0, detail
|
||||
targetloglevel = 3+verbosity-quietness
|
||||
reticulum = RNS.Reticulum(configdir=configdir, loglevel=targetloglevel)
|
||||
|
||||
reticulum.wants_destination_type(f"{APP_NAME}.execute")
|
||||
|
||||
if identity == None:
|
||||
prepare_identity(identitypath)
|
||||
|
||||
|
||||
+16
-2
@@ -1,6 +1,6 @@
|
||||
# Reticulum License
|
||||
#
|
||||
# Copyright (c) 2016-2025 Mark Qvist
|
||||
# Copyright (c) 2016-2026 Mark Qvist
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -41,6 +41,7 @@ import bisect
|
||||
from ._version import __version__
|
||||
from collections import deque
|
||||
from functools import partial, wraps
|
||||
from RNS.Stamps import quantize_cost
|
||||
|
||||
py_modules = glob.glob(os.path.dirname(__file__)+"/*.py")
|
||||
pyc_modules = glob.glob(os.path.dirname(__file__)+"/*.pyc")
|
||||
@@ -86,7 +87,7 @@ instance_random.seed(os.urandom(10))
|
||||
|
||||
_always_override_destination = False
|
||||
|
||||
logging_lock = threading.Lock()
|
||||
logging_lock = threading.RLock()
|
||||
|
||||
def loglevelname(level):
|
||||
if (level == LOG_CRITICAL): return "[Critical]"
|
||||
@@ -179,6 +180,19 @@ def prettyhexrep(data):
|
||||
hexrep = "<"+delimiter.join("{:02x}".format(c) for c in data)+">"
|
||||
return hexrep
|
||||
|
||||
__namehash_resolver = None
|
||||
def prettynamehash(name_hash):
|
||||
global __namehash_resolver
|
||||
if not __namehash_resolver:
|
||||
import RNS.Transport
|
||||
__namehash_resolver = RNS.Transport.destination_type_name
|
||||
return f"<{__namehash_resolver(name_hash)}>"
|
||||
|
||||
def prettycost(value):
|
||||
if value == None: return "n"
|
||||
elif not type(value) in (float, int): return "n"
|
||||
else: return f"{quantize_cost(value):.3f}"
|
||||
|
||||
def prettyspeed(num, suffix="b"):
|
||||
return prettysize(num/8, suffix=suffix)+"ps"
|
||||
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
__version__ = "1.5.5"
|
||||
__version__ = "1.6.1"
|
||||
@@ -1,5 +1,7 @@
|
||||
# Reporting Security Issues
|
||||
|
||||
Security notices that affect Reticulum are published [in-repository in the docs/security directory](./docs/security).
|
||||
|
||||
It goes without saying: If you have discovered a security issue in Reticulum or any related project, please report it responsibly to the maintainer over LXMF at `<8dd57a738226809646089335a6b03695>`. If you wish to remain anonymous, please create a disposable identity to send from, and notify us of any such wishes.
|
||||
|
||||
If you are not able to use LXMF, you can send an email to the address currently posted on the maintainer's profile on this site.
|
||||
@@ -204,6 +204,8 @@ Those people, are in their own words, "Killing Reticulum" (quote, Lew Palm, "aut
|
||||
|
||||
And all of those are [void and null](https://reticulum.network/manual/brandolinis.html#void-grants-legal-foundations-of-machine-generated-code), because what they *really* chose is **copyright violation**, and complete disrespect ([as is now becoming tradition](https://reticulum.network/manual/brandolinis.html#licensing-analysis)) for open source development practices, attribution and basic decency.
|
||||
|
||||
*(**Important Note From The Future, added November 2026**: When the maintainer of Ratspeak discovered he had made made a mistake in the licensing, he promptly contacted me, and corrected everything within a few hours. As of this update, all the Ratspeak implementations and derivatives are correctly distributed under the Reticulum License.)*
|
||||
|
||||
> Underneath the licence choice sits a harder problem, and it is the one this site keeps coming back to: a system can be decentralised in its architecture and completely centralised in who decides things.
|
||||
|
||||
Oooooh... Tension. Drama. Tell me more, let's have the juicy details, huh? Outrage incoming, I can feel it! Ramp up your audience like a good boy, Leo!
|
||||
@@ -228,7 +230,7 @@ The scraper was hitting *every node across the entire fucking intermesh*, from a
|
||||
|
||||
For what reason? To gouge tens of **millions** of requests to a broken piece of shit software that an idiot deployed and left running without oversight, trying to infintely download **everything that everyone had ever put on their nodes several times over** on a recursive loop.
|
||||
|
||||
Who made that stop? I did, because I contacted the idiot and talked him out of it.
|
||||
Who made that stop? I did, because I [contacted](https://github.com/roogle-dev/reticulum-phantom/issues/4) the idiot and talked him out of it.
|
||||
|
||||
Let's hear more of your brilliant ideas about how to "protect the commons" you fucking ape.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Sphinx build info version 1
|
||||
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||
config: a83095d108892439ad6027acd44f7c0a
|
||||
config: 6795d8fd07f6250f1b0bffe6d5069dbb
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||
@@ -163,7 +163,11 @@ A global, distributed backbone of Reticulum Transport Nodes is being run by volu
|
||||
As a good starting point, you can find interface definitions for connecting your own networks to this backbone on websites such as `directory.rns.recipes <https://directory.rns.recipes/>`_ and `rmap.world <https://rmap.world/>`_.
|
||||
|
||||
.. tip::
|
||||
Don't rely on just a single connection to the distributed backbone for everyday use. It is much better to have several redundant connections configured, and enable the interface discovery options, so your nodes can continously discover peering opportunities as the network evolves. Refer to the :ref:`Bootstrapping Connectivity<bootstrapping-connectivity>` section to understand the options.
|
||||
Don't rely on just a single connection to the distributed backbone for everyday use. It is much better to have several redundant connections configured, and enable the interface discovery options, so your nodes can continously discover peering opportunities as the network evolves.
|
||||
|
||||
But don't overdo it either! Auto-connecting to a hundred different nodes will waste capacity for node operators and not provide any benefit for yourself either.
|
||||
|
||||
Refer to the :ref:`Discovering Interfaces<using-interface_discovery>` section to understand the options.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ To enable the page node, add the following to your ``~/.rngit/config`` file:
|
||||
.. code:: text
|
||||
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
serve_nomadnet = yes
|
||||
|
||||
When the page node is enabled, ``rngit`` will listen on a Nomad Network node destination in addition to the Git repository destination. You can view the destination hash by running:
|
||||
|
||||
@@ -634,6 +634,15 @@ When the page node is enabled, ``rngit`` will listen on a Nomad Network node des
|
||||
Repositories Destination : <0d7334d411d00120cbad24edf355fdd2>
|
||||
Nomad Network Destination : <50824b711717f97c2fb1166ceddd5ea9>
|
||||
|
||||
You can configure the destination stamp value and required link establishment cost with the following options:
|
||||
|
||||
.. code:: text
|
||||
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
stamp_value = 25.0
|
||||
link_cost = 18.0
|
||||
|
||||
Accessing Repository Pages
|
||||
--------------------------
|
||||
|
||||
@@ -717,8 +726,8 @@ By default, the page node uses Nerd Font icons. If you prefer simpler icons or y
|
||||
.. code:: text
|
||||
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
|
||||
Repository Statistics
|
||||
---------------------
|
||||
@@ -746,6 +755,8 @@ A complete node configuration might look like this:
|
||||
node_name = My Git Node
|
||||
announce_interval = 360
|
||||
record_stats = yes
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.5
|
||||
|
||||
[repositories]
|
||||
public = /var/git/public
|
||||
@@ -758,6 +769,8 @@ A complete node configuration might look like this:
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = no
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.7
|
||||
|
||||
|
||||
Verified Releases
|
||||
|
||||
@@ -23,6 +23,7 @@ to participate in the development of Reticulum itself.
|
||||
zen
|
||||
software
|
||||
using
|
||||
protecting
|
||||
understanding
|
||||
hardware
|
||||
interfaces
|
||||
|
||||
@@ -230,6 +230,8 @@ specify the target Yggdrasil IPv6 address and port, like so:
|
||||
target_host = 201:5d78:af73:5caf:a4de:a79f:3278:71e5
|
||||
target_port = 4343
|
||||
|
||||
.. _interfaces-fastflap:
|
||||
|
||||
Automated Blocking
|
||||
------------------
|
||||
Listener instances of ``BackboneInterface`` will automatically block fast-flapping clients,
|
||||
@@ -965,13 +967,6 @@ Reticulum includes a powerful system for publishing your local interfaces to the
|
||||
|
||||
When an interface is made **discoverable**, your Reticulum instance will periodically broadcast an announce packet containing the connection details and parameters required for other peers to establish a connection. These announces are propagated over the network using the standard Reticulum announce mechanism using the ``rnstransport.discovery.interface`` destination type.
|
||||
|
||||
.. note::
|
||||
To use the interface discovery functionality, the ``LXMF`` module must be installed in your Python environment. You can install it using pip:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
pip install lxmf
|
||||
|
||||
|
||||
Enabling Discovery
|
||||
------------------
|
||||
@@ -1486,11 +1481,11 @@ but all the parameters are exposed for configuration if needed.
|
||||
sub-interfaces when a new client connects.
|
||||
|
||||
* | The ``ic_burst_freq_new`` option sets the maximum announce ingress
|
||||
frequency for newly spawned interfaces. Defaults to ``3.5``
|
||||
frequency for newly spawned interfaces. Defaults to ``3.0``
|
||||
announces per second.
|
||||
|
||||
* | The ``ic_burst_freq`` option sets the maximum announce ingress
|
||||
frequency for other interfaces. Defaults to ``12`` announces
|
||||
frequency for other interfaces. Defaults to ``10.0`` announces
|
||||
per second.
|
||||
|
||||
*If an interface exceeds its burst frequency, incoming announces
|
||||
@@ -1499,21 +1494,21 @@ but all the parameters are exposed for configuration if needed.
|
||||
|
||||
* | The ``ic_max_held_announces`` option sets the maximum amount of
|
||||
unique announces that will be held in the queue. Any additional
|
||||
unique announces will be dropped. Defaults to ``256`` announces.
|
||||
unique announces will be dropped. Defaults to ``64`` announces.
|
||||
|
||||
* | The ``ic_burst_hold`` option sets how much time (in seconds) must
|
||||
pass after the burst frequency drops below its threshold, for the
|
||||
announce burst to be considered cleared. Defaults to ``60``
|
||||
announce burst to be considered cleared. Defaults to ``15``
|
||||
seconds.
|
||||
|
||||
* | The ``ic_burst_penalty`` option sets how much time (in seconds) must
|
||||
pass after the burst is considered cleared, before held announces can
|
||||
start being released from the queue. Defaults to ``5*60``
|
||||
start being released from the queue. Defaults to ``15``
|
||||
seconds.
|
||||
|
||||
* | The ``ic_held_release_interval`` option sets how much time (in seconds)
|
||||
must pass between releasing each held announce from the queue. Defaults
|
||||
to ``30`` seconds.
|
||||
to ``5`` seconds.
|
||||
|
||||
All of the above settings can be configured both as instance-wide defaults
|
||||
under the ``[reticulum]`` section of the configuration file, or on a per-
|
||||
|
||||
@@ -0,0 +1,405 @@
|
||||
************************
|
||||
Protecting Open Networks
|
||||
************************
|
||||
|
||||
.. important::
|
||||
Reticulum is currently transitioning towards full, on-network stamp verification and enforcement via a phased transition:
|
||||
|
||||
- The ``1.6.0`` release completely implements the required mechanisms, and will start excercising the verification system in the transport backend. By default, ``1.6.0`` does not enable full stamp generation, emission and enforcement, but all of these options can be early-enabled in the configuration.
|
||||
|
||||
- The ``1.6.1`` release will enable full stamp generation and emission of all types by default, but will leave the *enforcement* a configurable option.
|
||||
|
||||
- The ``1.6.2`` release will complete the transition, activating full stamp enforcement across all the systems.
|
||||
|
||||
The stated version numbers are the *intended* release sequence. If any issues or implementation problems are found during the initial network deployments, the transition points may be pushed later than this plan by interim releases.
|
||||
|
||||
While you can create entirely closed-off and private networks with Reticulum, the protocol itself is open and permissionless. On widely interconnected networks, anyone can create identities and globally reachable destinations without external permission or approval, and establish links anonymously over the network.
|
||||
|
||||
Such capabilities are powerful, and a required characteristic of a truly functional communications fabric, but also raise very large challenges, that have been almost impossible to solve in legacy networking technologies.
|
||||
|
||||
Reticulum approaches this particular problem, like most others, by employing cryptographic principles. This provides a comprehensive, multi-layered repertoire of defense mechanisms, which can be composed and employed in very effective ways.
|
||||
|
||||
In contrast to other networking paradigms, these mechanisms do not have to be bolted on to the application layer in hindsight, but are a core part of the protocol itself, which means that they can be applied universally and effectively:
|
||||
|
||||
All nodes help combat spam and network abuse, according to the rules *set by the actual owners of supplied resources* - not by any bureaucracy or external authority.
|
||||
|
||||
Rules and requirements can be adjusted live, dynamically and directly, and by those that actually operate and run the infrastructure and services.
|
||||
|
||||
The system has been designed so that it becomes very cheap computationally for resource-providing nodes to verify or reject traffic, and very expensive for malicious nodes to abuse the shared resources provided by the network's operators.
|
||||
|
||||
|
||||
Cryptographic Stamps
|
||||
====================
|
||||
|
||||
All networking primitives that consume shared network resources are gated by *stamps*. A stamp is compact, cryptographic token that proves that a certain amount of computation and energy has been expended in its creation.
|
||||
|
||||
The amount of such computation required for a stamp to be considered valid can be configured individually by the operator of the resource being made available, whether that is network transport, a node providing information for retrieval, a shared voice room, or something else entirely.
|
||||
|
||||
While the core functionality is completely automatic, and handled by Reticulum itself, the primitives are made available at the application layer API as well, so that developers can use them to implement further protections, if required by their usage scenarios. In most cases, however, simply setting the target *values* and required *costs* for the built-in mechanisms will be sufficient.
|
||||
|
||||
The *value* of a stamp is a decimal representation of how difficult a stamp was to create, on a scale from ``0.0`` to ``100.0``. The scale is **exponential**. An increase of one point is equal to *doubling* the average compute time required. Fractional values are supported, such as ``14.125``.
|
||||
|
||||
Internally, the fractional part is quantized to ``256`` different values, giving an approximately ``0.27%`` difficulty increase per step. You can use any decimal number when configuring stamps, such as ``9.3691`` and you do not have to worry about "landing on" the correct step values. Reticulum will automatically handle the quantization, wire-transport representation and value comparisons.
|
||||
|
||||
The term *cost* is used everywhere a stamp value *requirement* is configured or specified. In general, *value* refers to the actual, determined value of a given stamp, *cost* refers to a value requirement.
|
||||
|
||||
Base Primitives
|
||||
---------------
|
||||
|
||||
Reticulum provides two types of base stamp primitives:
|
||||
|
||||
* **Detached stamps** can be tied to any external information, and are useful for stamping both static information and for one-time verification purposes. The stamp itself is a detached, short binary sequence, typically 14 to 32 bytes, that can be verified directly against the stamped material.
|
||||
|
||||
They can be configured from relatively easy to compute, even for embbedded systems and microcontrollers, all the way to something that is practically impossible, even with all the compute and memory on the planet.
|
||||
|
||||
* **Embedded stamps** are tied directly to a Reticulum Identity keyset, and embedded within it. The keyset itself *contains* the stamp, and there is no external, detached byte sequence for them.
|
||||
|
||||
Anyone can verify the value of an identity-embedded stamp simply from the public key material of the identity.
|
||||
|
||||
On-Network Types
|
||||
----------------
|
||||
|
||||
The base primitives are used to implement scenario-specific network-level primitives that, if configured correctly, make spam and network abuse expensive, but validation and enforcement cheap and efficient.
|
||||
|
||||
* **Destination Stamps** are detached stamps associated with reticulum destinations. They are included in all announces sent by a destination, and by verifying that their value matches a transport node's cost requirement, they can be either accepted for rebroadcast onto the network, or rejected and dropped.
|
||||
|
||||
Destination stamps are *one-time* generations, and are reusable across announces. They limit the number of *new* destinations that can be created, and makes it expensive to spam a network with destinations that do not provide anything meaningful. As such, these stamps will typically target relatively high values, and their cost requirements should be set accordingly.
|
||||
|
||||
A generation time for such stamps in *minutes* rather than seconds can very well be reasonable on large, open-access networks. Due to their detached nature, they can also be pre-generated off-device (and do not require the private key material for generation), so that even low-powered nodes, such as microcontrollers, can use high-value destination stamps, by having them generated and loaded externally as a one-time procedure.
|
||||
|
||||
* **Path Request Stamps** are also detached stamps, but generated *individually* for every path request emitted on the network. These will typically have a much lower cost requirement than destination stamps, but if a node is overwhelmed by path requests, it can be tuned higher.
|
||||
|
||||
The stamp is generated against the individually unique *emission*, so that unstamped or low-value path requests for a destination cannot disrupt the resolution of legitimate ones toward that same destination.
|
||||
|
||||
* **Link Request Stamps** are embedded stamps, carried in the ephemeral link request keyset. They are therefore completely transparent to the network, but can still be verified extremely quickly by any node along the link request path, who can then make a decision on whether or not to transport it.
|
||||
|
||||
Link request cost targets are set by the *endpoint destinations individually*. Every destination that includes a stamp in its announces will also include link request cost signalling. This means that any node that hears an announce from the destination will also know what link request stamp value to target, when establishing links to that destination.
|
||||
|
||||
Furthermore, spam and link request abuse can be filtered before even reaching the destination, if at least one node along the path validates the link request stamp value and cost requirement.
|
||||
|
||||
All of the stamp primitives, functionality and on-wire signalling is *transparent and backwards-compatible* with older versions of Reticulum transport nodes. This means, that even if a node doesn't itself understand stamp functionality, it will still transport all the required information. Stamped announces, path and link requests can cross older, non stamp-aware network segments transparently and unaffected.
|
||||
|
||||
.. _stamps-configuring:
|
||||
|
||||
Configuring Stamps
|
||||
------------------
|
||||
|
||||
Reticulum, and its included utilities, provide sane default cost requirements and value targets for the different types of network stamps, but it is entirely up to the operator whether to follow the defaults. All of them are configurable on a per-node, per-application and per-destination basis.
|
||||
|
||||
Instance Configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In reality, different kinds of networks will want to configure different kinds of costs and value targets for their use. For instance-wide defaults and settings, you can configure these in the ``[stamps]`` section of the Reticulum configuration file:
|
||||
|
||||
* | The ``destination_cost`` option sets the default required stamp
|
||||
cost for announced destinations to be accepted, and have their
|
||||
announces propagated by this node. Defaults to ``23.5``.
|
||||
|
||||
* | The ``destination_value`` option sets the default stamp value that
|
||||
this instance will target when generating new destination stamps.
|
||||
An application can request higher targets for destinations that it
|
||||
creates, but a requested lower value will always be clamped to the
|
||||
configured default as a minimum. Defaults to ``25.0``.
|
||||
|
||||
*Destination stamps are one-time generations per destination, so it
|
||||
is generally a good idea to target a slightly higher value than the
|
||||
minimum required cost of the networks you want the destination to
|
||||
be reachable on.*
|
||||
|
||||
* | The ``pr_cost`` option sets the required stamp cost for incoming
|
||||
path requests. Defaults to ``15.8``.
|
||||
|
||||
* | The ``pr_value`` option sets the target stamp value for path
|
||||
request stamps generated by this instance. Defaults to ``15.8``.
|
||||
|
||||
* | The ``lr_cost`` option sets the default link request stamp cost,
|
||||
that destinations created on this instance will require. This
|
||||
value can be freely overridden by applications that specify their
|
||||
own link request cost requirements, and is solely used as the
|
||||
default if no such specification is provided. Defaults to ``12.5``.
|
||||
|
||||
* | The ``lr_stamp_timeout`` and ``pr_stamp_timeout`` options set the
|
||||
maximum amount of time, in seconds, to spend while attempting to
|
||||
generate link and path request stamps respectively. If a stamp is
|
||||
not generated within this timespan, the generation is cancelled,
|
||||
and the link request or path request fails. Defaults to ``15``
|
||||
seconds for both options.
|
||||
|
||||
* | The ``stamp_destinations`` option enables generation and emission
|
||||
of destination stamps in announces. This is a transitory option.
|
||||
It will become mandatory and enabled by default in RNS ``1.6.1``.
|
||||
|
||||
* | The ``stamp_prs`` option enables stamping of path requests emitted
|
||||
by this instance. This is a transitory option. It will become
|
||||
mandatory and enabled by default in RNS ``1.6.1``.
|
||||
|
||||
* | The ``always_stamp_lrs`` option will stamp *all* outgoing link
|
||||
requests, even to destinations that have not announced a link
|
||||
request cost (and will, in that case, use the configured or
|
||||
default link request cost). This option is mostly useful for
|
||||
testing and diagnostics. In general use, Reticulum will handle
|
||||
link request stamping and cost targets automatically.
|
||||
|
||||
* | The ``enforce_stamps`` option allows early activation of stamp
|
||||
enforcement. When enabled, announces and path requests that do
|
||||
not meet the configured cost requirements are dropped, and link
|
||||
requests with insufficient stamps are ignored. This is a transitory
|
||||
option. It will become mandatory and enabled by default in RNS
|
||||
``1.6.2``.
|
||||
|
||||
An example of customised stamp cost and value configuration follows below:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[stamps]
|
||||
stamp_destinations = yes
|
||||
stamp_prs = yes
|
||||
|
||||
destination_cost = 24.8
|
||||
destination_value = 26.25
|
||||
|
||||
pr_cost = 15.8
|
||||
pr_value = 16.45
|
||||
|
||||
Stamp cost requirements can also be configured on a per-interface basis:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[[Public Gateway]]
|
||||
type = BackboneInterface
|
||||
mode = gateway
|
||||
listen_on = 0.0.0.0
|
||||
port = 4242
|
||||
|
||||
destination_cost = 25.0
|
||||
pr_cost = 17.2
|
||||
|
||||
[[Local RNode]]
|
||||
type = RNodeInterface
|
||||
port = /dev/ttyUSB0
|
||||
|
||||
# Much lower requirements
|
||||
# for the local network.
|
||||
destination_cost = 11.2
|
||||
pr_cost = 5.0
|
||||
|
||||
For Developers
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
Applications can dynamically set their own stamp values and required link requests costs at runtime. Whenever the values are adjusted, the destination will have to send an announce for the updated information to become known by the rest of the network.
|
||||
|
||||
If you are setting these values at destination creation time, ensure that they are set *immediately* after the destination is instantiated, as Reticulum may queue internal, instance-local announces for the destination shortly after creation, so that the local shared instance and its clients are aware of the newly created destination.
|
||||
|
||||
.. code:: python
|
||||
|
||||
# Create a new destination
|
||||
my_destination = RNS.Destination(
|
||||
my_identity,
|
||||
RNS.Destination.IN,
|
||||
RNS.Destination.SINGLE,
|
||||
"myapp", "service"
|
||||
)
|
||||
|
||||
# Configure stamps
|
||||
my_destination.set_value(30.0)
|
||||
my_destination.set_link_cost(15.0)
|
||||
|
||||
Dynamically adjusting link request costs is a viable and intended mechanism for mitigating resource abuse, scraping, DoS attempts and other malicious behaviour. An application may implement mechanisms to statically or dynamically raise link request costs under certain conditions.
|
||||
|
||||
.. tip::
|
||||
Remember here, though, that announce cadence should be preserved for such situations! If your destination is announcing too often in general, and wants to dynamically adjust link request costs at a critical moment, it may already have exhausted its announce rate limits on upstream nodes. So plan your application's announce cadence thoughtfully!
|
||||
|
||||
It is also possible for application code to directly get the destination value and link request cost for any known destination:
|
||||
|
||||
.. code:: python
|
||||
|
||||
# Get the value of a known destination
|
||||
RNS.Identity.recall_stamp_value(destination_hash)
|
||||
|
||||
# Get the current link cost requirement
|
||||
# of a known destination
|
||||
RNS.Identity.recall_link_cost(destination_hash)
|
||||
|
||||
|
||||
An ``Identity`` can be created with an embedded stamp value, by passing the target value at instantiation time:
|
||||
|
||||
.. code:: python
|
||||
|
||||
# Create a new, stamped identity
|
||||
my_identity = RNS.Identity(value=24.0)
|
||||
|
||||
# Get the value of any known identity
|
||||
another_identity.get_value()
|
||||
|
||||
As with destination stamps, this is a one-time generation procedure, that happens at Identity creation. Once an identity is created with an embedded stamp, its value *cannot* be upgraded at a later point as with detached stamps.
|
||||
|
||||
|
||||
Filtering & QoS
|
||||
===============
|
||||
|
||||
In addition to the stamp functionality explored above, Reticulum includes filtering options that allow operators to explicitly deny or allow certain destination *types* across an entire instance.
|
||||
|
||||
After filtering, all packets that are ultimately allowed into the transport engine, are sorted into prioritized QoS queues, which are drained and processed in priority order.
|
||||
|
||||
This provides a powerful system for both filtering, classifying and ensuring latency and service quality for the traffic and application types a node operator wants to provide.
|
||||
|
||||
Instance Configuration
|
||||
----------------------
|
||||
|
||||
The filtering subsystem can operate in two modes:
|
||||
|
||||
* | **Ignored Mode** will allow any destination type in the instance, *except* for those that have been explicitly added to the ``ignored_types`` list. This mode is useful for blocking the traffic of specific destination types from being transported across the instance.
|
||||
|
||||
* | **Required Only Mode** will allow *only* the destination types explicitly defined as required, and ignore *all* other types. A base set of required destination types can be defined instance-wide in the ``allowed_types`` list.
|
||||
|
||||
| In addition, any application using the shared instance can temporarily request required destination types for its use. Applications that request required destination types will automatically have them granted, unless they are included in the ``ignored_types`` list.
|
||||
|
||||
The filtering defaults and base settings are configured in the ``[filter]`` section of the configuration file. For example, it is possible to explicitly ignore a series of destination types, while also limiting hop reach to a more local topology.
|
||||
|
||||
.. tip::
|
||||
The ``hop_limiter`` in the filter section is an instance-wide setting. You can also use the ``hop_limiter`` option *per-interface* if you want to limit hops on some interfaces only.
|
||||
|
||||
If you do not know the human readable destination type aspects for a destination type you want to ignore, you can also add entries as 10-byte (20 hexadecimal character) hashes using the ``<c4ace368262d845c9dd3>`` format.
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[filter]
|
||||
hop_limiter = 14
|
||||
ignored_types = application.that.spams, traffic.heavy.service, <c4ace368262d845c9dd3>
|
||||
|
||||
In some situations, you may want to allow *only* certain destination types. If, for example, you are creating a high-performance transport node intended to handle thousands of simultaneous voice calls at minimal latency, a configuration might look something like:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[filter]
|
||||
required_only = yes
|
||||
allowed_types = lxst.telephony
|
||||
|
||||
The filtering subsystem provided in RNS ``1.6.0`` is functional and useful, but at an early stage, and relatively basic. In the upcoming releases, it will be expanded into a much more comprehensive and flexible system, that will include custom QoS and traffic class tagging, advanced rule definitions and more.
|
||||
|
||||
.. important::
|
||||
As the filtering and QoS system is developed and matures, the ``required_only`` mode will become the default operating mode for non-transport instances, since applications can already now dynamically request what destination types they are interested in.
|
||||
|
||||
This ensures that a local, non-transport node (running on resource-limited hardware, for example), does not have to process announces for, and waste CPU and memory on destination types that are completely irrelevant to it. It also greatly reduces power consumption on battery-powered and mobile devices, while they are connected to large and busy networks.
|
||||
|
||||
If you are a developer, see the following section.
|
||||
|
||||
Blocking Transport Nodes
|
||||
------------------------
|
||||
|
||||
Misbehaving, spamming and broken transport nodes can be completely blocked using the :ref:`Blackhole system<protecting-blackhole>`. First, obtain the Transport Identity hash of a misbehaving transport node, using ``rnstatus``:
|
||||
|
||||
.. code:: txt
|
||||
|
||||
$ rnstatus -FATa "71.29.190.5"
|
||||
|
||||
BackboneInterface[Client on Bern IPv4/71.29.190.5:37062]
|
||||
Status : Up
|
||||
Mode : Gateway
|
||||
Rate : 250.00 Mbps, MTU 65536
|
||||
Running : Unknown implementation
|
||||
Rem.Tr.ID : <a0c289d131c7bfa8d5ddc8b652c0f40d>
|
||||
Held : 64 announces
|
||||
Violatns. : 382 protocol
|
||||
Flt. Hits : 92
|
||||
Announces : 147174↓ 11193↑ total, 140554 filtered
|
||||
1.2 Hz↑ (↓0% / ↑0% of flow)
|
||||
7.8 Hz↓ (t:6h/p:0s/g:1) burst for 4h, 54m and 42.69s
|
||||
Traffic : ↑4.75 MB 0 bps
|
||||
↓1.50 MB 0 bps
|
||||
Filtered : ↑0 B 0 bps
|
||||
↓55.43 MB 380.14 Kbps
|
||||
|
||||
You can then block it by its Transport ID:
|
||||
|
||||
.. code:: txt
|
||||
|
||||
$ rnpath -B a0c289d131c7bfa8d5ddc8b652c0f40d --reason "Broken node"
|
||||
|
||||
Blackholed identity a0c289d131c7bfa8d5ddc8b652c0f40d
|
||||
|
||||
Its connection will be immediately torn down, and further reconnection attempts will be ignored.
|
||||
|
||||
For Developers
|
||||
--------------
|
||||
|
||||
At some point during the ``1.6.x`` release cycle, RNS will move to using the ``required_only`` mode for *non-transport* instances by default. This means that applications will, in most cases, have to request what types of destinations they are interested in receiving announces from.
|
||||
|
||||
If your application is only using the utility primitives included in RNS, or established protocols such as LXMF or LXST, **there is nothing you have to do**. The protocol primitives *themselves* request their required destination types, and this is the general pattern to follow here:
|
||||
|
||||
- If an application uses a common protocol or primitive, it is the importable primitive, protocol module, or relevant internal functionality that should request destination type requirements, at the point where they are actually needed.
|
||||
- Higher level application layers should not have to guess at or request destination types, unless it explicitly creates outbound destinations that are not covered by any already-used protocols or primitives.
|
||||
|
||||
If your protocol or application needs to receive announces for a specific destination type, it is very easy to register it. For example, at startup (or when the destination type is actually required), simply run something like:
|
||||
|
||||
.. code:: python
|
||||
|
||||
RNS.Reticulum.get_instance().wants_destination_type("my_app.service")
|
||||
|
||||
You do not *have to* explicitly deregister destination type requirements. Reticulum automatically deregisters when the shared instance connection for the application is torn down, but you may *want* to in certain cases, which follows the same pattern:
|
||||
|
||||
.. code:: python
|
||||
|
||||
RNS.Reticulum.get_instance().unwants_destination_type("my_app.service")
|
||||
|
||||
That's really all there is to it. If you already now want to make you application more CPU, memory and battery efficient, you can tell Reticulum to start serving only required destinations to it with only a few lines of additional code. A full setup of this functionality might look something like:
|
||||
|
||||
.. code:: python
|
||||
|
||||
for destination_type in self.REQUIRED_DESTINATION_TYPES:
|
||||
RNS.Reticulum.get_instance().wants_destination_type(destination_type)
|
||||
|
||||
RNS.Reticulum.get_instance().required_announces_only(True)
|
||||
|
||||
Your application will now only receive, and have to process, the announces and paths that it actually cares about.
|
||||
|
||||
|
||||
Ingress & Burst Control
|
||||
=======================
|
||||
|
||||
In addition to the economic incentives created by stamps, Reticulum enforces a set of hydraulic limits on how much announce traffic any peer or destination can inject into the network. These mechanisms work automatically, require no operator configuration (but can be tuned, if required), and apply equally to all peers.
|
||||
|
||||
At the most basic level, the ``announce_cap`` mechanism limits the bandwidth any interface will allocate to propagating announces and other network upkeep traffic, and prioritises the local topology. Destinations that rapidly re-announce are down-prioritised in the transmission queue, so attempting to gain reach through announce spam has the exact *opposite* effect.
|
||||
|
||||
On top of this, per-destination announce rate control can be configured on any interface, or as instance-wide defaults. Once configured, announces *received* for any one destination will only be re-broadcast to other interfaces at the configured target rate, no matter how often they are received. The grace option allows occasional rate violations, and a configurable penalty extends the interval between propagated announces for destinations that repeatedly exceed their target.
|
||||
|
||||
The final layer protects against bursts of announces for *newly created* destinations. If an interface receives a large influx of announces for previously unknown destinations in a short amount of time, these are held in a bounded queue, while announces for known and established destinations continue to be processed without interruption. After the burst subsides, and an additional waiting period has passed, held announces are released slowly until the queue is cleared.
|
||||
|
||||
A node that connects to a public interface, announces a large number of bogus destinations, and then disconnects, will therefore never get those destinations into path tables at all. When the interface they arrived on disappears, the held announces are simply dropped and forgotten.
|
||||
|
||||
Ingress control operates at the level of individual sub-interfaces, so one misbehaving client cannot disrupt announce processing for other clients connected to the same listener. Combined with stamps, these mechanisms are complementary:
|
||||
|
||||
Rate limiting bounds the *rate* at which abuse can occur, for everyone, while stamps make the *volume* of abuse from any actor computationally expensive.
|
||||
|
||||
Full configuration details are available in the :ref:`Announce Rate Control<interfaces-announcerates>` and :ref:`New Destination Rate Limiting<interfaces-ingress-control>` sections.
|
||||
|
||||
.. _protecting-blachole:
|
||||
|
||||
Blackhole Management
|
||||
====================
|
||||
|
||||
The *blackhole* system allows any node operator or individual user to block specific identities at the transport layer.
|
||||
|
||||
Once an identity has been blackholed on a node, announces originating from *any* destination associated with that identity are dropped, and the node will refuse to transport traffic, or establish and maintain links, to the blackholed identity's destinations.
|
||||
|
||||
It is important to understand the scope of this mechanism corrrectly. There is fundamentally **no way** to *globally* block or censor any identity or destination in Reticulum networks. A blackhole entry only applies on the network segments that enforce it, which is the exact intention. Operators retain full control over what is allowed on their own segments, while no one can impose restrictions on segments they do not operate.
|
||||
|
||||
Blackholes can be managed directly with the ``rnpath`` utility. Identities can be blocked (optionally with an expiry duration and a human-readable reason), unblocked, and the current local blocklist can be inspected at any time. This is well suited for immediate responses to announce spam, unwanted content or malicious behaviour observed on your own networks.
|
||||
|
||||
For anything larger than a few nodes, manual blocklist maintenance quickly becomes impractical. Reticulum therefore allows an instance to subscribe to blackhole lists published by trusted transport identities, periodically retrieving and merging them into the local list, and conversely to publish its own list to subscribers.
|
||||
|
||||
This makes it possible to federate community-maintained blocklists across large networks, with the important caveat that subscribing to a list is an act of trust in its maintainer. See the :ref:`Blackhole Management<using-blackhole_management>` section for full details on local management, automated list sourcing and publishing.
|
||||
|
||||
|
||||
Fast-Flap Blocking
|
||||
==================
|
||||
|
||||
High-performance listener interfaces, such as :ref:`BackboneInterface<interfaces-backbone>`, will automatically block *fast-flapping* clients; remote peers that repeatedly connect for a very short amount of time, and then disconnect.
|
||||
|
||||
This behaviour usually stems from attempts to dump announce or path request spam onto the network in short bursts, while rotating connections in an attempt to evade per-interface rate limits, but it can also be caused by broken implementations or automated scanning tools.
|
||||
|
||||
Such bypass attempts generally have very limited effect. Ingress limiters trigger *immediately* once rate limits are exceeded, but the behaviour still causes needless interface rotation and wasted resources on the transport instance.
|
||||
|
||||
With fast-flap blocking enabled, a client that exceeds the allowed flap grace is simply not allocated an actual interface again, for the configured block duration.
|
||||
|
||||
On the ``BackboneInterface`` type, fast-flap blocking is enabled by default, with sensible standard settings. All parameters can be adjusted if necessary. See the :ref:`Automated Blocking<interfaces-fastflap>` section of the Interfaces chapter.
|
||||
@@ -193,12 +193,14 @@ change anything, and you may already be connected to a wider network. If not,
|
||||
you will probably need to add relevant *interfaces* to the configuration, in
|
||||
order to communicate with other systems.
|
||||
|
||||
You can generate a much more verbose configuration example by running the command:
|
||||
The example above does not document all the available options, only the basics.
|
||||
To explore all the various configuration options available, you can generate a
|
||||
much more verbose and complete configuration example by running the command:
|
||||
|
||||
``rnsd --exampleconfig``
|
||||
|
||||
The output includes examples for most interface types supported
|
||||
by Reticulum, along with additional options and configuration parameters.
|
||||
The output includes examples for most interface types supported by Reticulum,
|
||||
along with additional options and configuration parameters.
|
||||
|
||||
It is a good idea to read the comments and explanations in the above default config.
|
||||
It will teach you the basic concepts you need to understand to configure your network.
|
||||
@@ -644,7 +646,7 @@ Or fetch a file from the remote system:
|
||||
|
||||
$ rncp --fetch ~/path/to/file.tgz 73cbd378bb0286ed11a707c13447bb1e
|
||||
|
||||
The default identity file is stored in ``~/.reticulum/identities/rncp``, but you can use
|
||||
The default identity file is stored in ``~/.reticulum/storage/identities/rncp``, but you can use
|
||||
another one, which will be created if it does not already exist
|
||||
|
||||
.. code:: text
|
||||
@@ -731,7 +733,7 @@ Or enter the interactive mode pseudo-shell:
|
||||
|
||||
$ rnx 7a55144adf826958a9529a3bcf08b149 -x
|
||||
|
||||
The default identity file is stored in ``~/.reticulum/identities/rnx``, but you can use
|
||||
The default identity file is stored in ``~/.reticulum/storage/identities/rnx``, but you can use
|
||||
another one, which will be created if it does not already exist
|
||||
|
||||
.. code:: text
|
||||
@@ -950,9 +952,10 @@ When connecting to a remote listener, several options are available:
|
||||
|
||||
**Identity & Destination**
|
||||
|
||||
The default identity file for ``rnsh`` is stored at
|
||||
``~/.reticulum/identities/rnsh``, but you can specify a different one with the
|
||||
``-i`` option, which will be created if it does not already exist:
|
||||
The default initiator identity file for ``rnsh`` is stored at
|
||||
``~/.rns/identity`` (default listener identity is in ``~/.rns/identity.default``),
|
||||
but you can specify a different one with the ``-i`` option, which will be created if
|
||||
it does not already exist:
|
||||
|
||||
.. code:: text
|
||||
|
||||
@@ -1144,6 +1147,19 @@ Reticulum includes built-in functionality for discovering connectable interfaces
|
||||
|
||||
Discovered interfaces can be **auto-connected** by Reticulum, which makes it possible to create setups where an arbitrary interface can act simply as a bootstrap connection, that can be torn down again once more suitable interfaces have been discovered and connected.
|
||||
|
||||
.. important::
|
||||
While it might be tempting to configure Reticulum to auto-connect dozens of interfaces, this will not provide you with any benefit. It will also waste the limited resources of transport node operators. In almost all situations, using 2-3 auto-connected interfaces will be sufficient.
|
||||
|
||||
**Remember**: A deeper, more branched topology is *much* more efficient than a completely flat fan-out, where everyone connects to everyone!
|
||||
|
||||
For **devices that connect directly** to the distributed backbone, such as phones and other mobile devices, use one or two auto-connects - or a fixed node you that you like, and an auto-connect as redundant backup.
|
||||
|
||||
For a transport **node in your home**, serving all devices within it, 2 or 3 autoconnects will be reasonable.
|
||||
|
||||
For a **fast boundary node** that sits between a large, internal network with hundreds of active destinations, you can consider using five to six auto-connects. The same is a sensible number for general-purpose transport-providing backbone nodes on the public internet.
|
||||
|
||||
In extreme cases, you *can* consider using up to 12 auto-connected interfaces. Almost nobody will need this, but there are edge cases where it could potentially be useful. Do not auto-connect that wide unless you are prepared and capable of processing some serious traffic.
|
||||
|
||||
The interface discovery mechanism uses announces sent over Reticulum itself, and supports both publicly readable interfaces and private, encrypted discovery, that can only be decoded by specified *network identities*. It is also possible to specify which network identities should be considered valid sources for discovered interfaces, so that interfaces published by unknown entities are ignored.
|
||||
|
||||
.. note::
|
||||
@@ -1388,7 +1404,7 @@ The blackhole system relies on the trust relationship between the subscriber and
|
||||
|
||||
As the ecosystem matures, this system is designed to integrate with **Network Identities**. This allows communities to verify that a published blackhole list is actually provided by a specific network or organization with a certain level of reputation and trustworthiness, adding a layer of cryptographic trust to the federation process. This prevents malicious actors from publishing fake lists intended to censor legitimate traffic.
|
||||
|
||||
For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative.
|
||||
For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative overhead.
|
||||
|
||||
Improving System Configuration
|
||||
------------------------------
|
||||
@@ -1470,6 +1486,7 @@ following content:
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
User=USERNAMEHERE
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=rnsd --service
|
||||
|
||||
[Install]
|
||||
@@ -1511,6 +1528,7 @@ Create a user systemd service files ``~/.config/systemd/user/rnsd.service`` with
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=RNS_BIN_DIR/rnsd --service
|
||||
|
||||
[Install]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const DOCUMENTATION_OPTIONS = {
|
||||
VERSION: '1.5.5',
|
||||
VERSION: '1.6.1',
|
||||
LANGUAGE: 'en',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Brandolini’s Reference - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Brandolini’s Reference - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -1601,7 +1602,7 @@ is where this project invested.</p></li>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Distributed Development - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Distributed Development - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -432,7 +433,7 @@
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Code Examples - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Code Examples - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -1068,6 +1069,9 @@
|
||||
<span class="s2">"linkexample"</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="c1"># We can optionally configure a link request stamp cost</span>
|
||||
<span class="n">server_destination</span><span class="o">.</span><span class="n">set_link_cost</span><span class="p">(</span><span class="mf">14.2</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># We configure a function that will get called every time</span>
|
||||
<span class="c1"># a new client creates a link to this destination.</span>
|
||||
<span class="n">server_destination</span><span class="o">.</span><span class="n">set_link_established_callback</span><span class="p">(</span><span class="n">client_connected</span><span class="p">)</span>
|
||||
@@ -3649,7 +3653,7 @@
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>An Explanation of Reticulum for Human Beings - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>An Explanation of Reticulum for Human Beings - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -297,7 +298,7 @@
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="color-scheme" content="light dark"><link rel="index" title="Index" href="#"><link rel="search" title="Search" href="search.html">
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 --><title>Index - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 --><title>Index - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -178,7 +178,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -202,7 +202,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -216,6 +216,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -443,6 +444,10 @@
|
||||
<li><a href="reference.html#RNS.Resource.get_hash">get_hash() (RNS.Resource method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Reticulum.get_instance">get_instance() (RNS.Reticulum static method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Reticulum.get_instance_pid">get_instance_pid() (RNS.Reticulum static method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Destination.get_link_cost">get_link_cost() (RNS.Destination method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Reticulum.get_lowest_interface_bitrate">get_lowest_interface_bitrate() (RNS.Reticulum method)</a>
|
||||
</li>
|
||||
@@ -511,6 +516,8 @@
|
||||
</li>
|
||||
</ul></li>
|
||||
<li><a href="reference.html#RNS.Resource.get_transfer_size">get_transfer_size() (RNS.Resource method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Identity.get_value">get_value() (RNS.Identity method)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
</tr></table>
|
||||
@@ -680,12 +687,16 @@
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Identity.recall_app_data">recall_app_data() (RNS.Identity static method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Transport.register_announce_handler">register_announce_handler() (RNS.Transport static method)</a>
|
||||
<li><a href="reference.html#RNS.Identity.recall_link_cost">recall_link_cost() (RNS.Identity static method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Channel.Channel.register_message_type">register_message_type() (RNS.Channel.Channel method)</a>
|
||||
<li><a href="reference.html#RNS.Identity.recall_stamp_value">recall_stamp_value() (RNS.Identity static method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Transport.register_announce_handler">register_announce_handler() (RNS.Transport static method)</a>
|
||||
</li>
|
||||
</ul></td>
|
||||
<td style="width: 33%; vertical-align: top;"><ul>
|
||||
<li><a href="reference.html#RNS.Channel.Channel.register_message_type">register_message_type() (RNS.Channel.Channel method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Destination.register_request_handler">register_request_handler() (RNS.Destination method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Reticulum.remote_management_enabled">remote_management_enabled() (RNS.Reticulum static method)</a>
|
||||
@@ -727,6 +738,8 @@
|
||||
<li><a href="reference.html#RNS.PacketReceipt.set_delivery_callback">set_delivery_callback() (RNS.PacketReceipt method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Link.set_link_closed_callback">set_link_closed_callback() (RNS.Link method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Destination.set_link_cost">set_link_cost() (RNS.Destination method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Destination.set_link_established_callback">set_link_established_callback() (RNS.Destination method)</a>
|
||||
</li>
|
||||
@@ -761,6 +774,8 @@
|
||||
<li><a href="reference.html#RNS.PacketReceipt.set_timeout">set_timeout() (RNS.PacketReceipt method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.PacketReceipt.set_timeout_callback">set_timeout_callback() (RNS.PacketReceipt method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Destination.set_value">set_value() (RNS.Destination method)</a>
|
||||
</li>
|
||||
<li><a href="reference.html#RNS.Reticulum.should_use_implicit_proof">should_use_implicit_proof() (RNS.Reticulum static method)</a>
|
||||
</li>
|
||||
@@ -857,7 +872,7 @@
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Getting Started Fast - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Getting Started Fast - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -377,7 +378,9 @@ sudo<span class="w"> </span>dnf<span class="w"> </span>groupinstall<span class="
|
||||
<p>As a good starting point, you can find interface definitions for connecting your own networks to this backbone on websites such as <a class="reference external" href="https://directory.rns.recipes/">directory.rns.recipes</a> and <a class="reference external" href="https://rmap.world/">rmap.world</a>.</p>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Tip</p>
|
||||
<p>Don’t rely on just a single connection to the distributed backbone for everyday use. It is much better to have several redundant connections configured, and enable the interface discovery options, so your nodes can continously discover peering opportunities as the network evolves. Refer to the <a class="reference internal" href="#bootstrapping-connectivity"><span class="std std-ref">Bootstrapping Connectivity</span></a> section to understand the options.</p>
|
||||
<p>Don’t rely on just a single connection to the distributed backbone for everyday use. It is much better to have several redundant connections configured, and enable the interface discovery options, so your nodes can continously discover peering opportunities as the network evolves.</p>
|
||||
<p>But don’t overdo it either! Auto-connecting to a hundred different nodes will waste capacity for node operators and not provide any benefit for yourself either.</p>
|
||||
<p>Refer to the <a class="reference internal" href="using.html#using-interface-discovery"><span class="std std-ref">Discovering Interfaces</span></a> section to understand the options.</p>
|
||||
</div>
|
||||
</section>
|
||||
<section id="hosting-public-entrypoints">
|
||||
@@ -777,7 +780,7 @@ section of this manual.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
+19
-7
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Git Over Reticulum - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Git Over Reticulum - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -758,7 +759,7 @@ options:
|
||||
<h3>Enabling the Git Page Node<a class="headerlink" href="#enabling-the-git-page-node" title="Link to this heading">¶</a></h3>
|
||||
<p>To enable the page node, add the following to your <code class="docutils literal notranslate"><span class="pre">~/.rngit/config</span></code> file:</p>
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>[pages]
|
||||
serve_nomadnet = yes
|
||||
serve_nomadnet = yes
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>When the page node is enabled, <code class="docutils literal notranslate"><span class="pre">rngit</span></code> will listen on a Nomad Network node destination in addition to the Git repository destination. You can view the destination hash by running:</p>
|
||||
@@ -770,6 +771,13 @@ Repositories Destination : <0d7334d411d00120cbad24edf355fdd2>
|
||||
Nomad Network Destination : <50824b711717f97c2fb1166ceddd5ea9>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>You can configure the destination stamp value and required link establishment cost with the following options:</p>
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>[pages]
|
||||
serve_nomadnet = yes
|
||||
stamp_value = 25.0
|
||||
link_cost = 18.0
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="accessing-repository-pages">
|
||||
<h3>Accessing Repository Pages<a class="headerlink" href="#accessing-repository-pages" title="Link to this heading">¶</a></h3>
|
||||
@@ -837,8 +845,8 @@ def hello_world():
|
||||
<p><strong>Icon Sets</strong></p>
|
||||
<p>By default, the page node uses Nerd Font icons. If you prefer simpler icons or your terminal does not support Nerd Fonts, you can enable Unicode icons instead:</p>
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -861,6 +869,8 @@ unicode_icons = yes
|
||||
node_name = My Git Node
|
||||
announce_interval = 360
|
||||
record_stats = yes
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.5
|
||||
|
||||
[repositories]
|
||||
public = /var/git/public
|
||||
@@ -873,6 +883,8 @@ unicode_icons = yes
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = no
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.7
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -1601,7 +1613,7 @@ done
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Communications Hardware - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Communications Hardware - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -677,7 +678,7 @@ can be used with Reticulum. This includes virtual software modems such as
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
+23
-4
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="#"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="#"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -452,6 +453,24 @@ to participate in the development of Reticulum itself.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="protecting.html#cryptographic-stamps">Cryptographic Stamps</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="protecting.html#base-primitives">Base Primitives</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="protecting.html#on-network-types">On-Network Types</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="protecting.html#configuring-stamps">Configuring Stamps</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="protecting.html#filtering-qos">Filtering & QoS</a><ul>
|
||||
<li class="toctree-l3"><a class="reference internal" href="protecting.html#id1">Instance Configuration</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="protecting.html#blocking-transport-nodes">Blocking Transport Nodes</a></li>
|
||||
<li class="toctree-l3"><a class="reference internal" href="protecting.html#id2">For Developers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="protecting.html#ingress-burst-control">Ingress & Burst Control</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="protecting.html#blackhole-management">Blackhole Management</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="protecting.html#fast-flap-blocking">Fast-Flap Blocking</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a><ul>
|
||||
<li class="toctree-l2"><a class="reference internal" href="understanding.html#motivation">Motivation</a></li>
|
||||
<li class="toctree-l2"><a class="reference internal" href="understanding.html#goals">Goals</a></li>
|
||||
@@ -830,7 +849,7 @@ to participate in the development of Reticulum itself.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
+12
-18
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Configuring Interfaces - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Configuring Interfaces - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Configuring Interfaces</a></li>
|
||||
@@ -462,7 +463,7 @@ specify the target Yggdrasil IPv6 address and port, like so:</p>
|
||||
</div>
|
||||
</section>
|
||||
<section id="automated-blocking">
|
||||
<h3>Automated Blocking<a class="headerlink" href="#automated-blocking" title="Link to this heading">¶</a></h3>
|
||||
<span id="interfaces-fastflap"></span><h3>Automated Blocking<a class="headerlink" href="#automated-blocking" title="Link to this heading">¶</a></h3>
|
||||
<p>Listener instances of <code class="docutils literal notranslate"><span class="pre">BackboneInterface</span></code> will automatically block fast-flapping clients,
|
||||
that repeatedly connect for a short amount of time, and then disconnect. Such behavior usually
|
||||
occurs from clients trying to spam the network with announces or path requests, by connecting, dumping
|
||||
@@ -1127,13 +1128,6 @@ relevant regulation for your location, and to make decisions accordingly.</p>
|
||||
<span id="interfaces-discoverable"></span><h2>Discoverable Interfaces<a class="headerlink" href="#discoverable-interfaces" title="Link to this heading">¶</a></h2>
|
||||
<p>Reticulum includes a powerful system for publishing your local interfaces to the wider network, allowing other peers to <a class="reference internal" href="using.html#using-interface-discovery"><span class="std std-ref">discover, validate, and automatically connect to them</span></a>. This feature is particularly useful for creating decentralized networks where peers can dynamically find entrypoints, such as public Internet gateways or local radio access points, without relying on static configuration files or centralized directories.</p>
|
||||
<p>When an interface is made <strong>discoverable</strong>, your Reticulum instance will periodically broadcast an announce packet containing the connection details and parameters required for other peers to establish a connection. These announces are propagated over the network using the standard Reticulum announce mechanism using the <code class="docutils literal notranslate"><span class="pre">rnstransport.discovery.interface</span></code> destination type.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>To use the interface discovery functionality, the <code class="docutils literal notranslate"><span class="pre">LXMF</span></code> module must be installed in your Python environment. You can install it using pip:</p>
|
||||
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>pip<span class="w"> </span>install<span class="w"> </span>lxmf
|
||||
</pre></div>
|
||||
</div>
|
||||
</div>
|
||||
<section id="enabling-discovery">
|
||||
<h3>Enabling Discovery<a class="headerlink" href="#enabling-discovery" title="Link to this heading">¶</a></h3>
|
||||
<p>Interface discovery is enabled on a per-interface basis. To make a specific interface discoverable, you must add the <code class="docutils literal notranslate"><span class="pre">discoverable</span></code> option to that interface’s configuration block and set it to <code class="docutils literal notranslate"><span class="pre">yes</span></code>.</p>
|
||||
@@ -1657,13 +1651,13 @@ sub-interfaces when a new client connects.</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">ic_burst_freq_new</span></code> option sets the maximum announce ingress
|
||||
frequency for newly spawned interfaces. Defaults to <code class="docutils literal notranslate"><span class="pre">3.5</span></code>
|
||||
frequency for newly spawned interfaces. Defaults to <code class="docutils literal notranslate"><span class="pre">3.0</span></code>
|
||||
announces per second.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">ic_burst_freq</span></code> option sets the maximum announce ingress
|
||||
frequency for other interfaces. Defaults to <code class="docutils literal notranslate"><span class="pre">12</span></code> announces
|
||||
frequency for other interfaces. Defaults to <code class="docutils literal notranslate"><span class="pre">10.0</span></code> announces
|
||||
per second.</div>
|
||||
</div>
|
||||
<blockquote>
|
||||
@@ -1675,27 +1669,27 @@ not processed until later.</em></p>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">ic_max_held_announces</span></code> option sets the maximum amount of
|
||||
unique announces that will be held in the queue. Any additional
|
||||
unique announces will be dropped. Defaults to <code class="docutils literal notranslate"><span class="pre">256</span></code> announces.</div>
|
||||
unique announces will be dropped. Defaults to <code class="docutils literal notranslate"><span class="pre">64</span></code> announces.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">ic_burst_hold</span></code> option sets how much time (in seconds) must
|
||||
pass after the burst frequency drops below its threshold, for the
|
||||
announce burst to be considered cleared. Defaults to <code class="docutils literal notranslate"><span class="pre">60</span></code>
|
||||
announce burst to be considered cleared. Defaults to <code class="docutils literal notranslate"><span class="pre">15</span></code>
|
||||
seconds.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">ic_burst_penalty</span></code> option sets how much time (in seconds) must
|
||||
pass after the burst is considered cleared, before held announces can
|
||||
start being released from the queue. Defaults to <code class="docutils literal notranslate"><span class="pre">5*60</span></code>
|
||||
start being released from the queue. Defaults to <code class="docutils literal notranslate"><span class="pre">15</span></code>
|
||||
seconds.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">ic_held_release_interval</span></code> option sets how much time (in seconds)
|
||||
must pass between releasing each held announce from the queue. Defaults
|
||||
to <code class="docutils literal notranslate"><span class="pre">30</span></code> seconds.</div>
|
||||
to <code class="docutils literal notranslate"><span class="pre">5</span></code> seconds.</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -1909,7 +1903,7 @@ queue. Defaults to <code class="docutils literal notranslate"><span class="pre">
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Reticulum License - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Reticulum License - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -346,7 +347,7 @@ SOFTWARE.
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Building Networks - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Building Networks - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -665,7 +666,7 @@ differently than a mobile device roaming between radio cells.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,720 @@
|
||||
<!doctype html>
|
||||
<html class="no-js" lang="en" data-content_root="./">
|
||||
<head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="index" title="Index" href="genindex.html"><link rel="search" title="Search" href="search.html"><link rel="next" title="Understanding Reticulum" href="understanding.html"><link rel="prev" title="Using Reticulum on Your System" href="using.html">
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Protecting Open Networks - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=8dab3a3b" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=e1715074" />
|
||||
|
||||
|
||||
|
||||
|
||||
<style>
|
||||
body {
|
||||
--color-code-background: #f2f2f2;
|
||||
--color-code-foreground: #1e1e1e;
|
||||
|
||||
}
|
||||
@media not print {
|
||||
body[data-theme="dark"] {
|
||||
--color-code-background: #202020;
|
||||
--color-code-foreground: #d0d0d0;
|
||||
--color-background-primary: #202b38;
|
||||
--color-background-secondary: #161f27;
|
||||
--color-foreground-primary: #dbdbdb;
|
||||
--color-foreground-secondary: #a9b1ba;
|
||||
--color-brand-primary: #41adff;
|
||||
--color-background-hover: #161f27;
|
||||
--color-api-name: #ffbe85;
|
||||
--color-api-pre-name: #efae75;
|
||||
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
body:not([data-theme="light"]) {
|
||||
--color-code-background: #202020;
|
||||
--color-code-foreground: #d0d0d0;
|
||||
--color-background-primary: #202b38;
|
||||
--color-background-secondary: #161f27;
|
||||
--color-foreground-primary: #dbdbdb;
|
||||
--color-foreground-secondary: #a9b1ba;
|
||||
--color-brand-primary: #41adff;
|
||||
--color-background-hover: #161f27;
|
||||
--color-api-name: #ffbe85;
|
||||
--color-api-pre-name: #efae75;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
</style></head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
document.body.dataset.theme = localStorage.getItem("theme") || "auto";
|
||||
</script>
|
||||
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
|
||||
<symbol id="svg-toc" viewBox="0 0 24 24">
|
||||
<title>Contents</title>
|
||||
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024">
|
||||
<path d="M408 442h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8zm-8 204c0 4.4 3.6 8 8 8h480c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8H408c-4.4 0-8 3.6-8 8v56zm504-486H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0 632H120c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM115.4 518.9L271.7 642c5.8 4.6 14.4.5 14.4-6.9V388.9c0-7.4-8.5-11.5-14.4-6.9L115.4 505.1a8.74 8.74 0 0 0 0 13.8z"/>
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-menu" viewBox="0 0 24 24">
|
||||
<title>Menu</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-menu">
|
||||
<line x1="3" y1="12" x2="21" y2="12"></line>
|
||||
<line x1="3" y1="6" x2="21" y2="6"></line>
|
||||
<line x1="3" y1="18" x2="21" y2="18"></line>
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-arrow-right" viewBox="0 0 24 24">
|
||||
<title>Expand</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather-chevron-right">
|
||||
<polyline points="9 18 15 12 9 6"></polyline>
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-sun" viewBox="0 0 24 24">
|
||||
<title>Light mode</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather-sun">
|
||||
<circle cx="12" cy="12" r="5"></circle>
|
||||
<line x1="12" y1="1" x2="12" y2="3"></line>
|
||||
<line x1="12" y1="21" x2="12" y2="23"></line>
|
||||
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
|
||||
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
|
||||
<line x1="1" y1="12" x2="3" y2="12"></line>
|
||||
<line x1="21" y1="12" x2="23" y2="12"></line>
|
||||
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
|
||||
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-moon" viewBox="0 0 24 24">
|
||||
<title>Dark mode</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-moon">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M12 3c.132 0 .263 0 .393 0a7.5 7.5 0 0 0 7.92 12.446a9 9 0 1 1 -8.313 -12.454z" />
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-sun-with-moon" viewBox="0 0 24 24">
|
||||
<title>Auto light/dark, in light mode</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="1" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="icon-custom-derived-from-feather-sun-and-tabler-moon">
|
||||
<path style="opacity: 50%" d="M 5.411 14.504 C 5.471 14.504 5.532 14.504 5.591 14.504 C 3.639 16.319 4.383 19.569 6.931 20.352 C 7.693 20.586 8.512 20.551 9.25 20.252 C 8.023 23.207 4.056 23.725 2.11 21.184 C 0.166 18.642 1.702 14.949 4.874 14.536 C 5.051 14.512 5.231 14.5 5.411 14.5 L 5.411 14.504 Z"/>
|
||||
<line x1="14.5" y1="3.25" x2="14.5" y2="1.25"/>
|
||||
<line x1="14.5" y1="15.85" x2="14.5" y2="17.85"/>
|
||||
<line x1="10.044" y1="5.094" x2="8.63" y2="3.68"/>
|
||||
<line x1="19" y1="14.05" x2="20.414" y2="15.464"/>
|
||||
<line x1="8.2" y1="9.55" x2="6.2" y2="9.55"/>
|
||||
<line x1="20.8" y1="9.55" x2="22.8" y2="9.55"/>
|
||||
<line x1="10.044" y1="14.006" x2="8.63" y2="15.42"/>
|
||||
<line x1="19" y1="5.05" x2="20.414" y2="3.636"/>
|
||||
<circle cx="14.5" cy="9.55" r="3.6"/>
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-moon-with-sun" viewBox="0 0 24 24">
|
||||
<title>Auto light/dark, in dark mode</title>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="1" stroke-linecap="round" stroke-linejoin="round"
|
||||
class="icon-custom-derived-from-feather-sun-and-tabler-moon">
|
||||
<path d="M 8.282 7.007 C 8.385 7.007 8.494 7.007 8.595 7.007 C 5.18 10.184 6.481 15.869 10.942 17.24 C 12.275 17.648 13.706 17.589 15 17.066 C 12.851 22.236 5.91 23.143 2.505 18.696 C -0.897 14.249 1.791 7.786 7.342 7.063 C 7.652 7.021 7.965 7 8.282 7 L 8.282 7.007 Z"/>
|
||||
<line style="opacity: 50%" x1="18" y1="3.705" x2="18" y2="2.5"/>
|
||||
<line style="opacity: 50%" x1="18" y1="11.295" x2="18" y2="12.5"/>
|
||||
<line style="opacity: 50%" x1="15.316" y1="4.816" x2="14.464" y2="3.964"/>
|
||||
<line style="opacity: 50%" x1="20.711" y1="10.212" x2="21.563" y2="11.063"/>
|
||||
<line style="opacity: 50%" x1="14.205" y1="7.5" x2="13.001" y2="7.5"/>
|
||||
<line style="opacity: 50%" x1="21.795" y1="7.5" x2="23" y2="7.5"/>
|
||||
<line style="opacity: 50%" x1="15.316" y1="10.184" x2="14.464" y2="11.036"/>
|
||||
<line style="opacity: 50%" x1="20.711" y1="4.789" x2="21.563" y2="3.937"/>
|
||||
<circle style="opacity: 50%" cx="18" cy="7.5" r="2.169"/>
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-pencil" viewBox="0 0 24 24">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-pencil-code">
|
||||
<path d="M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4" />
|
||||
<path d="M13.5 6.5l4 4" />
|
||||
<path d="M20 21l2 -2l-2 -2" />
|
||||
<path d="M17 17l-2 2l2 2" />
|
||||
</svg>
|
||||
</symbol>
|
||||
<symbol id="svg-eye" viewBox="0 0 24 24">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="icon-tabler-eye-code">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
|
||||
<path d="M10 12a2 2 0 1 0 4 0a2 2 0 0 0 -4 0" />
|
||||
<path
|
||||
d="M11.11 17.958c-3.209 -.307 -5.91 -2.293 -8.11 -5.958c2.4 -4 5.4 -6 9 -6c3.6 0 6.6 2 9 6c-.21 .352 -.427 .688 -.647 1.008" />
|
||||
<path d="M20 21l2 -2l-2 -2" />
|
||||
<path d="M17 17l-2 2l2 2" />
|
||||
</svg>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
||||
<input type="checkbox" class="sidebar-toggle" name="__navigation" id="__navigation" aria-label="Toggle site navigation sidebar">
|
||||
<input type="checkbox" class="sidebar-toggle" name="__toc" id="__toc" aria-label="Toggle table of contents sidebar">
|
||||
<label class="overlay sidebar-overlay" for="__navigation"></label>
|
||||
<label class="overlay toc-overlay" for="__toc"></label>
|
||||
|
||||
<a class="skip-to-content muted-link" href="#furo-main-content">Skip to content</a>
|
||||
|
||||
|
||||
|
||||
<div class="page">
|
||||
<header class="mobile-header">
|
||||
<div class="header-left">
|
||||
<label class="nav-overlay-icon" for="__navigation">
|
||||
<span class="icon"><svg><use href="#svg-menu"></use></svg></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
<button class="theme-toggle" aria-label="Toggle Light / Dark / Auto color theme">
|
||||
<svg class="theme-icon-when-auto-light"><use href="#svg-sun-with-moon"></use></svg>
|
||||
<svg class="theme-icon-when-auto-dark"><use href="#svg-moon-with-sun"></use></svg>
|
||||
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
|
||||
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
|
||||
</button>
|
||||
</div>
|
||||
<label class="toc-overlay-icon toc-header-icon" for="__toc">
|
||||
<span class="icon"><svg><use href="#svg-toc"></use></svg></span>
|
||||
</label>
|
||||
</div>
|
||||
</header>
|
||||
<aside class="sidebar-drawer">
|
||||
<div class="sidebar-container">
|
||||
|
||||
<div class="sidebar-sticky"><a class="sidebar-brand" href="index.html">
|
||||
<div class="sidebar-logo-container">
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
<input type="hidden" name="check_keywords" value="yes">
|
||||
<input type="hidden" name="area" value="default">
|
||||
</form>
|
||||
<div id="searchbox"></div><div class="sidebar-scroll"><div class="sidebar-tree">
|
||||
<ul class="current">
|
||||
<li class="toctree-l1"><a class="reference internal" href="whatis.html">What is Reticulum?</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="gettingstartedfast.html">Getting Started Fast</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="networks.html">Building Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="distributed.html">Distributed Development</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="git.html">Git Over Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="support.html">Support Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="examples.html">Code Examples</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="license.html">Reticulum License</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="brandolinis.html">Brandolini’s Reference</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li class="toctree-l1"><a class="reference internal" href="reference.html">API Reference</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</aside>
|
||||
<div class="main">
|
||||
<div class="content">
|
||||
<div class="article-container">
|
||||
<a href="#" class="back-to-top muted-link">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8v12z"></path>
|
||||
</svg>
|
||||
<span>Back to top</span>
|
||||
</a>
|
||||
<div class="content-icon-container">
|
||||
<div class="theme-toggle-container theme-toggle-content">
|
||||
<button class="theme-toggle" aria-label="Toggle Light / Dark / Auto color theme">
|
||||
<svg class="theme-icon-when-auto-light"><use href="#svg-sun-with-moon"></use></svg>
|
||||
<svg class="theme-icon-when-auto-dark"><use href="#svg-moon-with-sun"></use></svg>
|
||||
<svg class="theme-icon-when-dark"><use href="#svg-moon"></use></svg>
|
||||
<svg class="theme-icon-when-light"><use href="#svg-sun"></use></svg>
|
||||
</button>
|
||||
</div>
|
||||
<label class="toc-overlay-icon toc-content-icon" for="__toc">
|
||||
<span class="icon"><svg><use href="#svg-toc"></use></svg></span>
|
||||
</label>
|
||||
</div>
|
||||
<article role="main" id="furo-main-content">
|
||||
<section id="protecting-open-networks">
|
||||
<h1>Protecting Open Networks<a class="headerlink" href="#protecting-open-networks" title="Link to this heading">¶</a></h1>
|
||||
<div class="admonition important">
|
||||
<p class="admonition-title">Important</p>
|
||||
<p>Reticulum is currently transitioning towards full, on-network stamp verification and enforcement via a phased transition:</p>
|
||||
<ul class="simple">
|
||||
<li><p>The <code class="docutils literal notranslate"><span class="pre">1.6.0</span></code> release completely implements the required mechanisms, and will start excercising the verification system in the transport backend. By default, <code class="docutils literal notranslate"><span class="pre">1.6.0</span></code> does not enable full stamp generation, emission and enforcement, but all of these options can be early-enabled in the configuration.</p></li>
|
||||
<li><p>The <code class="docutils literal notranslate"><span class="pre">1.6.1</span></code> release will enable full stamp generation and emission of all types by default, but will leave the <em>enforcement</em> a configurable option.</p></li>
|
||||
<li><p>The <code class="docutils literal notranslate"><span class="pre">1.6.2</span></code> release will complete the transition, activating full stamp enforcement across all the systems.</p></li>
|
||||
</ul>
|
||||
<p>The stated version numbers are the <em>intended</em> release sequence. If any issues or implementation problems are found during the initial network deployments, the transition points may be pushed later than this plan by interim releases.</p>
|
||||
</div>
|
||||
<p>While you can create entirely closed-off and private networks with Reticulum, the protocol itself is open and permissionless. On widely interconnected networks, anyone can create identities and globally reachable destinations without external permission or approval, and establish links anonymously over the network.</p>
|
||||
<p>Such capabilities are powerful, and a required characteristic of a truly functional communications fabric, but also raise very large challenges, that have been almost impossible to solve in legacy networking technologies.</p>
|
||||
<p>Reticulum approaches this particular problem, like most others, by employing cryptographic principles. This provides a comprehensive, multi-layered repertoire of defense mechanisms, which can be composed and employed in very effective ways.</p>
|
||||
<p>In contrast to other networking paradigms, these mechanisms do not have to be bolted on to the application layer in hindsight, but are a core part of the protocol itself, which means that they can be applied universally and effectively:</p>
|
||||
<blockquote>
|
||||
<div><p>All nodes help combat spam and network abuse, according to the rules <em>set by the actual owners of supplied resources</em> - not by any bureaucracy or external authority.</p>
|
||||
<p>Rules and requirements can be adjusted live, dynamically and directly, and by those that actually operate and run the infrastructure and services.</p>
|
||||
</div></blockquote>
|
||||
<p>The system has been designed so that it becomes very cheap computationally for resource-providing nodes to verify or reject traffic, and very expensive for malicious nodes to abuse the shared resources provided by the network’s operators.</p>
|
||||
<section id="cryptographic-stamps">
|
||||
<h2>Cryptographic Stamps<a class="headerlink" href="#cryptographic-stamps" title="Link to this heading">¶</a></h2>
|
||||
<p>All networking primitives that consume shared network resources are gated by <em>stamps</em>. A stamp is compact, cryptographic token that proves that a certain amount of computation and energy has been expended in its creation.</p>
|
||||
<p>The amount of such computation required for a stamp to be considered valid can be configured individually by the operator of the resource being made available, whether that is network transport, a node providing information for retrieval, a shared voice room, or something else entirely.</p>
|
||||
<p>While the core functionality is completely automatic, and handled by Reticulum itself, the primitives are made available at the application layer API as well, so that developers can use them to implement further protections, if required by their usage scenarios. In most cases, however, simply setting the target <em>values</em> and required <em>costs</em> for the built-in mechanisms will be sufficient.</p>
|
||||
<p>The <em>value</em> of a stamp is a decimal representation of how difficult a stamp was to create, on a scale from <code class="docutils literal notranslate"><span class="pre">0.0</span></code> to <code class="docutils literal notranslate"><span class="pre">100.0</span></code>. The scale is <strong>exponential</strong>. An increase of one point is equal to <em>doubling</em> the average compute time required. Fractional values are supported, such as <code class="docutils literal notranslate"><span class="pre">14.125</span></code>.</p>
|
||||
<p>Internally, the fractional part is quantized to <code class="docutils literal notranslate"><span class="pre">256</span></code> different values, giving an approximately <code class="docutils literal notranslate"><span class="pre">0.27%</span></code> difficulty increase per step. You can use any decimal number when configuring stamps, such as <code class="docutils literal notranslate"><span class="pre">9.3691</span></code> and you do not have to worry about “landing on” the correct step values. Reticulum will automatically handle the quantization, wire-transport representation and value comparisons.</p>
|
||||
<p>The term <em>cost</em> is used everywhere a stamp value <em>requirement</em> is configured or specified. In general, <em>value</em> refers to the actual, determined value of a given stamp, <em>cost</em> refers to a value requirement.</p>
|
||||
<section id="base-primitives">
|
||||
<h3>Base Primitives<a class="headerlink" href="#base-primitives" title="Link to this heading">¶</a></h3>
|
||||
<p>Reticulum provides two types of base stamp primitives:</p>
|
||||
<blockquote>
|
||||
<div><ul>
|
||||
<li><p><strong>Detached stamps</strong> can be tied to any external information, and are useful for stamping both static information and for one-time verification purposes. The stamp itself is a detached, short binary sequence, typically 14 to 32 bytes, that can be verified directly against the stamped material.</p>
|
||||
<p>They can be configured from relatively easy to compute, even for embbedded systems and microcontrollers, all the way to something that is practically impossible, even with all the compute and memory on the planet.</p>
|
||||
</li>
|
||||
<li><p><strong>Embedded stamps</strong> are tied directly to a Reticulum Identity keyset, and embedded within it. The keyset itself <em>contains</em> the stamp, and there is no external, detached byte sequence for them.</p>
|
||||
<p>Anyone can verify the value of an identity-embedded stamp simply from the public key material of the identity.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
</section>
|
||||
<section id="on-network-types">
|
||||
<h3>On-Network Types<a class="headerlink" href="#on-network-types" title="Link to this heading">¶</a></h3>
|
||||
<p>The base primitives are used to implement scenario-specific network-level primitives that, if configured correctly, make spam and network abuse expensive, but validation and enforcement cheap and efficient.</p>
|
||||
<blockquote>
|
||||
<div><ul>
|
||||
<li><p><strong>Destination Stamps</strong> are detached stamps associated with reticulum destinations. They are included in all announces sent by a destination, and by verifying that their value matches a transport node’s cost requirement, they can be either accepted for rebroadcast onto the network, or rejected and dropped.</p>
|
||||
<p>Destination stamps are <em>one-time</em> generations, and are reusable across announces. They limit the number of <em>new</em> destinations that can be created, and makes it expensive to spam a network with destinations that do not provide anything meaningful. As such, these stamps will typically target relatively high values, and their cost requirements should be set accordingly.</p>
|
||||
<p>A generation time for such stamps in <em>minutes</em> rather than seconds can very well be reasonable on large, open-access networks. Due to their detached nature, they can also be pre-generated off-device (and do not require the private key material for generation), so that even low-powered nodes, such as microcontrollers, can use high-value destination stamps, by having them generated and loaded externally as a one-time procedure.</p>
|
||||
</li>
|
||||
<li><p><strong>Path Request Stamps</strong> are also detached stamps, but generated <em>individually</em> for every path request emitted on the network. These will typically have a much lower cost requirement than destination stamps, but if a node is overwhelmed by path requests, it can be tuned higher.</p>
|
||||
<p>The stamp is generated against the individually unique <em>emission</em>, so that unstamped or low-value path requests for a destination cannot disrupt the resolution of legitimate ones toward that same destination.</p>
|
||||
</li>
|
||||
<li><p><strong>Link Request Stamps</strong> are embedded stamps, carried in the ephemeral link request keyset. They are therefore completely transparent to the network, but can still be verified extremely quickly by any node along the link request path, who can then make a decision on whether or not to transport it.</p>
|
||||
<p>Link request cost targets are set by the <em>endpoint destinations individually</em>. Every destination that includes a stamp in its announces will also include link request cost signalling. This means that any node that hears an announce from the destination will also know what link request stamp value to target, when establishing links to that destination.</p>
|
||||
<p>Furthermore, spam and link request abuse can be filtered before even reaching the destination, if at least one node along the path validates the link request stamp value and cost requirement.</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
<p>All of the stamp primitives, functionality and on-wire signalling is <em>transparent and backwards-compatible</em> with older versions of Reticulum transport nodes. This means, that even if a node doesn’t itself understand stamp functionality, it will still transport all the required information. Stamped announces, path and link requests can cross older, non stamp-aware network segments transparently and unaffected.</p>
|
||||
</section>
|
||||
<section id="configuring-stamps">
|
||||
<span id="stamps-configuring"></span><h3>Configuring Stamps<a class="headerlink" href="#configuring-stamps" title="Link to this heading">¶</a></h3>
|
||||
<p>Reticulum, and its included utilities, provide sane default cost requirements and value targets for the different types of network stamps, but it is entirely up to the operator whether to follow the defaults. All of them are configurable on a per-node, per-application and per-destination basis.</p>
|
||||
<section id="instance-configuration">
|
||||
<h4>Instance Configuration<a class="headerlink" href="#instance-configuration" title="Link to this heading">¶</a></h4>
|
||||
<p>In reality, different kinds of networks will want to configure different kinds of costs and value targets for their use. For instance-wide defaults and settings, you can configure these in the <code class="docutils literal notranslate"><span class="pre">[stamps]</span></code> section of the Reticulum configuration file:</p>
|
||||
<blockquote>
|
||||
<div><ul>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">destination_cost</span></code> option sets the default required stamp
|
||||
cost for announced destinations to be accepted, and have their
|
||||
announces propagated by this node. Defaults to <code class="docutils literal notranslate"><span class="pre">23.5</span></code>.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">destination_value</span></code> option sets the default stamp value that
|
||||
this instance will target when generating new destination stamps.
|
||||
An application can request higher targets for destinations that it
|
||||
creates, but a requested lower value will always be clamped to the
|
||||
configured default as a minimum. Defaults to <code class="docutils literal notranslate"><span class="pre">25.0</span></code>.</div>
|
||||
</div>
|
||||
<blockquote>
|
||||
<div><p><em>Destination stamps are one-time generations per destination, so it
|
||||
is generally a good idea to target a slightly higher value than the
|
||||
minimum required cost of the networks you want the destination to
|
||||
be reachable on.</em></p>
|
||||
</div></blockquote>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">pr_cost</span></code> option sets the required stamp cost for incoming
|
||||
path requests. Defaults to <code class="docutils literal notranslate"><span class="pre">15.8</span></code>.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">pr_value</span></code> option sets the target stamp value for path
|
||||
request stamps generated by this instance. Defaults to <code class="docutils literal notranslate"><span class="pre">15.8</span></code>.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">lr_cost</span></code> option sets the default link request stamp cost,
|
||||
that destinations created on this instance will require. This
|
||||
value can be freely overridden by applications that specify their
|
||||
own link request cost requirements, and is solely used as the
|
||||
default if no such specification is provided. Defaults to <code class="docutils literal notranslate"><span class="pre">12.5</span></code>.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">lr_stamp_timeout</span></code> and <code class="docutils literal notranslate"><span class="pre">pr_stamp_timeout</span></code> options set the
|
||||
maximum amount of time, in seconds, to spend while attempting to
|
||||
generate link and path request stamps respectively. If a stamp is
|
||||
not generated within this timespan, the generation is cancelled,
|
||||
and the link request or path request fails. Defaults to <code class="docutils literal notranslate"><span class="pre">15</span></code>
|
||||
seconds for both options.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">stamp_destinations</span></code> option enables generation and emission
|
||||
of destination stamps in announces. This is a transitory option.
|
||||
It will become mandatory and enabled by default in RNS <code class="docutils literal notranslate"><span class="pre">1.6.1</span></code>.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">stamp_prs</span></code> option enables stamping of path requests emitted
|
||||
by this instance. This is a transitory option. It will become
|
||||
mandatory and enabled by default in RNS <code class="docutils literal notranslate"><span class="pre">1.6.1</span></code>.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">always_stamp_lrs</span></code> option will stamp <em>all</em> outgoing link
|
||||
requests, even to destinations that have not announced a link
|
||||
request cost (and will, in that case, use the configured or
|
||||
default link request cost). This option is mostly useful for
|
||||
testing and diagnostics. In general use, Reticulum will handle
|
||||
link request stamping and cost targets automatically.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line">The <code class="docutils literal notranslate"><span class="pre">enforce_stamps</span></code> option allows early activation of stamp
|
||||
enforcement. When enabled, announces and path requests that do
|
||||
not meet the configured cost requirements are dropped, and link
|
||||
requests with insufficient stamps are ignored. This is a transitory
|
||||
option. It will become mandatory and enabled by default in RNS
|
||||
<code class="docutils literal notranslate"><span class="pre">1.6.2</span></code>.</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
<p>An example of customised stamp cost and value configuration follows below:</p>
|
||||
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[stamps]</span>
|
||||
<span class="w"> </span><span class="na">stamp_destinations</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span>
|
||||
<span class="w"> </span><span class="na">stamp_prs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span>
|
||||
|
||||
<span class="w"> </span><span class="na">destination_cost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">24.8</span>
|
||||
<span class="w"> </span><span class="na">destination_value</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">26.25</span>
|
||||
|
||||
<span class="w"> </span><span class="na">pr_cost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">15.8</span>
|
||||
<span class="w"> </span><span class="na">pr_value</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">16.45</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Stamp cost requirements can also be configured on a per-interface basis:</p>
|
||||
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[[Public Gateway]]</span>
|
||||
<span class="w"> </span><span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">BackboneInterface</span>
|
||||
<span class="w"> </span><span class="na">mode</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">gateway</span>
|
||||
<span class="w"> </span><span class="na">listen_on</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">0.0.0.0</span>
|
||||
<span class="w"> </span><span class="na">port</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">4242</span>
|
||||
|
||||
<span class="w"> </span><span class="na">destination_cost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">25.0</span>
|
||||
<span class="w"> </span><span class="na">pr_cost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">17.2</span>
|
||||
|
||||
<span class="k">[[Local RNode]]</span>
|
||||
<span class="w"> </span><span class="na">type</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">RNodeInterface</span>
|
||||
<span class="w"> </span><span class="na">port</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">/dev/ttyUSB0</span>
|
||||
|
||||
<span class="w"> </span><span class="c1"># Much lower requirements</span>
|
||||
<span class="w"> </span><span class="c1"># for the local network.</span>
|
||||
<span class="w"> </span><span class="na">destination_cost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">11.2</span>
|
||||
<span class="w"> </span><span class="na">pr_cost</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">5.0</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</section>
|
||||
<section id="for-developers">
|
||||
<h4>For Developers<a class="headerlink" href="#for-developers" title="Link to this heading">¶</a></h4>
|
||||
<p>Applications can dynamically set their own stamp values and required link requests costs at runtime. Whenever the values are adjusted, the destination will have to send an announce for the updated information to become known by the rest of the network.</p>
|
||||
<p>If you are setting these values at destination creation time, ensure that they are set <em>immediately</em> after the destination is instantiated, as Reticulum may queue internal, instance-local announces for the destination shortly after creation, so that the local shared instance and its clients are aware of the newly created destination.</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create a new destination</span>
|
||||
<span class="n">my_destination</span> <span class="o">=</span> <span class="n">RNS</span><span class="o">.</span><span class="n">Destination</span><span class="p">(</span>
|
||||
<span class="n">my_identity</span><span class="p">,</span>
|
||||
<span class="n">RNS</span><span class="o">.</span><span class="n">Destination</span><span class="o">.</span><span class="n">IN</span><span class="p">,</span>
|
||||
<span class="n">RNS</span><span class="o">.</span><span class="n">Destination</span><span class="o">.</span><span class="n">SINGLE</span><span class="p">,</span>
|
||||
<span class="s2">"myapp"</span><span class="p">,</span> <span class="s2">"service"</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="c1"># Configure stamps</span>
|
||||
<span class="n">my_destination</span><span class="o">.</span><span class="n">set_value</span><span class="p">(</span><span class="mf">30.0</span><span class="p">)</span>
|
||||
<span class="n">my_destination</span><span class="o">.</span><span class="n">set_link_cost</span><span class="p">(</span><span class="mf">15.0</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Dynamically adjusting link request costs is a viable and intended mechanism for mitigating resource abuse, scraping, DoS attempts and other malicious behaviour. An application may implement mechanisms to statically or dynamically raise link request costs under certain conditions.</p>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Tip</p>
|
||||
<p>Remember here, though, that announce cadence should be preserved for such situations! If your destination is announcing too often in general, and wants to dynamically adjust link request costs at a critical moment, it may already have exhausted its announce rate limits on upstream nodes. So plan your application’s announce cadence thoughtfully!</p>
|
||||
</div>
|
||||
<p>It is also possible for application code to directly get the destination value and link request cost for any known destination:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Get the value of a known destination</span>
|
||||
<span class="n">RNS</span><span class="o">.</span><span class="n">Identity</span><span class="o">.</span><span class="n">recall_stamp_value</span><span class="p">(</span><span class="n">destination_hash</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Get the current link cost requirement</span>
|
||||
<span class="c1"># of a known destination</span>
|
||||
<span class="n">RNS</span><span class="o">.</span><span class="n">Identity</span><span class="o">.</span><span class="n">recall_link_cost</span><span class="p">(</span><span class="n">destination_hash</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>An <code class="docutils literal notranslate"><span class="pre">Identity</span></code> can be created with an embedded stamp value, by passing the target value at instantiation time:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># Create a new, stamped identity</span>
|
||||
<span class="n">my_identity</span> <span class="o">=</span> <span class="n">RNS</span><span class="o">.</span><span class="n">Identity</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="mf">24.0</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Get the value of any known identity</span>
|
||||
<span class="n">another_identity</span><span class="o">.</span><span class="n">get_value</span><span class="p">()</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>As with destination stamps, this is a one-time generation procedure, that happens at Identity creation. Once an identity is created with an embedded stamp, its value <em>cannot</em> be upgraded at a later point as with detached stamps.</p>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
<section id="filtering-qos">
|
||||
<h2>Filtering & QoS<a class="headerlink" href="#filtering-qos" title="Link to this heading">¶</a></h2>
|
||||
<p>In addition to the stamp functionality explored above, Reticulum includes filtering options that allow operators to explicitly deny or allow certain destination <em>types</em> across an entire instance.</p>
|
||||
<p>After filtering, all packets that are ultimately allowed into the transport engine, are sorted into prioritized QoS queues, which are drained and processed in priority order.</p>
|
||||
<p>This provides a powerful system for both filtering, classifying and ensuring latency and service quality for the traffic and application types a node operator wants to provide.</p>
|
||||
<section id="id1">
|
||||
<h3>Instance Configuration<a class="headerlink" href="#id1" title="Link to this heading">¶</a></h3>
|
||||
<p>The filtering subsystem can operate in two modes:</p>
|
||||
<blockquote>
|
||||
<div><ul>
|
||||
<li><div class="line-block">
|
||||
<div class="line"><strong>Ignored Mode</strong> will allow any destination type in the instance, <em>except</em> for those that have been explicitly added to the <code class="docutils literal notranslate"><span class="pre">ignored_types</span></code> list. This mode is useful for blocking the traffic of specific destination types from being transported across the instance.</div>
|
||||
</div>
|
||||
</li>
|
||||
<li><div class="line-block">
|
||||
<div class="line"><strong>Required Only Mode</strong> will allow <em>only</em> the destination types explicitly defined as required, and ignore <em>all</em> other types. A base set of required destination types can be defined instance-wide in the <code class="docutils literal notranslate"><span class="pre">allowed_types</span></code> list.</div>
|
||||
</div>
|
||||
<div class="line-block">
|
||||
<div class="line">In addition, any application using the shared instance can temporarily request required destination types for its use. Applications that request required destination types will automatically have them granted, unless they are included in the <code class="docutils literal notranslate"><span class="pre">ignored_types</span></code> list.</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
<p>The filtering defaults and base settings are configured in the <code class="docutils literal notranslate"><span class="pre">[filter]</span></code> section of the configuration file. For example, it is possible to explicitly ignore a series of destination types, while also limiting hop reach to a more local topology.</p>
|
||||
<div class="admonition tip">
|
||||
<p class="admonition-title">Tip</p>
|
||||
<p>The <code class="docutils literal notranslate"><span class="pre">hop_limiter</span></code> in the filter section is an instance-wide setting. You can also use the <code class="docutils literal notranslate"><span class="pre">hop_limiter</span></code> option <em>per-interface</em> if you want to limit hops on some interfaces only.</p>
|
||||
</div>
|
||||
<p>If you do not know the human readable destination type aspects for a destination type you want to ignore, you can also add entries as 10-byte (20 hexadecimal character) hashes using the <code class="docutils literal notranslate"><span class="pre"><c4ace368262d845c9dd3></span></code> format.</p>
|
||||
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[filter]</span>
|
||||
<span class="w"> </span><span class="na">hop_limiter</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">14</span>
|
||||
<span class="w"> </span><span class="na">ignored_types</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">application.that.spams, traffic.heavy.service, <c4ace368262d845c9dd3></span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>In some situations, you may want to allow <em>only</em> certain destination types. If, for example, you are creating a high-performance transport node intended to handle thousands of simultaneous voice calls at minimal latency, a configuration might look something like:</p>
|
||||
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="k">[filter]</span>
|
||||
<span class="w"> </span><span class="na">required_only</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">yes</span>
|
||||
<span class="w"> </span><span class="na">allowed_types</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">lxst.telephony</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The filtering subsystem provided in RNS <code class="docutils literal notranslate"><span class="pre">1.6.0</span></code> is functional and useful, but at an early stage, and relatively basic. In the upcoming releases, it will be expanded into a much more comprehensive and flexible system, that will include custom QoS and traffic class tagging, advanced rule definitions and more.</p>
|
||||
<div class="admonition important">
|
||||
<p class="admonition-title">Important</p>
|
||||
<p>As the filtering and QoS system is developed and matures, the <code class="docutils literal notranslate"><span class="pre">required_only</span></code> mode will become the default operating mode for non-transport instances, since applications can already now dynamically request what destination types they are interested in.</p>
|
||||
<p>This ensures that a local, non-transport node (running on resource-limited hardware, for example), does not have to process announces for, and waste CPU and memory on destination types that are completely irrelevant to it. It also greatly reduces power consumption on battery-powered and mobile devices, while they are connected to large and busy networks.</p>
|
||||
<p>If you are a developer, see the following section.</p>
|
||||
</div>
|
||||
</section>
|
||||
<section id="blocking-transport-nodes">
|
||||
<h3>Blocking Transport Nodes<a class="headerlink" href="#blocking-transport-nodes" title="Link to this heading">¶</a></h3>
|
||||
<p>Misbehaving, spamming and broken transport nodes can be completely blocked using the <span class="xref std std-ref">Blackhole system</span>. First, obtain the Transport Identity hash of a misbehaving transport node, using <code class="docutils literal notranslate"><span class="pre">rnstatus</span></code>:</p>
|
||||
<div class="highlight-txt notranslate"><div class="highlight"><pre><span></span>$ rnstatus -FATa "71.29.190.5"
|
||||
|
||||
BackboneInterface[Client on Bern IPv4/71.29.190.5:37062]
|
||||
Status : Up
|
||||
Mode : Gateway
|
||||
Rate : 250.00 Mbps, MTU 65536
|
||||
Running : Unknown implementation
|
||||
Rem.Tr.ID : <a0c289d131c7bfa8d5ddc8b652c0f40d>
|
||||
Held : 64 announces
|
||||
Violatns. : 382 protocol
|
||||
Flt. Hits : 92
|
||||
Announces : 147174↓ 11193↑ total, 140554 filtered
|
||||
1.2 Hz↑ (↓0% / ↑0% of flow)
|
||||
7.8 Hz↓ (t:6h/p:0s/g:1) burst for 4h, 54m and 42.69s
|
||||
Traffic : ↑4.75 MB 0 bps
|
||||
↓1.50 MB 0 bps
|
||||
Filtered : ↑0 B 0 bps
|
||||
↓55.43 MB 380.14 Kbps
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>You can then block it by its Transport ID:</p>
|
||||
<div class="highlight-txt notranslate"><div class="highlight"><pre><span></span>$ rnpath -B a0c289d131c7bfa8d5ddc8b652c0f40d --reason "Broken node"
|
||||
|
||||
Blackholed identity a0c289d131c7bfa8d5ddc8b652c0f40d
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Its connection will be immediately torn down, and further reconnection attempts will be ignored.</p>
|
||||
</section>
|
||||
<section id="id2">
|
||||
<h3>For Developers<a class="headerlink" href="#id2" title="Link to this heading">¶</a></h3>
|
||||
<p>At some point during the <code class="docutils literal notranslate"><span class="pre">1.6.x</span></code> release cycle, RNS will move to using the <code class="docutils literal notranslate"><span class="pre">required_only</span></code> mode for <em>non-transport</em> instances by default. This means that applications will, in most cases, have to request what types of destinations they are interested in receiving announces from.</p>
|
||||
<p>If your application is only using the utility primitives included in RNS, or established protocols such as LXMF or LXST, <strong>there is nothing you have to do</strong>. The protocol primitives <em>themselves</em> request their required destination types, and this is the general pattern to follow here:</p>
|
||||
<ul class="simple">
|
||||
<li><p>If an application uses a common protocol or primitive, it is the importable primitive, protocol module, or relevant internal functionality that should request destination type requirements, at the point where they are actually needed.</p></li>
|
||||
<li><p>Higher level application layers should not have to guess at or request destination types, unless it explicitly creates outbound destinations that are not covered by any already-used protocols or primitives.</p></li>
|
||||
</ul>
|
||||
<p>If your protocol or application needs to receive announces for a specific destination type, it is very easy to register it. For example, at startup (or when the destination type is actually required), simply run something like:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">RNS</span><span class="o">.</span><span class="n">Reticulum</span><span class="o">.</span><span class="n">get_instance</span><span class="p">()</span><span class="o">.</span><span class="n">wants_destination_type</span><span class="p">(</span><span class="s2">"my_app.service"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>You do not <em>have to</em> explicitly deregister destination type requirements. Reticulum automatically deregisters when the shared instance connection for the application is torn down, but you may <em>want</em> to in certain cases, which follows the same pattern:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="n">RNS</span><span class="o">.</span><span class="n">Reticulum</span><span class="o">.</span><span class="n">get_instance</span><span class="p">()</span><span class="o">.</span><span class="n">unwants_destination_type</span><span class="p">(</span><span class="s2">"my_app.service"</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>That’s really all there is to it. If you already now want to make you application more CPU, memory and battery efficient, you can tell Reticulum to start serving only required destinations to it with only a few lines of additional code. A full setup of this functionality might look something like:</p>
|
||||
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">destination_type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">REQUIRED_DESTINATION_TYPES</span><span class="p">:</span>
|
||||
<span class="n">RNS</span><span class="o">.</span><span class="n">Reticulum</span><span class="o">.</span><span class="n">get_instance</span><span class="p">()</span><span class="o">.</span><span class="n">wants_destination_type</span><span class="p">(</span><span class="n">destination_type</span><span class="p">)</span>
|
||||
|
||||
<span class="n">RNS</span><span class="o">.</span><span class="n">Reticulum</span><span class="o">.</span><span class="n">get_instance</span><span class="p">()</span><span class="o">.</span><span class="n">required_announces_only</span><span class="p">(</span><span class="kc">True</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>Your application will now only receive, and have to process, the announces and paths that it actually cares about.</p>
|
||||
</section>
|
||||
</section>
|
||||
<section id="ingress-burst-control">
|
||||
<h2>Ingress & Burst Control<a class="headerlink" href="#ingress-burst-control" title="Link to this heading">¶</a></h2>
|
||||
<p>In addition to the economic incentives created by stamps, Reticulum enforces a set of hydraulic limits on how much announce traffic any peer or destination can inject into the network. These mechanisms work automatically, require no operator configuration (but can be tuned, if required), and apply equally to all peers.</p>
|
||||
<p>At the most basic level, the <code class="docutils literal notranslate"><span class="pre">announce_cap</span></code> mechanism limits the bandwidth any interface will allocate to propagating announces and other network upkeep traffic, and prioritises the local topology. Destinations that rapidly re-announce are down-prioritised in the transmission queue, so attempting to gain reach through announce spam has the exact <em>opposite</em> effect.</p>
|
||||
<p>On top of this, per-destination announce rate control can be configured on any interface, or as instance-wide defaults. Once configured, announces <em>received</em> for any one destination will only be re-broadcast to other interfaces at the configured target rate, no matter how often they are received. The grace option allows occasional rate violations, and a configurable penalty extends the interval between propagated announces for destinations that repeatedly exceed their target.</p>
|
||||
<p>The final layer protects against bursts of announces for <em>newly created</em> destinations. If an interface receives a large influx of announces for previously unknown destinations in a short amount of time, these are held in a bounded queue, while announces for known and established destinations continue to be processed without interruption. After the burst subsides, and an additional waiting period has passed, held announces are released slowly until the queue is cleared.</p>
|
||||
<p>A node that connects to a public interface, announces a large number of bogus destinations, and then disconnects, will therefore never get those destinations into path tables at all. When the interface they arrived on disappears, the held announces are simply dropped and forgotten.</p>
|
||||
<p>Ingress control operates at the level of individual sub-interfaces, so one misbehaving client cannot disrupt announce processing for other clients connected to the same listener. Combined with stamps, these mechanisms are complementary:</p>
|
||||
<p>Rate limiting bounds the <em>rate</em> at which abuse can occur, for everyone, while stamps make the <em>volume</em> of abuse from any actor computationally expensive.</p>
|
||||
<p>Full configuration details are available in the <a class="reference internal" href="interfaces.html#interfaces-announcerates"><span class="std std-ref">Announce Rate Control</span></a> and <a class="reference internal" href="interfaces.html#interfaces-ingress-control"><span class="std std-ref">New Destination Rate Limiting</span></a> sections.</p>
|
||||
</section>
|
||||
<section id="blackhole-management">
|
||||
<span id="protecting-blachole"></span><h2>Blackhole Management<a class="headerlink" href="#blackhole-management" title="Link to this heading">¶</a></h2>
|
||||
<p>The <em>blackhole</em> system allows any node operator or individual user to block specific identities at the transport layer.</p>
|
||||
<p>Once an identity has been blackholed on a node, announces originating from <em>any</em> destination associated with that identity are dropped, and the node will refuse to transport traffic, or establish and maintain links, to the blackholed identity’s destinations.</p>
|
||||
<p>It is important to understand the scope of this mechanism corrrectly. There is fundamentally <strong>no way</strong> to <em>globally</em> block or censor any identity or destination in Reticulum networks. A blackhole entry only applies on the network segments that enforce it, which is the exact intention. Operators retain full control over what is allowed on their own segments, while no one can impose restrictions on segments they do not operate.</p>
|
||||
<p>Blackholes can be managed directly with the <code class="docutils literal notranslate"><span class="pre">rnpath</span></code> utility. Identities can be blocked (optionally with an expiry duration and a human-readable reason), unblocked, and the current local blocklist can be inspected at any time. This is well suited for immediate responses to announce spam, unwanted content or malicious behaviour observed on your own networks.</p>
|
||||
<p>For anything larger than a few nodes, manual blocklist maintenance quickly becomes impractical. Reticulum therefore allows an instance to subscribe to blackhole lists published by trusted transport identities, periodically retrieving and merging them into the local list, and conversely to publish its own list to subscribers.</p>
|
||||
<p>This makes it possible to federate community-maintained blocklists across large networks, with the important caveat that subscribing to a list is an act of trust in its maintainer. See the <a class="reference internal" href="using.html#using-blackhole-management"><span class="std std-ref">Blackhole Management</span></a> section for full details on local management, automated list sourcing and publishing.</p>
|
||||
</section>
|
||||
<section id="fast-flap-blocking">
|
||||
<h2>Fast-Flap Blocking<a class="headerlink" href="#fast-flap-blocking" title="Link to this heading">¶</a></h2>
|
||||
<p>High-performance listener interfaces, such as <a class="reference internal" href="interfaces.html#interfaces-backbone"><span class="std std-ref">BackboneInterface</span></a>, will automatically block <em>fast-flapping</em> clients; remote peers that repeatedly connect for a very short amount of time, and then disconnect.</p>
|
||||
<p>This behaviour usually stems from attempts to dump announce or path request spam onto the network in short bursts, while rotating connections in an attempt to evade per-interface rate limits, but it can also be caused by broken implementations or automated scanning tools.</p>
|
||||
<p>Such bypass attempts generally have very limited effect. Ingress limiters trigger <em>immediately</em> once rate limits are exceeded, but the behaviour still causes needless interface rotation and wasted resources on the transport instance.</p>
|
||||
<p>With fast-flap blocking enabled, a client that exceeds the allowed flap grace is simply not allocated an actual interface again, for the configured block duration.</p>
|
||||
<p>On the <code class="docutils literal notranslate"><span class="pre">BackboneInterface</span></code> type, fast-flap blocking is enabled by default, with sensible standard settings. All parameters can be adjusted if necessary. See the <a class="reference internal" href="interfaces.html#interfaces-fastflap"><span class="std std-ref">Automated Blocking</span></a> section of the Interfaces chapter.</p>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
|
||||
<div class="related-pages">
|
||||
<a class="next-page" href="understanding.html">
|
||||
<div class="page-info">
|
||||
<div class="context">
|
||||
<span>Next</span>
|
||||
</div>
|
||||
<div class="title">Understanding Reticulum</div>
|
||||
</div>
|
||||
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
|
||||
</a>
|
||||
<a class="prev-page" href="using.html">
|
||||
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
|
||||
<div class="page-info">
|
||||
<div class="context">
|
||||
<span>Previous</span>
|
||||
</div>
|
||||
|
||||
<div class="title">Using Reticulum on Your System</div>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<div class="bottom-of-page">
|
||||
<div class="left-details">
|
||||
<div class="copyright">
|
||||
Copyright © 2025, Mark Qvist
|
||||
</div>
|
||||
Generated with <a href="https://www.sphinx-doc.org/">Sphinx</a> and
|
||||
<a href="https://github.com/pradyunsg/furo">Furo</a>
|
||||
|
||||
</div>
|
||||
<div class="right-details">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
<aside class="toc-drawer">
|
||||
|
||||
|
||||
<div class="toc-sticky toc-scroll">
|
||||
<div class="toc-title-container">
|
||||
<span class="toc-title">
|
||||
On this page
|
||||
</span>
|
||||
</div>
|
||||
<div class="toc-tree-container">
|
||||
<div class="toc-tree">
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Protecting Open Networks</a><ul>
|
||||
<li><a class="reference internal" href="#cryptographic-stamps">Cryptographic Stamps</a><ul>
|
||||
<li><a class="reference internal" href="#base-primitives">Base Primitives</a></li>
|
||||
<li><a class="reference internal" href="#on-network-types">On-Network Types</a></li>
|
||||
<li><a class="reference internal" href="#configuring-stamps">Configuring Stamps</a><ul>
|
||||
<li><a class="reference internal" href="#instance-configuration">Instance Configuration</a></li>
|
||||
<li><a class="reference internal" href="#for-developers">For Developers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#filtering-qos">Filtering & QoS</a><ul>
|
||||
<li><a class="reference internal" href="#id1">Instance Configuration</a></li>
|
||||
<li><a class="reference internal" href="#blocking-transport-nodes">Blocking Transport Nodes</a></li>
|
||||
<li><a class="reference internal" href="#id2">For Developers</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#ingress-burst-control">Ingress & Burst Control</a></li>
|
||||
<li><a class="reference internal" href="#blackhole-management">Blackhole Management</a></li>
|
||||
<li><a class="reference internal" href="#fast-flap-blocking">Fast-Flap Blocking</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
|
||||
<script src="_static/copybutton.js?v=f281be69"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>API Reference - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>API Reference - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -270,7 +271,7 @@ This chapter lists and explains all classes exposed by the Reticulum Network Sta
|
||||
<p id="api-reticulum"><h3> Reticulum </h3></p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="RNS.Reticulum">
|
||||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">RNS.</span></span><span class="sig-name descname"><span class="pre">Reticulum</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">configdir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">loglevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">logdest</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">require_shared_instance</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shared_instance_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Reticulum" title="Link to this definition">¶</a></dt>
|
||||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">RNS.</span></span><span class="sig-name descname"><span class="pre">Reticulum</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">configdir</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">loglevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">logdest</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">verbosity</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">require_shared_instance</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">shared_instance_type</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enable_stamping</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">enforce_stamps</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Reticulum" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>This class is used to initialise access to Reticulum within a
|
||||
program. You must create exactly one instance of this class before
|
||||
carrying out any other RNS operations, such as creating destinations
|
||||
@@ -348,6 +349,12 @@ to successfully establish links. Currently 5 bits per second.</p>
|
||||
<dd><p>Returns the currently running Reticulum instance.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Reticulum.get_instance_pid">
|
||||
<em class="property"><span class="k"><span class="pre">static</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">get_instance_pid</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Reticulum.get_instance_pid" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns the main process ID of the currently running Reticulum instance.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Reticulum.get_first_hop_timeout">
|
||||
<span class="sig-name descname"><span class="pre">get_first_hop_timeout</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">destination</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Reticulum.get_first_hop_timeout" title="Link to this definition">¶</a></dt>
|
||||
@@ -453,7 +460,7 @@ can remotely query and manage this instance.</p>
|
||||
to be considered valid and remembered.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p>The required stamp value as an integer.</p>
|
||||
<dd class="field-odd"><p>The required stamp value as a float.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
@@ -510,7 +517,7 @@ interfaces are discovered.</p>
|
||||
<p id="api-identity"><h3> Identity </h3></p>
|
||||
<dl class="py class">
|
||||
<dt class="sig sig-object py" id="RNS.Identity">
|
||||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">RNS.</span></span><span class="sig-name descname"><span class="pre">Identity</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">create_keys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Identity" title="Link to this definition">¶</a></dt>
|
||||
<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">RNS.</span></span><span class="sig-name descname"><span class="pre">Identity</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">create_keys</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">value</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Identity" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>This class is used to manage identities in Reticulum. It provides methods
|
||||
for encryption, decryption, signatures and verification, and is the basis
|
||||
for all encrypted communication over Reticulum networks.</p>
|
||||
@@ -588,6 +595,34 @@ search for an identity from a known <em>identity hash</em>, by setting the
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Identity.recall_stamp_value">
|
||||
<em class="property"><span class="k"><span class="pre">static</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">recall_stamp_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">destination_hash</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Identity.recall_stamp_value" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Recall last heard announce stamp value for a destination hash.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>destination_hash</strong> – Destination hash as <em>bytes</em>.</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-even"><p><em>Float</em>, or <em>None</em> if the destination is unknown.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Identity.recall_link_cost">
|
||||
<em class="property"><span class="k"><span class="pre">static</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">recall_link_cost</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">destination_hash</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Identity.recall_link_cost" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Recall the link request stamp cost announced by a destination.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>destination_hash</strong> – Destination hash as <em>bytes</em>.</p>
|
||||
</dd>
|
||||
<dt class="field-even">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-even"><p><em>Float</em>, or <em>None</em> if the destination is unknown or has not announced a cost.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Identity.full_hash">
|
||||
<em class="property"><span class="k"><span class="pre">static</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">full_hash</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Identity.full_hash" title="Link to this definition">¶</a></dt>
|
||||
@@ -704,6 +739,16 @@ communication for the identity. Be very careful with this method.</p>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Identity.get_value">
|
||||
<span class="sig-name descname"><span class="pre">get_value</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Identity.get_value" title="Link to this definition">¶</a></dt>
|
||||
<dd><dl class="field-list simple">
|
||||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p>The stamp value of this identity as a <em>float</em></p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Identity.get_private_key">
|
||||
<span class="sig-name descname"><span class="pre">get_private_key</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Identity.get_private_key" title="Link to this definition">¶</a></dt>
|
||||
@@ -913,6 +958,41 @@ relevant interfaces. Application specific data can be added to the announce.</p>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Destination.set_value">
|
||||
<span class="sig-name descname"><span class="pre">set_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Destination.set_value" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Sets the target stamp value for this destination.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>value</strong> – The target value as a <em>float</em>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Destination.set_link_cost">
|
||||
<span class="sig-name descname"><span class="pre">set_link_cost</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cost</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Destination.set_link_cost" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Sets the required link establishment stamp cost for this destination. Set to 0 to disable.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p><strong>cost</strong> – The required cost as a <em>float</em>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Destination.get_link_cost">
|
||||
<span class="sig-name descname"><span class="pre">get_link_cost</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Destination.get_link_cost" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Returns the link request stamp cost to be announced for this
|
||||
destination, as a float. If no destination-specific cost has
|
||||
been set, the default link request cost is returned.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p>The announced link request cost as a <em>float</em>.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Destination.accepts_links">
|
||||
<span class="sig-name descname"><span class="pre">accepts_links</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">accepts</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Destination.accepts_links" title="Link to this definition">¶</a></dt>
|
||||
@@ -2285,7 +2365,7 @@ blocks until the path is available, or the timeout is reached.</p>
|
||||
|
||||
<dl class="py method">
|
||||
<dt class="sig sig-object py" id="RNS.Transport.request_path">
|
||||
<em class="property"><span class="k"><span class="pre">static</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">request_path</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">destination_hash</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">on_interface</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">recursive</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Transport.request_path" title="Link to this definition">¶</a></dt>
|
||||
<em class="property"><span class="k"><span class="pre">static</span></span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">request_path</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">destination_hash</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">on_interface</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tag</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">recursive</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ext_payload</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#RNS.Transport.request_path" title="Link to this definition">¶</a></dt>
|
||||
<dd><p>Requests a path to the destination from the network. If
|
||||
another reachable peer on the network knows a path, it
|
||||
will announce it.</p>
|
||||
@@ -2294,6 +2374,7 @@ will announce it.</p>
|
||||
<dd class="field-odd"><ul class="simple">
|
||||
<li><p><strong>destination_hash</strong> – A destination hash as <em>bytes</em>.</p></li>
|
||||
<li><p><strong>on_interface</strong> – If specified, the path request will only be sent on this interface. In normal use, Reticulum handles this automatically, and this parameter should not be used.</p></li>
|
||||
<li><p><strong>ext_payload</strong> – Internal use by <a class="reference internal" href="#api-transport"><span class="std std-ref">RNS.Transport</span></a>. Ignore.</p></li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
@@ -2389,6 +2470,7 @@ will announce it.</p>
|
||||
<li><a class="reference internal" href="#RNS.Reticulum.MINIMUM_BITRATE"><code class="docutils literal notranslate"><span class="pre">MINIMUM_BITRATE</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Reticulum.DEFAULT_PER_HOP_TIMEOUT"><code class="docutils literal notranslate"><span class="pre">DEFAULT_PER_HOP_TIMEOUT</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Reticulum.get_instance"><code class="docutils literal notranslate"><span class="pre">get_instance()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Reticulum.get_instance_pid"><code class="docutils literal notranslate"><span class="pre">get_instance_pid()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Reticulum.get_first_hop_timeout"><code class="docutils literal notranslate"><span class="pre">get_first_hop_timeout()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Reticulum.get_lowest_interface_bitrate"><code class="docutils literal notranslate"><span class="pre">get_lowest_interface_bitrate()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Reticulum.get_medium_path_timeout"><code class="docutils literal notranslate"><span class="pre">get_medium_path_timeout()</span></code></a></li>
|
||||
@@ -2411,6 +2493,8 @@ will announce it.</p>
|
||||
<li><a class="reference internal" href="#RNS.Identity.TRUNCATED_HASHLENGTH"><code class="docutils literal notranslate"><span class="pre">TRUNCATED_HASHLENGTH</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.recall"><code class="docutils literal notranslate"><span class="pre">recall()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.recall_app_data"><code class="docutils literal notranslate"><span class="pre">recall_app_data()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.recall_stamp_value"><code class="docutils literal notranslate"><span class="pre">recall_stamp_value()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.recall_link_cost"><code class="docutils literal notranslate"><span class="pre">recall_link_cost()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.full_hash"><code class="docutils literal notranslate"><span class="pre">full_hash()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.truncated_hash"><code class="docutils literal notranslate"><span class="pre">truncated_hash()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.get_random_hash"><code class="docutils literal notranslate"><span class="pre">get_random_hash()</span></code></a></li>
|
||||
@@ -2419,6 +2503,7 @@ will announce it.</p>
|
||||
<li><a class="reference internal" href="#RNS.Identity.from_file"><code class="docutils literal notranslate"><span class="pre">from_file()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.to_file"><code class="docutils literal notranslate"><span class="pre">to_file()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.pub_to_file"><code class="docutils literal notranslate"><span class="pre">pub_to_file()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.get_value"><code class="docutils literal notranslate"><span class="pre">get_value()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.get_private_key"><code class="docutils literal notranslate"><span class="pre">get_private_key()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.get_public_key"><code class="docutils literal notranslate"><span class="pre">get_public_key()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Identity.load_private_key"><code class="docutils literal notranslate"><span class="pre">load_private_key()</span></code></a></li>
|
||||
@@ -2437,6 +2522,9 @@ will announce it.</p>
|
||||
<li><a class="reference internal" href="#RNS.Destination.hash_from_name_and_identity"><code class="docutils literal notranslate"><span class="pre">hash_from_name_and_identity()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.hash"><code class="docutils literal notranslate"><span class="pre">hash()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.announce"><code class="docutils literal notranslate"><span class="pre">announce()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.set_value"><code class="docutils literal notranslate"><span class="pre">set_value()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.set_link_cost"><code class="docutils literal notranslate"><span class="pre">set_link_cost()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.get_link_cost"><code class="docutils literal notranslate"><span class="pre">get_link_cost()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.accepts_links"><code class="docutils literal notranslate"><span class="pre">accepts_links()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.set_link_established_callback"><code class="docutils literal notranslate"><span class="pre">set_link_established_callback()</span></code></a></li>
|
||||
<li><a class="reference internal" href="#RNS.Destination.set_packet_callback"><code class="docutils literal notranslate"><span class="pre">set_packet_callback()</span></code></a></li>
|
||||
@@ -2589,7 +2677,7 @@ will announce it.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<meta name="robots" content="noindex" />
|
||||
<title>Search - Reticulum Network Stack 1.5.5 documentation</title><link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<title>Search - Reticulum Network Stack 1.6.1 documentation</title><link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=8dab3a3b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="#" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -305,7 +306,7 @@
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -1 +1 @@
|
||||
Search.setIndex({"alltitles":{"A Carrier-Grade Fallacy":[[17,"a-carrier-grade-fallacy"]],"A History Of What Works":[[0,"a-history-of-what-works"]],"A Persistent, But Fragile Triad":[[0,"a-persistent-but-fragile-triad"]],"API Reference":[[11,null]],"ARM64":[[4,"arm64"]],"AX.25 KISS Interface":[[8,"ax-25-kiss-interface"]],"Accessing Repository Pages":[[5,"accessing-repository-pages"]],"Addendum A: The Prns Case":[[0,"addendum-a-the-prns-case"]],"Adding Radio Interfaces":[[4,"adding-radio-interfaces"]],"Agency and answerability":[[0,"agency-and-answerability"]],"An Explanation of Reticulum for Human Beings":[[3,null]],"Anchor In The Flow":[[17,"anchor-in-the-flow"]],"Android":[[4,"android"]],"Announce":[[2,"announce"]],"Announce Propagation Rules":[[14,"announce-propagation-rules"]],"Announce Rate Control":[[8,"announce-rate-control"]],"Announcing Presence":[[17,"announcing-presence"]],"Artifact-Centered Workflows":[[1,"artifact-centered-workflows"]],"Assistance Versus Machine-Substitution":[[0,"assistance-versus-machine-substitution"]],"Author Identity Binding":[[5,"author-identity-binding"]],"Auto Interface":[[8,"auto-interface"]],"Automated Blocking":[[8,"automated-blocking"]],"Automated List Sourcing":[[15,"automated-list-sourcing"]],"Automatic Mirror Synchronization":[[5,"automatic-mirror-synchronization"]],"Backbone Interface":[[8,"backbone-interface"]],"Blackhole Management":[[15,"blackhole-management"]],"Bootstrapping Connectivity":[[4,"bootstrapping-connectivity"]],"Brandolini\u2019s Reference":[[0,null]],"Broadcast":[[2,"broadcast"]],"Browsing & Publishing":[[12,"browsing-publishing"]],"Buffer":[[2,"buffer"]],"Build Personal Infrastructure":[[4,"build-personal-infrastructure"]],"Building Networks":[[10,null]],"Channel":[[2,"channel"]],"Chat":[[12,"chat"]],"Code Examples":[[2,null]],"Columba":[[12,"id8"]],"Combining Hardware Types":[[6,"combining-hardware-types"]],"Command-Line Interaction":[[5,"command-line-interaction"]],"Commit Signing":[[5,"commit-signing"]],"Common Interface Options":[[8,"common-interface-options"]],"Communications Hardware":[[6,null]],"Composable Primitives":[[1,"composable-primitives"]],"Concepts & Overview":[[10,"concepts-overview"]],"Conceptual Overview":[[14,"conceptual-overview"]],"Conclusion":[[0,"conclusion"]],"Configuration":[[5,"configuration"],[5,"id1"]],"Configuration & Data":[[15,"configuration-data"]],"Configuration Example":[[5,"configuration-example"]],"Configuration Methods":[[5,"configuration-methods"]],"Configuring Interfaces":[[8,null]],"Connect to the Distributed Backbone":[[4,"connect-to-the-distributed-backbone"]],"Connecting Remotes":[[8,"connecting-remotes"]],"Connecting Reticulum Instances Over the Internet":[[4,"connecting-reticulum-instances-over-the-internet"]],"Consequences":[[0,"consequences"]],"Contributing to the Global Ret":[[4,"contributing-to-the-global-ret"]],"Copyright & The Two Legal Layers":[[0,"copyright-the-two-legal-layers"]],"Cost Of A Byte":[[17,"cost-of-a-byte"]],"Creating Empty Repositories":[[5,"creating-empty-repositories"]],"Creating RNodes":[[6,"creating-rnodes"]],"Creating Signed Releases":[[5,"creating-signed-releases"]],"Creating a Network With Reticulum":[[4,"creating-a-network-with-reticulum"]],"Creating and Using Custom Interfaces":[[4,"creating-and-using-custom-interfaces"]],"Creating and Using a Network Identity":[[14,"creating-and-using-a-network-identity"]],"Creator Permissions":[[5,"creator-permissions"]],"Cryptographic Attribution":[[5,"cryptographic-attribution"]],"Cryptographic Primitives":[[14,"cryptographic-primitives"]],"Current Status":[[16,"current-status"]],"Current Usage":[[14,"current-usage"]],"Custom Interfaces":[[2,"custom-interfaces"],[8,"custom-interfaces"]],"Customizing Templates":[[5,"customizing-templates"]],"Dating":[[0,"dating"]],"Death To The Address":[[17,"death-to-the-address"]],"Debian Bookworm":[[4,"debian-bookworm"]],"Decentralization Or Uncentralizability?":[[17,"decentralization-or-uncentralizability"]],"Defence Of The Commons":[[0,"defence-of-the-commons"]],"Design Patterns For Post-IP Systems":[[17,"design-patterns-for-post-ip-systems"]],"Destination Naming":[[14,"destination-naming"]],"Destinations":[[14,"destinations"]],"Destinations, Not Addresses":[[10,"destinations-not-addresses"]],"Develop a Program with Reticulum":[[4,"develop-a-program-with-reticulum"]],"Device Flashers":[[12,"device-flashers"]],"Disclosed Assistance Or Laundered Generation":[[0,"disclosed-assistance-or-laundered-generation"]],"Discoverable Interfaces":[[8,"discoverable-interfaces"]],"Discovering Interfaces":[[15,"discovering-interfaces"]],"Discovery Parameters":[[8,"discovery-parameters"]],"Distributed Development":[[1,null]],"Distribution Without Intermediaries":[[1,"distribution-without-intermediaries"]],"Donations":[[13,"donations"]],"Echo":[[2,"echo"]],"Emergent Patterns":[[17,"emergent-patterns"]],"Enabling Discovery":[[8,"enabling-discovery"]],"Enabling the Git Page Node":[[5,"enabling-the-git-page-node"]],Line truncated
|
||||
Search.setIndex({"alltitles":{"A Carrier-Grade Fallacy":[[18,"a-carrier-grade-fallacy"]],"A History Of What Works":[[0,"a-history-of-what-works"]],"A Persistent, But Fragile Triad":[[0,"a-persistent-but-fragile-triad"]],"API Reference":[[12,null]],"ARM64":[[4,"arm64"]],"AX.25 KISS Interface":[[8,"ax-25-kiss-interface"]],"Accessing Repository Pages":[[5,"accessing-repository-pages"]],"Addendum A: The Prns Case":[[0,"addendum-a-the-prns-case"]],"Adding Radio Interfaces":[[4,"adding-radio-interfaces"]],"Agency and answerability":[[0,"agency-and-answerability"]],"An Explanation of Reticulum for Human Beings":[[3,null]],"Anchor In The Flow":[[18,"anchor-in-the-flow"]],"Android":[[4,"android"]],"Announce":[[2,"announce"]],"Announce Propagation Rules":[[15,"announce-propagation-rules"]],"Announce Rate Control":[[8,"announce-rate-control"]],"Announcing Presence":[[18,"announcing-presence"]],"Artifact-Centered Workflows":[[1,"artifact-centered-workflows"]],"Assistance Versus Machine-Substitution":[[0,"assistance-versus-machine-substitution"]],"Author Identity Binding":[[5,"author-identity-binding"]],"Auto Interface":[[8,"auto-interface"]],"Automated Blocking":[[8,"automated-blocking"]],"Automated List Sourcing":[[16,"automated-list-sourcing"]],"Automatic Mirror Synchronization":[[5,"automatic-mirror-synchronization"]],"Backbone Interface":[[8,"backbone-interface"]],"Base Primitives":[[11,"base-primitives"]],"Blackhole Management":[[11,"blackhole-management"],[16,"blackhole-management"]],"Blocking Transport Nodes":[[11,"blocking-transport-nodes"]],"Bootstrapping Connectivity":[[4,"bootstrapping-connectivity"]],"Brandolini\u2019s Reference":[[0,null]],"Broadcast":[[2,"broadcast"]],"Browsing & Publishing":[[13,"browsing-publishing"]],"Buffer":[[2,"buffer"]],"Build Personal Infrastructure":[[4,"build-personal-infrastructure"]],"Building Networks":[[10,null]],"Channel":[[2,"channel"]],"Chat":[[13,"chat"]],"Code Examples":[[2,null]],"Columba":[[13,"id8"]],"Combining Hardware Types":[[6,"combining-hardware-types"]],"Command-Line Interaction":[[5,"command-line-interaction"]],"Commit Signing":[[5,"commit-signing"]],"Common Interface Options":[[8,"common-interface-options"]],"Communications Hardware":[[6,null]],"Composable Primitives":[[1,"composable-primitives"]],"Concepts & Overview":[[10,"concepts-overview"]],"Conceptual Overview":[[15,"conceptual-overview"]],"Conclusion":[[0,"conclusion"]],"Configuration":[[5,"configuration"],[5,"id1"]],"Configuration & Data":[[16,"configuration-data"]],"Configuration Example":[[5,"configuration-example"]],"Configuration Methods":[[5,"configuration-methods"]],"Configuring Interfaces":[[8,null]],"Configuring Stamps":[[11,"configuring-stamps"]],"Connect to the Distributed Backbone":[[4,"connect-to-the-distributed-backbone"]],"Connecting Remotes":[[8,"connecting-remotes"]],"Connecting Reticulum Instances Over the Internet":[[4,"connecting-reticulum-instances-over-the-internet"]],"Consequences":[[0,"consequences"]],"Contributing to the Global Ret":[[4,"contributing-to-the-global-ret"]],"Copyright & The Two Legal Layers":[[0,"copyright-the-two-legal-layers"]],"Cost Of A Byte":[[18,"cost-of-a-byte"]],"Creating Empty Repositories":[[5,"creating-empty-repositories"]],"Creating RNodes":[[6,"creating-rnodes"]],"Creating Signed Releases":[[5,"creating-signed-releases"]],"Creating a Network With Reticulum":[[4,"creating-a-network-with-reticulum"]],"Creating and Using Custom Interfaces":[[4,"creating-and-using-custom-interfaces"]],"Creating and Using a Network Identity":[[15,"creating-and-using-a-network-identity"]],"Creator Permissions":[[5,"creator-permissions"]],"Cryptographic Attribution":[[5,"cryptographic-attribution"]],"Cryptographic Primitives":[[15,"cryptographic-primitives"]],"Cryptographic Stamps":[[11,"cryptographic-stamps"]],"Current Status":[[17,"current-status"]],"Current Usage":[[15,"current-usage"]],"Custom Interfaces":[[2,"custom-interfaces"],[8,"custom-interfaces"]],"Customizing Templates":[[5,"customizing-templates"]],"Dating":[[0,"dating"]],"Death To The Address":[[18,"death-to-the-address"]],"Debian Bookworm":[[4,"debian-bookworm"]],"Decentralization Or Uncentralizability?":[[18,"decentralization-or-uncentralizability"]],"Defence Of The Commons":[[0,"defence-of-the-commons"]],"Design Patterns For Post-IP Systems":[[18,"design-patterns-for-post-ip-systems"]],"Destination Naming":[[15,"destination-naming"]],"Destinations":[[15,"destinations"]],"Destinations, Not Addresses":[[10,"destinations-not-addresses"]],"Develop a Program with Reticulum":[[4,"develop-a-program-with-reticulum"]],"Device Flashers":[[13,"device-flashers"]],"Disclosed Assistance Or Laundered Generation":[[0,"disclosed-assistance-or-laundered-generation"]],"Discoverable Interfaces":[[8,"discoverable-interfaces"]],"Discovering Interfaces":[[16,"discovering-interfaces"]],"Discovery Parameters":[[8,"discovery-parameters"]],"Distributed Development":[[1,null]],"Distribution Without Intermediaries":[[1,"distribution-wiLine truncated
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Programs Using Reticulum - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Programs Using Reticulum - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -594,7 +595,7 @@ when link throughput is counted in a few hundreds of bits per second.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Support Reticulum - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Support Reticulum - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -382,7 +383,7 @@ circumstances, so we rely on old-fashioned human feedback.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
<head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="index" title="Index" href="genindex.html"><link rel="search" title="Search" href="search.html"><link rel="next" title="Communications Hardware" href="hardware.html"><link rel="prev" title="Using Reticulum on Your System" href="using.html">
|
||||
<link rel="index" title="Index" href="genindex.html"><link rel="search" title="Search" href="search.html"><link rel="next" title="Communications Hardware" href="hardware.html"><link rel="prev" title="Protecting Open Networks" href="protecting.html">
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Understanding Reticulum - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Understanding Reticulum - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -1030,14 +1031,14 @@ those risks are acceptable to you.</p>
|
||||
</div>
|
||||
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
|
||||
</a>
|
||||
<a class="prev-page" href="using.html">
|
||||
<a class="prev-page" href="protecting.html">
|
||||
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
|
||||
<div class="page-info">
|
||||
<div class="context">
|
||||
<span>Previous</span>
|
||||
</div>
|
||||
|
||||
<div class="title">Using Reticulum on Your System</div>
|
||||
<div class="title">Protecting Open Networks</div>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
@@ -1120,7 +1121,7 @@ those risks are acceptable to you.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
+31
-16
@@ -3,11 +3,11 @@
|
||||
<head><meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="index" title="Index" href="genindex.html"><link rel="search" title="Search" href="search.html"><link rel="next" title="Understanding Reticulum" href="understanding.html"><link rel="prev" title="Programs Using Reticulum" href="software.html">
|
||||
<link rel="index" title="Index" href="genindex.html"><link rel="search" title="Search" href="search.html"><link rel="next" title="Protecting Open Networks" href="protecting.html"><link rel="prev" title="Programs Using Reticulum" href="software.html">
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Using Reticulum on Your System - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Using Reticulum on Your System - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -443,10 +444,12 @@ configuration file is created. The default configuration looks like this:</p>
|
||||
change anything, and you may already be connected to a wider network. If not,
|
||||
you will probably need to add relevant <em>interfaces</em> to the configuration, in
|
||||
order to communicate with other systems.</p>
|
||||
<p>You can generate a much more verbose configuration example by running the command:</p>
|
||||
<p>The example above does not document all the available options, only the basics.
|
||||
To explore all the various configuration options available, you can generate a
|
||||
much more verbose and complete configuration example by running the command:</p>
|
||||
<p><code class="docutils literal notranslate"><span class="pre">rnsd</span> <span class="pre">--exampleconfig</span></code></p>
|
||||
<p>The output includes examples for most interface types supported
|
||||
by Reticulum, along with additional options and configuration parameters.</p>
|
||||
<p>The output includes examples for most interface types supported by Reticulum,
|
||||
along with additional options and configuration parameters.</p>
|
||||
<p>It is a good idea to read the comments and explanations in the above default config.
|
||||
It will teach you the basic concepts you need to understand to configure your network.
|
||||
Once you have done that, take a look at the <a class="reference internal" href="interfaces.html#interfaces-main"><span class="std std-ref">Interfaces</span></a> chapter
|
||||
@@ -821,7 +824,7 @@ and simply running the program in listener mode:</p>
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>$ rncp --fetch ~/path/to/file.tgz 73cbd378bb0286ed11a707c13447bb1e
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The default identity file is stored in <code class="docutils literal notranslate"><span class="pre">~/.reticulum/identities/rncp</span></code>, but you can use
|
||||
<p>The default identity file is stored in <code class="docutils literal notranslate"><span class="pre">~/.reticulum/storage/identities/rncp</span></code>, but you can use
|
||||
another one, which will be created if it does not already exist</p>
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>$ rncp ~/path/to/file.tgz 73cbd378bb0286ed11a707c13447bb1e -i /path/to/identity
|
||||
</pre></div>
|
||||
@@ -891,7 +894,7 @@ at the <a class="reference internal" href="#using-rnsh"><span class="std std-ref
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>$ rnx 7a55144adf826958a9529a3bcf08b149 -x
|
||||
</pre></div>
|
||||
</div>
|
||||
<p>The default identity file is stored in <code class="docutils literal notranslate"><span class="pre">~/.reticulum/identities/rnx</span></code>, but you can use
|
||||
<p>The default identity file is stored in <code class="docutils literal notranslate"><span class="pre">~/.reticulum/storage/identities/rnx</span></code>, but you can use
|
||||
another one, which will be created if it does not already exist</p>
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>$ rnx 7a55144adf826958a9529a3bcf08b149 -i /path/to/identity -x
|
||||
</pre></div>
|
||||
@@ -1065,9 +1068,10 @@ the remote process, rather than always returning <code class="docutils literal n
|
||||
seconds. By default, the timeout matches the Reticulum path request timeout.</p></li>
|
||||
</ul>
|
||||
<p><strong>Identity & Destination</strong></p>
|
||||
<p>The default identity file for <code class="docutils literal notranslate"><span class="pre">rnsh</span></code> is stored at
|
||||
<code class="docutils literal notranslate"><span class="pre">~/.reticulum/identities/rnsh</span></code>, but you can specify a different one with the
|
||||
<code class="docutils literal notranslate"><span class="pre">-i</span></code> option, which will be created if it does not already exist:</p>
|
||||
<p>The default initiator identity file for <code class="docutils literal notranslate"><span class="pre">rnsh</span></code> is stored at
|
||||
<code class="docutils literal notranslate"><span class="pre">~/.rns/identity</span></code> (default listener identity is in <code class="docutils literal notranslate"><span class="pre">~/.rns/identity.default</span></code>),
|
||||
but you can specify a different one with the <code class="docutils literal notranslate"><span class="pre">-i</span></code> option, which will be created if
|
||||
it does not already exist:</p>
|
||||
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>$ rnsh -l -i /path/to/identity
|
||||
</pre></div>
|
||||
</div>
|
||||
@@ -1241,6 +1245,15 @@ section of this manual.</p>
|
||||
<li><p>Maintain connectivity to RNS instances with unknown or changing IP addresses</p></li>
|
||||
</ul>
|
||||
<p>Discovered interfaces can be <strong>auto-connected</strong> by Reticulum, which makes it possible to create setups where an arbitrary interface can act simply as a bootstrap connection, that can be torn down again once more suitable interfaces have been discovered and connected.</p>
|
||||
<div class="admonition important">
|
||||
<p class="admonition-title">Important</p>
|
||||
<p>While it might be tempting to configure Reticulum to auto-connect dozens of interfaces, this will not provide you with any benefit. It will also waste the limited resources of transport node operators. In almost all situations, using 2-3 auto-connected interfaces will be sufficient.</p>
|
||||
<p><strong>Remember</strong>: A deeper, more branched topology is <em>much</em> more efficient than a completely flat fan-out, where everyone connects to everyone!</p>
|
||||
<p>For <strong>devices that connect directly</strong> to the distributed backbone, such as phones and other mobile devices, use one or two auto-connects - or a fixed node you that you like, and an auto-connect as redundant backup.</p>
|
||||
<p>For a transport <strong>node in your home</strong>, serving all devices within it, 2 or 3 autoconnects will be reasonable.</p>
|
||||
<p>For a <strong>fast boundary node</strong> that sits between a large, internal network with hundreds of active destinations, you can consider using five to six auto-connects. The same is a sensible number for general-purpose transport-providing backbone nodes on the public internet.</p>
|
||||
<p>In extreme cases, you <em>can</em> consider using up to 12 auto-connected interfaces. Almost nobody will need this, but there are edge cases where it could potentially be useful. Do not auto-connect that wide unless you are prepared and capable of processing some serious traffic.</p>
|
||||
</div>
|
||||
<p>The interface discovery mechanism uses announces sent over Reticulum itself, and supports both publicly readable interfaces and private, encrypted discovery, that can only be decoded by specified <em>network identities</em>. It is also possible to specify which network identities should be considered valid sources for discovered interfaces, so that interfaces published by unknown entities are ignored.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
@@ -1431,7 +1444,7 @@ remote_management_allowed = 9fb6d773498fb3feda407ed8ef2c3229, 2d882c5586e548d79b
|
||||
<p><strong>Federation and Trust</strong></p>
|
||||
<p>The blackhole system relies on the trust relationship between the subscriber and the publisher. By subscribing to a source, you are implicitly trusting that source to only block identities that are genuinely detrimental to the network.</p>
|
||||
<p>As the ecosystem matures, this system is designed to integrate with <strong>Network Identities</strong>. This allows communities to verify that a published blackhole list is actually provided by a specific network or organization with a certain level of reputation and trustworthiness, adding a layer of cryptographic trust to the federation process. This prevents malicious actors from publishing fake lists intended to censor legitimate traffic.</p>
|
||||
<p>For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative.</p>
|
||||
<p>For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative overhead.</p>
|
||||
</section>
|
||||
</section>
|
||||
<section id="improving-system-configuration">
|
||||
@@ -1497,6 +1510,7 @@ Type=simple
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
User=USERNAMEHERE
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=rnsd --service
|
||||
|
||||
[Install]
|
||||
@@ -1531,6 +1545,7 @@ After=default.target
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=RNS_BIN_DIR/rnsd --service
|
||||
|
||||
[Install]
|
||||
@@ -1558,12 +1573,12 @@ systemctl --user enable rnsd.service
|
||||
<footer>
|
||||
|
||||
<div class="related-pages">
|
||||
<a class="next-page" href="understanding.html">
|
||||
<a class="next-page" href="protecting.html">
|
||||
<div class="page-info">
|
||||
<div class="context">
|
||||
<span>Next</span>
|
||||
</div>
|
||||
<div class="title">Understanding Reticulum</div>
|
||||
<div class="title">Protecting Open Networks</div>
|
||||
</div>
|
||||
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
|
||||
</a>
|
||||
@@ -1650,7 +1665,7 @@ systemctl --user enable rnsd.service
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>What is Reticulum? - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>What is Reticulum? - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1"><a class="reference internal" href="zen.html">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -506,7 +507,7 @@ network, and vice versa.</p>
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="prefetch" href="_static/rns_logo_512.png" as="image">
|
||||
|
||||
<!-- Generated with Sphinx 8.2.3 and Furo 2025.09.25.dev1 -->
|
||||
<title>Zen of Reticulum - Reticulum Network Stack 1.5.5 documentation</title>
|
||||
<title>Zen of Reticulum - Reticulum Network Stack 1.6.1 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=580074bf" />
|
||||
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
|
||||
@@ -180,7 +180,7 @@
|
||||
</label>
|
||||
</div>
|
||||
<div class="header-center">
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.5.5 documentation</div></a>
|
||||
<a href="index.html"><div class="brand">Reticulum Network Stack 1.6.1 documentation</div></a>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<div class="theme-toggle-container theme-toggle-header">
|
||||
@@ -204,7 +204,7 @@
|
||||
<img class="sidebar-logo" src="_static/rns_logo_512.png" alt="Logo"/>
|
||||
</div>
|
||||
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.5.5 documentation</span>
|
||||
<span class="sidebar-brand-text">Reticulum Network Stack 1.6.1 documentation</span>
|
||||
|
||||
</a><form class="sidebar-search-container" method="get" action="search.html" role="search">
|
||||
<input class="sidebar-search" placeholder="Search" name="q" aria-label="Search">
|
||||
@@ -218,6 +218,7 @@
|
||||
<li class="toctree-l1 current current-page"><a class="current reference internal" href="#">Zen of Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="software.html">Programs Using Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="using.html">Using Reticulum on Your System</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="protecting.html">Protecting Open Networks</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="understanding.html">Understanding Reticulum</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="hardware.html">Communications Hardware</a></li>
|
||||
<li class="toctree-l1"><a class="reference internal" href="interfaces.html">Configuring Interfaces</a></li>
|
||||
@@ -678,7 +679,7 @@ Imagine a messaging app. You write it once. It works on a laptop connected to fi
|
||||
|
||||
</aside>
|
||||
</div>
|
||||
</div><script src="_static/documentation_options.js?v=b8aeccfa"></script>
|
||||
</div><script src="_static/documentation_options.js?v=d6a008b6"></script>
|
||||
<script src="_static/doctools.js?v=9bcbadda"></script>
|
||||
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
|
||||
<script src="_static/scripts/furo.js?v=46bd48cc"></script>
|
||||
|
||||
@@ -805,6 +805,9 @@ def server(configpath):
|
||||
"linkexample"
|
||||
)
|
||||
|
||||
# We can optionally configure a link request stamp cost
|
||||
server_destination.set_link_cost(14.2)
|
||||
|
||||
# We configure a function that will get called every time
|
||||
# a new client creates a link to this destination.
|
||||
server_destination.set_link_established_callback(client_connected)
|
||||
|
||||
+16
-3
@@ -566,7 +566,7 @@ To enable the page node, add the following to your `~/.rngit/config` file:
|
||||
|
||||
```text
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
serve_nomadnet = yes
|
||||
```
|
||||
|
||||
When the page node is enabled, `rngit` will listen on a Nomad Network node destination in addition to the Git repository destination. You can view the destination hash by running:
|
||||
@@ -580,6 +580,15 @@ Repositories Destination : <0d7334d411d00120cbad24edf355fdd2>
|
||||
Nomad Network Destination : <50824b711717f97c2fb1166ceddd5ea9>
|
||||
```
|
||||
|
||||
You can configure the destination stamp value and required link establishment cost with the following options:
|
||||
|
||||
```text
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
stamp_value = 25.0
|
||||
link_cost = 18.0
|
||||
```
|
||||
|
||||
### Accessing Repository Pages
|
||||
|
||||
Once the page node is running, you can access it from any Nomad Network client by connecting to the Nomad Network destination. The page node provides the following views:
|
||||
@@ -659,8 +668,8 @@ By default, the page node uses Nerd Font icons. If you prefer simpler icons or y
|
||||
|
||||
```text
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
```
|
||||
|
||||
### Repository Statistics
|
||||
@@ -686,6 +695,8 @@ A complete node configuration might look like this:
|
||||
node_name = My Git Node
|
||||
announce_interval = 360
|
||||
record_stats = yes
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.5
|
||||
|
||||
[repositories]
|
||||
public = /var/git/public
|
||||
@@ -698,6 +709,8 @@ A complete node configuration might look like this:
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = no
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.7
|
||||
```
|
||||
|
||||
## Verified Releases
|
||||
|
||||
@@ -130,6 +130,18 @@ to participate in the development of Reticulum itself.
|
||||
* [Improving System Configuration](using.md#improving-system-configuration)
|
||||
* [Fixed Serial Port Names](using.md#fixed-serial-port-names)
|
||||
* [Reticulum as a System Service](using.md#reticulum-as-a-system-service)
|
||||
* [Protecting Open Networks](protecting.md)
|
||||
* [Cryptographic Stamps](protecting.md#cryptographic-stamps)
|
||||
* [Base Primitives](protecting.md#base-primitives)
|
||||
* [On-Network Types](protecting.md#on-network-types)
|
||||
* [Configuring Stamps](protecting.md#configuring-stamps)
|
||||
* [Filtering & QoS](protecting.md#filtering-qos)
|
||||
* [Instance Configuration](protecting.md#id1)
|
||||
* [Blocking Transport Nodes](protecting.md#blocking-transport-nodes)
|
||||
* [For Developers](protecting.md#id2)
|
||||
* [Ingress & Burst Control](protecting.md#ingress-burst-control)
|
||||
* [Blackhole Management](protecting.md#blackhole-management)
|
||||
* [Fast-Flap Blocking](protecting.md#fast-flap-blocking)
|
||||
* [Understanding Reticulum](understanding.md)
|
||||
* [Motivation](understanding.md#motivation)
|
||||
* [Goals](understanding.md#goals)
|
||||
|
||||
@@ -910,13 +910,6 @@ Reticulum includes a powerful system for publishing your local interfaces to the
|
||||
|
||||
When an interface is made **discoverable**, your Reticulum instance will periodically broadcast an announce packet containing the connection details and parameters required for other peers to establish a connection. These announces are propagated over the network using the standard Reticulum announce mechanism using the `rnstransport.discovery.interface` destination type.
|
||||
|
||||
#### NOTE
|
||||
To use the interface discovery functionality, the `LXMF` module must be installed in your Python environment. You can install it using pip:
|
||||
|
||||
```sh
|
||||
pip install lxmf
|
||||
```
|
||||
|
||||
### Enabling Discovery
|
||||
|
||||
Interface discovery is enabled on a per-interface basis. To make a specific interface discoverable, you must add the `discoverable` option to that interface’s configuration block and set it to `yes`.
|
||||
@@ -1405,11 +1398,11 @@ but all the parameters are exposed for configuration if needed.
|
||||
> sub-interfaces when a new client connects.
|
||||
>
|
||||
> * The `ic_burst_freq_new` option sets the maximum announce ingress
|
||||
> frequency for newly spawned interfaces. Defaults to `3.5`
|
||||
> frequency for newly spawned interfaces. Defaults to `3.0`
|
||||
> announces per second.
|
||||
>
|
||||
> * The `ic_burst_freq` option sets the maximum announce ingress
|
||||
> frequency for other interfaces. Defaults to `12` announces
|
||||
> frequency for other interfaces. Defaults to `10.0` announces
|
||||
> per second.
|
||||
>
|
||||
> > *If an interface exceeds its burst frequency, incoming announces
|
||||
@@ -1417,21 +1410,21 @@ but all the parameters are exposed for configuration if needed.
|
||||
> > not processed until later.*
|
||||
> * The `ic_max_held_announces` option sets the maximum amount of
|
||||
> unique announces that will be held in the queue. Any additional
|
||||
> unique announces will be dropped. Defaults to `256` announces.
|
||||
> unique announces will be dropped. Defaults to `64` announces.
|
||||
>
|
||||
> * The `ic_burst_hold` option sets how much time (in seconds) must
|
||||
> pass after the burst frequency drops below its threshold, for the
|
||||
> announce burst to be considered cleared. Defaults to `60`
|
||||
> announce burst to be considered cleared. Defaults to `15`
|
||||
> seconds.
|
||||
>
|
||||
> * The `ic_burst_penalty` option sets how much time (in seconds) must
|
||||
> pass after the burst is considered cleared, before held announces can
|
||||
> start being released from the queue. Defaults to `5*60`
|
||||
> start being released from the queue. Defaults to `15`
|
||||
> seconds.
|
||||
>
|
||||
> * The `ic_held_release_interval` option sets how much time (in seconds)
|
||||
> must pass between releasing each held announce from the queue. Defaults
|
||||
> to `30` seconds.
|
||||
> to `5` seconds.
|
||||
>
|
||||
|
||||
All of the above settings can be configured both as instance-wide defaults
|
||||
|
||||
@@ -0,0 +1,371 @@
|
||||
# Protecting Open Networks
|
||||
|
||||
#### IMPORTANT
|
||||
Reticulum is currently transitioning towards full, on-network stamp verification and enforcement via a phased transition:
|
||||
|
||||
- The `1.6.0` release completely implements the required mechanisms, and will start excercising the verification system in the transport backend. By default, `1.6.0` does not enable full stamp generation, emission and enforcement, but all of these options can be early-enabled in the configuration.
|
||||
- The `1.6.1` release will enable full stamp generation and emission of all types by default, but will leave the *enforcement* a configurable option.
|
||||
- The `1.6.2` release will complete the transition, activating full stamp enforcement across all the systems.
|
||||
|
||||
The stated version numbers are the *intended* release sequence. If any issues or implementation problems are found during the initial network deployments, the transition points may be pushed later than this plan by interim releases.
|
||||
|
||||
While you can create entirely closed-off and private networks with Reticulum, the protocol itself is open and permissionless. On widely interconnected networks, anyone can create identities and globally reachable destinations without external permission or approval, and establish links anonymously over the network.
|
||||
|
||||
Such capabilities are powerful, and a required characteristic of a truly functional communications fabric, but also raise very large challenges, that have been almost impossible to solve in legacy networking technologies.
|
||||
|
||||
Reticulum approaches this particular problem, like most others, by employing cryptographic principles. This provides a comprehensive, multi-layered repertoire of defense mechanisms, which can be composed and employed in very effective ways.
|
||||
|
||||
In contrast to other networking paradigms, these mechanisms do not have to be bolted on to the application layer in hindsight, but are a core part of the protocol itself, which means that they can be applied universally and effectively:
|
||||
|
||||
> All nodes help combat spam and network abuse, according to the rules *set by the actual owners of supplied resources* - not by any bureaucracy or external authority.
|
||||
|
||||
> Rules and requirements can be adjusted live, dynamically and directly, and by those that actually operate and run the infrastructure and services.
|
||||
|
||||
The system has been designed so that it becomes very cheap computationally for resource-providing nodes to verify or reject traffic, and very expensive for malicious nodes to abuse the shared resources provided by the network’s operators.
|
||||
|
||||
## Cryptographic Stamps
|
||||
|
||||
All networking primitives that consume shared network resources are gated by *stamps*. A stamp is compact, cryptographic token that proves that a certain amount of computation and energy has been expended in its creation.
|
||||
|
||||
The amount of such computation required for a stamp to be considered valid can be configured individually by the operator of the resource being made available, whether that is network transport, a node providing information for retrieval, a shared voice room, or something else entirely.
|
||||
|
||||
While the core functionality is completely automatic, and handled by Reticulum itself, the primitives are made available at the application layer API as well, so that developers can use them to implement further protections, if required by their usage scenarios. In most cases, however, simply setting the target *values* and required *costs* for the built-in mechanisms will be sufficient.
|
||||
|
||||
The *value* of a stamp is a decimal representation of how difficult a stamp was to create, on a scale from `0.0` to `100.0`. The scale is **exponential**. An increase of one point is equal to *doubling* the average compute time required. Fractional values are supported, such as `14.125`.
|
||||
|
||||
Internally, the fractional part is quantized to `256` different values, giving an approximately `0.27%` difficulty increase per step. You can use any decimal number when configuring stamps, such as `9.3691` and you do not have to worry about “landing on” the correct step values. Reticulum will automatically handle the quantization, wire-transport representation and value comparisons.
|
||||
|
||||
The term *cost* is used everywhere a stamp value *requirement* is configured or specified. In general, *value* refers to the actual, determined value of a given stamp, *cost* refers to a value requirement.
|
||||
|
||||
### Base Primitives
|
||||
|
||||
Reticulum provides two types of base stamp primitives:
|
||||
|
||||
> * **Detached stamps** can be tied to any external information, and are useful for stamping both static information and for one-time verification purposes. The stamp itself is a detached, short binary sequence, typically 14 to 32 bytes, that can be verified directly against the stamped material.
|
||||
|
||||
> They can be configured from relatively easy to compute, even for embbedded systems and microcontrollers, all the way to something that is practically impossible, even with all the compute and memory on the planet.
|
||||
> * **Embedded stamps** are tied directly to a Reticulum Identity keyset, and embedded within it. The keyset itself *contains* the stamp, and there is no external, detached byte sequence for them.
|
||||
|
||||
> Anyone can verify the value of an identity-embedded stamp simply from the public key material of the identity.
|
||||
|
||||
### On-Network Types
|
||||
|
||||
The base primitives are used to implement scenario-specific network-level primitives that, if configured correctly, make spam and network abuse expensive, but validation and enforcement cheap and efficient.
|
||||
|
||||
> * **Destination Stamps** are detached stamps associated with reticulum destinations. They are included in all announces sent by a destination, and by verifying that their value matches a transport node’s cost requirement, they can be either accepted for rebroadcast onto the network, or rejected and dropped.
|
||||
|
||||
> Destination stamps are *one-time* generations, and are reusable across announces. They limit the number of *new* destinations that can be created, and makes it expensive to spam a network with destinations that do not provide anything meaningful. As such, these stamps will typically target relatively high values, and their cost requirements should be set accordingly.
|
||||
|
||||
> A generation time for such stamps in *minutes* rather than seconds can very well be reasonable on large, open-access networks. Due to their detached nature, they can also be pre-generated off-device (and do not require the private key material for generation), so that even low-powered nodes, such as microcontrollers, can use high-value destination stamps, by having them generated and loaded externally as a one-time procedure.
|
||||
> * **Path Request Stamps** are also detached stamps, but generated *individually* for every path request emitted on the network. These will typically have a much lower cost requirement than destination stamps, but if a node is overwhelmed by path requests, it can be tuned higher.
|
||||
|
||||
> The stamp is generated against the individually unique *emission*, so that unstamped or low-value path requests for a destination cannot disrupt the resolution of legitimate ones toward that same destination.
|
||||
> * **Link Request Stamps** are embedded stamps, carried in the ephemeral link request keyset. They are therefore completely transparent to the network, but can still be verified extremely quickly by any node along the link request path, who can then make a decision on whether or not to transport it.
|
||||
|
||||
> Link request cost targets are set by the *endpoint destinations individually*. Every destination that includes a stamp in its announces will also include link request cost signalling. This means that any node that hears an announce from the destination will also know what link request stamp value to target, when establishing links to that destination.
|
||||
|
||||
> Furthermore, spam and link request abuse can be filtered before even reaching the destination, if at least one node along the path validates the link request stamp value and cost requirement.
|
||||
|
||||
All of the stamp primitives, functionality and on-wire signalling is *transparent and backwards-compatible* with older versions of Reticulum transport nodes. This means, that even if a node doesn’t itself understand stamp functionality, it will still transport all the required information. Stamped announces, path and link requests can cross older, non stamp-aware network segments transparently and unaffected.
|
||||
|
||||
### Configuring Stamps
|
||||
|
||||
Reticulum, and its included utilities, provide sane default cost requirements and value targets for the different types of network stamps, but it is entirely up to the operator whether to follow the defaults. All of them are configurable on a per-node, per-application and per-destination basis.
|
||||
|
||||
#### Instance Configuration
|
||||
|
||||
In reality, different kinds of networks will want to configure different kinds of costs and value targets for their use. For instance-wide defaults and settings, you can configure these in the `[stamps]` section of the Reticulum configuration file:
|
||||
|
||||
> * The `destination_cost` option sets the default required stamp
|
||||
> cost for announced destinations to be accepted, and have their
|
||||
> announces propagated by this node. Defaults to `23.5`.
|
||||
>
|
||||
> * The `destination_value` option sets the default stamp value that
|
||||
> this instance will target when generating new destination stamps.
|
||||
> An application can request higher targets for destinations that it
|
||||
> creates, but a requested lower value will always be clamped to the
|
||||
> configured default as a minimum. Defaults to `25.0`.
|
||||
>
|
||||
> > *Destination stamps are one-time generations per destination, so it
|
||||
> > is generally a good idea to target a slightly higher value than the
|
||||
> > minimum required cost of the networks you want the destination to
|
||||
> > be reachable on.*
|
||||
> * The `pr_cost` option sets the required stamp cost for incoming
|
||||
> path requests. Defaults to `15.8`.
|
||||
>
|
||||
> * The `pr_value` option sets the target stamp value for path
|
||||
> request stamps generated by this instance. Defaults to `15.8`.
|
||||
>
|
||||
> * The `lr_cost` option sets the default link request stamp cost,
|
||||
> that destinations created on this instance will require. This
|
||||
> value can be freely overridden by applications that specify their
|
||||
> own link request cost requirements, and is solely used as the
|
||||
> default if no such specification is provided. Defaults to `12.5`.
|
||||
>
|
||||
> * The `lr_stamp_timeout` and `pr_stamp_timeout` options set the
|
||||
> maximum amount of time, in seconds, to spend while attempting to
|
||||
> generate link and path request stamps respectively. If a stamp is
|
||||
> not generated within this timespan, the generation is cancelled,
|
||||
> and the link request or path request fails. Defaults to `15`
|
||||
> seconds for both options.
|
||||
>
|
||||
> * The `stamp_destinations` option enables generation and emission
|
||||
> of destination stamps in announces. This is a transitory option.
|
||||
> It will become mandatory and enabled by default in RNS `1.6.1`.
|
||||
>
|
||||
> * The `stamp_prs` option enables stamping of path requests emitted
|
||||
> by this instance. This is a transitory option. It will become
|
||||
> mandatory and enabled by default in RNS `1.6.1`.
|
||||
>
|
||||
> * The `always_stamp_lrs` option will stamp *all* outgoing link
|
||||
> requests, even to destinations that have not announced a link
|
||||
> request cost (and will, in that case, use the configured or
|
||||
> default link request cost). This option is mostly useful for
|
||||
> testing and diagnostics. In general use, Reticulum will handle
|
||||
> link request stamping and cost targets automatically.
|
||||
>
|
||||
> * The `enforce_stamps` option allows early activation of stamp
|
||||
> enforcement. When enabled, announces and path requests that do
|
||||
> not meet the configured cost requirements are dropped, and link
|
||||
> requests with insufficient stamps are ignored. This is a transitory
|
||||
> option. It will become mandatory and enabled by default in RNS
|
||||
> `1.6.2`.
|
||||
>
|
||||
|
||||
An example of customised stamp cost and value configuration follows below:
|
||||
|
||||
```ini
|
||||
[stamps]
|
||||
stamp_destinations = yes
|
||||
stamp_prs = yes
|
||||
|
||||
destination_cost = 24.8
|
||||
destination_value = 26.25
|
||||
|
||||
pr_cost = 15.8
|
||||
pr_value = 16.45
|
||||
```
|
||||
|
||||
Stamp cost requirements can also be configured on a per-interface basis:
|
||||
|
||||
```ini
|
||||
[[Public Gateway]]
|
||||
type = BackboneInterface
|
||||
mode = gateway
|
||||
listen_on = 0.0.0.0
|
||||
port = 4242
|
||||
|
||||
destination_cost = 25.0
|
||||
pr_cost = 17.2
|
||||
|
||||
[[Local RNode]]
|
||||
type = RNodeInterface
|
||||
port = /dev/ttyUSB0
|
||||
|
||||
# Much lower requirements
|
||||
# for the local network.
|
||||
destination_cost = 11.2
|
||||
pr_cost = 5.0
|
||||
```
|
||||
|
||||
#### For Developers
|
||||
|
||||
Applications can dynamically set their own stamp values and required link requests costs at runtime. Whenever the values are adjusted, the destination will have to send an announce for the updated information to become known by the rest of the network.
|
||||
|
||||
If you are setting these values at destination creation time, ensure that they are set *immediately* after the destination is instantiated, as Reticulum may queue internal, instance-local announces for the destination shortly after creation, so that the local shared instance and its clients are aware of the newly created destination.
|
||||
|
||||
```python
|
||||
# Create a new destination
|
||||
my_destination = RNS.Destination(
|
||||
my_identity,
|
||||
RNS.Destination.IN,
|
||||
RNS.Destination.SINGLE,
|
||||
"myapp", "service"
|
||||
)
|
||||
|
||||
# Configure stamps
|
||||
my_destination.set_value(30.0)
|
||||
my_destination.set_link_cost(15.0)
|
||||
```
|
||||
|
||||
Dynamically adjusting link request costs is a viable and intended mechanism for mitigating resource abuse, scraping, DoS attempts and other malicious behaviour. An application may implement mechanisms to statically or dynamically raise link request costs under certain conditions.
|
||||
|
||||
It is also possible for application code to directly get the destination value and link request cost for any known destination:
|
||||
|
||||
```python
|
||||
# Get the value of a known destination
|
||||
RNS.Identity.recall_stamp_value(destination_hash)
|
||||
|
||||
# Get the current link cost requirement
|
||||
# of a known destination
|
||||
RNS.Identity.recall_link_cost(destination_hash)
|
||||
```
|
||||
|
||||
An `Identity` can be created with an embedded stamp value, by passing the target value at instantiation time:
|
||||
|
||||
```python
|
||||
# Create a new, stamped identity
|
||||
my_identity = RNS.Identity(value=24.0)
|
||||
|
||||
# Get the value of any known identity
|
||||
another_identity.get_value()
|
||||
```
|
||||
|
||||
As with destination stamps, this is a one-time generation procedure, that happens at Identity creation. Once an identity is created with an embedded stamp, its value *cannot* be upgraded at a later point as with detached stamps.
|
||||
|
||||
## Filtering & QoS
|
||||
|
||||
In addition to the stamp functionality explored above, Reticulum includes filtering options that allow operators to explicitly deny or allow certain destination *types* across an entire instance.
|
||||
|
||||
After filtering, all packets that are ultimately allowed into the transport engine, are sorted into prioritized QoS queues, which are drained and processed in priority order.
|
||||
|
||||
This provides a powerful system for both filtering, classifying and ensuring latency and service quality for the traffic and application types a node operator wants to provide.
|
||||
|
||||
### Instance Configuration
|
||||
|
||||
The filtering subsystem can operate in two modes:
|
||||
|
||||
> * **Ignored Mode** will allow any destination type in the instance, *except* for those that have been explicitly added to the `ignored_types` list. This mode is useful for blocking the traffic of specific destination types from being transported across the instance.
|
||||
>
|
||||
> * **Required Only Mode** will allow *only* the destination types explicitly defined as required, and ignore *all* other types. A base set of required destination types can be defined instance-wide in the `allowed_types` list.
|
||||
>
|
||||
> In addition, any application using the shared instance can temporarily request required destination types for its use. Applications that request required destination types will automatically have them granted, unless they are included in the `ignored_types` list.
|
||||
>
|
||||
|
||||
The filtering defaults and base settings are configured in the `[filter]` section of the configuration file. For example, it is possible to explicitly ignore a series of destination types, while also limiting hop reach to a more local topology.
|
||||
|
||||
If you do not know the human readable destination type aspects for a destination type you want to ignore, you can also add entries as 10-byte (20 hexadecimal character) hashes using the `<c4ace368262d845c9dd3>` format.
|
||||
|
||||
```ini
|
||||
[filter]
|
||||
hop_limiter = 14
|
||||
ignored_types = application.that.spams, traffic.heavy.service, <c4ace368262d845c9dd3>
|
||||
```
|
||||
|
||||
In some situations, you may want to allow *only* certain destination types. If, for example, you are creating a high-performance transport node intended to handle thousands of simultaneous voice calls at minimal latency, a configuration might look something like:
|
||||
|
||||
```ini
|
||||
[filter]
|
||||
required_only = yes
|
||||
allowed_types = lxst.telephony
|
||||
```
|
||||
|
||||
The filtering subsystem provided in RNS `1.6.0` is functional and useful, but at an early stage, and relatively basic. In the upcoming releases, it will be expanded into a much more comprehensive and flexible system, that will include custom QoS and traffic class tagging, advanced rule definitions and more.
|
||||
|
||||
#### IMPORTANT
|
||||
As the filtering and QoS system is developed and matures, the `required_only` mode will become the default operating mode for non-transport instances, since applications can already now dynamically request what destination types they are interested in.
|
||||
|
||||
This ensures that a local, non-transport node (running on resource-limited hardware, for example), does not have to process announces for, and waste CPU and memory on destination types that are completely irrelevant to it. It also greatly reduces power consumption on battery-powered and mobile devices, while they are connected to large and busy networks.
|
||||
|
||||
If you are a developer, see the following section.
|
||||
|
||||
### Blocking Transport Nodes
|
||||
|
||||
Misbehaving, spamming and broken transport nodes can be completely blocked using the Blackhole system. First, obtain the Transport Identity hash of a misbehaving transport node, using `rnstatus`:
|
||||
|
||||
```txt
|
||||
$ rnstatus -FATa "71.29.190.5"
|
||||
|
||||
BackboneInterface[Client on Bern IPv4/71.29.190.5:37062]
|
||||
Status : Up
|
||||
Mode : Gateway
|
||||
Rate : 250.00 Mbps, MTU 65536
|
||||
Running : Unknown implementation
|
||||
Rem.Tr.ID : <a0c289d131c7bfa8d5ddc8b652c0f40d>
|
||||
Held : 64 announces
|
||||
Violatns. : 382 protocol
|
||||
Flt. Hits : 92
|
||||
Announces : 147174↓ 11193↑ total, 140554 filtered
|
||||
1.2 Hz↑ (↓0% / ↑0% of flow)
|
||||
7.8 Hz↓ (t:6h/p:0s/g:1) burst for 4h, 54m and 42.69s
|
||||
Traffic : ↑4.75 MB 0 bps
|
||||
↓1.50 MB 0 bps
|
||||
Filtered : ↑0 B 0 bps
|
||||
↓55.43 MB 380.14 Kbps
|
||||
```
|
||||
|
||||
You can then block it by its Transport ID:
|
||||
|
||||
```txt
|
||||
$ rnpath -B a0c289d131c7bfa8d5ddc8b652c0f40d --reason "Broken node"
|
||||
|
||||
Blackholed identity a0c289d131c7bfa8d5ddc8b652c0f40d
|
||||
```
|
||||
|
||||
Its connection will be immediately torn down, and further reconnection attempts will be ignored.
|
||||
|
||||
### For Developers
|
||||
|
||||
At some point during the `1.6.x` release cycle, RNS will move to using the `required_only` mode for *non-transport* instances by default. This means that applications will, in most cases, have to request what types of destinations they are interested in receiving announces from.
|
||||
|
||||
If your application is only using the utility primitives included in RNS, or established protocols such as LXMF or LXST, **there is nothing you have to do**. The protocol primitives *themselves* request their required destination types, and this is the general pattern to follow here:
|
||||
|
||||
- If an application uses a common protocol or primitive, it is the importable primitive, protocol module, or relevant internal functionality that should request destination type requirements, at the point where they are actually needed.
|
||||
- Higher level application layers should not have to guess at or request destination types, unless it explicitly creates outbound destinations that are not covered by any already-used protocols or primitives.
|
||||
|
||||
If your protocol or application needs to receive announces for a specific destination type, it is very easy to register it. For example, at startup (or when the destination type is actually required), simply run something like:
|
||||
|
||||
```python
|
||||
RNS.Reticulum.get_instance().wants_destination_type("my_app.service")
|
||||
```
|
||||
|
||||
You do not *have to* explicitly deregister destination type requirements. Reticulum automatically deregisters when the shared instance connection for the application is torn down, but you may *want* to in certain cases, which follows the same pattern:
|
||||
|
||||
```python
|
||||
RNS.Reticulum.get_instance().unwants_destination_type("my_app.service")
|
||||
```
|
||||
|
||||
That’s really all there is to it. If you already now want to make you application more CPU, memory and battery efficient, you can tell Reticulum to start serving only required destinations to it with only a few lines of additional code. A full setup of this functionality might look something like:
|
||||
|
||||
```python
|
||||
for destination_type in self.REQUIRED_DESTINATION_TYPES:
|
||||
RNS.Reticulum.get_instance().wants_destination_type(destination_type)
|
||||
|
||||
RNS.Reticulum.get_instance().required_announces_only(True)
|
||||
```
|
||||
|
||||
Your application will now only receive, and have to process, the announces and paths that it actually cares about.
|
||||
|
||||
## Ingress & Burst Control
|
||||
|
||||
In addition to the economic incentives created by stamps, Reticulum enforces a set of hydraulic limits on how much announce traffic any peer or destination can inject into the network. These mechanisms work automatically, require no operator configuration (but can be tuned, if required), and apply equally to all peers.
|
||||
|
||||
At the most basic level, the `announce_cap` mechanism limits the bandwidth any interface will allocate to propagating announces and other network upkeep traffic, and prioritises the local topology. Destinations that rapidly re-announce are down-prioritised in the transmission queue, so attempting to gain reach through announce spam has the exact *opposite* effect.
|
||||
|
||||
On top of this, per-destination announce rate control can be configured on any interface, or as instance-wide defaults. Once configured, announces *received* for any one destination will only be re-broadcast to other interfaces at the configured target rate, no matter how often they are received. The grace option allows occasional rate violations, and a configurable penalty extends the interval between propagated announces for destinations that repeatedly exceed their target.
|
||||
|
||||
The final layer protects against bursts of announces for *newly created* destinations. If an interface receives a large influx of announces for previously unknown destinations in a short amount of time, these are held in a bounded queue, while announces for known and established destinations continue to be processed without interruption. After the burst subsides, and an additional waiting period has passed, held announces are released slowly until the queue is cleared.
|
||||
|
||||
A node that connects to a public interface, announces a large number of bogus destinations, and then disconnects, will therefore never get those destinations into path tables at all. When the interface they arrived on disappears, the held announces are simply dropped and forgotten.
|
||||
|
||||
Ingress control operates at the level of individual sub-interfaces, so one misbehaving client cannot disrupt announce processing for other clients connected to the same listener. Combined with stamps, these mechanisms are complementary:
|
||||
|
||||
Rate limiting bounds the *rate* at which abuse can occur, for everyone, while stamps make the *volume* of abuse from any actor computationally expensive.
|
||||
|
||||
Full configuration details are available in the [Announce Rate Control](interfaces.md#interfaces-announcerates) and [New Destination Rate Limiting](interfaces.md#interfaces-ingress-control) sections.
|
||||
|
||||
## Blackhole Management
|
||||
|
||||
The *blackhole* system allows any node operator or individual user to block specific identities at the transport layer.
|
||||
|
||||
Once an identity has been blackholed on a node, announces originating from *any* destination associated with that identity are dropped, and the node will refuse to transport traffic, or establish and maintain links, to the blackholed identity’s destinations.
|
||||
|
||||
It is important to understand the scope of this mechanism corrrectly. There is fundamentally **no way** to *globally* block or censor any identity or destination in Reticulum networks. A blackhole entry only applies on the network segments that enforce it, which is the exact intention. Operators retain full control over what is allowed on their own segments, while no one can impose restrictions on segments they do not operate.
|
||||
|
||||
Blackholes can be managed directly with the `rnpath` utility. Identities can be blocked (optionally with an expiry duration and a human-readable reason), unblocked, and the current local blocklist can be inspected at any time. This is well suited for immediate responses to announce spam, unwanted content or malicious behaviour observed on your own networks.
|
||||
|
||||
For anything larger than a few nodes, manual blocklist maintenance quickly becomes impractical. Reticulum therefore allows an instance to subscribe to blackhole lists published by trusted transport identities, periodically retrieving and merging them into the local list, and conversely to publish its own list to subscribers.
|
||||
|
||||
This makes it possible to federate community-maintained blocklists across large networks, with the important caveat that subscribing to a list is an act of trust in its maintainer. See the [Blackhole Management](using.md#using-blackhole-management) section for full details on local management, automated list sourcing and publishing.
|
||||
|
||||
## Fast-Flap Blocking
|
||||
|
||||
High-performance listener interfaces, such as [BackboneInterface](interfaces.md#interfaces-backbone), will automatically block *fast-flapping* clients; remote peers that repeatedly connect for a very short amount of time, and then disconnect.
|
||||
|
||||
This behaviour usually stems from attempts to dump announce or path request spam onto the network in short bursts, while rotating connections in an attempt to evade per-interface rate limits, but it can also be caused by broken implementations or automated scanning tools.
|
||||
|
||||
Such bypass attempts generally have very limited effect. Ingress limiters trigger *immediately* once rate limits are exceeded, but the behaviour still causes needless interface rotation and wasted resources on the transport instance.
|
||||
|
||||
With fast-flap blocking enabled, a client that exceeds the allowed flap grace is simply not allocated an actual interface again, for the configured block duration.
|
||||
|
||||
On the `BackboneInterface` type, fast-flap blocking is enabled by default, with sensible standard settings. All parameters can be adjusted if necessary. See the [Automated Blocking](interfaces.md#interfaces-fastflap) section of the Interfaces chapter.
|
||||
@@ -3,7 +3,7 @@
|
||||
Communication over Reticulum networks is achieved by using a simple set of classes exposed by the RNS API.
|
||||
This chapter lists and explains all classes exposed by the Reticulum Network Stack API, along with their method signatures and usage. It can be used as a reference while writing applications that utilise Reticulum, or it can be read in entirity to gain an understanding of the complete functionality of RNS from a developers perspective.
|
||||
|
||||
### `class RNS.Reticulum(configdir=None, loglevel=None, logdest=None, verbosity=None, require_shared_instance=False, shared_instance_type=None)`
|
||||
### `class RNS.Reticulum(configdir=None, loglevel=None, logdest=None, verbosity=None, require_shared_instance=False, shared_instance_type=None, enable_stamping=False, enforce_stamps=False)`
|
||||
|
||||
This class is used to initialise access to Reticulum within a
|
||||
program. You must create exactly one instance of this class before
|
||||
@@ -77,6 +77,10 @@ The default per-hop timeout value used in various timeout calculations.
|
||||
|
||||
Returns the currently running Reticulum instance.
|
||||
|
||||
#### `static get_instance_pid()`
|
||||
|
||||
Returns the main process ID of the currently running Reticulum instance.
|
||||
|
||||
#### `get_first_hop_timeout(destination)`
|
||||
|
||||
Returns a best-effort estimate of a reasonable minimum
|
||||
@@ -156,7 +160,7 @@ Returns the required stamp value for a discovered interface
|
||||
to be considered valid and remembered.
|
||||
|
||||
* **Returns:**
|
||||
The required stamp value as an integer.
|
||||
The required stamp value as a float.
|
||||
|
||||
#### `static publish_blackhole_enabled()`
|
||||
|
||||
@@ -189,7 +193,7 @@ interfaces are discovered.
|
||||
* **Returns:**
|
||||
A list of identity hashes.
|
||||
|
||||
### `class RNS.Identity(create_keys=True)`
|
||||
### `class RNS.Identity(create_keys=True, value=None)`
|
||||
|
||||
This class is used to manage identities in Reticulum. It provides methods
|
||||
for encryption, decryption, signatures and verification, and is the basis
|
||||
@@ -247,6 +251,26 @@ Recall last heard app_data for a destination hash.
|
||||
* **Returns:**
|
||||
*Bytes* containing app_data, or *None* if the destination is unknown.
|
||||
|
||||
#### `static recall_stamp_value(destination_hash)`
|
||||
|
||||
Recall last heard announce stamp value for a destination hash.
|
||||
|
||||
* **Parameters:**
|
||||
**destination_hash** – Destination hash as *bytes*.
|
||||
|
||||
* **Returns:**
|
||||
*Float*, or *None* if the destination is unknown.
|
||||
|
||||
#### `static recall_link_cost(destination_hash)`
|
||||
|
||||
Recall the link request stamp cost announced by a destination.
|
||||
|
||||
* **Parameters:**
|
||||
**destination_hash** – Destination hash as *bytes*.
|
||||
|
||||
* **Returns:**
|
||||
*Float*, or *None* if the destination is unknown or has not announced a cost.
|
||||
|
||||
#### `static full_hash(data)`
|
||||
|
||||
Get a SHA-256 hash of passed data.
|
||||
@@ -331,6 +355,11 @@ Saves the public identity to a file.
|
||||
* **Returns:**
|
||||
True if the file was saved, otherwise False.
|
||||
|
||||
#### `get_value()`
|
||||
|
||||
* **Returns:**
|
||||
The stamp value of this identity as a *float*
|
||||
|
||||
#### `get_private_key()`
|
||||
|
||||
* **Returns:**
|
||||
@@ -467,6 +496,29 @@ relevant interfaces. Application specific data can be added to the announce.
|
||||
* **app_data** – *bytes* containing the app_data.
|
||||
* **path_response** – Internal flag used by [RNS.Transport](#api-transport). Ignore.
|
||||
|
||||
#### `set_value(value)`
|
||||
|
||||
Sets the target stamp value for this destination.
|
||||
|
||||
* **Parameters:**
|
||||
**value** – The target value as a *float*.
|
||||
|
||||
#### `set_link_cost(cost)`
|
||||
|
||||
Sets the required link establishment stamp cost for this destination. Set to 0 to disable.
|
||||
|
||||
* **Parameters:**
|
||||
**cost** – The required cost as a *float*.
|
||||
|
||||
#### `get_link_cost()`
|
||||
|
||||
Returns the link request stamp cost to be announced for this
|
||||
destination, as a float. If no destination-specific cost has
|
||||
been set, the default link request cost is returned.
|
||||
|
||||
* **Returns:**
|
||||
The announced link request cost as a *float*.
|
||||
|
||||
#### `accepts_links(accepts=None)`
|
||||
|
||||
Set or query whether the destination accepts incoming link requests.
|
||||
@@ -1373,7 +1425,7 @@ blocks until the path is available, or the timeout is reached.
|
||||
* **Returns:**
|
||||
*True* if a path to the destination is found, otherwise *False*.
|
||||
|
||||
#### `static request_path(destination_hash, on_interface=None, tag=None, recursive=False)`
|
||||
#### `static request_path(destination_hash, on_interface=None, tag=None, recursive=False, ext_payload=None)`
|
||||
|
||||
Requests a path to the destination from the network. If
|
||||
another reachable peer on the network knows a path, it
|
||||
@@ -1382,6 +1434,7 @@ will announce it.
|
||||
* **Parameters:**
|
||||
* **destination_hash** – A destination hash as *bytes*.
|
||||
* **on_interface** – If specified, the path request will only be sent on this interface. In normal use, Reticulum handles this automatically, and this parameter should not be used.
|
||||
* **ext_payload** – Internal use by [RNS.Transport](#api-transport). Ignore.
|
||||
|
||||
#### `static blackhole_identity(identity_hash, until=None, reason=None)`
|
||||
|
||||
|
||||
+27
-9
@@ -178,12 +178,14 @@ change anything, and you may already be connected to a wider network. If not,
|
||||
you will probably need to add relevant *interfaces* to the configuration, in
|
||||
order to communicate with other systems.
|
||||
|
||||
You can generate a much more verbose configuration example by running the command:
|
||||
The example above does not document all the available options, only the basics.
|
||||
To explore all the various configuration options available, you can generate a
|
||||
much more verbose and complete configuration example by running the command:
|
||||
|
||||
`rnsd --exampleconfig`
|
||||
|
||||
The output includes examples for most interface types supported
|
||||
by Reticulum, along with additional options and configuration parameters.
|
||||
The output includes examples for most interface types supported by Reticulum,
|
||||
along with additional options and configuration parameters.
|
||||
|
||||
It is a good idea to read the comments and explanations in the above default config.
|
||||
It will teach you the basic concepts you need to understand to configure your network.
|
||||
@@ -617,7 +619,7 @@ Or fetch a file from the remote system:
|
||||
$ rncp --fetch ~/path/to/file.tgz 73cbd378bb0286ed11a707c13447bb1e
|
||||
```
|
||||
|
||||
The default identity file is stored in `~/.reticulum/identities/rncp`, but you can use
|
||||
The default identity file is stored in `~/.reticulum/storage/identities/rncp`, but you can use
|
||||
another one, which will be created if it does not already exist
|
||||
|
||||
```text
|
||||
@@ -700,7 +702,7 @@ Or enter the interactive mode pseudo-shell:
|
||||
$ rnx 7a55144adf826958a9529a3bcf08b149 -x
|
||||
```
|
||||
|
||||
The default identity file is stored in `~/.reticulum/identities/rnx`, but you can use
|
||||
The default identity file is stored in `~/.reticulum/storage/identities/rnx`, but you can use
|
||||
another one, which will be created if it does not already exist
|
||||
|
||||
```text
|
||||
@@ -912,9 +914,10 @@ When connecting to a remote listener, several options are available:
|
||||
|
||||
**Identity & Destination**
|
||||
|
||||
The default identity file for `rnsh` is stored at
|
||||
`~/.reticulum/identities/rnsh`, but you can specify a different one with the
|
||||
`-i` option, which will be created if it does not already exist:
|
||||
The default initiator identity file for `rnsh` is stored at
|
||||
`~/.rns/identity` (default listener identity is in `~/.rns/identity.default`),
|
||||
but you can specify a different one with the `-i` option, which will be created if
|
||||
it does not already exist:
|
||||
|
||||
```text
|
||||
$ rnsh -l -i /path/to/identity
|
||||
@@ -1101,6 +1104,19 @@ Reticulum includes built-in functionality for discovering connectable interfaces
|
||||
|
||||
Discovered interfaces can be **auto-connected** by Reticulum, which makes it possible to create setups where an arbitrary interface can act simply as a bootstrap connection, that can be torn down again once more suitable interfaces have been discovered and connected.
|
||||
|
||||
#### IMPORTANT
|
||||
While it might be tempting to configure Reticulum to auto-connect dozens of interfaces, this will not provide you with any benefit. It will also waste the limited resources of transport node operators. In almost all situations, using 2-3 auto-connected interfaces will be sufficient.
|
||||
|
||||
**Remember**: A deeper, more branched topology is *much* more efficient than a completely flat fan-out, where everyone connects to everyone!
|
||||
|
||||
For **devices that connect directly** to the distributed backbone, such as phones and other mobile devices, use one or two auto-connects - or a fixed node you that you like, and an auto-connect as redundant backup.
|
||||
|
||||
For a transport **node in your home**, serving all devices within it, 2 or 3 autoconnects will be reasonable.
|
||||
|
||||
For a **fast boundary node** that sits between a large, internal network with hundreds of active destinations, you can consider using five to six auto-connects. The same is a sensible number for general-purpose transport-providing backbone nodes on the public internet.
|
||||
|
||||
In extreme cases, you *can* consider using up to 12 auto-connected interfaces. Almost nobody will need this, but there are edge cases where it could potentially be useful. Do not auto-connect that wide unless you are prepared and capable of processing some serious traffic.
|
||||
|
||||
The interface discovery mechanism uses announces sent over Reticulum itself, and supports both publicly readable interfaces and private, encrypted discovery, that can only be decoded by specified *network identities*. It is also possible to specify which network identities should be considered valid sources for discovered interfaces, so that interfaces published by unknown entities are ignored.
|
||||
|
||||
#### NOTE
|
||||
@@ -1328,7 +1344,7 @@ The blackhole system relies on the trust relationship between the subscriber and
|
||||
|
||||
As the ecosystem matures, this system is designed to integrate with **Network Identities**. This allows communities to verify that a published blackhole list is actually provided by a specific network or organization with a certain level of reputation and trustworthiness, adding a layer of cryptographic trust to the federation process. This prevents malicious actors from publishing fake lists intended to censor legitimate traffic.
|
||||
|
||||
For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative.
|
||||
For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative overhead.
|
||||
|
||||
## Improving System Configuration
|
||||
|
||||
@@ -1402,6 +1418,7 @@ Type=simple
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
User=USERNAMEHERE
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=rnsd --service
|
||||
|
||||
[Install]
|
||||
@@ -1442,6 +1459,7 @@ After=default.target
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=RNS_BIN_DIR/rnsd --service
|
||||
|
||||
[Install]
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# Media Conversion in rngit and nomadnet
|
||||
|
||||
## Short Overview
|
||||
|
||||
A security vulnerability has been discovered in operating-system provided or user-installed libraries that RNS *could* potentially use as external backends for media conversion.
|
||||
|
||||
Anyone hosting nodes with `rngit`, `nomadnet` and potentially other programs that *serve* or *convert* untrusted media files using the RNS API-provided `convert_to_webp` and `convert_file_to_webp` media conversion functionality, should upgrade to the latest release update of RNS 1.6.1, **right now**.
|
||||
|
||||
The initial discovery information and general shape of the potential exploit was provided to me by Hunter from [Ratspeak](https://ratspeak.org), at `2026-11-19 01:30 CEST`, and when I saw the mail around `02:00`, I started investigating the issue.
|
||||
|
||||
The release files were updated on `2026-11-19 18:55 CEST`, and replaced the files uploaded yesterday.
|
||||
|
||||
## Where is the vulnerability located?
|
||||
|
||||
**This is not a vulnerability in RNS itself**, but in external libraries that RNS can *potentially* invoke while converting media files for serving to `nomadnet` clients. The vulnerabilities therefore become exploitable through services such as `rngit` and `nomadnet`. Whether RNS invokes the specific, vulnerable libraries depends on what is installed on your system.
|
||||
|
||||
Even if your system uses the affected software, not all version are equally vulnerable, **but do not count on your system being unaffected**. The attack surface is complex here, and there is not one single set of versions you can check to ensure your system is patched. The only way currently to protect against this, is to update RNS to a version that actively mitigates the vulnerability. See below for more details.
|
||||
|
||||
Additionally, I'd recommend updating your packages and OS fully if you run any kind of software that serves or converts media files that could come from external sources. This affects libraries that are used in a very large amount of packages that serve media files in web-applications, for example.
|
||||
|
||||
However, updating the affected packages is **not universally sufficient**. As of this writing, the latest versions are still vulnerable in several distros, which is why I have decided to hot-patch the RNS 1.6.1 release with a full mitigation, that blocks any potential invocation of the vulnerable paths.
|
||||
|
||||
## What is exploitable?
|
||||
|
||||
On affected systems, it is possible to obtain arbitrary read access to any file that the process-owning user can read, and potentially exfiltrate that data from the system.
|
||||
|
||||
## Who is affected?
|
||||
|
||||
Anyone running a service with public read access to media files, *if those media files can be supplied from external sources*. That could, for example, be via a `git push` or file uploads.
|
||||
|
||||
If an attacker can upload a malicious file to your system, and later display that file, it can lead to arbitrary data exfiltration.
|
||||
|
||||
No networking or core functionality, including the standard utilities and command line tools, are affected, and this vulnerability has no interaction with the networking, transport or cryptography parts of RNS.
|
||||
|
||||
If you do not run some kind of service that serves media files while also accepting untrusted uploads, you are not affected. **But**, I would still recommend updating anyway, in case you forget about this, and later decide to host exactly such a service.
|
||||
|
||||
## How is it mitigated?
|
||||
|
||||
Update RNS to the *latest* upload of RNS 1.6.1:
|
||||
|
||||
```sh
|
||||
# Using pip
|
||||
pip uninstall rns -y
|
||||
pip install rns -U --no-cache-dir
|
||||
```
|
||||
|
||||
If updating using `pip`, ensure that the downloaded file is exactly `rns-1.6.1-0-py3-none-any.whl` (note the `-0` in the filename).
|
||||
|
||||
```sh
|
||||
# Using rngit
|
||||
rngit release rns://7649a50d84610232d1416b41d2896aff/reticulum/reticulum fetch "latest:rns-*.whl"
|
||||
pip uninstall rns -y
|
||||
pip install ./rns-1.6.1-py3-none-any.whl
|
||||
```
|
||||
|
||||
Once this update has been installed, the exploitable code paths will be unreachable from RNS applications. Remember to restart any applications that use RNS.
|
||||
|
||||
**Very important!** This *only* fixes the exploit path for RNS-based applications. Any other program on your system that uses the vulnerable libraries will still be exploitable.
|
||||
|
||||
## How can I determine if my system was exploitable?
|
||||
|
||||
It can be relatively easy to determine that your system was *not* affected, but unfortunately, it can also be relatively difficult to determine if it potentially *was*. Please see the following section.
|
||||
|
||||
## Some more technical information
|
||||
|
||||
Due to the severity of the vulnerability, and how relatively easy it is to exploit it if the system is vulnerable, I will not provide a full description of the exploit path, or any proof-of-concept code. First of all, this is a relatively complex issue, and it has several different exploitable paths, that can lead to different levels of information disclosure from the system.
|
||||
|
||||
I was initially made aware of this around 2AM this night, and spent until about 4.15AM investigating the extent to which Reticulum users could potentially be affected. At that point, I had to actually get some sleep, and then spent the entire day today on it as well. It has taken me approximately 10 hours to map the surface of the issue, and unfortunately, the conclusion here is, that there is no clear-cut version number or similar where the package could be considered patched.
|
||||
|
||||
The affected software library is the popular `ImageMagick` module, used in basically everything that handles image conversions or processing, for all kinds of applications.
|
||||
|
||||
The easy version: **If you do not have `ImageMagick` installed on your system, it has not been vulnerable**
|
||||
|
||||
If you do have `ImageMagick` installed, and it was used as the media conversion backend for anything, here is the complicated version:
|
||||
|
||||
Whether or not a particular installation of the software is exploitable will be a result of interactions between:
|
||||
|
||||
- The installed version of the software itself
|
||||
- The exact build configuration that was used to compile the distributed binaries
|
||||
- The particular rendering libraries that the binary was linked and compiled against, and the versions of these
|
||||
- The configuration and policies shipped as default in the package the software was installed from
|
||||
- Any potential system or user-side modifications to the above
|
||||
- Potential other software that was installed on the system, which `ImageMagick` can dynamically call at run-time
|
||||
|
||||
As you can see, the amount of combinations here have now exploded, and it is impossible to say whether or not your particular installation is vulnerable. The short version here is, that in many different combinations, `ImageMagick` can be exploited to read arbitrary data and incorporate it into output images. The extent of this, what can be done, what can be read, et cetera, varies wildly with exact situation on a given system.
|
||||
|
||||
Several distributions already have patched and updated packages, that block the most severe forms. For example, Debian and Arch provide patched binaries, Ubuntu does not. **But** even on the patched versions, in many cases, I was able to find new exploit paths **that are not yet patched**. I could not find any combination of latest versions and operating systems, where there was not *some* form of exploitable path available in the default, as-installed configuration. Additionally, there are some paths that no amount of settings or policy tweaking can protect against.
|
||||
|
||||
Therefore, it is **not** safe to assume that your distribution has been patched and is secure. As I investigated this, it turned out to be a real Pandora's box of hornet nests, and that it is not likely to be reliably patched in any reasonably soonish OS/package update.
|
||||
|
||||
The only reasonable way I could find to reliably deal with this, was to ensure that all potential media conversions handled by this particular software can never reach the problematic code paths.
|
||||
@@ -163,7 +163,11 @@ A global, distributed backbone of Reticulum Transport Nodes is being run by volu
|
||||
As a good starting point, you can find interface definitions for connecting your own networks to this backbone on websites such as `directory.rns.recipes <https://directory.rns.recipes/>`_ and `rmap.world <https://rmap.world/>`_.
|
||||
|
||||
.. tip::
|
||||
Don't rely on just a single connection to the distributed backbone for everyday use. It is much better to have several redundant connections configured, and enable the interface discovery options, so your nodes can continously discover peering opportunities as the network evolves. Refer to the :ref:`Bootstrapping Connectivity<bootstrapping-connectivity>` section to understand the options.
|
||||
Don't rely on just a single connection to the distributed backbone for everyday use. It is much better to have several redundant connections configured, and enable the interface discovery options, so your nodes can continously discover peering opportunities as the network evolves.
|
||||
|
||||
But don't overdo it either! Auto-connecting to a hundred different nodes will waste capacity for node operators and not provide any benefit for yourself either.
|
||||
|
||||
Refer to the :ref:`Discovering Interfaces<using-interface_discovery>` section to understand the options.
|
||||
|
||||
|
||||
|
||||
|
||||
+16
-3
@@ -621,7 +621,7 @@ To enable the page node, add the following to your ``~/.rngit/config`` file:
|
||||
.. code:: text
|
||||
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
serve_nomadnet = yes
|
||||
|
||||
When the page node is enabled, ``rngit`` will listen on a Nomad Network node destination in addition to the Git repository destination. You can view the destination hash by running:
|
||||
|
||||
@@ -634,6 +634,15 @@ When the page node is enabled, ``rngit`` will listen on a Nomad Network node des
|
||||
Repositories Destination : <0d7334d411d00120cbad24edf355fdd2>
|
||||
Nomad Network Destination : <50824b711717f97c2fb1166ceddd5ea9>
|
||||
|
||||
You can configure the destination stamp value and required link establishment cost with the following options:
|
||||
|
||||
.. code:: text
|
||||
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
stamp_value = 25.0
|
||||
link_cost = 18.0
|
||||
|
||||
Accessing Repository Pages
|
||||
--------------------------
|
||||
|
||||
@@ -717,8 +726,8 @@ By default, the page node uses Nerd Font icons. If you prefer simpler icons or y
|
||||
.. code:: text
|
||||
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = yes
|
||||
|
||||
Repository Statistics
|
||||
---------------------
|
||||
@@ -746,6 +755,8 @@ A complete node configuration might look like this:
|
||||
node_name = My Git Node
|
||||
announce_interval = 360
|
||||
record_stats = yes
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.5
|
||||
|
||||
[repositories]
|
||||
public = /var/git/public
|
||||
@@ -758,6 +769,8 @@ A complete node configuration might look like this:
|
||||
[pages]
|
||||
serve_nomadnet = yes
|
||||
unicode_icons = no
|
||||
stamp_value = 27.5
|
||||
link_cost = 18.7
|
||||
|
||||
|
||||
Verified Releases
|
||||
|
||||
@@ -23,6 +23,7 @@ to participate in the development of Reticulum itself.
|
||||
zen
|
||||
software
|
||||
using
|
||||
protecting
|
||||
understanding
|
||||
hardware
|
||||
interfaces
|
||||
|
||||
@@ -230,6 +230,8 @@ specify the target Yggdrasil IPv6 address and port, like so:
|
||||
target_host = 201:5d78:af73:5caf:a4de:a79f:3278:71e5
|
||||
target_port = 4343
|
||||
|
||||
.. _interfaces-fastflap:
|
||||
|
||||
Automated Blocking
|
||||
------------------
|
||||
Listener instances of ``BackboneInterface`` will automatically block fast-flapping clients,
|
||||
@@ -965,13 +967,6 @@ Reticulum includes a powerful system for publishing your local interfaces to the
|
||||
|
||||
When an interface is made **discoverable**, your Reticulum instance will periodically broadcast an announce packet containing the connection details and parameters required for other peers to establish a connection. These announces are propagated over the network using the standard Reticulum announce mechanism using the ``rnstransport.discovery.interface`` destination type.
|
||||
|
||||
.. note::
|
||||
To use the interface discovery functionality, the ``LXMF`` module must be installed in your Python environment. You can install it using pip:
|
||||
|
||||
.. code:: sh
|
||||
|
||||
pip install lxmf
|
||||
|
||||
|
||||
Enabling Discovery
|
||||
------------------
|
||||
@@ -1486,11 +1481,11 @@ but all the parameters are exposed for configuration if needed.
|
||||
sub-interfaces when a new client connects.
|
||||
|
||||
* | The ``ic_burst_freq_new`` option sets the maximum announce ingress
|
||||
frequency for newly spawned interfaces. Defaults to ``3.5``
|
||||
frequency for newly spawned interfaces. Defaults to ``3.0``
|
||||
announces per second.
|
||||
|
||||
* | The ``ic_burst_freq`` option sets the maximum announce ingress
|
||||
frequency for other interfaces. Defaults to ``12`` announces
|
||||
frequency for other interfaces. Defaults to ``10.0`` announces
|
||||
per second.
|
||||
|
||||
*If an interface exceeds its burst frequency, incoming announces
|
||||
@@ -1499,21 +1494,21 @@ but all the parameters are exposed for configuration if needed.
|
||||
|
||||
* | The ``ic_max_held_announces`` option sets the maximum amount of
|
||||
unique announces that will be held in the queue. Any additional
|
||||
unique announces will be dropped. Defaults to ``256`` announces.
|
||||
unique announces will be dropped. Defaults to ``64`` announces.
|
||||
|
||||
* | The ``ic_burst_hold`` option sets how much time (in seconds) must
|
||||
pass after the burst frequency drops below its threshold, for the
|
||||
announce burst to be considered cleared. Defaults to ``60``
|
||||
announce burst to be considered cleared. Defaults to ``15``
|
||||
seconds.
|
||||
|
||||
* | The ``ic_burst_penalty`` option sets how much time (in seconds) must
|
||||
pass after the burst is considered cleared, before held announces can
|
||||
start being released from the queue. Defaults to ``5*60``
|
||||
start being released from the queue. Defaults to ``15``
|
||||
seconds.
|
||||
|
||||
* | The ``ic_held_release_interval`` option sets how much time (in seconds)
|
||||
must pass between releasing each held announce from the queue. Defaults
|
||||
to ``30`` seconds.
|
||||
to ``5`` seconds.
|
||||
|
||||
All of the above settings can be configured both as instance-wide defaults
|
||||
under the ``[reticulum]`` section of the configuration file, or on a per-
|
||||
|
||||
@@ -0,0 +1,405 @@
|
||||
************************
|
||||
Protecting Open Networks
|
||||
************************
|
||||
|
||||
.. important::
|
||||
Reticulum is currently transitioning towards full, on-network stamp verification and enforcement via a phased transition:
|
||||
|
||||
- The ``1.6.0`` release completely implements the required mechanisms, and will start excercising the verification system in the transport backend. By default, ``1.6.0`` does not enable full stamp generation, emission and enforcement, but all of these options can be early-enabled in the configuration.
|
||||
|
||||
- The ``1.6.1`` release will enable full stamp generation and emission of all types by default, but will leave the *enforcement* a configurable option.
|
||||
|
||||
- The ``1.6.2`` release will complete the transition, activating full stamp enforcement across all the systems.
|
||||
|
||||
The stated version numbers are the *intended* release sequence. If any issues or implementation problems are found during the initial network deployments, the transition points may be pushed later than this plan by interim releases.
|
||||
|
||||
While you can create entirely closed-off and private networks with Reticulum, the protocol itself is open and permissionless. On widely interconnected networks, anyone can create identities and globally reachable destinations without external permission or approval, and establish links anonymously over the network.
|
||||
|
||||
Such capabilities are powerful, and a required characteristic of a truly functional communications fabric, but also raise very large challenges, that have been almost impossible to solve in legacy networking technologies.
|
||||
|
||||
Reticulum approaches this particular problem, like most others, by employing cryptographic principles. This provides a comprehensive, multi-layered repertoire of defense mechanisms, which can be composed and employed in very effective ways.
|
||||
|
||||
In contrast to other networking paradigms, these mechanisms do not have to be bolted on to the application layer in hindsight, but are a core part of the protocol itself, which means that they can be applied universally and effectively:
|
||||
|
||||
All nodes help combat spam and network abuse, according to the rules *set by the actual owners of supplied resources* - not by any bureaucracy or external authority.
|
||||
|
||||
Rules and requirements can be adjusted live, dynamically and directly, and by those that actually operate and run the infrastructure and services.
|
||||
|
||||
The system has been designed so that it becomes very cheap computationally for resource-providing nodes to verify or reject traffic, and very expensive for malicious nodes to abuse the shared resources provided by the network's operators.
|
||||
|
||||
|
||||
Cryptographic Stamps
|
||||
====================
|
||||
|
||||
All networking primitives that consume shared network resources are gated by *stamps*. A stamp is compact, cryptographic token that proves that a certain amount of computation and energy has been expended in its creation.
|
||||
|
||||
The amount of such computation required for a stamp to be considered valid can be configured individually by the operator of the resource being made available, whether that is network transport, a node providing information for retrieval, a shared voice room, or something else entirely.
|
||||
|
||||
While the core functionality is completely automatic, and handled by Reticulum itself, the primitives are made available at the application layer API as well, so that developers can use them to implement further protections, if required by their usage scenarios. In most cases, however, simply setting the target *values* and required *costs* for the built-in mechanisms will be sufficient.
|
||||
|
||||
The *value* of a stamp is a decimal representation of how difficult a stamp was to create, on a scale from ``0.0`` to ``100.0``. The scale is **exponential**. An increase of one point is equal to *doubling* the average compute time required. Fractional values are supported, such as ``14.125``.
|
||||
|
||||
Internally, the fractional part is quantized to ``256`` different values, giving an approximately ``0.27%`` difficulty increase per step. You can use any decimal number when configuring stamps, such as ``9.3691`` and you do not have to worry about "landing on" the correct step values. Reticulum will automatically handle the quantization, wire-transport representation and value comparisons.
|
||||
|
||||
The term *cost* is used everywhere a stamp value *requirement* is configured or specified. In general, *value* refers to the actual, determined value of a given stamp, *cost* refers to a value requirement.
|
||||
|
||||
Base Primitives
|
||||
---------------
|
||||
|
||||
Reticulum provides two types of base stamp primitives:
|
||||
|
||||
* **Detached stamps** can be tied to any external information, and are useful for stamping both static information and for one-time verification purposes. The stamp itself is a detached, short binary sequence, typically 14 to 32 bytes, that can be verified directly against the stamped material.
|
||||
|
||||
They can be configured from relatively easy to compute, even for embbedded systems and microcontrollers, all the way to something that is practically impossible, even with all the compute and memory on the planet.
|
||||
|
||||
* **Embedded stamps** are tied directly to a Reticulum Identity keyset, and embedded within it. The keyset itself *contains* the stamp, and there is no external, detached byte sequence for them.
|
||||
|
||||
Anyone can verify the value of an identity-embedded stamp simply from the public key material of the identity.
|
||||
|
||||
On-Network Types
|
||||
----------------
|
||||
|
||||
The base primitives are used to implement scenario-specific network-level primitives that, if configured correctly, make spam and network abuse expensive, but validation and enforcement cheap and efficient.
|
||||
|
||||
* **Destination Stamps** are detached stamps associated with reticulum destinations. They are included in all announces sent by a destination, and by verifying that their value matches a transport node's cost requirement, they can be either accepted for rebroadcast onto the network, or rejected and dropped.
|
||||
|
||||
Destination stamps are *one-time* generations, and are reusable across announces. They limit the number of *new* destinations that can be created, and makes it expensive to spam a network with destinations that do not provide anything meaningful. As such, these stamps will typically target relatively high values, and their cost requirements should be set accordingly.
|
||||
|
||||
A generation time for such stamps in *minutes* rather than seconds can very well be reasonable on large, open-access networks. Due to their detached nature, they can also be pre-generated off-device (and do not require the private key material for generation), so that even low-powered nodes, such as microcontrollers, can use high-value destination stamps, by having them generated and loaded externally as a one-time procedure.
|
||||
|
||||
* **Path Request Stamps** are also detached stamps, but generated *individually* for every path request emitted on the network. These will typically have a much lower cost requirement than destination stamps, but if a node is overwhelmed by path requests, it can be tuned higher.
|
||||
|
||||
The stamp is generated against the individually unique *emission*, so that unstamped or low-value path requests for a destination cannot disrupt the resolution of legitimate ones toward that same destination.
|
||||
|
||||
* **Link Request Stamps** are embedded stamps, carried in the ephemeral link request keyset. They are therefore completely transparent to the network, but can still be verified extremely quickly by any node along the link request path, who can then make a decision on whether or not to transport it.
|
||||
|
||||
Link request cost targets are set by the *endpoint destinations individually*. Every destination that includes a stamp in its announces will also include link request cost signalling. This means that any node that hears an announce from the destination will also know what link request stamp value to target, when establishing links to that destination.
|
||||
|
||||
Furthermore, spam and link request abuse can be filtered before even reaching the destination, if at least one node along the path validates the link request stamp value and cost requirement.
|
||||
|
||||
All of the stamp primitives, functionality and on-wire signalling is *transparent and backwards-compatible* with older versions of Reticulum transport nodes. This means, that even if a node doesn't itself understand stamp functionality, it will still transport all the required information. Stamped announces, path and link requests can cross older, non stamp-aware network segments transparently and unaffected.
|
||||
|
||||
.. _stamps-configuring:
|
||||
|
||||
Configuring Stamps
|
||||
------------------
|
||||
|
||||
Reticulum, and its included utilities, provide sane default cost requirements and value targets for the different types of network stamps, but it is entirely up to the operator whether to follow the defaults. All of them are configurable on a per-node, per-application and per-destination basis.
|
||||
|
||||
Instance Configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In reality, different kinds of networks will want to configure different kinds of costs and value targets for their use. For instance-wide defaults and settings, you can configure these in the ``[stamps]`` section of the Reticulum configuration file:
|
||||
|
||||
* | The ``destination_cost`` option sets the default required stamp
|
||||
cost for announced destinations to be accepted, and have their
|
||||
announces propagated by this node. Defaults to ``23.5``.
|
||||
|
||||
* | The ``destination_value`` option sets the default stamp value that
|
||||
this instance will target when generating new destination stamps.
|
||||
An application can request higher targets for destinations that it
|
||||
creates, but a requested lower value will always be clamped to the
|
||||
configured default as a minimum. Defaults to ``25.0``.
|
||||
|
||||
*Destination stamps are one-time generations per destination, so it
|
||||
is generally a good idea to target a slightly higher value than the
|
||||
minimum required cost of the networks you want the destination to
|
||||
be reachable on.*
|
||||
|
||||
* | The ``pr_cost`` option sets the required stamp cost for incoming
|
||||
path requests. Defaults to ``15.8``.
|
||||
|
||||
* | The ``pr_value`` option sets the target stamp value for path
|
||||
request stamps generated by this instance. Defaults to ``15.8``.
|
||||
|
||||
* | The ``lr_cost`` option sets the default link request stamp cost,
|
||||
that destinations created on this instance will require. This
|
||||
value can be freely overridden by applications that specify their
|
||||
own link request cost requirements, and is solely used as the
|
||||
default if no such specification is provided. Defaults to ``12.5``.
|
||||
|
||||
* | The ``lr_stamp_timeout`` and ``pr_stamp_timeout`` options set the
|
||||
maximum amount of time, in seconds, to spend while attempting to
|
||||
generate link and path request stamps respectively. If a stamp is
|
||||
not generated within this timespan, the generation is cancelled,
|
||||
and the link request or path request fails. Defaults to ``15``
|
||||
seconds for both options.
|
||||
|
||||
* | The ``stamp_destinations`` option enables generation and emission
|
||||
of destination stamps in announces. This is a transitory option.
|
||||
It will become mandatory and enabled by default in RNS ``1.6.1``.
|
||||
|
||||
* | The ``stamp_prs`` option enables stamping of path requests emitted
|
||||
by this instance. This is a transitory option. It will become
|
||||
mandatory and enabled by default in RNS ``1.6.1``.
|
||||
|
||||
* | The ``always_stamp_lrs`` option will stamp *all* outgoing link
|
||||
requests, even to destinations that have not announced a link
|
||||
request cost (and will, in that case, use the configured or
|
||||
default link request cost). This option is mostly useful for
|
||||
testing and diagnostics. In general use, Reticulum will handle
|
||||
link request stamping and cost targets automatically.
|
||||
|
||||
* | The ``enforce_stamps`` option allows early activation of stamp
|
||||
enforcement. When enabled, announces and path requests that do
|
||||
not meet the configured cost requirements are dropped, and link
|
||||
requests with insufficient stamps are ignored. This is a transitory
|
||||
option. It will become mandatory and enabled by default in RNS
|
||||
``1.6.2``.
|
||||
|
||||
An example of customised stamp cost and value configuration follows below:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[stamps]
|
||||
stamp_destinations = yes
|
||||
stamp_prs = yes
|
||||
|
||||
destination_cost = 24.8
|
||||
destination_value = 26.25
|
||||
|
||||
pr_cost = 15.8
|
||||
pr_value = 16.45
|
||||
|
||||
Stamp cost requirements can also be configured on a per-interface basis:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[[Public Gateway]]
|
||||
type = BackboneInterface
|
||||
mode = gateway
|
||||
listen_on = 0.0.0.0
|
||||
port = 4242
|
||||
|
||||
destination_cost = 25.0
|
||||
pr_cost = 17.2
|
||||
|
||||
[[Local RNode]]
|
||||
type = RNodeInterface
|
||||
port = /dev/ttyUSB0
|
||||
|
||||
# Much lower requirements
|
||||
# for the local network.
|
||||
destination_cost = 11.2
|
||||
pr_cost = 5.0
|
||||
|
||||
For Developers
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
Applications can dynamically set their own stamp values and required link requests costs at runtime. Whenever the values are adjusted, the destination will have to send an announce for the updated information to become known by the rest of the network.
|
||||
|
||||
If you are setting these values at destination creation time, ensure that they are set *immediately* after the destination is instantiated, as Reticulum may queue internal, instance-local announces for the destination shortly after creation, so that the local shared instance and its clients are aware of the newly created destination.
|
||||
|
||||
.. code:: python
|
||||
|
||||
# Create a new destination
|
||||
my_destination = RNS.Destination(
|
||||
my_identity,
|
||||
RNS.Destination.IN,
|
||||
RNS.Destination.SINGLE,
|
||||
"myapp", "service"
|
||||
)
|
||||
|
||||
# Configure stamps
|
||||
my_destination.set_value(30.0)
|
||||
my_destination.set_link_cost(15.0)
|
||||
|
||||
Dynamically adjusting link request costs is a viable and intended mechanism for mitigating resource abuse, scraping, DoS attempts and other malicious behaviour. An application may implement mechanisms to statically or dynamically raise link request costs under certain conditions.
|
||||
|
||||
.. tip::
|
||||
Remember here, though, that announce cadence should be preserved for such situations! If your destination is announcing too often in general, and wants to dynamically adjust link request costs at a critical moment, it may already have exhausted its announce rate limits on upstream nodes. So plan your application's announce cadence thoughtfully!
|
||||
|
||||
It is also possible for application code to directly get the destination value and link request cost for any known destination:
|
||||
|
||||
.. code:: python
|
||||
|
||||
# Get the value of a known destination
|
||||
RNS.Identity.recall_stamp_value(destination_hash)
|
||||
|
||||
# Get the current link cost requirement
|
||||
# of a known destination
|
||||
RNS.Identity.recall_link_cost(destination_hash)
|
||||
|
||||
|
||||
An ``Identity`` can be created with an embedded stamp value, by passing the target value at instantiation time:
|
||||
|
||||
.. code:: python
|
||||
|
||||
# Create a new, stamped identity
|
||||
my_identity = RNS.Identity(value=24.0)
|
||||
|
||||
# Get the value of any known identity
|
||||
another_identity.get_value()
|
||||
|
||||
As with destination stamps, this is a one-time generation procedure, that happens at Identity creation. Once an identity is created with an embedded stamp, its value *cannot* be upgraded at a later point as with detached stamps.
|
||||
|
||||
|
||||
Filtering & QoS
|
||||
===============
|
||||
|
||||
In addition to the stamp functionality explored above, Reticulum includes filtering options that allow operators to explicitly deny or allow certain destination *types* across an entire instance.
|
||||
|
||||
After filtering, all packets that are ultimately allowed into the transport engine, are sorted into prioritized QoS queues, which are drained and processed in priority order.
|
||||
|
||||
This provides a powerful system for both filtering, classifying and ensuring latency and service quality for the traffic and application types a node operator wants to provide.
|
||||
|
||||
Instance Configuration
|
||||
----------------------
|
||||
|
||||
The filtering subsystem can operate in two modes:
|
||||
|
||||
* | **Ignored Mode** will allow any destination type in the instance, *except* for those that have been explicitly added to the ``ignored_types`` list. This mode is useful for blocking the traffic of specific destination types from being transported across the instance.
|
||||
|
||||
* | **Required Only Mode** will allow *only* the destination types explicitly defined as required, and ignore *all* other types. A base set of required destination types can be defined instance-wide in the ``allowed_types`` list.
|
||||
|
||||
| In addition, any application using the shared instance can temporarily request required destination types for its use. Applications that request required destination types will automatically have them granted, unless they are included in the ``ignored_types`` list.
|
||||
|
||||
The filtering defaults and base settings are configured in the ``[filter]`` section of the configuration file. For example, it is possible to explicitly ignore a series of destination types, while also limiting hop reach to a more local topology.
|
||||
|
||||
.. tip::
|
||||
The ``hop_limiter`` in the filter section is an instance-wide setting. You can also use the ``hop_limiter`` option *per-interface* if you want to limit hops on some interfaces only.
|
||||
|
||||
If you do not know the human readable destination type aspects for a destination type you want to ignore, you can also add entries as 10-byte (20 hexadecimal character) hashes using the ``<c4ace368262d845c9dd3>`` format.
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[filter]
|
||||
hop_limiter = 14
|
||||
ignored_types = application.that.spams, traffic.heavy.service, <c4ace368262d845c9dd3>
|
||||
|
||||
In some situations, you may want to allow *only* certain destination types. If, for example, you are creating a high-performance transport node intended to handle thousands of simultaneous voice calls at minimal latency, a configuration might look something like:
|
||||
|
||||
.. code:: ini
|
||||
|
||||
[filter]
|
||||
required_only = yes
|
||||
allowed_types = lxst.telephony
|
||||
|
||||
The filtering subsystem provided in RNS ``1.6.0`` is functional and useful, but at an early stage, and relatively basic. In the upcoming releases, it will be expanded into a much more comprehensive and flexible system, that will include custom QoS and traffic class tagging, advanced rule definitions and more.
|
||||
|
||||
.. important::
|
||||
As the filtering and QoS system is developed and matures, the ``required_only`` mode will become the default operating mode for non-transport instances, since applications can already now dynamically request what destination types they are interested in.
|
||||
|
||||
This ensures that a local, non-transport node (running on resource-limited hardware, for example), does not have to process announces for, and waste CPU and memory on destination types that are completely irrelevant to it. It also greatly reduces power consumption on battery-powered and mobile devices, while they are connected to large and busy networks.
|
||||
|
||||
If you are a developer, see the following section.
|
||||
|
||||
Blocking Transport Nodes
|
||||
------------------------
|
||||
|
||||
Misbehaving, spamming and broken transport nodes can be completely blocked using the :ref:`Blackhole system<protecting-blackhole>`. First, obtain the Transport Identity hash of a misbehaving transport node, using ``rnstatus``:
|
||||
|
||||
.. code:: txt
|
||||
|
||||
$ rnstatus -FATa "71.29.190.5"
|
||||
|
||||
BackboneInterface[Client on Bern IPv4/71.29.190.5:37062]
|
||||
Status : Up
|
||||
Mode : Gateway
|
||||
Rate : 250.00 Mbps, MTU 65536
|
||||
Running : Unknown implementation
|
||||
Rem.Tr.ID : <a0c289d131c7bfa8d5ddc8b652c0f40d>
|
||||
Held : 64 announces
|
||||
Violatns. : 382 protocol
|
||||
Flt. Hits : 92
|
||||
Announces : 147174↓ 11193↑ total, 140554 filtered
|
||||
1.2 Hz↑ (↓0% / ↑0% of flow)
|
||||
7.8 Hz↓ (t:6h/p:0s/g:1) burst for 4h, 54m and 42.69s
|
||||
Traffic : ↑4.75 MB 0 bps
|
||||
↓1.50 MB 0 bps
|
||||
Filtered : ↑0 B 0 bps
|
||||
↓55.43 MB 380.14 Kbps
|
||||
|
||||
You can then block it by its Transport ID:
|
||||
|
||||
.. code:: txt
|
||||
|
||||
$ rnpath -B a0c289d131c7bfa8d5ddc8b652c0f40d --reason "Broken node"
|
||||
|
||||
Blackholed identity a0c289d131c7bfa8d5ddc8b652c0f40d
|
||||
|
||||
Its connection will be immediately torn down, and further reconnection attempts will be ignored.
|
||||
|
||||
For Developers
|
||||
--------------
|
||||
|
||||
At some point during the ``1.6.x`` release cycle, RNS will move to using the ``required_only`` mode for *non-transport* instances by default. This means that applications will, in most cases, have to request what types of destinations they are interested in receiving announces from.
|
||||
|
||||
If your application is only using the utility primitives included in RNS, or established protocols such as LXMF or LXST, **there is nothing you have to do**. The protocol primitives *themselves* request their required destination types, and this is the general pattern to follow here:
|
||||
|
||||
- If an application uses a common protocol or primitive, it is the importable primitive, protocol module, or relevant internal functionality that should request destination type requirements, at the point where they are actually needed.
|
||||
- Higher level application layers should not have to guess at or request destination types, unless it explicitly creates outbound destinations that are not covered by any already-used protocols or primitives.
|
||||
|
||||
If your protocol or application needs to receive announces for a specific destination type, it is very easy to register it. For example, at startup (or when the destination type is actually required), simply run something like:
|
||||
|
||||
.. code:: python
|
||||
|
||||
RNS.Reticulum.get_instance().wants_destination_type("my_app.service")
|
||||
|
||||
You do not *have to* explicitly deregister destination type requirements. Reticulum automatically deregisters when the shared instance connection for the application is torn down, but you may *want* to in certain cases, which follows the same pattern:
|
||||
|
||||
.. code:: python
|
||||
|
||||
RNS.Reticulum.get_instance().unwants_destination_type("my_app.service")
|
||||
|
||||
That's really all there is to it. If you already now want to make you application more CPU, memory and battery efficient, you can tell Reticulum to start serving only required destinations to it with only a few lines of additional code. A full setup of this functionality might look something like:
|
||||
|
||||
.. code:: python
|
||||
|
||||
for destination_type in self.REQUIRED_DESTINATION_TYPES:
|
||||
RNS.Reticulum.get_instance().wants_destination_type(destination_type)
|
||||
|
||||
RNS.Reticulum.get_instance().required_announces_only(True)
|
||||
|
||||
Your application will now only receive, and have to process, the announces and paths that it actually cares about.
|
||||
|
||||
|
||||
Ingress & Burst Control
|
||||
=======================
|
||||
|
||||
In addition to the economic incentives created by stamps, Reticulum enforces a set of hydraulic limits on how much announce traffic any peer or destination can inject into the network. These mechanisms work automatically, require no operator configuration (but can be tuned, if required), and apply equally to all peers.
|
||||
|
||||
At the most basic level, the ``announce_cap`` mechanism limits the bandwidth any interface will allocate to propagating announces and other network upkeep traffic, and prioritises the local topology. Destinations that rapidly re-announce are down-prioritised in the transmission queue, so attempting to gain reach through announce spam has the exact *opposite* effect.
|
||||
|
||||
On top of this, per-destination announce rate control can be configured on any interface, or as instance-wide defaults. Once configured, announces *received* for any one destination will only be re-broadcast to other interfaces at the configured target rate, no matter how often they are received. The grace option allows occasional rate violations, and a configurable penalty extends the interval between propagated announces for destinations that repeatedly exceed their target.
|
||||
|
||||
The final layer protects against bursts of announces for *newly created* destinations. If an interface receives a large influx of announces for previously unknown destinations in a short amount of time, these are held in a bounded queue, while announces for known and established destinations continue to be processed without interruption. After the burst subsides, and an additional waiting period has passed, held announces are released slowly until the queue is cleared.
|
||||
|
||||
A node that connects to a public interface, announces a large number of bogus destinations, and then disconnects, will therefore never get those destinations into path tables at all. When the interface they arrived on disappears, the held announces are simply dropped and forgotten.
|
||||
|
||||
Ingress control operates at the level of individual sub-interfaces, so one misbehaving client cannot disrupt announce processing for other clients connected to the same listener. Combined with stamps, these mechanisms are complementary:
|
||||
|
||||
Rate limiting bounds the *rate* at which abuse can occur, for everyone, while stamps make the *volume* of abuse from any actor computationally expensive.
|
||||
|
||||
Full configuration details are available in the :ref:`Announce Rate Control<interfaces-announcerates>` and :ref:`New Destination Rate Limiting<interfaces-ingress-control>` sections.
|
||||
|
||||
.. _protecting-blachole:
|
||||
|
||||
Blackhole Management
|
||||
====================
|
||||
|
||||
The *blackhole* system allows any node operator or individual user to block specific identities at the transport layer.
|
||||
|
||||
Once an identity has been blackholed on a node, announces originating from *any* destination associated with that identity are dropped, and the node will refuse to transport traffic, or establish and maintain links, to the blackholed identity's destinations.
|
||||
|
||||
It is important to understand the scope of this mechanism corrrectly. There is fundamentally **no way** to *globally* block or censor any identity or destination in Reticulum networks. A blackhole entry only applies on the network segments that enforce it, which is the exact intention. Operators retain full control over what is allowed on their own segments, while no one can impose restrictions on segments they do not operate.
|
||||
|
||||
Blackholes can be managed directly with the ``rnpath`` utility. Identities can be blocked (optionally with an expiry duration and a human-readable reason), unblocked, and the current local blocklist can be inspected at any time. This is well suited for immediate responses to announce spam, unwanted content or malicious behaviour observed on your own networks.
|
||||
|
||||
For anything larger than a few nodes, manual blocklist maintenance quickly becomes impractical. Reticulum therefore allows an instance to subscribe to blackhole lists published by trusted transport identities, periodically retrieving and merging them into the local list, and conversely to publish its own list to subscribers.
|
||||
|
||||
This makes it possible to federate community-maintained blocklists across large networks, with the important caveat that subscribing to a list is an act of trust in its maintainer. See the :ref:`Blackhole Management<using-blackhole_management>` section for full details on local management, automated list sourcing and publishing.
|
||||
|
||||
|
||||
Fast-Flap Blocking
|
||||
==================
|
||||
|
||||
High-performance listener interfaces, such as :ref:`BackboneInterface<interfaces-backbone>`, will automatically block *fast-flapping* clients; remote peers that repeatedly connect for a very short amount of time, and then disconnect.
|
||||
|
||||
This behaviour usually stems from attempts to dump announce or path request spam onto the network in short bursts, while rotating connections in an attempt to evade per-interface rate limits, but it can also be caused by broken implementations or automated scanning tools.
|
||||
|
||||
Such bypass attempts generally have very limited effect. Ingress limiters trigger *immediately* once rate limits are exceeded, but the behaviour still causes needless interface rotation and wasted resources on the transport instance.
|
||||
|
||||
With fast-flap blocking enabled, a client that exceeds the allowed flap grace is simply not allocated an actual interface again, for the configured block duration.
|
||||
|
||||
On the ``BackboneInterface`` type, fast-flap blocking is enabled by default, with sensible standard settings. All parameters can be adjusted if necessary. See the :ref:`Automated Blocking<interfaces-fastflap>` section of the Interfaces chapter.
|
||||
+27
-9
@@ -193,12 +193,14 @@ change anything, and you may already be connected to a wider network. If not,
|
||||
you will probably need to add relevant *interfaces* to the configuration, in
|
||||
order to communicate with other systems.
|
||||
|
||||
You can generate a much more verbose configuration example by running the command:
|
||||
The example above does not document all the available options, only the basics.
|
||||
To explore all the various configuration options available, you can generate a
|
||||
much more verbose and complete configuration example by running the command:
|
||||
|
||||
``rnsd --exampleconfig``
|
||||
|
||||
The output includes examples for most interface types supported
|
||||
by Reticulum, along with additional options and configuration parameters.
|
||||
The output includes examples for most interface types supported by Reticulum,
|
||||
along with additional options and configuration parameters.
|
||||
|
||||
It is a good idea to read the comments and explanations in the above default config.
|
||||
It will teach you the basic concepts you need to understand to configure your network.
|
||||
@@ -644,7 +646,7 @@ Or fetch a file from the remote system:
|
||||
|
||||
$ rncp --fetch ~/path/to/file.tgz 73cbd378bb0286ed11a707c13447bb1e
|
||||
|
||||
The default identity file is stored in ``~/.reticulum/identities/rncp``, but you can use
|
||||
The default identity file is stored in ``~/.reticulum/storage/identities/rncp``, but you can use
|
||||
another one, which will be created if it does not already exist
|
||||
|
||||
.. code:: text
|
||||
@@ -731,7 +733,7 @@ Or enter the interactive mode pseudo-shell:
|
||||
|
||||
$ rnx 7a55144adf826958a9529a3bcf08b149 -x
|
||||
|
||||
The default identity file is stored in ``~/.reticulum/identities/rnx``, but you can use
|
||||
The default identity file is stored in ``~/.reticulum/storage/identities/rnx``, but you can use
|
||||
another one, which will be created if it does not already exist
|
||||
|
||||
.. code:: text
|
||||
@@ -950,9 +952,10 @@ When connecting to a remote listener, several options are available:
|
||||
|
||||
**Identity & Destination**
|
||||
|
||||
The default identity file for ``rnsh`` is stored at
|
||||
``~/.reticulum/identities/rnsh``, but you can specify a different one with the
|
||||
``-i`` option, which will be created if it does not already exist:
|
||||
The default initiator identity file for ``rnsh`` is stored at
|
||||
``~/.rns/identity`` (default listener identity is in ``~/.rns/identity.default``),
|
||||
but you can specify a different one with the ``-i`` option, which will be created if
|
||||
it does not already exist:
|
||||
|
||||
.. code:: text
|
||||
|
||||
@@ -1144,6 +1147,19 @@ Reticulum includes built-in functionality for discovering connectable interfaces
|
||||
|
||||
Discovered interfaces can be **auto-connected** by Reticulum, which makes it possible to create setups where an arbitrary interface can act simply as a bootstrap connection, that can be torn down again once more suitable interfaces have been discovered and connected.
|
||||
|
||||
.. important::
|
||||
While it might be tempting to configure Reticulum to auto-connect dozens of interfaces, this will not provide you with any benefit. It will also waste the limited resources of transport node operators. In almost all situations, using 2-3 auto-connected interfaces will be sufficient.
|
||||
|
||||
**Remember**: A deeper, more branched topology is *much* more efficient than a completely flat fan-out, where everyone connects to everyone!
|
||||
|
||||
For **devices that connect directly** to the distributed backbone, such as phones and other mobile devices, use one or two auto-connects - or a fixed node you that you like, and an auto-connect as redundant backup.
|
||||
|
||||
For a transport **node in your home**, serving all devices within it, 2 or 3 autoconnects will be reasonable.
|
||||
|
||||
For a **fast boundary node** that sits between a large, internal network with hundreds of active destinations, you can consider using five to six auto-connects. The same is a sensible number for general-purpose transport-providing backbone nodes on the public internet.
|
||||
|
||||
In extreme cases, you *can* consider using up to 12 auto-connected interfaces. Almost nobody will need this, but there are edge cases where it could potentially be useful. Do not auto-connect that wide unless you are prepared and capable of processing some serious traffic.
|
||||
|
||||
The interface discovery mechanism uses announces sent over Reticulum itself, and supports both publicly readable interfaces and private, encrypted discovery, that can only be decoded by specified *network identities*. It is also possible to specify which network identities should be considered valid sources for discovered interfaces, so that interfaces published by unknown entities are ignored.
|
||||
|
||||
.. note::
|
||||
@@ -1388,7 +1404,7 @@ The blackhole system relies on the trust relationship between the subscriber and
|
||||
|
||||
As the ecosystem matures, this system is designed to integrate with **Network Identities**. This allows communities to verify that a published blackhole list is actually provided by a specific network or organization with a certain level of reputation and trustworthiness, adding a layer of cryptographic trust to the federation process. This prevents malicious actors from publishing fake lists intended to censor legitimate traffic.
|
||||
|
||||
For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative.
|
||||
For operators, this creates a scalable model where maintaining a single high-quality blocklist can protect thousands of downstream peers, drastically reducing the administrative overhead.
|
||||
|
||||
Improving System Configuration
|
||||
------------------------------
|
||||
@@ -1470,6 +1486,7 @@ following content:
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
User=USERNAMEHERE
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=rnsd --service
|
||||
|
||||
[Install]
|
||||
@@ -1511,6 +1528,7 @@ Create a user systemd service files ``~/.config/systemd/user/rnsd.service`` with
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
Environment=MALLOC_ARENA_MAX=2
|
||||
ExecStart=RNS_BIN_DIR/rnsd --service
|
||||
|
||||
[Install]
|
||||
|
||||
@@ -7,6 +7,10 @@ from .link import TestLink
|
||||
from .channel import TestChannel
|
||||
from .hkdf import TestHKDF
|
||||
from .ifac import TestIFAC
|
||||
from .stamps import TestStampFixedPoint
|
||||
from .stamps import TestStampWorkblock
|
||||
from .stamps import TestStampGeneration
|
||||
from .stamps import TestStampPersistence
|
||||
from .coalesced_transmit import TestTransmitBuffer
|
||||
from .hdlc import TestReceiveBuffer
|
||||
from .egress import TestHWMLimiter
|
||||
|
||||
+39
-1
@@ -1,4 +1,4 @@
|
||||
# Partially generated with lc/kimi_k2.6
|
||||
# Partially generated with lc/kimi_k2.6 and lc/deepseek_v4_flash_q8_k_xl
|
||||
# Reviewed and approved by Mark Qvist
|
||||
import unittest
|
||||
|
||||
@@ -203,4 +203,42 @@ class TestHWMLimiter(unittest.TestCase):
|
||||
self.assertEqual(iface.tx_dropped_bytes, len(framed(b"gated-frame")))
|
||||
self.assertEqual(len(iface.transmit_buffer), 0)
|
||||
|
||||
def test_12_ec_state_reset_on_teardown(self):
|
||||
print("")
|
||||
# When a dead peer escalates to teardown, the interface instance
|
||||
# persists, but the socket is closed. On initiator interfaces the
|
||||
# same instance is later re-registered on reconnection, so the
|
||||
# egress-control state and transmit buffer must be reset at
|
||||
# teardown.
|
||||
tb = TransmitBuffer()
|
||||
iface = FakeIF(tb)
|
||||
while len(tb) <= BackboneInterface.DP_EC_MID_WM: tb.append(framed(b"y" * 4096))
|
||||
iface._dp_ec_last_drain = 10.0
|
||||
iface._dp_ec_zero_ticks = BackboneInterface.DP_EC_STALL_TICKS
|
||||
iface.tx_stalled = True
|
||||
|
||||
escalated = BackboneInterface._dp_ec_evaluate(iface, 100.0)
|
||||
self.assertTrue(escalated)
|
||||
self.assertTrue(iface.torn_down)
|
||||
|
||||
# The persisted instance must be left in a clean post-teardown
|
||||
# state, ready for the reconnection cycle to re-register and
|
||||
# re-evaluate it.
|
||||
self.assertEqual(iface._dp_ec_prev_sent, 0)
|
||||
self.assertEqual(iface._dp_ec_zero_ticks, 0)
|
||||
self.assertGreaterEqual(iface._dp_ec_last_drain, 100.0)
|
||||
self.assertFalse(iface.tx_stalled)
|
||||
self.assertIsNot(iface.transmit_buffer, tb)
|
||||
self.assertEqual(len(iface.transmit_buffer), 0)
|
||||
|
||||
# Simulate the re-established connection: the same instance is
|
||||
# evaluated again. A stale dead-drain state would re-trigger the
|
||||
# teardown on this tick; a reset instance must not.
|
||||
iface.torn_down = False # This is a bit janky, but will do for
|
||||
# now as a simulation.
|
||||
re_escalated = BackboneInterface._dp_ec_evaluate(iface, 101.0)
|
||||
self.assertFalse(re_escalated)
|
||||
self.assertFalse(iface.torn_down)
|
||||
self.assertFalse(iface.tx_stalled)
|
||||
|
||||
if __name__ == "__main__": unittest.main(verbosity=2)
|
||||
+18
-11
@@ -30,6 +30,7 @@ BUFFER_TEST_TARGET = 256000
|
||||
BUFFER_TEST_TARGET_SLOW = 1800
|
||||
SLOW_TEST_MARKER = b"@SLOW_TEST_MARKER"
|
||||
LINK_UP_WAIT = 0.050
|
||||
LINK_TIMEOUT = 1.000
|
||||
|
||||
def targets_job(caller):
|
||||
cmd = "python -c \"from tests.link import targets; targets()\""
|
||||
@@ -61,6 +62,12 @@ def close_rns():
|
||||
if c_rns != None:
|
||||
c_rns.m_proc.kill()
|
||||
|
||||
def await_link(link, timeout):
|
||||
deadline = time.time()+timeout
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
while link.status < RNS.Link.ACTIVE and time.time() < deadline:
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
|
||||
class TestLink(unittest.TestCase):
|
||||
def setUp(self):
|
||||
pass
|
||||
@@ -115,7 +122,7 @@ class TestLink(unittest.TestCase):
|
||||
|
||||
print("Testing default mode link establishment...")
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
l1.teardown()
|
||||
@@ -130,7 +137,7 @@ class TestLink(unittest.TestCase):
|
||||
|
||||
print("Testing AES_256_CBC mode link establishment...")
|
||||
l3 = RNS.Link(dest, mode=RNS.Link.MODE_AES256_CBC)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l3, LINK_TIMEOUT)
|
||||
self.assertEqual(l3.status, RNS.Link.ACTIVE)
|
||||
self.assertEqual(l3.mode, RNS.Link.MODE_AES256_CBC)
|
||||
self.assertEqual(len(l3.derived_key), 64)
|
||||
@@ -157,7 +164,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
b = 0
|
||||
@@ -230,7 +237,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest, mode=RNS.Link.MODE_AES256_CBC)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
b = 0
|
||||
@@ -303,7 +310,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
resource_timeout = 120
|
||||
@@ -367,7 +374,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
resource_timeout = 120
|
||||
@@ -423,7 +430,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
resource_timeout = 120
|
||||
@@ -482,7 +489,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
resource_timeout = 120
|
||||
@@ -544,7 +551,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
resource_timeout = 120
|
||||
@@ -599,7 +606,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(1)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
|
||||
received = []
|
||||
@@ -651,7 +658,7 @@ class TestLink(unittest.TestCase):
|
||||
self.assertEqual(dest.hash, bytes.fromhex("fb48da0e82e6e01ba0c014513f74540d"))
|
||||
|
||||
l1 = RNS.Link(dest)
|
||||
time.sleep(LINK_UP_WAIT)
|
||||
await_link(l1, LINK_TIMEOUT)
|
||||
self.assertEqual(l1.status, RNS.Link.ACTIVE)
|
||||
buffer = None
|
||||
|
||||
|
||||
+469
@@ -0,0 +1,469 @@
|
||||
# Generated with lc/glm5.3_flash_q6_k_xl
|
||||
# Reviewed and approved by Mark Qvist
|
||||
|
||||
import unittest
|
||||
import os
|
||||
import time
|
||||
import math
|
||||
import random
|
||||
import shutil
|
||||
import tempfile
|
||||
import threading
|
||||
from unittest import skipIf
|
||||
|
||||
import RNS
|
||||
from RNS import Stamps
|
||||
import RNS.vendor.umsgpack as msgpack
|
||||
|
||||
# The stamper itself is intentionally seeded from os.urandom, but the
|
||||
# value and target layers are pure deterministic math. Seeded test
|
||||
# vectors therefore make the statistical tests exact and repeatable
|
||||
# on any platform and any hash backend.
|
||||
rng = random.Random(28411)
|
||||
|
||||
def rb(n):
|
||||
return bytes(rng.getrandbits(8) for _ in range(n))
|
||||
|
||||
def fp_of(value):
|
||||
# stamp_value returns cost_from_fp(value_fp), and division by
|
||||
# COST_FP (a power of two) is exact in binary floating point,
|
||||
# so the fixed-point representation can be recovered losslessly.
|
||||
fp = round(value * Stamps.COST_FP)
|
||||
assert fp == int(value * Stamps.COST_FP)
|
||||
return fp
|
||||
|
||||
|
||||
class TestStampFixedPoint(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# A shared pool of deterministic workblock/stamp samples,
|
||||
# used to lock in the value layer invariants.
|
||||
cls.samples = []
|
||||
for _ in range(3000):
|
||||
wb = rb(rng.randint(0, 48))
|
||||
stamp = rb(rng.choice((RNS.Identity.STAMPLENGTH, Stamps.STAMP_SIZE)))
|
||||
hn = int.from_bytes(RNS.Identity.full_hash(wb+stamp), byteorder="big")
|
||||
vleg = Stamps.stamp_value_legacy(wb, stamp)
|
||||
v = Stamps.stamp_value(wb, stamp)
|
||||
exact = 256 - math.log2(hn)
|
||||
cls.samples.append((wb, stamp, hn, vleg, v, exact))
|
||||
|
||||
def test_00_fixed_point_conversions(self):
|
||||
cap = RNS.Transport.STAMP_COST_CAP
|
||||
for cost in range(0, cap+1):
|
||||
self.assertEqual(Stamps.cost_to_fp(cost), cost*Stamps.COST_FP)
|
||||
self.assertEqual(Stamps.cost_from_fp(Stamps.cost_to_fp(cost)), cost)
|
||||
|
||||
self.assertEqual(Stamps.cost_to_fp(8.5), 8.5*Stamps.COST_FP)
|
||||
self.assertEqual(Stamps.cost_from_fp(8.5*Stamps.COST_FP), 8.5)
|
||||
self.assertEqual(Stamps.cost_to_fp(0.5), 128)
|
||||
self.assertEqual(Stamps.cost_to_fp(-1), 0)
|
||||
self.assertEqual(Stamps.cost_to_fp(cap+1), cap*Stamps.COST_FP)
|
||||
|
||||
for fp in list(range(0, 65536, 97)) + [0, 255, 256, 65535]:
|
||||
packed = Stamps.fp_to_bytes(fp)
|
||||
self.assertEqual(len(packed), 2)
|
||||
self.assertEqual(Stamps.fp_from_bytes(packed), fp)
|
||||
|
||||
for cost in (0, 1, 4, 8.5, 64, 100):
|
||||
self.assertEqual(Stamps.cost_from_bytes(Stamps.cost_to_bytes(cost)), cost)
|
||||
|
||||
self.assertEqual(Stamps.cost_int(8*Stamps.COST_FP + 128), 8)
|
||||
self.assertEqual(Stamps.cost_str(8*Stamps.COST_FP), "8")
|
||||
self.assertEqual(Stamps.cost_str(8*Stamps.COST_FP + 128), "8.5")
|
||||
self.assertEqual(Stamps.cost_str(0), "0")
|
||||
|
||||
def test_01_target_for_integer_costs(self):
|
||||
cap = RNS.Transport.STAMP_COST_CAP
|
||||
for cost in range(0, cap+1):
|
||||
self.assertEqual(Stamps.target_from_cost(cost), 2**(256-cost))
|
||||
|
||||
self.assertEqual(Stamps.target_from_fp(0), 2**256)
|
||||
self.assertRaises(AssertionError, Stamps.target_from_fp, -1)
|
||||
self.assertRaises(AssertionError, Stamps.target_from_fp, cap*Stamps.COST_FP + 1)
|
||||
|
||||
def test_02_target_monotonic_and_exact(self):
|
||||
# Targets must strictly decrease as cost increases
|
||||
cap = RNS.Transport.STAMP_COST_CAP
|
||||
last = None
|
||||
for fp in range(0, cap*Stamps.COST_FP + 1):
|
||||
target = Stamps.target_from_fp(fp)
|
||||
if last != None:
|
||||
self.assertLess(target, last)
|
||||
last = target
|
||||
|
||||
# Independent verification of the whole mantissa/shift
|
||||
# construction against floor(2^(256 - fp/256)), computed
|
||||
# with exact integer arithmetic: The 256th root of
|
||||
# 2^(33*256+f), obtained by a Newton iteration, is exactly
|
||||
# floor(2^(33+f/256)), and shifting by the integer part of
|
||||
# the exponent yields the exact target for every step.
|
||||
def iroot(n, k):
|
||||
x = 1 << ((n.bit_length() + k - 1)//k)
|
||||
while True:
|
||||
y = ((k-1)*x + n//x**(k-1))//k
|
||||
if y >= x:
|
||||
return x
|
||||
x = y
|
||||
|
||||
roots = [iroot(1 << (Stamps.MANTISSA_BITS*Stamps.COST_FP + f), Stamps.COST_FP) for f in range(Stamps.COST_FP)]
|
||||
for fp in range(0, cap*Stamps.COST_FP + 1):
|
||||
i, f = divmod(256*Stamps.COST_FP - fp, Stamps.COST_FP)
|
||||
self.assertEqual(Stamps.target_from_fp(fp), roots[f] << (i - Stamps.MANTISSA_BITS))
|
||||
|
||||
def test_03_value_matches_legacy_integer_value(self):
|
||||
# The compatibility invariant: old clients parse fractional
|
||||
# stamps at their integer value. The legacy value function
|
||||
# must therefore always be the integer floor of the new one.
|
||||
for wb, stamp, hn, vleg, v, exact in self.samples:
|
||||
self.assertEqual(vleg, 256 - hn.bit_length())
|
||||
self.assertLessEqual(vleg, v)
|
||||
self.assertLess(v, vleg + 1)
|
||||
self.assertEqual(fp_of(v) // Stamps.COST_FP, vleg)
|
||||
|
||||
# Empty and None workblocks are handled identically
|
||||
wb, stamp, hn, vleg, v, exact = self.samples[0]
|
||||
self.assertEqual(Stamps.stamp_value(None, stamp), Stamps.stamp_value(b"", stamp))
|
||||
self.assertEqual(Stamps.stamp_value_legacy(None, stamp), Stamps.stamp_value_legacy(b"", stamp))
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, 0, None))
|
||||
|
||||
def test_04_value_never_overreports(self):
|
||||
# The reported value must never exceed the exact value of
|
||||
# the stamp product, and must be within one quantisation
|
||||
# step (1/256th) below it.
|
||||
step = 1.0 / Stamps.COST_FP
|
||||
for wb, stamp, hn, vleg, v, exact in self.samples:
|
||||
self.assertLessEqual(v, exact + 1e-9)
|
||||
self.assertLessEqual(exact, v + step + 1e-9)
|
||||
|
||||
def test_05_value_monotone_in_stamp_product(self):
|
||||
# A smaller stamp product (numerically) always means a more
|
||||
# rare hash, and must never yield a smaller value.
|
||||
ordered = sorted(self.samples, key=lambda sample: sample[2])
|
||||
last = None
|
||||
for wb, stamp, hn, vleg, v, exact in ordered:
|
||||
fp = fp_of(v)
|
||||
if last != None:
|
||||
self.assertLessEqual(fp, last)
|
||||
last = fp
|
||||
|
||||
def test_06_validity_boundaries(self):
|
||||
cap = RNS.Transport.STAMP_COST_CAP
|
||||
for wb, stamp, hn, vleg, v, exact in self.samples:
|
||||
# Any stamp is always valid at its legacy integer value,
|
||||
# and always invalid at exactly one step above it. This
|
||||
# locks stamp_valid and stamp_value into one scheme.
|
||||
if vleg <= cap:
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, vleg, wb))
|
||||
if vleg + 1 <= cap:
|
||||
self.assertFalse(Stamps.stamp_valid(stamp, vleg + 1, wb))
|
||||
|
||||
# Directional consistency between value and validity
|
||||
for wb, stamp, hn, vleg, v, exact in self.samples[:500]:
|
||||
fp = fp_of(v)
|
||||
for cost in (1, 2, 3):
|
||||
if fp >= cost * Stamps.COST_FP:
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, cost, wb))
|
||||
if Stamps.stamp_valid(stamp, cost, wb):
|
||||
self.assertGreaterEqual(fp, (cost - 1) * Stamps.COST_FP)
|
||||
|
||||
def test_07_target_probability_calibration(self):
|
||||
# The defining semantic of cost: a random stamp is valid for
|
||||
# cost c with probability exactly 2^-c.
|
||||
for cost in (2, 4):
|
||||
trials = 20000
|
||||
wb = rb(32)
|
||||
valid = sum(1 for _ in range(trials) if Stamps.stamp_valid(rb(14), cost, wb))
|
||||
fraction = valid / trials
|
||||
expected = 2.0**-cost
|
||||
sigma = math.sqrt(expected * (1-expected) / trials)
|
||||
self.assertLess(abs(fraction - expected), 5*sigma)
|
||||
|
||||
def test_08_value_deterministic(self):
|
||||
for wb, stamp, hn, vleg, v, exact in self.samples[:100]:
|
||||
self.assertEqual(Stamps.stamp_value(wb, stamp), v)
|
||||
self.assertEqual(Stamps.stamp_value_legacy(wb, stamp), vleg)
|
||||
|
||||
|
||||
class TestStampWorkblock(unittest.TestCase):
|
||||
def test_00_no_expand(self):
|
||||
material = rb(64)
|
||||
self.assertIs(Stamps.stamp_workblock(material, no_expand=True), material)
|
||||
self.assertIs(Stamps.stamp_workblock(material, expand_rounds=0), material)
|
||||
self.assertEqual(Stamps.stamp_workblock(material, expand_rounds=16, no_expand=True), material)
|
||||
|
||||
def test_01_expansion(self):
|
||||
material = rb(32)
|
||||
wb1 = Stamps.stamp_workblock(material, expand_rounds=16)
|
||||
wb2 = Stamps.stamp_workblock(material, expand_rounds=16)
|
||||
self.assertEqual(len(wb1), 16*256)
|
||||
self.assertEqual(wb1, wb2)
|
||||
self.assertNotEqual(wb1, Stamps.stamp_workblock(rb(32), expand_rounds=16))
|
||||
|
||||
def test_02_default_expansion(self):
|
||||
material = rb(32)
|
||||
wb = Stamps.stamp_workblock(material)
|
||||
self.assertEqual(len(wb), Stamps.WORKBLOCK_EXPAND_ROUNDS*256)
|
||||
self.assertEqual(wb, Stamps.stamp_workblock(material))
|
||||
|
||||
|
||||
class TestStampGeneration(unittest.TestCase):
|
||||
def _wait_registered(self, mid, timeout=15):
|
||||
for _ in range(int(timeout/0.05)):
|
||||
if mid in Stamps.active_jobs:
|
||||
return True
|
||||
time.sleep(0.05)
|
||||
return False
|
||||
|
||||
def test_00_generate_stamp_low_costs(self):
|
||||
for cost in (0, 4, 8):
|
||||
mid = rb(32)
|
||||
stamp, value = Stamps.generate_stamp(mid, cost, no_expand=True)
|
||||
self.assertNotEqual(stamp, None)
|
||||
self.assertIsInstance(stamp, bytes)
|
||||
self.assertEqual(len(stamp), Stamps.STAMP_SIZE)
|
||||
|
||||
# The generation contract: the stamp must validate at
|
||||
# the requested cost, and the reported value must be
|
||||
# within one quantisation step of the requested cost.
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, cost, mid))
|
||||
self.assertGreaterEqual(fp_of(value), (cost - 1) * Stamps.COST_FP)
|
||||
|
||||
# Old clients parse the fractional value at its integer
|
||||
# value, so that must always be at least cost - 1, and
|
||||
# must match the legacy value function exactly.
|
||||
vleg = Stamps.stamp_value_legacy(mid, stamp)
|
||||
self.assertGreaterEqual(vleg, cost - 1)
|
||||
self.assertEqual(fp_of(value) // Stamps.COST_FP, vleg)
|
||||
self.assertLess(value, 256)
|
||||
self.assertEqual(value, Stamps.stamp_value(mid, stamp))
|
||||
|
||||
def test_01_generate_stamp_expanded_workblock(self):
|
||||
mid = rb(32)
|
||||
stamp, value = Stamps.generate_stamp(mid, 4, expand_rounds=16)
|
||||
wb = Stamps.stamp_workblock(mid, expand_rounds=16)
|
||||
self.assertEqual(len(wb), 16*256)
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, 4, wb))
|
||||
self.assertEqual(value, Stamps.stamp_value(wb, stamp))
|
||||
|
||||
def test_02_generate_stamp_default_workblock(self):
|
||||
mid = rb(32)
|
||||
stamp, value = Stamps.generate_stamp(mid, 4)
|
||||
wb = Stamps.stamp_workblock(mid)
|
||||
self.assertEqual(len(wb), Stamps.WORKBLOCK_EXPAND_ROUNDS*256)
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, 4, wb))
|
||||
|
||||
def test_03_generate_stamped_key(self):
|
||||
material = rb(32)
|
||||
keypair, value = Stamps.generate_stamped_key(material, 4)
|
||||
private, public = keypair
|
||||
self.assertEqual(len(private), 32)
|
||||
self.assertEqual(len(public), 32)
|
||||
self.assertEqual(RNS.Cryptography.X25519PrivateKey.from_private_bytes(private).public_key().public_bytes(), public)
|
||||
|
||||
# Keystamp validation uses the public key bytes as the stamp
|
||||
self.assertTrue(Stamps.stamp_valid(public, 4, material))
|
||||
self.assertEqual(value, Stamps.stamp_value(material, public))
|
||||
self.assertGreaterEqual(fp_of(value), 3 * Stamps.COST_FP)
|
||||
|
||||
def test_04_generate_stamped_key_empty_material(self):
|
||||
keypair, value = Stamps.generate_stamped_key(None, 2)
|
||||
private, public = keypair
|
||||
self.assertTrue(Stamps.stamp_valid(public, 2, b""))
|
||||
self.assertEqual(value, Stamps.stamp_value(b"", public))
|
||||
|
||||
def test_05_invalid_costs_rejected(self):
|
||||
cap = RNS.Transport.STAMP_COST_CAP
|
||||
mid = rb(16)
|
||||
for cost in (-1, cap + 1):
|
||||
with self.assertRaises(ValueError):
|
||||
Stamps.generate_stamp(mid, cost, no_expand=True)
|
||||
with self.assertRaises(ValueError):
|
||||
Stamps.generate_stamped_key(mid, cost)
|
||||
|
||||
def test_06_duplicate_job_rejected(self):
|
||||
mid = rb(16)
|
||||
Stamps.active_jobs[mid] = False
|
||||
try:
|
||||
with self.assertRaises(RuntimeError):
|
||||
Stamps.generate_stamp(mid, 4, no_expand=True)
|
||||
with self.assertRaises(RuntimeError):
|
||||
Stamps.generate_stamped_key(mid, 4)
|
||||
finally:
|
||||
del Stamps.active_jobs[mid]
|
||||
|
||||
def test_07_cancel_unknown_job(self):
|
||||
# Cancelling a job that was never started must be a safe no-op
|
||||
Stamps.cancel_work(rb(16))
|
||||
|
||||
def test_08_cancel_simple_job(self):
|
||||
mid = rb(16)
|
||||
wb = rb(32)
|
||||
result = {}
|
||||
def work():
|
||||
result["r"] = Stamps.job_simple(30*Stamps.COST_FP, wb, mid, Stamps.STAMP_SIZE)
|
||||
|
||||
worker = threading.Thread(target=work, daemon=True)
|
||||
worker.start()
|
||||
self.assertTrue(self._wait_registered(mid))
|
||||
time.sleep(0.2)
|
||||
self.assertIs(Stamps.active_jobs[mid], False) # Still running
|
||||
|
||||
Stamps.cancel_work(mid)
|
||||
worker.join(timeout=10)
|
||||
self.assertFalse(worker.is_alive())
|
||||
|
||||
# Cost 30 can never complete, so a timely return with no
|
||||
# stamp proves cancellation worked, and that work was done.
|
||||
self.assertEqual(result["r"][0], None)
|
||||
self.assertGreater(result["r"][1], 0)
|
||||
self.assertNotIn(mid, Stamps.active_jobs)
|
||||
|
||||
def test_09_cancel_generation_job(self):
|
||||
mid = rb(16)
|
||||
result = {}
|
||||
def work():
|
||||
result["r"] = Stamps.generate_stamp(mid, 30, no_expand=True)
|
||||
|
||||
worker = threading.Thread(target=work, daemon=True)
|
||||
worker.start()
|
||||
self.assertTrue(self._wait_registered(mid))
|
||||
time.sleep(0.3)
|
||||
Stamps.cancel_work(mid)
|
||||
worker.join(timeout=30)
|
||||
self.assertFalse(worker.is_alive())
|
||||
|
||||
stamp, value = result["r"]
|
||||
self.assertEqual(stamp, None)
|
||||
self.assertNotIn(mid, Stamps.active_jobs)
|
||||
|
||||
@skipIf(not RNS.vendor.platformutils.is_linux(), "Direct multiprocess dispatchers are Linux-only paths")
|
||||
def test_10_direct_multiprocess_dispatch(self):
|
||||
# generate_stamp only routes to the multiprocess dispatchers
|
||||
# at cost >= POOLING_THRESHOLD_COST, so they are exercised
|
||||
# directly here at a trivial cost. This covers both the
|
||||
# classic and managed worker mechanisms regardless of the
|
||||
# Python version in use.
|
||||
wb = rb(32)
|
||||
mid1 = rb(16)
|
||||
mid2 = rb(16)
|
||||
|
||||
stamp, rounds = Stamps.job_linux(4*Stamps.COST_FP, wb, mid1, Stamps.STAMP_SIZE)
|
||||
self.assertNotEqual(stamp, None)
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, 4, wb))
|
||||
self.assertGreater(rounds, 0)
|
||||
self.assertNotIn(mid1, Stamps.active_jobs)
|
||||
|
||||
stamp, rounds = Stamps.job_linux_managed(5*Stamps.COST_FP, wb, mid2, Stamps.STAMP_SIZE)
|
||||
self.assertNotEqual(stamp, None)
|
||||
self.assertTrue(Stamps.stamp_valid(stamp, 5, wb))
|
||||
self.assertGreater(rounds, 0)
|
||||
self.assertNotIn(mid2, Stamps.active_jobs)
|
||||
|
||||
|
||||
class TestStampPersistence(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.tmpdir = None
|
||||
cls.owns_instance = False
|
||||
# The full test suite shares one Reticulum instance, created
|
||||
# by whichever test needed it first. If none is running, a
|
||||
# temporary instance is created for this class only, and
|
||||
# cleanly detached again afterwards.
|
||||
if not RNS.Reticulum.storagepath:
|
||||
cls.tmpdir = tempfile.mkdtemp(prefix="rns_stamp_tests_")
|
||||
RNS.Reticulum(configdir=cls.tmpdir, loglevel=RNS.LOG_CRITICAL)
|
||||
cls.owns_instance = True
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
if cls.owns_instance:
|
||||
RNS.Reticulum._Reticulum__instance = None
|
||||
RNS.Reticulum.configpath = ""
|
||||
RNS.Reticulum.storagepath = ""
|
||||
RNS.Reticulum.cachepath = ""
|
||||
RNS.Reticulum.interfacepath = ""
|
||||
if cls.tmpdir:
|
||||
shutil.rmtree(cls.tmpdir, ignore_errors=True)
|
||||
|
||||
def _make_stamp(self, dest, cost=4):
|
||||
# Destination stamps are STAMPLENGTH bytes, and are generated
|
||||
# without workblock expansion, since the persistence layer
|
||||
# recomputes the workblock as the unexpanded material.
|
||||
return Stamps.generate_stamp(dest, cost, no_expand=True, size=RNS.Identity.STAMPLENGTH)
|
||||
|
||||
def _cleanup(self, dest):
|
||||
path = Stamps.destination_stamp_file(dest)
|
||||
if path and os.path.isfile(path):
|
||||
os.remove(path)
|
||||
|
||||
def test_00_store_load_roundtrip(self):
|
||||
dest = rb(16)
|
||||
self.addCleanup(self._cleanup, dest)
|
||||
stamp, value = self._make_stamp(dest)
|
||||
|
||||
self.assertTrue(Stamps.store_destination_stamp(dest, stamp, value))
|
||||
loaded = Stamps.load_destination_stamp(dest, dest, 4)
|
||||
self.assertNotEqual(loaded, None)
|
||||
lstamp, lvalue = loaded
|
||||
self.assertEqual(lstamp, stamp)
|
||||
self.assertEqual(lvalue, value)
|
||||
|
||||
def test_01_load_value_boundaries(self):
|
||||
dest = rb(16)
|
||||
self.addCleanup(self._cleanup, dest)
|
||||
stamp, value = self._make_stamp(dest)
|
||||
Stamps.store_destination_stamp(dest, stamp, value)
|
||||
|
||||
# A stamp is always valid at its legacy integer value
|
||||
vleg = Stamps.stamp_value_legacy(dest, stamp)
|
||||
loaded = Stamps.load_destination_stamp(dest, dest, vleg)
|
||||
self.assertNotEqual(loaded, None)
|
||||
self.assertEqual(loaded[0], stamp)
|
||||
|
||||
# ... and never at a full step above its own value
|
||||
self.assertEqual(Stamps.load_destination_stamp(dest, dest, value + 1), None)
|
||||
|
||||
def test_02_load_nonexistent(self):
|
||||
self.assertEqual(Stamps.load_destination_stamp(rb(16), rb(16), 1), None)
|
||||
|
||||
def test_03_load_corrupt_file(self):
|
||||
dest = rb(16)
|
||||
self.addCleanup(self._cleanup, dest)
|
||||
stamp, value = self._make_stamp(dest)
|
||||
Stamps.store_destination_stamp(dest, stamp, value)
|
||||
with open(Stamps.destination_stamp_file(dest), "wb") as file:
|
||||
file.write(rb(64))
|
||||
self.assertEqual(Stamps.load_destination_stamp(dest, dest, 1), None)
|
||||
|
||||
def test_04_load_wrong_version(self):
|
||||
dest = rb(16)
|
||||
self.addCleanup(self._cleanup, dest)
|
||||
stamp, value = self._make_stamp(dest)
|
||||
Stamps.store_destination_stamp(dest, stamp, value)
|
||||
with open(Stamps.destination_stamp_file(dest), "wb") as file:
|
||||
file.write(msgpack.packb({"v": 99, "stamp": stamp, "value": value, "generated": time.time()}))
|
||||
self.assertEqual(Stamps.load_destination_stamp(dest, dest, 1), None)
|
||||
|
||||
def test_05_load_wrong_stamp_length(self):
|
||||
dest = rb(16)
|
||||
self.addCleanup(self._cleanup, dest)
|
||||
stamp, value = self._make_stamp(dest)
|
||||
Stamps.store_destination_stamp(dest, stamp, value)
|
||||
with open(Stamps.destination_stamp_file(dest), "wb") as file:
|
||||
file.write(msgpack.packb({"v": Stamps.STAMP_FILE_VERSION, "stamp": rb(8), "value": value, "generated": time.time()}))
|
||||
self.assertEqual(Stamps.load_destination_stamp(dest, dest, 1), None)
|
||||
|
||||
def test_06_stamp_paths(self):
|
||||
directory = Stamps.stamps_dir(create=True)
|
||||
self.assertNotEqual(directory, None)
|
||||
self.assertTrue(os.path.isdir(directory))
|
||||
|
||||
dest = rb(16)
|
||||
path = Stamps.destination_stamp_file(dest)
|
||||
self.assertEqual(os.path.dirname(path), directory)
|
||||
self.assertTrue(path.endswith(RNS.hexrep(dest, delimit=False) + Stamps.DESTINATION_STAMP_EXTENSION))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
||||
Loaded 100 of 101 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user