mirror of
https://github.com/ratspeak/rsReticulum
synced 2026-11-22 23:10:33 +00:00
ble: upgrade btleplug with bounded Windows address recovery
Require Rust 1.89 for the host workspace and align manifests, CI, source contracts and locks. Apply the compiler's required let-chain lint fixes without changing public API snapshots. Keep Apple bindings explicit, preserve native Android owners, and qualify Windows BLE tests alongside other platforms.
This commit is contained in:
1 parent
5edb8f22f5
commit
f64b4d22d9
68 files changed
+1456
-1023
No files matched your search
@@ -61,8 +61,7 @@ jobs:
|
||||
run: cargo test --workspace --locked
|
||||
- name: Build application examples
|
||||
run: cargo build -p rns-runtime --examples --locked
|
||||
- name: Test BLE interface features (Linux/macOS)
|
||||
if: runner.os != 'Windows'
|
||||
- name: Test BLE interface features
|
||||
run: cargo test -p rns-interface --features ble --locked
|
||||
|
||||
lint:
|
||||
@@ -90,14 +89,14 @@ jobs:
|
||||
- run: cargo check --workspace --no-default-features --locked
|
||||
|
||||
msrv:
|
||||
name: Rust 1.87 MSRV
|
||||
name: Rust 1.89 MSRV
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
||||
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
|
||||
with:
|
||||
toolchain: 1.87.0
|
||||
toolchain: 1.89.0
|
||||
components: clippy
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
|
||||
with:
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
|
||||
with:
|
||||
toolchain: 1.87.0
|
||||
toolchain: 1.89.0
|
||||
- run: python3 scripts/ci/check_source_release_contract.py --release-tag "${RELEASE_TAG}"
|
||||
|
||||
build:
|
||||
@@ -59,7 +59,7 @@ jobs:
|
||||
ref: ${{ env.RELEASE_TAG }}
|
||||
- uses: dtolnay/rust-toolchain@6c977a6ca4077a0ceb28ffbe03f59d46e9ac8772 # master
|
||||
with:
|
||||
toolchain: 1.87.0
|
||||
toolchain: 1.89.0
|
||||
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2
|
||||
with:
|
||||
cache-bin: false
|
||||
|
||||
@@ -8,8 +8,16 @@
|
||||
|
||||
### Fixed and improved
|
||||
|
||||
- Updated btleplug to 0.13.4, including upstream Windows discovery and reconnect fixes. Windows can try an explicitly configured RNode MAC or an eligible remembered BLE Peer absent from scan results, with bounded GATT setup, existing backoff and signed peer identity checks.
|
||||
- Installed desktop BLE notification receivers before subscribing and limited packet fragments to the negotiated ATT payload.
|
||||
|
||||
- Improved Bluetooth Peer packet sizing and flow control, including Apple write handling and queued sends.
|
||||
|
||||
### Build and compatibility
|
||||
|
||||
- Raised the full Rust workspace minimum compiler to Rust 1.89. Apple native BLE bindings now declare their required features explicitly. Android consumers must use btleplug's matching 0.13.4 Java bridge and JNI 0.22 initialization.
|
||||
|
||||
|
||||
|
||||
## 1.3.0 - 2026-09-10
|
||||
|
||||
|
||||
Generated
+269
-207
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -17,7 +17,7 @@ members = [
|
||||
version = "1.3.0"
|
||||
edition = "2024"
|
||||
license = "AGPL-3.0-or-later"
|
||||
rust-version = "1.87"
|
||||
rust-version = "1.89"
|
||||
|
||||
[workspace.dependencies]
|
||||
# Crypto
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
[](LICENSE)
|
||||
[](https://www.rust-lang.org)
|
||||
[](https://www.rust-lang.org)
|
||||
[](https://reticulum.network/)
|
||||
[](#feature-status)
|
||||
|
||||
|
||||
Generated
+158
-108
@@ -44,9 +44,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.1"
|
||||
version = "2.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da"
|
||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
@@ -72,7 +72,16 @@ version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f"
|
||||
dependencies = [
|
||||
"objc2",
|
||||
"objc2 0.5.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block2"
|
||||
version = "0.6.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
|
||||
dependencies = [
|
||||
"objc2 0.6.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -110,7 +119,7 @@ version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84ae4213cc2a8dc663acecac67bbdad05142be4d8ef372b6903abf878b0c690a"
|
||||
dependencies = [
|
||||
"bitflags 2.13.1",
|
||||
"bitflags 2.13.2",
|
||||
"bluez-generated",
|
||||
"dbus",
|
||||
"dbus-tokio",
|
||||
@@ -135,29 +144,28 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "btleplug"
|
||||
version = "0.11.8"
|
||||
version = "0.13.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9a11621cb2c8c024e444734292482b1ad86fb50ded066cf46252e46643c8748"
|
||||
checksum = "f48faeeeb43498bf6f58a610cb92e68ac3ebef7dd723963fd172e67f045b058c"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"bitflags 2.13.1",
|
||||
"bitflags 2.13.2",
|
||||
"bluez-async",
|
||||
"dashmap 6.2.1",
|
||||
"dashmap",
|
||||
"dbus",
|
||||
"futures",
|
||||
"jni",
|
||||
"jni-utils",
|
||||
"jni 0.22.4",
|
||||
"log",
|
||||
"objc2",
|
||||
"objc2-core-bluetooth",
|
||||
"objc2-foundation",
|
||||
"objc2 0.6.5",
|
||||
"objc2-core-bluetooth 0.3.2",
|
||||
"objc2-foundation 0.3.2",
|
||||
"once_cell",
|
||||
"static_assertions",
|
||||
"thiserror 2.0.20",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
"uuid",
|
||||
"windows 0.61.3",
|
||||
"windows 0.62.2",
|
||||
"windows-future",
|
||||
]
|
||||
|
||||
@@ -360,19 +368,6 @@ dependencies = [
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "5.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"hashbrown",
|
||||
"lock_api",
|
||||
"once_cell",
|
||||
"parking_lot_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dashmap"
|
||||
version = "6.2.1"
|
||||
@@ -490,7 +485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -726,6 +721,36 @@ dependencies = [
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jni"
|
||||
version = "0.22.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"combine",
|
||||
"jni-macros",
|
||||
"jni-sys 0.4.1",
|
||||
"log",
|
||||
"simd_cesu8",
|
||||
"thiserror 2.0.20",
|
||||
"walkdir",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jni-macros"
|
||||
version = "0.22.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rustc_version",
|
||||
"simd_cesu8",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jni-sys"
|
||||
version = "0.3.1"
|
||||
@@ -754,26 +779,11 @@ dependencies = [
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jni-utils"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "259e9f2c3ead61de911f147000660511f07ab00adeed1d84f5ac4d0386e7a6c4"
|
||||
dependencies = [
|
||||
"dashmap 5.5.3",
|
||||
"futures",
|
||||
"jni",
|
||||
"log",
|
||||
"once_cell",
|
||||
"static_assertions",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.104"
|
||||
version = "0.3.103"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e0c1080212aad755ea003d18543e8768dd432c48819efd73a7bf1e39b7a5a3a"
|
||||
checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"futures-util",
|
||||
@@ -818,9 +828,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.33"
|
||||
version = "0.4.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
|
||||
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
||||
|
||||
[[package]]
|
||||
name = "macaddr"
|
||||
@@ -881,7 +891,7 @@ version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
||||
dependencies = [
|
||||
"bitflags 2.13.1",
|
||||
"bitflags 2.13.2",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
@@ -923,15 +933,35 @@ dependencies = [
|
||||
"objc2-encode",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8"
|
||||
dependencies = [
|
||||
"objc2-encode",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-core-bluetooth"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a644b62ffb826a5277f536cf0f701493de420b13d40e700c452c36567771111"
|
||||
dependencies = [
|
||||
"bitflags 2.13.1",
|
||||
"objc2",
|
||||
"objc2-foundation",
|
||||
"bitflags 2.13.2",
|
||||
"objc2 0.5.2",
|
||||
"objc2-foundation 0.2.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-core-bluetooth"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79b30b9eacc37434a61377866f68b27acef9fa5496f25cc9ca8b2549032e0394"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"objc2 0.6.5",
|
||||
"objc2-foundation 0.3.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -946,10 +976,21 @@ version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8"
|
||||
dependencies = [
|
||||
"bitflags 2.13.1",
|
||||
"block2",
|
||||
"bitflags 2.13.2",
|
||||
"block2 0.5.1",
|
||||
"libc",
|
||||
"objc2",
|
||||
"objc2 0.5.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "objc2-foundation"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
|
||||
dependencies = [
|
||||
"bitflags 2.13.2",
|
||||
"block2 0.6.2",
|
||||
"objc2 0.6.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -978,7 +1019,7 @@ dependencies = [
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
"smallvec",
|
||||
"windows-link 0.2.1",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1092,7 +1133,7 @@ version = "0.5.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||
dependencies = [
|
||||
"bitflags 2.13.1",
|
||||
"bitflags 2.13.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1179,13 +1220,13 @@ dependencies = [
|
||||
"futures",
|
||||
"hex",
|
||||
"if-addrs",
|
||||
"jni",
|
||||
"jni 0.19.0",
|
||||
"libc",
|
||||
"md-5",
|
||||
"mio",
|
||||
"objc2",
|
||||
"objc2-core-bluetooth",
|
||||
"objc2-foundation",
|
||||
"objc2 0.5.2",
|
||||
"objc2-core-bluetooth 0.2.2",
|
||||
"objc2-foundation 0.2.2",
|
||||
"rand",
|
||||
"rns-crypto",
|
||||
"rns-identity",
|
||||
@@ -1395,7 +1436,7 @@ version = "4.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4d91116f97173694f1642263b2ff837f80d933aa837e2314969f6728f661df3"
|
||||
dependencies = [
|
||||
"bitflags 2.13.1",
|
||||
"bitflags 2.13.2",
|
||||
"cfg-if",
|
||||
"core-foundation",
|
||||
"core-foundation-sys",
|
||||
@@ -1437,6 +1478,22 @@ dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd_cesu8"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520"
|
||||
dependencies = [
|
||||
"rustc_version",
|
||||
"simdutf8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simdutf8"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
@@ -1699,9 +1756,9 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
|
||||
|
||||
[[package]]
|
||||
name = "uuid"
|
||||
version = "1.24.1"
|
||||
version = "1.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cefc03fd367c0c6d4305de1b312cf00248c4114f4a0418ce6a6af769e3b0bd9"
|
||||
checksum = "97277d36b9c3ace13e58fa6e753f8b0bbbf302a18dd193240d70f9e29681059a"
|
||||
dependencies = [
|
||||
"getrandom 0.4.3",
|
||||
"js-sys",
|
||||
@@ -1732,9 +1789,9 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.127"
|
||||
version = "0.2.126"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b70935747edd64d89de3efa29d73789b806c15798f8e7dca4d8ac356b50ce70"
|
||||
checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
@@ -1745,9 +1802,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.127"
|
||||
version = "0.2.126"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77775f8f3f7217702089053b94958f8f54061a3f663417df76e19cbdcca29bc1"
|
||||
checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -1755,9 +1812,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.127"
|
||||
version = "0.2.126"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e11d33f857dc2fb11b8bc75aee111aa9cbeb12cd9f25efd3d4c2a3dd4e235284"
|
||||
checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"proc-macro2",
|
||||
@@ -1768,9 +1825,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.127"
|
||||
version = "0.2.126"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ef64dbcc55df09c7e5a46182d181c2cfa3e925f3da937ea764728b4bbb9dcbf"
|
||||
checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -1781,7 +1838,7 @@ version = "0.1.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1796,24 +1853,23 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.61.3"
|
||||
version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
|
||||
checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"
|
||||
dependencies = [
|
||||
"windows-collections",
|
||||
"windows-core 0.61.2",
|
||||
"windows-core 0.62.2",
|
||||
"windows-future",
|
||||
"windows-link 0.1.3",
|
||||
"windows-numerics",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-collections"
|
||||
version = "0.2.0"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8"
|
||||
checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
"windows-core 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1831,25 +1887,25 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.61.2"
|
||||
version = "0.62.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
||||
checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
|
||||
dependencies = [
|
||||
"windows-implement 0.60.2",
|
||||
"windows-interface 0.59.3",
|
||||
"windows-link 0.1.3",
|
||||
"windows-result 0.3.4",
|
||||
"windows-strings 0.4.2",
|
||||
"windows-link",
|
||||
"windows-result 0.4.1",
|
||||
"windows-strings 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-future"
|
||||
version = "0.2.1"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
|
||||
checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
"windows-link 0.1.3",
|
||||
"windows-core 0.62.2",
|
||||
"windows-link",
|
||||
"windows-threading",
|
||||
]
|
||||
|
||||
@@ -1897,12 +1953,6 @@ dependencies = [
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
@@ -1911,12 +1961,12 @@ checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-numerics"
|
||||
version = "0.2.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1"
|
||||
checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26"
|
||||
dependencies = [
|
||||
"windows-core 0.61.2",
|
||||
"windows-link 0.1.3",
|
||||
"windows-core 0.62.2",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1930,11 +1980,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.3.4"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
|
||||
checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
|
||||
dependencies = [
|
||||
"windows-link 0.1.3",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1949,11 +1999,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.4.2"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
|
||||
checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
|
||||
dependencies = [
|
||||
"windows-link 0.1.3",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1980,7 +2030,7 @@ version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link 0.2.1",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2001,11 +2051,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "windows-threading"
|
||||
version = "0.1.0"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6"
|
||||
checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"
|
||||
dependencies = [
|
||||
"windows-link 0.1.3",
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
{
|
||||
"name": "rns-crypto",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"default": [
|
||||
@@ -174,7 +174,7 @@
|
||||
{
|
||||
"name": "rns-identity",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {},
|
||||
"targets": [
|
||||
@@ -337,7 +337,7 @@
|
||||
{
|
||||
"name": "rns-interface",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"ble": [
|
||||
@@ -373,7 +373,7 @@
|
||||
"rename": null,
|
||||
"kind": null,
|
||||
"target": null,
|
||||
"requirement": "^0.11",
|
||||
"requirement": "=0.13.4",
|
||||
"optional": true,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
@@ -608,7 +608,10 @@
|
||||
"requirement": "^0.2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"features": [
|
||||
"CBAdvertisementData",
|
||||
"CBCentralManagerConstants"
|
||||
],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
@@ -619,7 +622,9 @@
|
||||
"requirement": "^0.2",
|
||||
"optional": false,
|
||||
"defaultFeatures": true,
|
||||
"features": [],
|
||||
"features": [
|
||||
"NSString"
|
||||
],
|
||||
"sourceKind": "registry"
|
||||
},
|
||||
{
|
||||
@@ -692,7 +697,7 @@
|
||||
{
|
||||
"name": "rns-link",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"default": [
|
||||
@@ -822,7 +827,7 @@
|
||||
{
|
||||
"name": "rns-protocol",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {},
|
||||
"targets": [
|
||||
@@ -959,7 +964,7 @@
|
||||
{
|
||||
"name": "rns-ratkey",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"default": [],
|
||||
@@ -1193,7 +1198,7 @@
|
||||
{
|
||||
"name": "rns-runtime",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"ble": [
|
||||
@@ -1471,7 +1476,7 @@
|
||||
{
|
||||
"name": "rns-tools",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"default": [],
|
||||
@@ -1747,7 +1752,7 @@
|
||||
{
|
||||
"name": "rns-transport",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"default": [],
|
||||
@@ -1922,7 +1927,7 @@
|
||||
{
|
||||
"name": "rns-wire",
|
||||
"version": "1.3.0",
|
||||
"rustVersion": "1.87",
|
||||
"rustVersion": "1.89",
|
||||
"edition": "2024",
|
||||
"features": {
|
||||
"default": [
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
# Keep Clippy suggestions aligned with the public MSRV in Cargo.toml.
|
||||
msrv = "1.87"
|
||||
msrv = "1.89"
|
||||
@@ -289,8 +289,9 @@ impl AnnounceData {
|
||||
|
||||
// First-seen key binding: a valid signature on a different public key
|
||||
// for an already-known destination hash implies a collision attack.
|
||||
if let Some(known_key) = known_public_key {
|
||||
if known_key != &self.public_key {
|
||||
if let Some(known_key) = known_public_key
|
||||
&& known_key != &self.public_key
|
||||
{
|
||||
tracing::error!(
|
||||
dest = hex::encode(packet_dest_hash),
|
||||
"announce has valid signature and destination hash, but public key \
|
||||
@@ -298,7 +299,6 @@ impl AnnounceData {
|
||||
);
|
||||
return Err(AnnounceError::HashCollision);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -852,11 +852,11 @@ impl Destination {
|
||||
|
||||
let plaintext = self.decrypt_with_ratchets(data, identity, ratchet_keys)?;
|
||||
|
||||
if packet_type == 0x00 {
|
||||
if let Some(ref cb) = self.packet_callback {
|
||||
if packet_type == 0x00
|
||||
&& let Some(ref cb) = self.packet_callback
|
||||
{
|
||||
cb(&plaintext, raw_packet);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Some(plaintext))
|
||||
}
|
||||
@@ -968,11 +968,11 @@ impl Destination {
|
||||
self.path_responses
|
||||
.retain(|_, v| time.cache <= v.timestamp + PR_TAG_WINDOW);
|
||||
|
||||
if let Some(tag_bytes) = tag {
|
||||
if let Some(cached) = self.path_responses.get(tag_bytes) {
|
||||
if let Some(tag_bytes) = tag
|
||||
&& let Some(cached) = self.path_responses.get(tag_bytes)
|
||||
{
|
||||
return Ok((cached.announce_data.clone(), cached.has_ratchet));
|
||||
}
|
||||
}
|
||||
|
||||
let effective_app_data = app_data
|
||||
.map(|d| d.to_vec())
|
||||
|
||||
@@ -357,18 +357,16 @@ impl Identity {
|
||||
let mut shared = ratchet_prv.exchange(&peer_pub);
|
||||
let derived_result = derive_key_64(&shared, &self.hash);
|
||||
shared.zeroize();
|
||||
if let Ok(derived) = derived_result {
|
||||
if let Ok(plaintext) = token::decrypt(ct, &derived) {
|
||||
if let Ok(derived) = derived_result
|
||||
&& let Ok(plaintext) = token::decrypt(ct, &derived)
|
||||
{
|
||||
return Ok(DecryptionResult {
|
||||
plaintext,
|
||||
ratchet_id: Some(Self::ratchet_id(
|
||||
&ratchet_prv.public_key().to_bytes(),
|
||||
)),
|
||||
ratchet_id: Some(Self::ratchet_id(&ratchet_prv.public_key().to_bytes())),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if enforce_ratchets {
|
||||
return Err(IdentityError::DecryptionFailed);
|
||||
|
||||
@@ -150,11 +150,11 @@ fn atomic_write_inner(
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
if let Some(dir) = path.parent() {
|
||||
if let Ok(d) = fs::File::open(dir) {
|
||||
if let Some(dir) = path.parent()
|
||||
&& let Ok(d) = fs::File::open(dir)
|
||||
{
|
||||
let _ = d.sync_all();
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})();
|
||||
|
||||
@@ -763,11 +763,11 @@ impl ReceivedRatchetStore {
|
||||
/// Record a ratchet with an explicit local receive time. Re-inserting the
|
||||
/// same key remains a no-op and therefore cannot extend its lifetime.
|
||||
pub fn remember_at(&mut self, dest_hash: [u8; 16], ratchet_pub: [u8; 32], received_at: f64) {
|
||||
if let Some(existing) = self.entries.get(&dest_hash) {
|
||||
if existing.ratchet_pub == ratchet_pub {
|
||||
if let Some(existing) = self.entries.get(&dest_hash)
|
||||
&& existing.ratchet_pub == ratchet_pub
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let received = ReceivedRatchet::new_at(ratchet_pub, received_at);
|
||||
|
||||
@@ -793,8 +793,9 @@ impl ReceivedRatchetStore {
|
||||
}
|
||||
|
||||
pub fn get_at(&mut self, dest_hash: &[u8; 16], now: f64) -> Option<[u8; 32]> {
|
||||
if !self.entries.contains_key(dest_hash) {
|
||||
if let Some(ref dir) = self.storage_dir {
|
||||
if !self.entries.contains_key(dest_hash)
|
||||
&& let Some(ref dir) = self.storage_dir
|
||||
{
|
||||
let hexhash = hex::encode(dest_hash);
|
||||
let path = dir.join(&hexhash);
|
||||
if path.exists() {
|
||||
@@ -817,7 +818,6 @@ impl ReceivedRatchetStore {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.entries
|
||||
.get(dest_hash)
|
||||
|
||||
@@ -29,7 +29,7 @@ tracing = { workspace = true }
|
||||
socket2 = { workspace = true }
|
||||
if-addrs = { workspace = true }
|
||||
serialport = { workspace = true, optional = true }
|
||||
btleplug = { version = "0.11", optional = true }
|
||||
btleplug = { version = "=0.13.4", optional = true }
|
||||
futures = { version = "0.3", optional = true }
|
||||
uuid = { version = "1", optional = true }
|
||||
rand = { workspace = true }
|
||||
@@ -39,15 +39,15 @@ hex = { workspace = true }
|
||||
md-5 = { workspace = true }
|
||||
|
||||
# Apple BLE Peripheral (CoreBluetooth GATT server, iOS + macOS).
|
||||
# Version pinned to match btleplug's internal objc2 version so the shared
|
||||
# runtime types stay binary-compatible. objc2-core-bluetooth gives us
|
||||
# These native owners do not exchange Objective-C types with btleplug. Keep
|
||||
# their binding generation and required features explicit. objc2-core-bluetooth gives us
|
||||
# linked-symbol access to NSString constants (CBCentralManagerScanOption*,
|
||||
# CB*RestoreIdentifierKey, etc.) instead of re-declaring their literal
|
||||
# values, which Apple is free to change.
|
||||
[target.'cfg(any(target_os = "ios", target_os = "macos"))'.dependencies]
|
||||
objc2 = "0.5"
|
||||
objc2-foundation = "0.2"
|
||||
objc2-core-bluetooth = "0.2"
|
||||
objc2-foundation = { version = "0.2", features = ["NSString"] }
|
||||
objc2-core-bluetooth = { version = "0.2", features = ["CBAdvertisementData", "CBCentralManagerConstants"] }
|
||||
|
||||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
libc = "0.2"
|
||||
|
||||
@@ -1712,11 +1712,11 @@ pub(crate) async fn run_usb_tx_pump(
|
||||
if application_rx.pending.is_none() {
|
||||
// A due beacon follows an already-pending application packet but
|
||||
// does not starve behind continuous later application traffic.
|
||||
if let Some((interval, ref callsign)) = beacon {
|
||||
if first_tx.is_some_and(|started| started.elapsed() >= interval) {
|
||||
if let Some((interval, ref callsign)) = beacon
|
||||
&& first_tx.is_some_and(|started| started.elapsed() >= interval)
|
||||
{
|
||||
application_rx.pending = Some(UsbPendingPacket::new(callsign.clone(), true));
|
||||
}
|
||||
}
|
||||
if application_rx.pending.is_none() {
|
||||
let payload = tokio::select! {
|
||||
biased;
|
||||
@@ -3808,11 +3808,9 @@ mod tests {
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.len()
|
||||
>= 3;
|
||||
if init_was_sent {
|
||||
if let Some(post_init) = self.post_init.take() {
|
||||
if init_was_sent && let Some(post_init) = self.post_init.take() {
|
||||
return Ok(UsbReadResult::Data(post_init));
|
||||
}
|
||||
}
|
||||
// `run_usb_reader` can call us again only after its prior
|
||||
// blocking_send of the stale read completed.
|
||||
self.stale_enqueued.store(true, Ordering::Release);
|
||||
|
||||
@@ -579,11 +579,11 @@ fn iface_passes_filters(
|
||||
if ignored_devices.iter().any(|n| n == iface_name) {
|
||||
return false;
|
||||
}
|
||||
if let Some(allowed) = devices {
|
||||
if !allowed.iter().any(|n| n == iface_name) {
|
||||
if let Some(allowed) = devices
|
||||
&& !allowed.iter().any(|n| n == iface_name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -623,8 +623,9 @@ fn get_link_local_addrs(
|
||||
if !iface_passes_filters(&iface.name, devices, ignored_devices) {
|
||||
continue;
|
||||
}
|
||||
if let std::net::IpAddr::V6(addr) = iface.addr.ip() {
|
||||
if (addr.segments()[0] & 0xffc0) == 0xfe80 {
|
||||
if let std::net::IpAddr::V6(addr) = iface.addr.ip()
|
||||
&& (addr.segments()[0] & 0xffc0) == 0xfe80
|
||||
{
|
||||
let scope_id = iface_scope_id(&iface);
|
||||
if scope_id == 0 {
|
||||
tracing::warn!(
|
||||
@@ -638,7 +639,6 @@ fn get_link_local_addrs(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
tracing::warn!(error = %e, "if_addrs::get_if_addrs() failed");
|
||||
}
|
||||
|
||||
@@ -256,17 +256,17 @@ pub async fn teardown_central() -> Result<(), String> {
|
||||
}
|
||||
|
||||
fn finalize_stop() {
|
||||
if let Some(lock) = POWERED_ON_TX.get() {
|
||||
if let Ok(mut g) = lock.lock() {
|
||||
if let Some(lock) = POWERED_ON_TX.get()
|
||||
&& let Ok(mut g) = lock.lock()
|
||||
{
|
||||
*g = None;
|
||||
}
|
||||
}
|
||||
// Drop the discovery sender so receivers don't hang on recv.
|
||||
if let Some(lock) = DISCOVERY_TX.get() {
|
||||
if let Ok(mut g) = lock.lock() {
|
||||
if let Some(lock) = DISCOVERY_TX.get()
|
||||
&& let Ok(mut g) = lock.lock()
|
||||
{
|
||||
*g = None;
|
||||
}
|
||||
}
|
||||
apply_event(CentralEvent::ScanStopped);
|
||||
apply_event(CentralEvent::Reset);
|
||||
}
|
||||
@@ -566,14 +566,12 @@ fn get_delegate_class() -> &'static AnyClass {
|
||||
|
||||
// No sender means stop_scan raced us between the radio event
|
||||
// and this callback — drop silently.
|
||||
if let Some(lock) = DISCOVERY_TX.get() {
|
||||
if let Ok(g) = lock.lock() {
|
||||
if let Some(tx) = g.as_ref() {
|
||||
if let Some(lock) = DISCOVERY_TX.get()
|
||||
&& let Ok(g) = lock.lock()
|
||||
&& let Some(tx) = g.as_ref() {
|
||||
let _ = tx.send(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Connection-state callbacks share this delegate (one delegate per
|
||||
// CBCentralManager) and forward to ble_central_apple_connect.
|
||||
|
||||
@@ -732,11 +732,11 @@ pub fn on_did_disconnect(address: &str, err: Option<String>) {
|
||||
if let Some(peer) = removed {
|
||||
peer.online.store(false, Ordering::SeqCst);
|
||||
}
|
||||
if let Ok(mut g) = online_flags().lock() {
|
||||
if let Some(flag) = g.remove(address) {
|
||||
if let Ok(mut g) = online_flags().lock()
|
||||
&& let Some(flag) = g.remove(address)
|
||||
{
|
||||
flag.store(false, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
let classified = classify_disconnect_reason(err.as_deref());
|
||||
if let Ok(mut g) = last_disconnect_reason().lock() {
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
//! Private bounds for desktop GATT setup and Windows address resolution.
|
||||
|
||||
use std::{fmt::Display, future::Future, time::Duration};
|
||||
|
||||
const OPERATION_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
|
||||
pub(super) async fn operation<T, E: Display>(
|
||||
label: &str,
|
||||
future: impl Future<Output = Result<T, E>>,
|
||||
) -> Result<T, String> {
|
||||
tokio::time::timeout(OPERATION_TIMEOUT, future)
|
||||
.await
|
||||
.map_err(|_| format!("{label}: timed out"))?
|
||||
.map_err(|error| format!("{label}: {error}"))
|
||||
}
|
||||
|
||||
/// Cancels an in-flight setup when its interface generation ends. The caller
|
||||
/// retains the peripheral in the teardown registry until cleanup completes.
|
||||
pub(super) async fn while_current<T>(
|
||||
future: impl Future<Output = Result<T, String>>,
|
||||
current: impl Fn() -> bool,
|
||||
) -> Result<T, String> {
|
||||
tokio::pin!(future);
|
||||
let mut tick = tokio::time::interval(Duration::from_millis(50));
|
||||
loop {
|
||||
if !current() {
|
||||
return Err("BLE connection cancelled".into());
|
||||
}
|
||||
tokio::select! {
|
||||
biased;
|
||||
_ = tick.tick() => {},
|
||||
result = &mut future => {
|
||||
return if current() { result } else { Err("BLE connection cancelled".into()) };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", test))]
|
||||
pub(super) fn known_address(value: &str) -> Option<btleplug::api::BDAddr> {
|
||||
let address: btleplug::api::BDAddr = value.parse().ok()?;
|
||||
// Neither sentinel can identify an explicitly selected device.
|
||||
(!matches!(
|
||||
address.to_string().as_str(),
|
||||
"00:00:00:00:00:00" | "FF:FF:FF:FF:FF:FF"
|
||||
))
|
||||
.then_some(address)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", test))]
|
||||
pub(super) async fn resolve_address<T, E: Display, F: Future<Output = Result<T, E>>>(
|
||||
cached: Option<T>,
|
||||
address: &str,
|
||||
add: impl FnOnce(btleplug::api::BDAddr) -> F,
|
||||
) -> Result<T, String> {
|
||||
if let Some(peripheral) = cached {
|
||||
return Ok(peripheral);
|
||||
}
|
||||
let address = known_address(address).ok_or("No valid configured BLE address")?;
|
||||
operation("Resolve BLE address", add(address)).await
|
||||
}
|
||||
|
||||
/// Keep the existing desktop ceiling; only shrink writes when the negotiated
|
||||
/// ATT MTU requires it. Unknown/invalid MTUs use BLE's mandatory baseline.
|
||||
pub(super) fn write_payload(mtu: u16) -> usize {
|
||||
if mtu < 23 {
|
||||
20
|
||||
} else {
|
||||
usize::from(mtu - 3).min(182)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::{
|
||||
Arc,
|
||||
atomic::{AtomicBool, Ordering},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
async fn cached_device_does_not_attempt_address_creation() {
|
||||
let result = resolve_address(Some(7), "platform-id", |_| async {
|
||||
panic!("must not add a cached peripheral");
|
||||
#[allow(unreachable_code)]
|
||||
Ok::<_, String>(8)
|
||||
})
|
||||
.await;
|
||||
assert_eq!(result, Ok(7));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn only_explicit_addresses_can_create_peripherals() {
|
||||
for invalid in [
|
||||
"",
|
||||
"RNode One",
|
||||
"1234",
|
||||
"00:00:00:00:00:00",
|
||||
"FF:FF:FF:FF:FF:FF",
|
||||
"AE34CD04-9854-4E64-8870-D58631FBBCC4",
|
||||
] {
|
||||
assert!(
|
||||
resolve_address::<(), String, _>(None, invalid, |_| async {
|
||||
panic!("invalid target reached the platform");
|
||||
#[allow(unreachable_code)]
|
||||
Ok(())
|
||||
})
|
||||
.await
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
resolve_address(None, "aa:bb:cc:dd:ee:01", |address| async move {
|
||||
Ok::<_, String>(address.to_string())
|
||||
})
|
||||
.await
|
||||
.unwrap(),
|
||||
"AA:BB:CC:DD:EE:01"
|
||||
);
|
||||
assert!(
|
||||
resolve_address::<(), _, _>(None, "AA:BB:CC:DD:EE:01", |_| async {
|
||||
Err("adapter unavailable")
|
||||
})
|
||||
.await
|
||||
.unwrap_err()
|
||||
.contains("adapter unavailable")
|
||||
);
|
||||
}
|
||||
|
||||
struct DropFlag(Arc<AtomicBool>);
|
||||
impl Drop for DropFlag {
|
||||
fn drop(&mut self) {
|
||||
self.0.store(true, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn unavailable_device_is_bounded_and_releases_pending_work() {
|
||||
let dropped = Arc::new(AtomicBool::new(false));
|
||||
let guard = DropFlag(dropped.clone());
|
||||
let result = resolve_address::<(), String, _>(None, "AA:BB:CC:DD:EE:01", |_| async move {
|
||||
let _guard = guard;
|
||||
std::future::pending().await
|
||||
})
|
||||
.await;
|
||||
assert!(result.unwrap_err().contains("timed out"));
|
||||
assert!(dropped.load(Ordering::SeqCst));
|
||||
}
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn generation_change_cancels_pending_setup_before_timeout() {
|
||||
let active = Arc::new(AtomicBool::new(true));
|
||||
let stop = active.clone();
|
||||
let dropped = Arc::new(AtomicBool::new(false));
|
||||
let guard = DropFlag(dropped.clone());
|
||||
tokio::spawn(async move {
|
||||
tokio::time::sleep(Duration::from_millis(75)).await;
|
||||
stop.store(false, Ordering::SeqCst);
|
||||
});
|
||||
let start = tokio::time::Instant::now();
|
||||
let result: Result<(), String> = while_current(
|
||||
async move {
|
||||
let _guard = guard;
|
||||
std::future::pending().await
|
||||
},
|
||||
|| active.load(Ordering::SeqCst),
|
||||
)
|
||||
.await;
|
||||
assert!(result.unwrap_err().contains("cancelled"));
|
||||
assert!(start.elapsed() < Duration::from_secs(1));
|
||||
assert!(dropped.load(Ordering::SeqCst));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn negotiated_mtu_never_exceeds_existing_write_ceiling() {
|
||||
for (mtu, expected) in [
|
||||
(0, 20),
|
||||
(22, 20),
|
||||
(23, 20),
|
||||
(100, 97),
|
||||
(185, 182),
|
||||
(247, 182),
|
||||
] {
|
||||
assert_eq!(write_payload(mtu), expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,11 @@ pub fn seed_recently_disconnected(map: &RecentlyDisconnected, addresses: Vec<Str
|
||||
if let Ok(mut guard) = map.lock() {
|
||||
let now = Instant::now();
|
||||
for address in addresses {
|
||||
// Windows scans emit canonical MACs. Normalize persisted route
|
||||
// hints too, so case changes cannot split connection/backoff keys.
|
||||
#[cfg(target_os = "windows")]
|
||||
let address =
|
||||
crate::ble_connect::known_address(&address).map_or(address, |mac| mac.to_string());
|
||||
if !address.is_empty() {
|
||||
guard.entry(address).or_insert((now, 0));
|
||||
}
|
||||
@@ -170,13 +175,13 @@ pub fn anti_loop_record(map: &AntiLoopMap, source: String, payload: &[u8]) {
|
||||
/// false iff `dest` is one of the peers `payload` arrived from.
|
||||
pub fn anti_loop_should_send(map: &AntiLoopMap, dest: &str, payload: &[u8]) -> bool {
|
||||
let h = payload_hash(payload);
|
||||
if let Ok(g) = map.lock() {
|
||||
if let Some((srcs, t)) = g.get(&h) {
|
||||
if t.elapsed() < ANTI_LOOP_TTL && srcs.contains(dest) {
|
||||
if let Ok(g) = map.lock()
|
||||
&& let Some((srcs, t)) = g.get(&h)
|
||||
&& t.elapsed() < ANTI_LOOP_TTL
|
||||
&& srcs.contains(dest)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
@@ -237,11 +242,10 @@ fn reconnect_in_backoff(map: &RecentlyDisconnected, address: &str) -> bool {
|
||||
if in_churn_backoff(address) {
|
||||
return true;
|
||||
}
|
||||
if let Ok(guard) = map.lock() {
|
||||
if let Some((when, fails)) = guard.get(address) {
|
||||
return *fails >= RECONNECT_BACKOFF_FAILURES
|
||||
&& when.elapsed() < RECONNECT_BACKOFF_DURATION;
|
||||
}
|
||||
if let Ok(guard) = map.lock()
|
||||
&& let Some((when, fails)) = guard.get(address)
|
||||
{
|
||||
return *fails >= RECONNECT_BACKOFF_FAILURES && when.elapsed() < RECONNECT_BACKOFF_DURATION;
|
||||
}
|
||||
false
|
||||
}
|
||||
@@ -346,8 +350,9 @@ fn note_peer_disconnected(address: &str) {
|
||||
if address.is_empty() {
|
||||
return;
|
||||
}
|
||||
if let Ok(mut g) = churn_track().lock() {
|
||||
if let Some(e) = g.get_mut(address) {
|
||||
if let Ok(mut g) = churn_track().lock()
|
||||
&& let Some(e) = g.get_mut(address)
|
||||
{
|
||||
// Only count as a flap when we know it connected recently; a
|
||||
// missing connect stamp defaults to "stable" so a missed
|
||||
// note_peer_connected can never manufacture wrongful backoff.
|
||||
@@ -356,15 +361,13 @@ fn note_peer_disconnected(address: &str) {
|
||||
e.0 = None;
|
||||
e.2 = Instant::now();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn in_churn_backoff(address: &str) -> bool {
|
||||
if let Ok(g) = churn_track().lock() {
|
||||
if let Some((_, count, last)) = g.get(address) {
|
||||
return *count >= RECONNECT_BACKOFF_FAILURES
|
||||
&& last.elapsed() < RECONNECT_BACKOFF_DURATION;
|
||||
}
|
||||
if let Ok(g) = churn_track().lock()
|
||||
&& let Some((_, count, last)) = g.get(address)
|
||||
{
|
||||
return *count >= RECONNECT_BACKOFF_FAILURES && last.elapsed() < RECONNECT_BACKOFF_DURATION;
|
||||
}
|
||||
false
|
||||
}
|
||||
@@ -550,16 +553,15 @@ pub fn clear_event_dispatcher() {
|
||||
/// can happen during burst events. Log so we see it instead of state silently
|
||||
/// going stale (e.g. UI stuck "Scanning…" because a Connected was dropped).
|
||||
pub(crate) fn dispatch_event(event: BlePeerEvent) {
|
||||
if let Ok(slot) = event_dispatch_slot().read() {
|
||||
if let Some(tx) = slot.as_ref() {
|
||||
if let Err(e) = tx.try_send(event) {
|
||||
if let Ok(slot) = event_dispatch_slot().read()
|
||||
&& let Some(tx) = slot.as_ref()
|
||||
&& let Err(e) = tx.try_send(event)
|
||||
{
|
||||
tracing::warn!(
|
||||
error = %e,
|
||||
"BLE peer event dispatch dropped — relay channel full or closed"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn peer_state_for_count(peer_count: usize) -> PeerState {
|
||||
@@ -688,8 +690,8 @@ pub async fn disconnect_mesh_peer(address: &str) {
|
||||
.lock()
|
||||
.ok()
|
||||
.and_then(|mut reg| reg.remove(address));
|
||||
if let Some(p) = peripheral {
|
||||
let _ = p.disconnect().await;
|
||||
if let Some((_, p)) = peripheral {
|
||||
let _ = crate::ble_connect::operation("Disconnect peer", p.disconnect()).await;
|
||||
}
|
||||
}
|
||||
#[cfg(not(any(
|
||||
@@ -2213,11 +2215,10 @@ mod apple_peripheral {
|
||||
pending.schedule.retain(|key| key != &(id.clone(), uuid));
|
||||
let all_gone = {
|
||||
let mut chars_map = central_subscribed_chars_map().lock().unwrap();
|
||||
if let Some(u) = char_uuid {
|
||||
if let Some(set) = chars_map.get_mut(&id) {
|
||||
if let Some(u) = char_uuid
|
||||
&& let Some(set) = chars_map.get_mut(&id) {
|
||||
set.remove(&u);
|
||||
}
|
||||
}
|
||||
let empty = chars_map.get(&id).is_none_or(|s| s.is_empty());
|
||||
if empty {
|
||||
chars_map.remove(&id);
|
||||
@@ -4338,8 +4339,7 @@ mod windows_peripheral {
|
||||
type InboundSender = mpsc::Sender<InboundFrame>;
|
||||
type InboundReceiver = mpsc::Receiver<InboundFrame>;
|
||||
static INBOUND_TX: OnceLock<Mutex<Option<InboundSender>>> = OnceLock::new();
|
||||
static INBOUND_RX: OnceLock<Mutex<Option<mpsc::Receiver<(String, bool, Vec<u8>)>>>> =
|
||||
OnceLock::new();
|
||||
static INBOUND_RX: OnceLock<Mutex<Option<InboundReceiver>>> = OnceLock::new();
|
||||
|
||||
/// Held state across a single start/stop cycle. `_provider` keeps the
|
||||
/// service registration alive; `_tx_chars` keeps the notifiable
|
||||
@@ -4492,8 +4492,9 @@ mod windows_peripheral {
|
||||
let len = reader.UnconsumedBufferLength()? as usize;
|
||||
let mut bytes = vec![0u8; len];
|
||||
reader.ReadBytes(&mut bytes)?;
|
||||
if let Some(tx) = inbound_sender() {
|
||||
if let Err(e) = tx.try_send((device_id.clone(), false, bytes)) {
|
||||
if let Some(tx) = inbound_sender()
|
||||
&& let Err(e) = tx.try_send((device_id.clone(), false, bytes))
|
||||
{
|
||||
tracing::warn!(
|
||||
target: "ble_trace",
|
||||
step = "windows_rx.channel_full",
|
||||
@@ -4502,7 +4503,6 @@ mod windows_peripheral {
|
||||
"Windows BLE RX: inbound channel full, dropping frame"
|
||||
);
|
||||
}
|
||||
}
|
||||
let _ = request.Respond();
|
||||
if let Some(d) = deferral {
|
||||
let _ = d.Complete();
|
||||
@@ -4818,10 +4818,15 @@ mod windows_peripheral {
|
||||
not(any(target_os = "android", target_os = "ios", target_os = "macos"))
|
||||
))]
|
||||
struct MeshPeerConnection {
|
||||
generation: u64,
|
||||
connection_id: u64,
|
||||
peripheral: btleplug::platform::Peripheral,
|
||||
rx_char: btleplug::api::Characteristic,
|
||||
tx_char: btleplug::api::Characteristic,
|
||||
write_mtu: usize,
|
||||
protocol: PeerProtocol,
|
||||
notifications:
|
||||
std::pin::Pin<Box<dyn futures::Stream<Item = btleplug::api::ValueNotification> + Send>>,
|
||||
/// Source key used by the anti-loop map. Matches the BLE address
|
||||
/// the Central sees so per-payload "do not echo back" filtering aligns
|
||||
/// with what the periph_rx consumer records on inbound reassembly.
|
||||
@@ -4837,9 +4842,9 @@ struct MeshPeerConnection {
|
||||
not(any(target_os = "android", target_os = "ios", target_os = "macos"))
|
||||
))]
|
||||
fn central_peripherals()
|
||||
-> &'static std::sync::Mutex<HashMap<String, btleplug::platform::Peripheral>> {
|
||||
-> &'static std::sync::Mutex<HashMap<String, (u64, btleplug::platform::Peripheral)>> {
|
||||
static REG: std::sync::OnceLock<
|
||||
std::sync::Mutex<HashMap<String, btleplug::platform::Peripheral>>,
|
||||
std::sync::Mutex<HashMap<String, (u64, btleplug::platform::Peripheral)>>,
|
||||
> = std::sync::OnceLock::new();
|
||||
REG.get_or_init(|| std::sync::Mutex::new(HashMap::new()))
|
||||
}
|
||||
@@ -4851,11 +4856,11 @@ fn central_peripherals()
|
||||
async fn disconnect_central_peripherals() {
|
||||
use btleplug::api::Peripheral as _;
|
||||
let peripherals: Vec<btleplug::platform::Peripheral> = match central_peripherals().lock() {
|
||||
Ok(mut m) => m.drain().map(|(_, p)| p).collect(),
|
||||
Ok(mut m) => m.drain().map(|(_, (_, p))| p).collect(),
|
||||
Err(_) => return,
|
||||
};
|
||||
for p in peripherals {
|
||||
let _ = p.disconnect().await;
|
||||
let _ = crate::ble_connect::operation("Disconnect peer", p.disconnect()).await;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4874,153 +4879,211 @@ async fn disconnect_central_peripherals() {
|
||||
async fn connect_mesh_peer(
|
||||
adapter: &btleplug::platform::Adapter,
|
||||
peer: &BlePeer,
|
||||
generation: u64,
|
||||
) -> Result<MeshPeerConnection, String> {
|
||||
use crate::ble_connect::{operation, while_current};
|
||||
use btleplug::api::{Central, Peripheral as _};
|
||||
|
||||
tracing::info!(
|
||||
target: "ble_trace",
|
||||
step = "peer.connect_begin",
|
||||
address = %peer.ble_address,
|
||||
rssi = peer.rssi,
|
||||
protocol = ?peer.protocol,
|
||||
"BLE mesh: starting connect"
|
||||
);
|
||||
|
||||
// Find peripheral by address from the adapter's cached list.
|
||||
//
|
||||
// Match on `p.address().to_string()` (MAC) rather than
|
||||
// `p.id().to_string()` because btleplug's `id()` is platform-
|
||||
// dependent — D-Bus path on Linux, MAC on Windows, CB UUID on
|
||||
// Apple — while `peer.ble_address` is always populated from
|
||||
// `props.address.to_string()` upstream (MAC). Matching on `id()`
|
||||
// would never resolve the Linux peer and surface the misleading
|
||||
// "Peer X no longer visible" error even though the peripheral was
|
||||
// freshly discovered. (Apple uses a separate native central path
|
||||
// — see `apple_scan_mesh_peers` — and never enters this loop.)
|
||||
let peripherals = adapter
|
||||
.peripherals()
|
||||
.await
|
||||
.map_err(|e| format!("Peripheral list: {e}"))?;
|
||||
let peripheral = peripherals
|
||||
.into_iter()
|
||||
.find(|p| {
|
||||
let peripheral = while_current(
|
||||
async {
|
||||
let peripherals = operation("Peripheral list", adapter.peripherals()).await?;
|
||||
let cached = peripherals.into_iter().find(|p| {
|
||||
p.address()
|
||||
.to_string()
|
||||
.eq_ignore_ascii_case(&peer.ble_address)
|
||||
})
|
||||
.ok_or_else(|| format!("Peer {} no longer visible", peer.ble_address))?;
|
||||
});
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
crate::ble_connect::resolve_address(
|
||||
cached,
|
||||
&peer.ble_address,
|
||||
|address| async move { adapter.add_peripheral(&address.into()).await },
|
||||
)
|
||||
.await
|
||||
}
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
cached.ok_or_else(|| format!("Peer {} no longer visible", peer.ble_address))
|
||||
},
|
||||
|| generation_is_current(generation),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// Connect with retry (pattern from ble_rnode.rs)
|
||||
let mut last_err = String::new();
|
||||
for attempt in 1..=3 {
|
||||
match peripheral.connect().await {
|
||||
Ok(()) => {
|
||||
tracing::info!(
|
||||
target: "ble_trace",
|
||||
step = "peer.connect_ok",
|
||||
address = %peer.ble_address,
|
||||
attempt,
|
||||
"BLE mesh: GATT connect succeeded"
|
||||
static NEXT_CONNECTION_ID: AtomicU64 = AtomicU64::new(1);
|
||||
let connection_id = NEXT_CONNECTION_ID.fetch_add(1, Ordering::Relaxed);
|
||||
|
||||
// Register BEFORE connecting: an abort during setup must still be covered
|
||||
// by interface teardown. Checking the generation under the registry lock
|
||||
// prevents a stopped generation from inserting after teardown drained it.
|
||||
{
|
||||
let mut reg = central_peripherals()
|
||||
.lock()
|
||||
.map_err(|_| "BLE registry unavailable")?;
|
||||
if !generation_is_current(generation) {
|
||||
return Err("BLE connection cancelled".into());
|
||||
}
|
||||
reg.insert(
|
||||
peer.ble_address.clone(),
|
||||
(connection_id, peripheral.clone()),
|
||||
);
|
||||
}
|
||||
|
||||
let result = while_current(
|
||||
async {
|
||||
let mut connected = false;
|
||||
let mut last_error = String::new();
|
||||
for attempt in 1..=3 {
|
||||
match operation("Connect peer", peripheral.connect()).await {
|
||||
Ok(()) => {
|
||||
connected = true;
|
||||
break;
|
||||
}
|
||||
Err(e) => {
|
||||
last_err = format!("{e}");
|
||||
tracing::warn!(
|
||||
target: "ble_trace",
|
||||
step = "peer.connect_fail",
|
||||
attempt,
|
||||
address = %peer.ble_address,
|
||||
error = %e,
|
||||
"BLE mesh connect attempt failed"
|
||||
);
|
||||
Err(error) => {
|
||||
last_error = error;
|
||||
// Clear partially created services/session before retry.
|
||||
operation("Reset peer connection", peripheral.disconnect()).await?;
|
||||
if attempt < 3 {
|
||||
tokio::time::sleep(Duration::from_secs(2)).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !peripheral.is_connected().await.unwrap_or(false) {
|
||||
return Err(format!("Connect failed after 3 attempts: {last_err}"));
|
||||
}
|
||||
|
||||
// Discover services
|
||||
peripheral
|
||||
.discover_services()
|
||||
.await
|
||||
.map_err(|e| format!("Service discovery: {e}"))?;
|
||||
let chars = peripheral.characteristics();
|
||||
tracing::info!(
|
||||
target: "ble_trace",
|
||||
step = "peer.services_discovered",
|
||||
address = %peer.ble_address,
|
||||
char_count = chars.len(),
|
||||
char_uuids = ?chars.iter().map(|c| c.uuid.to_string()).collect::<Vec<_>>(),
|
||||
"BLE mesh: GATT services discovered"
|
||||
);
|
||||
|
||||
// Find characteristics — try Ratspeak UUIDs first, fall back to Columba
|
||||
let (rx_uuid, tx_uuid, protocol) = if peer.protocol == PeerProtocol::Ratspeak {
|
||||
(RATSPEAK_RX_UUID, RATSPEAK_TX_UUID, PeerProtocol::Ratspeak)
|
||||
} else {
|
||||
(COLUMBA_RX_UUID, COLUMBA_TX_UUID, PeerProtocol::Columba)
|
||||
};
|
||||
|
||||
let rx_char = chars
|
||||
.iter()
|
||||
.find(|c| c.uuid == rx_uuid)
|
||||
.ok_or_else(|| format!("RX characteristic not found for {:?}", protocol))?
|
||||
.clone();
|
||||
let tx_char = chars
|
||||
.iter()
|
||||
.find(|c| c.uuid == tx_uuid)
|
||||
.ok_or_else(|| format!("TX characteristic not found for {:?}", protocol))?
|
||||
.clone();
|
||||
|
||||
// Subscribe to TX notifications (peer → us)
|
||||
peripheral
|
||||
.subscribe(&tx_char)
|
||||
.await
|
||||
.map_err(|e| format!("Subscribe TX: {e}"))?;
|
||||
tracing::info!(
|
||||
target: "ble_trace",
|
||||
step = "peer.subscribed",
|
||||
address = %peer.ble_address,
|
||||
tx_char = %tx_uuid,
|
||||
"BLE mesh: subscribed to peer TX notifications"
|
||||
);
|
||||
|
||||
// btleplug 0.11 exposes no negotiated-MTU getter, and there is no length
|
||||
// field to detect a stack-side truncation, so we must not assume more than
|
||||
// the lowest MTU any real peer negotiates. 182 = the iOS default ATT MTU
|
||||
// 185 minus the 3-byte ATT header; every modern BLE stack negotiates at
|
||||
// least this, so writes of this size are never silently truncated (the
|
||||
// 244 assumption corrupted multi-fragment packets sent to a <247-MTU peer,
|
||||
// e.g. an iOS peripheral). Per-peer negotiated sizing here waits on a
|
||||
// btleplug MTU API.
|
||||
let write_mtu = 182;
|
||||
|
||||
tracing::info!(
|
||||
target: "ble_trace",
|
||||
step = "peer.connected",
|
||||
address = %peer.ble_address,
|
||||
protocol = ?protocol,
|
||||
"BLE mesh peer connected"
|
||||
);
|
||||
|
||||
// Register for explicit disconnect on interface teardown (the read loop's
|
||||
// own disconnect is skipped when its task is aborted).
|
||||
if let Ok(mut reg) = central_peripherals().lock() {
|
||||
reg.insert(peer.ble_address.clone(), peripheral.clone());
|
||||
if !connected {
|
||||
return Err(format!("Connect failed after 3 attempts: {last_error}"));
|
||||
}
|
||||
operation("Service discovery", peripheral.discover_services()).await?;
|
||||
let (protocol, rx_char, tx_char) =
|
||||
mesh_gatt_characteristics(&peripheral.characteristics(), peer.protocol)
|
||||
.ok_or("Peer has no supported writable/notify mesh service")?;
|
||||
|
||||
// Install the receiver first so a peer's immediate first-contact
|
||||
// notification cannot fall into a subscribe-to-read-loop gap.
|
||||
let notifications =
|
||||
operation("Notification stream", peripheral.notifications()).await?;
|
||||
operation("Subscribe TX", peripheral.subscribe(&tx_char)).await?;
|
||||
Ok(MeshPeerConnection {
|
||||
peripheral,
|
||||
generation,
|
||||
connection_id,
|
||||
write_mtu: crate::ble_connect::write_payload(peripheral.mtu()),
|
||||
peripheral: peripheral.clone(),
|
||||
rx_char,
|
||||
tx_char,
|
||||
write_mtu,
|
||||
protocol,
|
||||
notifications,
|
||||
ble_address: peer.ble_address.clone(),
|
||||
})
|
||||
},
|
||||
|| generation_is_current(generation),
|
||||
)
|
||||
.await;
|
||||
|
||||
if result.is_err() {
|
||||
// Retain the entry during disconnect so an abort here is also cleaned
|
||||
// up by teardown. A later generation owns its own entry and cleanup.
|
||||
let owned = central_peripherals().lock().ok().is_some_and(|reg| {
|
||||
reg.get(&peer.ble_address)
|
||||
.is_some_and(|(owner, _)| *owner == connection_id)
|
||||
});
|
||||
if owned {
|
||||
let _ = operation("Failed peer cleanup", peripheral.disconnect()).await;
|
||||
remove_central_peripheral(&peer.ble_address, connection_id);
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[cfg(all(
|
||||
feature = "ble",
|
||||
not(any(target_os = "android", target_os = "ios", target_os = "macos"))
|
||||
))]
|
||||
fn remove_central_peripheral(address: &str, connection_id: u64) {
|
||||
if let Ok(mut reg) = central_peripherals().lock()
|
||||
&& reg
|
||||
.get(address)
|
||||
.is_some_and(|(owner, _)| *owner == connection_id)
|
||||
{
|
||||
reg.remove(address);
|
||||
}
|
||||
}
|
||||
|
||||
/// A remembered address has no trustworthy advertisement protocol hint.
|
||||
/// Validate a complete service tuple, preserving the discovered preference
|
||||
/// when a device offers both protocols. Identity still comes from an announce.
|
||||
#[cfg(any(test, target_os = "linux", target_os = "windows"))]
|
||||
fn mesh_gatt_characteristics(
|
||||
chars: &std::collections::BTreeSet<btleplug::api::Characteristic>,
|
||||
preferred: PeerProtocol,
|
||||
) -> Option<(
|
||||
PeerProtocol,
|
||||
btleplug::api::Characteristic,
|
||||
btleplug::api::Characteristic,
|
||||
)> {
|
||||
use btleplug::api::CharPropFlags;
|
||||
let alternatives = match preferred {
|
||||
PeerProtocol::Ratspeak => [PeerProtocol::Ratspeak, PeerProtocol::Columba],
|
||||
PeerProtocol::Columba => [PeerProtocol::Columba, PeerProtocol::Ratspeak],
|
||||
};
|
||||
for protocol in alternatives {
|
||||
let (service, rx, tx) = match protocol {
|
||||
PeerProtocol::Ratspeak => (RATSPEAK_SERVICE_UUID, RATSPEAK_RX_UUID, RATSPEAK_TX_UUID),
|
||||
PeerProtocol::Columba => (COLUMBA_SERVICE_UUID, COLUMBA_RX_UUID, COLUMBA_TX_UUID),
|
||||
};
|
||||
let receive = chars.iter().find(|c| {
|
||||
c.service_uuid == service
|
||||
&& c.uuid == rx
|
||||
&& c.properties.contains(CharPropFlags::WRITE_WITHOUT_RESPONSE)
|
||||
});
|
||||
let transmit = chars.iter().find(|c| {
|
||||
c.service_uuid == service
|
||||
&& c.uuid == tx
|
||||
&& c.properties.contains(CharPropFlags::NOTIFY)
|
||||
});
|
||||
if let (Some(rx), Some(tx)) = (receive, transmit) {
|
||||
return Some((protocol, rx.clone(), tx.clone()));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Admit at most one unseen remembered target per scan cycle, after visible
|
||||
/// peers. This bounds the offline-address cost and preserves scan priority.
|
||||
#[cfg(any(target_os = "windows", test))]
|
||||
fn remembered_peer_candidate(
|
||||
peers: &[BlePeer],
|
||||
connected: &HashMap<String, Arc<AtomicBool>>,
|
||||
recent: &RecentlyDisconnected,
|
||||
) -> Option<BlePeer> {
|
||||
if connected.len() >= MAX_PEERS {
|
||||
return None;
|
||||
}
|
||||
let mut entries: Vec<_> = recent
|
||||
.lock()
|
||||
.ok()?
|
||||
.iter()
|
||||
.filter(|(_, (when, _))| when.elapsed() < RECONNECT_PRUNE_AFTER)
|
||||
.map(|(address, (when, _))| (address.clone(), *when))
|
||||
.collect();
|
||||
// Release the map lock before consulting the shared backoff/churn policy.
|
||||
entries.sort_by(|a, b| b.1.cmp(&a.1).then_with(|| a.0.cmp(&b.0)));
|
||||
for (address, _) in entries {
|
||||
if crate::ble_connect::known_address(&address).is_none()
|
||||
|| peers
|
||||
.iter()
|
||||
.any(|p| p.ble_address.eq_ignore_ascii_case(&address))
|
||||
|| connected.keys().any(|a| a.eq_ignore_ascii_case(&address))
|
||||
|| reconnect_in_backoff(recent, &address)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return Some(BlePeer {
|
||||
identity_hash: String::new(),
|
||||
ble_address: address,
|
||||
rssi: 0,
|
||||
// A preference only, resolved from actual GATT before Connected.
|
||||
protocol: PeerProtocol::Ratspeak,
|
||||
connected: false,
|
||||
});
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Per-peer read loop: receive notifications, reassemble fragments, forward
|
||||
@@ -5097,14 +5160,7 @@ async fn peer_read_loop(conn: MeshPeerConnection, ctx: PeerReadLoopCtx) {
|
||||
use btleplug::api::Peripheral as _;
|
||||
use futures::StreamExt;
|
||||
|
||||
let mut notification_stream = match conn.peripheral.notifications().await {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
tracing::warn!(error = %e, "BLE mesh notification stream failed");
|
||||
peer_online.store(false, Ordering::SeqCst);
|
||||
return;
|
||||
}
|
||||
};
|
||||
let mut notification_stream = conn.notifications;
|
||||
|
||||
// Fragment reassembly buffer: maps total_count to per-sequence payload slots.
|
||||
let mut reassembly: FragmentReassembly = HashMap::new();
|
||||
@@ -5115,7 +5171,7 @@ async fn peer_read_loop(conn: MeshPeerConnection, ctx: PeerReadLoopCtx) {
|
||||
// the per-peer `peer_online` flag. Flipping `peer_online` here as well
|
||||
// lets the write-side and scan-side cleanup see the peer as dead on
|
||||
// their next tick, matching the keepalive-timeout cleanup path below.
|
||||
if !peer_online.load(Ordering::SeqCst) || !running_flag().load(Ordering::SeqCst) {
|
||||
if !peer_online.load(Ordering::SeqCst) || !generation_is_current(conn.generation) {
|
||||
peer_online.store(false, Ordering::SeqCst);
|
||||
break;
|
||||
}
|
||||
@@ -5164,7 +5220,9 @@ async fn peer_read_loop(conn: MeshPeerConnection, ctx: PeerReadLoopCtx) {
|
||||
};
|
||||
|
||||
match notification {
|
||||
Some(n) if n.uuid == conn.tx_char.uuid => {
|
||||
Some(n)
|
||||
if n.uuid == conn.tx_char.uuid && n.service_uuid == conn.tx_char.service_uuid =>
|
||||
{
|
||||
let data = n.value;
|
||||
if data.is_empty() {
|
||||
continue;
|
||||
@@ -5225,9 +5283,14 @@ async fn peer_read_loop(conn: MeshPeerConnection, ctx: PeerReadLoopCtx) {
|
||||
}
|
||||
|
||||
// Cleanup: disconnect and remove writer
|
||||
let _ = conn.peripheral.disconnect().await;
|
||||
if let Ok(mut reg) = central_peripherals().lock() {
|
||||
reg.remove(&peer_address);
|
||||
let owned = central_peripherals().lock().ok().is_some_and(|reg| {
|
||||
reg.get(&peer_address)
|
||||
.is_some_and(|(owner, _)| *owner == conn.connection_id)
|
||||
});
|
||||
if owned {
|
||||
let _ =
|
||||
crate::ble_connect::operation("Disconnect peer", conn.peripheral.disconnect()).await;
|
||||
remove_central_peripheral(&peer_address, conn.connection_id);
|
||||
}
|
||||
let mut writers = peer_writers.write().await;
|
||||
remove_peer_writer_if_current(&mut writers, &peer_writer_key, peer_writer_lease_id);
|
||||
@@ -5237,6 +5300,9 @@ async fn peer_read_loop(conn: MeshPeerConnection, ctx: PeerReadLoopCtx) {
|
||||
// The scan loop checks this map and uses SCAN_ACTIVE_INTERVAL until
|
||||
// either we reconnect or the entry expires. Identity-keyed
|
||||
// tracking is gone because the BLE link no longer exchanges identity.
|
||||
if !owned || !generation_is_current(conn.generation) {
|
||||
return;
|
||||
}
|
||||
record_disconnect(&recently_disconnected, &peer_address);
|
||||
dispatch_event(BlePeerEvent::Disconnected {
|
||||
address: peer_address,
|
||||
@@ -5848,6 +5914,13 @@ pub async fn spawn_ble_peer_interface(
|
||||
// the MAX_PEERS slots with the nearest peers instead of
|
||||
// whatever scan order returned.
|
||||
peers.sort_by_key(|p| std::cmp::Reverse(p.rssi));
|
||||
let discovered_count = peers.len();
|
||||
#[cfg(target_os = "windows")]
|
||||
if let Some(peer) =
|
||||
remembered_peer_candidate(&peers, &connected_addrs, &recently_disc)
|
||||
{
|
||||
peers.push(peer);
|
||||
}
|
||||
// Active scan only when there is something to act on: an
|
||||
// unconnected, non-backoff candidate with a free slot, or
|
||||
// a wanted-reconnect. A stable mesh keeps seeing its
|
||||
@@ -5879,12 +5952,17 @@ pub async fn spawn_ble_peer_interface(
|
||||
}
|
||||
scan_interval = next_interval;
|
||||
|
||||
for peer in &peers {
|
||||
for (index, peer) in peers.iter().enumerate() {
|
||||
if !generation_is_current(generation) {
|
||||
break;
|
||||
}
|
||||
if index < discovered_count {
|
||||
dispatch_event(BlePeerEvent::Discovered {
|
||||
address: peer.ble_address.clone(),
|
||||
rssi: peer.rssi,
|
||||
protocol: peer.protocol,
|
||||
});
|
||||
}
|
||||
// Skip if already connected
|
||||
if connected_addrs.contains_key(&peer.ble_address) {
|
||||
dispatch_event(BlePeerEvent::RssiUpdate {
|
||||
@@ -5913,20 +5991,21 @@ pub async fn spawn_ble_peer_interface(
|
||||
|
||||
tracing::info!(
|
||||
target: "ble_trace",
|
||||
step = "peer.discovered",
|
||||
step = "peer.connect_candidate",
|
||||
discovered = index < discovered_count,
|
||||
name = %mesh_name,
|
||||
address = %peer.ble_address,
|
||||
rssi = peer.rssi,
|
||||
protocol = ?peer.protocol,
|
||||
connected_count = connected_addrs.len(),
|
||||
"BLE mesh peer discovered, connecting..."
|
||||
"BLE mesh candidate, connecting..."
|
||||
);
|
||||
|
||||
// Connect, subscribe, set up data flow.
|
||||
// No BLE-level identity exchange — identity is
|
||||
// learned later from the first signed Reticulum
|
||||
// announce that flows over the link.
|
||||
match connect_mesh_peer(&adapter, peer).await {
|
||||
match connect_mesh_peer(&adapter, peer, generation).await {
|
||||
Ok(conn) => {
|
||||
// Drop the wanted-reconnect entry now
|
||||
// that we've reconnected.
|
||||
@@ -5979,7 +6058,7 @@ pub async fn spawn_ble_peer_interface(
|
||||
let recently_r = recently_disc.clone();
|
||||
let anti_loop_r = anti_loop.clone();
|
||||
let link_registry_r = link_registry.clone();
|
||||
let proto_evt = peer.protocol;
|
||||
let proto_evt = conn.protocol;
|
||||
let addr_evt = peer.ble_address.clone();
|
||||
track_child_task(
|
||||
generation,
|
||||
@@ -6738,6 +6817,111 @@ pub async fn spawn_ble_peer_interface(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn remembered_candidates_obey_discovery_expiry_capacity_and_backoff() {
|
||||
let recent = new_recently_disconnected();
|
||||
let address = "AA:BB:CC:DD:11:01";
|
||||
seed_recently_disconnected(&recent, vec![address.to_owned(), "invalid-name".to_owned()]);
|
||||
let mut connected = HashMap::new();
|
||||
let candidate = remembered_peer_candidate(&[], &connected, &recent).unwrap();
|
||||
assert_eq!(candidate.ble_address, address);
|
||||
assert!(candidate.identity_hash.is_empty());
|
||||
let mut visible = candidate.clone();
|
||||
visible.ble_address = address.to_lowercase();
|
||||
assert!(remembered_peer_candidate(&[visible], &connected, &recent).is_none());
|
||||
connected.insert(address.to_lowercase(), Arc::new(AtomicBool::new(true)));
|
||||
assert!(remembered_peer_candidate(&[], &connected, &recent).is_none());
|
||||
connected.clear();
|
||||
for i in 0..MAX_PEERS {
|
||||
connected.insert(format!("busy-{i}"), Arc::new(AtomicBool::new(true)));
|
||||
}
|
||||
assert!(remembered_peer_candidate(&[], &connected, &recent).is_none());
|
||||
connected.clear();
|
||||
for _ in 0..RECONNECT_BACKOFF_FAILURES {
|
||||
record_reconnect_failure(&recent, address);
|
||||
}
|
||||
assert!(remembered_peer_candidate(&[], &connected, &recent).is_none());
|
||||
recent.lock().unwrap().insert(
|
||||
address.into(),
|
||||
(
|
||||
Instant::now() - RECONNECT_BACKOFF_DURATION,
|
||||
RECONNECT_BACKOFF_FAILURES,
|
||||
),
|
||||
);
|
||||
assert!(remembered_peer_candidate(&[], &connected, &recent).is_some());
|
||||
recent
|
||||
.lock()
|
||||
.unwrap()
|
||||
.insert(address.into(), (Instant::now() - RECONNECT_PRUNE_AFTER, 0));
|
||||
assert!(remembered_peer_candidate(&[], &connected, &recent).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn remembered_candidates_respect_churn_and_admit_only_one() {
|
||||
let recent = new_recently_disconnected();
|
||||
let churn = "AA:BB:CC:DD:12:01";
|
||||
let other = "AA:BB:CC:DD:12:02";
|
||||
seed_recently_disconnected(&recent, vec![churn.into(), other.into()]);
|
||||
for _ in 0..RECONNECT_BACKOFF_FAILURES {
|
||||
note_peer_connected(churn);
|
||||
record_disconnect(&recent, churn);
|
||||
}
|
||||
assert_eq!(
|
||||
remembered_peer_candidate(&[], &HashMap::new(), &recent)
|
||||
.unwrap()
|
||||
.ble_address,
|
||||
other
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mesh_service_validation_handles_unknown_protocol_without_trusting_address() {
|
||||
use btleplug::api::{CharPropFlags, Characteristic};
|
||||
let make = |service, uuid, properties| Characteristic {
|
||||
uuid,
|
||||
service_uuid: service,
|
||||
properties,
|
||||
descriptors: Default::default(),
|
||||
};
|
||||
let rx = make(
|
||||
COLUMBA_SERVICE_UUID,
|
||||
COLUMBA_RX_UUID,
|
||||
CharPropFlags::WRITE_WITHOUT_RESPONSE,
|
||||
);
|
||||
let tx = make(COLUMBA_SERVICE_UUID, COLUMBA_TX_UUID, CharPropFlags::NOTIFY);
|
||||
let chars = [rx.clone(), tx.clone()].into_iter().collect();
|
||||
assert_eq!(
|
||||
mesh_gatt_characteristics(&chars, PeerProtocol::Ratspeak)
|
||||
.unwrap()
|
||||
.0,
|
||||
PeerProtocol::Columba
|
||||
);
|
||||
assert!(
|
||||
mesh_gatt_characteristics(&[rx.clone()].into_iter().collect(), PeerProtocol::Columba)
|
||||
.is_none()
|
||||
);
|
||||
let wrong_service = make(
|
||||
RATSPEAK_SERVICE_UUID,
|
||||
COLUMBA_TX_UUID,
|
||||
CharPropFlags::NOTIFY,
|
||||
);
|
||||
assert!(
|
||||
mesh_gatt_characteristics(
|
||||
&[rx.clone(), wrong_service].into_iter().collect(),
|
||||
PeerProtocol::Columba
|
||||
)
|
||||
.is_none()
|
||||
);
|
||||
let read_only = make(COLUMBA_SERVICE_UUID, COLUMBA_RX_UUID, CharPropFlags::READ);
|
||||
assert!(
|
||||
mesh_gatt_characteristics(
|
||||
&[read_only, tx].into_iter().collect(),
|
||||
PeerProtocol::Columba
|
||||
)
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simultaneous_roles_keep_fragment_streams_separate() {
|
||||
let left = vec![0x55; 483];
|
||||
|
||||
@@ -85,12 +85,9 @@ const BLE_OPERATION_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
const BLE_CONTROL_STAGE_SETTLE: Duration = Duration::from_millis(150);
|
||||
const BLE_POST_INIT_SETTLE: Duration = Duration::from_secs(1);
|
||||
/// ATT's mandatory 23-byte baseline MTU leaves 20 bytes for a characteristic
|
||||
/// value. CoreBluetooth exposes the negotiated per-peripheral limit through
|
||||
/// `maximumWriteValueLength(for:)`, but btleplug 0.11.8 neither calls nor
|
||||
/// exposes it. Its no-response write path also reports success immediately,
|
||||
/// even when CoreBluetooth cannot deliver the value. Upstream Reticulum avoids
|
||||
/// this by reading Bleak's `max_write_without_response_size` for every link.
|
||||
/// Stay at the guaranteed baseline on Apple until btleplug exposes that value.
|
||||
/// value. Preserve the physically reviewed Apple RNode write size and
|
||||
/// response pacing through dependency upgrades. Increasing that size requires
|
||||
/// separate radio/firmware validation even though btleplug now exposes MTU.
|
||||
const BLE_DEFAULT_ATT_WRITE_PAYLOAD: usize = 20;
|
||||
/// RNode's reviewed high-throughput ATT MTU is 247 (247 - 3 ATT bytes).
|
||||
const BLE_RNODE_ATT_WRITE_PAYLOAD: usize = 244;
|
||||
@@ -183,13 +180,13 @@ fn unregister_running(id: InterfaceId, running: &Arc<AtomicBool>) {
|
||||
/// [`crate::rnode::RNodeDriverHandle::request_shutdown`] so later ID reuse
|
||||
/// cannot redirect the request.
|
||||
pub fn stop_ble_rnode_interface(id: InterfaceId) {
|
||||
if let Ok(map) = running_map().lock() {
|
||||
if let Some(flag) = map.get(&id) {
|
||||
if let Ok(map) = running_map().lock()
|
||||
&& let Some(flag) = map.get(&id)
|
||||
{
|
||||
flag.store(false, Ordering::SeqCst);
|
||||
tracing::info!(id, "BLE RNode: stop signal sent");
|
||||
ble_diag(format!("[ble] stop_ble_rnode_interface({id})"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn reconnect_try_exhausted(tries: &mut usize) -> bool {
|
||||
@@ -222,7 +219,7 @@ const fn ble_write_chunk_size() -> usize {
|
||||
|
||||
const fn ble_write_type() -> WriteType {
|
||||
if cfg!(any(target_os = "ios", target_os = "macos")) {
|
||||
// btleplug 0.11.8's CoreBluetooth no-response path returns before the
|
||||
// CoreBluetooth no-response writes can return before the
|
||||
// controller accepts the value and does not observe
|
||||
// canSendWriteWithoutResponse. Ordered response writes are the only
|
||||
// acknowledgement boundary this driver can safely own on Apple.
|
||||
@@ -1501,15 +1498,14 @@ async fn resolve_ble_target(
|
||||
}
|
||||
// A populated list without NUS means a different device;
|
||||
// only fall back to the name on empty service lists.
|
||||
if props.services.is_empty() {
|
||||
if let Some(ref name) = props.local_name {
|
||||
if name.starts_with("RNode ") {
|
||||
if props.services.is_empty()
|
||||
&& let Some(ref name) = props.local_name
|
||||
&& name.starts_with("RNode ")
|
||||
{
|
||||
return Ok((p.clone(), BleTargetResolutionClass::FirstRnode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Err(InterfaceError::SendFailed(
|
||||
"No RNode BLE device found".into(),
|
||||
));
|
||||
@@ -1525,14 +1521,27 @@ async fn resolve_ble_target(
|
||||
}
|
||||
}
|
||||
|
||||
// Windows can create a peripheral from an explicit MAC even when this
|
||||
// scan did not see it. Names, empty discovery targets and Apple UUIDs
|
||||
// never enter this path; normal GATT/NUS validation still follows.
|
||||
#[cfg(target_os = "windows")]
|
||||
if crate::ble_connect::known_address(target).is_some() {
|
||||
let peripheral = crate::ble_connect::resolve_address(None, target, |address| async move {
|
||||
adapter.add_peripheral(&address.into()).await
|
||||
})
|
||||
.await
|
||||
.map_err(InterfaceError::SendFailed)?;
|
||||
return Ok((peripheral, BleTargetResolutionClass::PrimaryId));
|
||||
}
|
||||
|
||||
// Friendly-name resolution remains a fallback behind the configured
|
||||
// platform ID. After an exact first generation, its verified RNode name is
|
||||
// retained in memory so a post-bond CoreBluetooth handle replacement can
|
||||
// be resolved without changing the public/configured identity.
|
||||
for p in &peripherals {
|
||||
if let Ok(Some(props)) = bounded_ble_operation("properties", p.properties()).await {
|
||||
if let Some(ref name) = props.local_name {
|
||||
if let Some(resolution_class) =
|
||||
if let Ok(Some(props)) = bounded_ble_operation("properties", p.properties()).await
|
||||
&& let Some(ref name) = props.local_name
|
||||
&& let Some(resolution_class) =
|
||||
ble_name_resolution_class(target, generation_stable_name, name)
|
||||
{
|
||||
if resolution_class == BleTargetResolutionClass::PrimaryName {
|
||||
@@ -1543,8 +1552,6 @@ async fn resolve_ble_target(
|
||||
return Ok((p.clone(), resolution_class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ble_diag(format!(
|
||||
"[ble] resolve failed: no peripheral matches '{target}'"
|
||||
@@ -1829,18 +1836,15 @@ async fn connect_rnode(
|
||||
InterfaceError::SendFailed("NUS TX characteristic not found. Is this an RNode?".into())
|
||||
})?
|
||||
.clone();
|
||||
if generation_stable_name.is_none() {
|
||||
if let Ok(Some(properties)) =
|
||||
if generation_stable_name.is_none()
|
||||
&& let Ok(Some(properties)) =
|
||||
bounded_ble_operation("resolved target properties", peripheral.properties()).await
|
||||
{
|
||||
if let Some(name) = properties
|
||||
&& let Some(name) = properties
|
||||
.local_name
|
||||
.filter(|name| name.starts_with("RNode "))
|
||||
{
|
||||
*generation_stable_name = Some(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
ble_diag(format!(
|
||||
"[ble] RX/TX chars found; RX props={:?} TX props={:?}",
|
||||
rx_char.properties, tx_char.properties
|
||||
@@ -2545,15 +2549,15 @@ where
|
||||
let deadline = tokio::time::Instant::now() + BleOperationStage::Detect.deadline();
|
||||
loop {
|
||||
let evidence = protocol_state.evidence();
|
||||
if evidence.detected {
|
||||
if let Some(firmware) = evidence.firmware {
|
||||
if evidence.detected
|
||||
&& let Some(firmware) = evidence.firmware
|
||||
{
|
||||
return if firmware.is_supported() {
|
||||
BleHandshakeOutcome::Observed
|
||||
} else {
|
||||
BleHandshakeOutcome::Retry("RNode firmware is unsupported")
|
||||
};
|
||||
}
|
||||
}
|
||||
if evidence.radio_initialisation_fault {
|
||||
return BleHandshakeOutcome::Retry("RNode reported a radio initialisation fault");
|
||||
}
|
||||
@@ -3484,16 +3488,13 @@ pub async fn spawn_ble_rnode_interface_with_driver_and_options(
|
||||
break 'read;
|
||||
}
|
||||
GenerationEvent::Poll => {
|
||||
if pending_outbound.is_none() {
|
||||
if let (Some((interval, callsign)), Some(first)) =
|
||||
if pending_outbound.is_none()
|
||||
&& let (Some((interval, callsign)), Some(first)) =
|
||||
(beacon.as_ref(), first_tx)
|
||||
&& first.elapsed() >= *interval
|
||||
{
|
||||
if first.elapsed() >= *interval {
|
||||
tracing::debug!("BLE RNode scheduling station-ID beacon");
|
||||
pending_outbound =
|
||||
Some(PendingOutbound::new(callsign.clone(), true));
|
||||
}
|
||||
}
|
||||
pending_outbound = Some(PendingOutbound::new(callsign.clone(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4285,22 +4286,18 @@ pub async fn spawn_ble_rnode_interface_native_with_driver_and_options(
|
||||
);
|
||||
break 'read;
|
||||
}
|
||||
if pending_outbound.is_none() {
|
||||
if let (Some((interval, callsign)), Some(first)) =
|
||||
if pending_outbound.is_none()
|
||||
&& let (Some((interval, callsign)), Some(first)) =
|
||||
(beacon.as_ref(), first_tx)
|
||||
&& first.elapsed() >= *interval
|
||||
{
|
||||
if first.elapsed() >= *interval {
|
||||
tracing::debug!(
|
||||
"BLE RNode (native) scheduling station-ID beacon"
|
||||
);
|
||||
tracing::debug!("BLE RNode (native) scheduling station-ID beacon");
|
||||
pending_outbound = Some(NativePendingOutbound::new(
|
||||
PendingOutbound::new(callsign.clone(), true),
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let should_write = pending_outbound
|
||||
.as_ref()
|
||||
@@ -4441,6 +4438,7 @@ mod tests {
|
||||
bytes
|
||||
.chunks(180)
|
||||
.map(|chunk| ValueNotification {
|
||||
service_uuid: NUS_SERVICE_UUID,
|
||||
uuid: NUS_TX_CHAR_UUID,
|
||||
value: chunk.to_vec(),
|
||||
})
|
||||
@@ -6186,6 +6184,7 @@ mod tests {
|
||||
] {
|
||||
let mut queued = capability_notifications(&response);
|
||||
queued.push(ValueNotification {
|
||||
service_uuid: NUS_SERVICE_UUID,
|
||||
uuid: NUS_TX_CHAR_UUID,
|
||||
value: kiss::frame(b"queued-before-init"),
|
||||
});
|
||||
|
||||
@@ -39,12 +39,7 @@ pub(super) enum BleOperationStage {
|
||||
)]
|
||||
PairingRead,
|
||||
#[cfg_attr(
|
||||
not(any(
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "windows",
|
||||
target_os = "android"
|
||||
)),
|
||||
not(any(target_os = "ios", target_os = "macos", test)),
|
||||
allow(dead_code)
|
||||
)]
|
||||
PairingSubscribe,
|
||||
|
||||
@@ -16,6 +16,8 @@ pub mod ble_central_apple;
|
||||
pub mod ble_central_apple_connect;
|
||||
#[cfg(feature = "ble")]
|
||||
pub mod ble_central_lifecycle;
|
||||
#[cfg(all(feature = "ble", any(target_os = "windows", target_os = "linux", test)))]
|
||||
mod ble_connect;
|
||||
#[cfg(feature = "ble")]
|
||||
pub mod ble_peer;
|
||||
#[cfg(feature = "ble")]
|
||||
|
||||
@@ -21,11 +21,11 @@ pub const DEFAULT_SOCKET_PATH: &str = "/tmp/rns_reticulum.sock";
|
||||
|
||||
/// On Android `/tmp` isn't writable; falls back to caller's data directory.
|
||||
pub fn socket_path(data_dir: Option<&std::path::Path>) -> std::path::PathBuf {
|
||||
if cfg!(target_os = "android") {
|
||||
if let Some(dir) = data_dir {
|
||||
if cfg!(target_os = "android")
|
||||
&& let Some(dir) = data_dir
|
||||
{
|
||||
return dir.join("cache").join("rns_reticulum.sock");
|
||||
}
|
||||
}
|
||||
std::path::PathBuf::from(DEFAULT_SOCKET_PATH)
|
||||
}
|
||||
|
||||
@@ -686,6 +686,7 @@ mod tests {
|
||||
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
let _ = prefix;
|
||||
let listener =
|
||||
std::net::TcpListener::bind("127.0.0.1:0").expect("reserve local test port");
|
||||
let port = listener.local_addr().expect("read local test port").port();
|
||||
|
||||
@@ -1349,21 +1349,20 @@ impl RNodeWriteInterrupt {
|
||||
|
||||
fn interrupt(&mut self) {
|
||||
#[cfg(feature = "serial")]
|
||||
if let Some(stream) = self.serial.take() {
|
||||
if let Err(error) = stream
|
||||
if let Some(stream) = self.serial.take()
|
||||
&& let Err(error) = stream
|
||||
.into_inner()
|
||||
.unwrap_or_else(std::sync::PoisonError::into_inner)
|
||||
.clear(serialport::ClearBuffer::Output)
|
||||
{
|
||||
tracing::debug!(error = %error, "RNode serial output purge during writer cleanup");
|
||||
}
|
||||
}
|
||||
if let Some(stream) = self.tcp.take() {
|
||||
if let Err(error) = stream.shutdown(std::net::Shutdown::Both) {
|
||||
if let Some(stream) = self.tcp.take()
|
||||
&& let Err(error) = stream.shutdown(std::net::Shutdown::Both)
|
||||
{
|
||||
tracing::debug!(error = %error, "RNode TCP shutdown during writer cleanup");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "serial", feature = "rnode-tcp"))]
|
||||
@@ -1638,14 +1637,13 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
if pending_packet.is_none() {
|
||||
if let Some((interval, ref callsign)) = context.beacon {
|
||||
if first_tx.is_some_and(|started| started.elapsed() >= interval) {
|
||||
if pending_packet.is_none()
|
||||
&& let Some((interval, ref callsign)) = context.beacon
|
||||
&& first_tx.is_some_and(|started| started.elapsed() >= interval)
|
||||
{
|
||||
tracing::debug!(id = context.id, "RNode station-ID beacon is due");
|
||||
pending_packet = Some(callsign.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let packet_permitted = pending_packet.is_some()
|
||||
&& context.carrier_online.load(Ordering::SeqCst)
|
||||
|
||||
@@ -149,22 +149,22 @@ impl SubInterfaceConfig {
|
||||
self.coding_rate, self.name
|
||||
));
|
||||
}
|
||||
if let Some(st) = self.st_alock {
|
||||
if !(0.0..=100.0).contains(&st) {
|
||||
if let Some(st) = self.st_alock
|
||||
&& !(0.0..=100.0).contains(&st)
|
||||
{
|
||||
return Err(format!(
|
||||
"Invalid short-term airtime limit {} for sub-interface {}",
|
||||
st, self.name
|
||||
));
|
||||
}
|
||||
}
|
||||
if let Some(lt) = self.lt_alock {
|
||||
if !(0.0..=100.0).contains(<) {
|
||||
if let Some(lt) = self.lt_alock
|
||||
&& !(0.0..=100.0).contains(<)
|
||||
{
|
||||
return Err(format!(
|
||||
"Invalid long-term airtime limit {} for sub-interface {}",
|
||||
lt, self.name
|
||||
));
|
||||
}
|
||||
}
|
||||
if self.vport as usize >= MAX_SUBINTERFACES {
|
||||
return Err(format!(
|
||||
"Virtual port {} is outside 0..{} for sub-interface {}",
|
||||
|
||||
@@ -231,23 +231,23 @@ mod tests {
|
||||
let candidates = ["lo", "lo0", "Loopback Pseudo-Interface 1"];
|
||||
let mut found_v4 = false;
|
||||
for name in candidates {
|
||||
if let Some(IpAddr::V4(v4)) = iface_addr_for(name, false) {
|
||||
if v4.is_loopback() {
|
||||
if let Some(IpAddr::V4(v4)) = iface_addr_for(name, false)
|
||||
&& v4.is_loopback()
|
||||
{
|
||||
found_v4 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Hermetic CI may not expose loopback by name; only assert when seen.
|
||||
if let Ok(ifaces) = if_addrs::get_if_addrs() {
|
||||
if ifaces.iter().any(|i| candidates.contains(&i.name.as_str())) {
|
||||
if let Ok(ifaces) = if_addrs::get_if_addrs()
|
||||
&& ifaces.iter().any(|i| candidates.contains(&i.name.as_str()))
|
||||
{
|
||||
assert!(
|
||||
found_v4,
|
||||
"expected a loopback IPv4 on one of {candidates:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn iface_addr_for_missing_returns_none() {
|
||||
|
||||
@@ -102,11 +102,9 @@ fn address_for_device(device: &str, prefer_ipv6: bool) -> Option<std::net::IpAdd
|
||||
.filter(|a| a.name == device)
|
||||
.map(|a| a.ip())
|
||||
.collect();
|
||||
if prefer_ipv6 {
|
||||
if let Some(v6) = on_dev.iter().find(|ip| ip.is_ipv6()) {
|
||||
if prefer_ipv6 && let Some(v6) = on_dev.iter().find(|ip| ip.is_ipv6()) {
|
||||
return Some(*v6);
|
||||
}
|
||||
}
|
||||
on_dev
|
||||
.iter()
|
||||
.find(|ip| ip.is_ipv4())
|
||||
|
||||
@@ -59,8 +59,9 @@ pub async fn spawn_udp_interface(
|
||||
// config error, not a silent fallback to wildcard.
|
||||
let mut listen_ip_cfg = config.listen_ip.clone();
|
||||
let mut forward_ip_cfg = config.forward_ip.clone();
|
||||
if let Some(device) = config.device.as_deref() {
|
||||
if listen_ip_cfg.is_none() || forward_ip_cfg.is_none() {
|
||||
if let Some(device) = config.device.as_deref()
|
||||
&& (listen_ip_cfg.is_none() || forward_ip_cfg.is_none())
|
||||
{
|
||||
let bcast = crate::socket_tuning::iface_broadcast_for(device).ok_or_else(|| {
|
||||
crate::traits::InterfaceError::SendFailed(format!(
|
||||
"UDP device '{device}' not found or has no IPv4 broadcast address"
|
||||
@@ -73,7 +74,6 @@ pub async fn spawn_udp_interface(
|
||||
forward_ip_cfg = Some(bcast.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let listen_ip = listen_ip_cfg.as_deref().unwrap_or("0.0.0.0");
|
||||
let listen_port = config.listen_port.unwrap_or(0);
|
||||
|
||||
@@ -137,16 +137,16 @@ impl KeepaliveState {
|
||||
|
||||
pub(crate) fn is_stale_at(&self, now: Instant) -> bool {
|
||||
let mut latest = self.last_inbound;
|
||||
if let Some(proof) = self.last_proof {
|
||||
if proof > latest {
|
||||
if let Some(proof) = self.last_proof
|
||||
&& proof > latest
|
||||
{
|
||||
latest = proof;
|
||||
}
|
||||
}
|
||||
if let Some(activated) = self.activated_at {
|
||||
if activated > latest {
|
||||
if let Some(activated) = self.activated_at
|
||||
&& activated > latest
|
||||
{
|
||||
latest = activated;
|
||||
}
|
||||
}
|
||||
now.saturating_duration_since(latest) >= self.stale_time
|
||||
}
|
||||
|
||||
|
||||
@@ -581,15 +581,15 @@ impl Link {
|
||||
.map_err(|_| HandshakeError::InvalidSignature)?;
|
||||
|
||||
// RTT is a msgpack f64 — see matching encode in validate_proof().
|
||||
if let Ok(value) = rmpv::decode::read_value(&mut &plaintext[..]) {
|
||||
if let Some(peer_rtt) = value.as_f64() {
|
||||
if let Ok(value) = rmpv::decode::read_value(&mut &plaintext[..])
|
||||
&& let Some(peer_rtt) = value.as_f64()
|
||||
{
|
||||
let local_rtt = self.request_time.elapsed().as_secs_f64();
|
||||
let rtt = local_rtt.max(peer_rtt);
|
||||
let rtt_dur = Duration::from_secs_f64(rtt);
|
||||
self.rtt = Some(rtt_dur);
|
||||
self.keepalive.update_from_rtt(rtt_dur);
|
||||
}
|
||||
}
|
||||
|
||||
self.state = LinkState::Active;
|
||||
self.activated_at = Some(Instant::now());
|
||||
@@ -1432,13 +1432,13 @@ impl Link {
|
||||
// otherwise we'd have nothing to sign the teardown with.
|
||||
let rtt = self.rtt.unwrap_or(Duration::from_secs(1));
|
||||
let grace = self.keepalive.stale_grace_timeout(rtt);
|
||||
if let Some(stale_since) = self.stale_since {
|
||||
if now.saturating_duration_since(stale_since) >= grace {
|
||||
if let Some(stale_since) = self.stale_since
|
||||
&& now.saturating_duration_since(stale_since) >= grace
|
||||
{
|
||||
let teardown_data = self.encrypt(&self.link_id).unwrap_or_default();
|
||||
self.close(CloseReason::Timeout);
|
||||
return LinkAction::SendTeardownAndClose(teardown_data);
|
||||
}
|
||||
}
|
||||
LinkAction::None
|
||||
}
|
||||
LinkState::Closed => LinkAction::None,
|
||||
|
||||
@@ -154,12 +154,13 @@ impl StreamWriter {
|
||||
if segment_len <= 32 {
|
||||
break;
|
||||
}
|
||||
if let Ok(compressed) = compression::bz2_compress(&chunk[..segment_len]) {
|
||||
if compressed.len() < self.max_data_len && compressed.len() < segment_len {
|
||||
if let Ok(compressed) = compression::bz2_compress(&chunk[..segment_len])
|
||||
&& compressed.len() < self.max_data_len
|
||||
&& compressed.len() < segment_len
|
||||
{
|
||||
return (compressed, segment_len, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let send_len = chunk.len().min(self.max_data_len);
|
||||
(chunk[..send_len].to_vec(), send_len, false)
|
||||
|
||||
@@ -362,14 +362,14 @@ impl Channel {
|
||||
|
||||
let seq = self.next_tx_sequence;
|
||||
let mut envelope = Envelope::pack(msg, seq);
|
||||
if let Some(max) = max_envelope_size {
|
||||
if envelope.raw.len() > max {
|
||||
if let Some(max) = max_envelope_size
|
||||
&& envelope.raw.len() > max
|
||||
{
|
||||
return Err(ChannelError::MessageTooLarge {
|
||||
actual: envelope.raw.len(),
|
||||
max,
|
||||
});
|
||||
}
|
||||
}
|
||||
self.next_tx_sequence = ((self.next_tx_sequence as u32 + 1) % SEQ_MODULUS) as u16;
|
||||
envelope.state = MessageState::Sent;
|
||||
envelope.tries = 1;
|
||||
|
||||
@@ -1731,8 +1731,8 @@ impl OutboundTransfer {
|
||||
for i in search_start..search_end {
|
||||
if i < self.resource.map_hashes.len()
|
||||
&& requested_map_hashes.contains(&self.resource.map_hashes[i])
|
||||
&& let Some(part_data) = self.resource.get_part(i)
|
||||
{
|
||||
if let Some(part_data) = self.resource.get_part(i) {
|
||||
actions.push(TransferAction::SendPart(i, part_data.to_vec()));
|
||||
if self.sent_part_indices.insert(i) {
|
||||
self.sent_parts += 1;
|
||||
@@ -1740,7 +1740,6 @@ impl OutboundTransfer {
|
||||
sent_count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if wants_more_hashmap && request_data.len() > MAPHASH_LEN {
|
||||
let mut last_map_hash = [0u8; MAPHASH_LEN];
|
||||
@@ -2419,11 +2418,9 @@ impl InboundTransfer {
|
||||
hmu.push(exhausted);
|
||||
|
||||
// If exhausted (complete), include the last map hash
|
||||
if is_complete {
|
||||
if let Some(last_mh) = self.resource.map_hashes.last() {
|
||||
if is_complete && let Some(last_mh) = self.resource.map_hashes.last() {
|
||||
hmu.extend_from_slice(last_mh);
|
||||
}
|
||||
}
|
||||
|
||||
// Include the resource hash for identification
|
||||
hmu.extend_from_slice(&self.resource.resource_hash);
|
||||
|
||||
@@ -552,11 +552,11 @@ fn value_to_u64(value: &Value, field: &'static str) -> Result<u64, RnshCodecErro
|
||||
if let Some(number) = value.as_u64() {
|
||||
return Ok(number);
|
||||
}
|
||||
if let Some(number) = value.as_i64() {
|
||||
if number >= 0 {
|
||||
if let Some(number) = value.as_i64()
|
||||
&& number >= 0
|
||||
{
|
||||
return Ok(number as u64);
|
||||
}
|
||||
}
|
||||
Err(RnshCodecError::InvalidShape(field))
|
||||
}
|
||||
|
||||
@@ -564,11 +564,11 @@ fn value_to_i64(value: &Value, field: &'static str) -> Result<i64, RnshCodecErro
|
||||
if let Some(number) = value.as_i64() {
|
||||
return Ok(number);
|
||||
}
|
||||
if let Some(number) = value.as_u64() {
|
||||
if number <= i64::MAX as u64 {
|
||||
if let Some(number) = value.as_u64()
|
||||
&& number <= i64::MAX as u64
|
||||
{
|
||||
return Ok(number as i64);
|
||||
}
|
||||
}
|
||||
Err(RnshCodecError::InvalidShape(field))
|
||||
}
|
||||
|
||||
|
||||
@@ -565,15 +565,14 @@ fn find_tlv_value(data: &[u8], target_tag: u8) -> Option<&[u8]> {
|
||||
return Some(value);
|
||||
}
|
||||
|
||||
if tag_first == TAG_DYNAMIC_AUTH
|
||||
if (tag_first == TAG_DYNAMIC_AUTH
|
||||
|| tag_first == 0xAC
|
||||
|| tag_first == 0x53
|
||||
|| (tag_total_len == 2)
|
||||
|| (tag_total_len == 2))
|
||||
&& let Some(found) = find_tlv_value(value, target_tag)
|
||||
{
|
||||
if let Some(found) = find_tlv_value(value, target_tag) {
|
||||
return Some(found);
|
||||
}
|
||||
}
|
||||
|
||||
pos += value_len;
|
||||
}
|
||||
|
||||
@@ -255,14 +255,13 @@ fn bundled_trust_anchors() -> Vec<TrustAnchor> {
|
||||
(YUBICO_PIV_ROOT_CA_LEGACY_PEM, YUBICO_LEGACY_ROOT_SHA256),
|
||||
(YUBICO_ATTESTATION_ROOT_1_PEM, YUBICO_NEW_ROOT_SHA256),
|
||||
] {
|
||||
if let Some(der) = pem_to_der(pem) {
|
||||
if hex::encode(Sha256::digest(&der)) == fp {
|
||||
if let Ok(cert) = Certificate::from_der(&der) {
|
||||
if let Some(der) = pem_to_der(pem)
|
||||
&& hex::encode(Sha256::digest(&der)) == fp
|
||||
&& let Ok(cert) = Certificate::from_der(&der)
|
||||
{
|
||||
anchors.push(TrustAnchor { cert });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
anchors
|
||||
}
|
||||
|
||||
@@ -505,14 +504,14 @@ fn find_oid_value(der: &[u8], oid_bytes: &[u8]) -> Option<Vec<u8>> {
|
||||
// Unwrap one level if OCTET STRING wraps another OCTET STRING or INTEGER.
|
||||
if tag == 0x04 && value.len() >= 2 {
|
||||
let inner_tag = value[0];
|
||||
if inner_tag == 0x04 || inner_tag == 0x02 {
|
||||
if let Some((inner_len, inner_len_bytes)) = decode_der_length(&value[1..]) {
|
||||
if (inner_tag == 0x04 || inner_tag == 0x02)
|
||||
&& let Some((inner_len, inner_len_bytes)) = decode_der_length(&value[1..])
|
||||
{
|
||||
let inner_start = 1 + inner_len_bytes;
|
||||
if inner_start + inner_len <= value.len() {
|
||||
return Some(value[inner_start..inner_start + inner_len].to_vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
return Some(value.to_vec());
|
||||
}
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ impl LocalKeyBackend for HardwareBackend {
|
||||
|
||||
fn lock(&self) {
|
||||
let (reply, rx) = mpsc::channel();
|
||||
if let Ok(tx) = self.cmd_tx.lock() {
|
||||
if tx.send(Cmd::Lock { reply }).is_ok() {
|
||||
if let Ok(tx) = self.cmd_tx.lock()
|
||||
&& tx.send(Cmd::Lock { reply }).is_ok()
|
||||
{
|
||||
let _ = rx.recv();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Connect to the token described by `hwid`, verify the on-device keys match it
|
||||
|
||||
@@ -186,11 +186,12 @@ impl MockPivSession {
|
||||
}
|
||||
|
||||
fn check_touch(&self, slot: u8) -> Result<(), RatkeyError> {
|
||||
if let Some(slot_state) = self.slots.get(&slot) {
|
||||
if slot_state.touch_policy == TouchPolicy::Always && self.touch_required {
|
||||
if let Some(slot_state) = self.slots.get(&slot)
|
||||
&& slot_state.touch_policy == TouchPolicy::Always
|
||||
&& self.touch_required
|
||||
{
|
||||
return Err(RatkeyError::TouchRequired);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -430,14 +430,14 @@ pub fn synthesize_interface(
|
||||
|
||||
// IFAC sizes outside 1..=64 would panic deep in the transport actor on
|
||||
// first egress (`ifac_sign` asserts); reject at config parse instead.
|
||||
if let Some(size) = section.get_uint("ifac_size") {
|
||||
if !(1..=64).contains(&size) {
|
||||
if let Some(size) = section.get_uint("ifac_size")
|
||||
&& !(1..=64).contains(&size)
|
||||
{
|
||||
return Err(InterfaceFactoryError::InvalidValue {
|
||||
field: format!("{name}.ifac_size"),
|
||||
message: format!("{size} is out of range (1-64 bytes)"),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let iface_type = section.get("type").ok_or_else(|| {
|
||||
warn!(interface = %name, "interface missing 'type' field");
|
||||
@@ -1102,22 +1102,22 @@ fn parse_rnode_airtime(
|
||||
.get_float("airtime_limit_long")
|
||||
.or_else(|| section.get_float("lt_alock"))
|
||||
.map(|v| v as f32);
|
||||
if let Some(v) = st_alock {
|
||||
if !(0.0..=100.0).contains(&v) {
|
||||
if let Some(v) = st_alock
|
||||
&& !(0.0..=100.0).contains(&v)
|
||||
{
|
||||
return Err(InterfaceFactoryError::InvalidValue {
|
||||
field: format!("{name}.airtime_limit_short"),
|
||||
message: format!("{v} is outside 0..=100 percent"),
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(v) = lt_alock {
|
||||
if !(0.0..=100.0).contains(&v) {
|
||||
if let Some(v) = lt_alock
|
||||
&& !(0.0..=100.0).contains(&v)
|
||||
{
|
||||
return Err(InterfaceFactoryError::InvalidValue {
|
||||
field: format!("{name}.airtime_limit_long"),
|
||||
message: format!("{v} is outside 0..=100 percent"),
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok((flow_control, st_alock, lt_alock))
|
||||
}
|
||||
|
||||
@@ -1382,22 +1382,22 @@ fn validate_rnode_multi_subinterface(
|
||||
message: format!("{} is outside 5..=8", sub.coding_rate),
|
||||
});
|
||||
}
|
||||
if let Some(v) = sub.st_alock {
|
||||
if !(0.0..=100.0).contains(&v) {
|
||||
if let Some(v) = sub.st_alock
|
||||
&& !(0.0..=100.0).contains(&v)
|
||||
{
|
||||
return Err(InterfaceFactoryError::InvalidValue {
|
||||
field: format!("{}.airtime_limit_short", sub.name),
|
||||
message: format!("{v} is outside 0..=100 percent"),
|
||||
});
|
||||
}
|
||||
}
|
||||
if let Some(v) = sub.lt_alock {
|
||||
if !(0.0..=100.0).contains(&v) {
|
||||
if let Some(v) = sub.lt_alock
|
||||
&& !(0.0..=100.0).contains(&v)
|
||||
{
|
||||
return Err(InterfaceFactoryError::InvalidValue {
|
||||
field: format!("{}.airtime_limit_long", sub.name),
|
||||
message: format!("{v} is outside 0..=100 percent"),
|
||||
});
|
||||
}
|
||||
}
|
||||
if sub.frequency == 0 {
|
||||
return Err(InterfaceFactoryError::InvalidValue {
|
||||
field: format!("{}.frequency", sub.name),
|
||||
|
||||
@@ -892,8 +892,9 @@ impl LinkManager {
|
||||
continue;
|
||||
};
|
||||
let key = (*link_id, Self::outbound_resource_identity(transfer).0);
|
||||
if self.outbound_resource_waits.get(&key) != Some(&window) {
|
||||
if let Some(tx) = &self.accounting_event_tx {
|
||||
if self.outbound_resource_waits.get(&key) != Some(&window)
|
||||
&& let Some(tx) = &self.accounting_event_tx
|
||||
{
|
||||
let _ = tx.send(LinkManagerAccountingEvent::OutboundResourceWait {
|
||||
link_id: key.0,
|
||||
resource_id: key.1,
|
||||
@@ -901,7 +902,6 @@ impl LinkManager {
|
||||
timeout: window.1,
|
||||
});
|
||||
}
|
||||
}
|
||||
current.insert(key, window);
|
||||
}
|
||||
}
|
||||
@@ -1010,8 +1010,9 @@ impl LinkManager {
|
||||
}
|
||||
};
|
||||
progressed = true;
|
||||
if let Some((started_at, timeout, awaiting_admission)) = window {
|
||||
if let Some(tx) = &self.accounting_event_tx {
|
||||
if let Some((started_at, timeout, awaiting_admission)) = window
|
||||
&& let Some(tx) = &self.accounting_event_tx
|
||||
{
|
||||
let _ = tx.send(LinkManagerAccountingEvent::OutboundPacketWait {
|
||||
receipt: pending.receipt,
|
||||
started_at,
|
||||
@@ -1021,7 +1022,6 @@ impl LinkManager {
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
self.pending_packet_dispatches = waiting;
|
||||
for link_id in failed_links {
|
||||
self.close_active_link(link_id, CloseReason::DestinationClosed, false);
|
||||
@@ -1119,9 +1119,10 @@ impl LinkManager {
|
||||
Ok(
|
||||
result @ (LinkEndpointSendResult::Sent | LinkEndpointSendResult::Queued { .. }),
|
||||
) => {
|
||||
if let Some(packet_hash) = pending.packet_proof_hash {
|
||||
if let Some(active) = self.active_links.get(&pending.link_id) {
|
||||
if let Some(tx) = &self.accounting_event_tx {
|
||||
if let Some(packet_hash) = pending.packet_proof_hash
|
||||
&& let Some(active) = self.active_links.get(&pending.link_id)
|
||||
&& let Some(tx) = &self.accounting_event_tx
|
||||
{
|
||||
let _ = tx.send(LinkManagerAccountingEvent::OutboundPacketWait {
|
||||
receipt: LinkPacketSendReceipt {
|
||||
link_id: pending.link_id,
|
||||
@@ -1142,8 +1143,6 @@ impl LinkManager {
|
||||
cancellation: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if pending.final_unbind {
|
||||
accepted_final_sends.push((pending.link_id, pending.role));
|
||||
}
|
||||
@@ -1369,11 +1368,11 @@ impl LinkManager {
|
||||
return true;
|
||||
}
|
||||
let result = self.send_link_packet(&link_id, &payload);
|
||||
if let Some(tx) = result_tx {
|
||||
if let Err(Ok(receipt)) = tx.send(result) {
|
||||
if let Some(tx) = result_tx
|
||||
&& let Err(Ok(receipt)) = tx.send(result)
|
||||
{
|
||||
self.cancel_unadmitted_packet(&receipt);
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
LinkManagerCommand::SendLinkResource {
|
||||
@@ -1846,13 +1845,13 @@ impl LinkManager {
|
||||
response_tx,
|
||||
},
|
||||
);
|
||||
if let Some(tombstone) = self.endpoint_tombstones.get_mut(&link_id) {
|
||||
if tombstone.ownership == ownership {
|
||||
if let Some(tombstone) = self.endpoint_tombstones.get_mut(&link_id)
|
||||
&& tombstone.ownership == ownership
|
||||
{
|
||||
tombstone.lifecycle_required |= lifecycle_required;
|
||||
tombstone.finalization_rx = Some(response_rx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn poll_endpoint_finalizations(&mut self) -> bool {
|
||||
let mut progressed = false;
|
||||
@@ -2083,12 +2082,12 @@ impl LinkManager {
|
||||
|
||||
let hops = header.hops;
|
||||
|
||||
if let Some(ref dest) = self.destination {
|
||||
if !dest.accept_link_requests {
|
||||
if let Some(ref dest) = self.destination
|
||||
&& !dest.accept_link_requests
|
||||
{
|
||||
tracing::debug!("link request rejected — destination not accepting links");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let responder = match (&self.identity_key, &self.identity) {
|
||||
(Some(identity_key), _) => {
|
||||
@@ -3082,21 +3081,21 @@ impl LinkManager {
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(action) = resource_action_to_send {
|
||||
if !Self::send_resource_action(
|
||||
if let Some(action) = resource_action_to_send
|
||||
&& !Self::send_resource_action(
|
||||
&self.transport_tx,
|
||||
&mut self.pending_link_control,
|
||||
&mut self.pending_endpoint_sends,
|
||||
active,
|
||||
&link_id,
|
||||
action,
|
||||
) {
|
||||
)
|
||||
{
|
||||
tracing::error!(
|
||||
link_id = hex::encode(link_id),
|
||||
"Resource flow-control packet could not be retained"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(rh) = completed_rh {
|
||||
// Reverses pre-chunk encryption (Resource.py:424).
|
||||
@@ -3355,8 +3354,9 @@ impl LinkManager {
|
||||
if let Some(active) = self.active_links.get_mut(&link_id) {
|
||||
active.link.record_inbound();
|
||||
active.link.record_rx(data.len());
|
||||
if let Ok(plaintext) = active.link.decrypt(data) {
|
||||
if plaintext.len() > 32 {
|
||||
if let Ok(plaintext) = active.link.decrypt(data)
|
||||
&& plaintext.len() > 32
|
||||
{
|
||||
// Exhaustion flag shifts the resource hash by MAPHASH_LEN.
|
||||
let resource_hash_start =
|
||||
if plaintext[0] == rns_protocol::resource::HASHMAP_IS_EXHAUSTED {
|
||||
@@ -3418,14 +3418,14 @@ impl LinkManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rns_wire::context::PacketContext::ResourceIcl => {
|
||||
// Sender-initiated cancel of an inbound transfer (Link.py:1135-1142).
|
||||
if let Some(active) = self.active_links.get_mut(&link_id) {
|
||||
active.link.record_inbound();
|
||||
active.link.record_rx(data.len());
|
||||
if let Ok(plaintext) = active.link.decrypt(data) {
|
||||
if plaintext.len() >= 32 {
|
||||
if let Ok(plaintext) = active.link.decrypt(data)
|
||||
&& plaintext.len() >= 32
|
||||
{
|
||||
let mut rh = [0u8; 32];
|
||||
rh.copy_from_slice(&plaintext[..32]);
|
||||
let resource_id = active
|
||||
@@ -3459,14 +3459,14 @@ impl LinkManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rns_wire::context::PacketContext::ResourceRcl => {
|
||||
// Receiver-initiated reject of an outbound transfer (Link.py:1144-1151).
|
||||
if let Some(active) = self.active_links.get_mut(&link_id) {
|
||||
active.link.record_inbound();
|
||||
active.link.record_rx(data.len());
|
||||
if let Ok(plaintext) = active.link.decrypt(data) {
|
||||
if plaintext.len() >= 32 {
|
||||
if let Ok(plaintext) = active.link.decrypt(data)
|
||||
&& plaintext.len() >= 32
|
||||
{
|
||||
let mut rh = [0u8; 32];
|
||||
rh.copy_from_slice(&plaintext[..32]);
|
||||
let resource_id = active
|
||||
@@ -3499,23 +3499,19 @@ impl LinkManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rns_wire::context::PacketContext::ResourceHmu => {
|
||||
if let Some(active) = self.active_links.get_mut(&link_id) {
|
||||
active.link.record_inbound();
|
||||
active.link.record_rx(data.len());
|
||||
if let Ok(plaintext) = active.link.decrypt(data) {
|
||||
if let Ok((rh, segment, hashmap)) =
|
||||
if let Ok(plaintext) = active.link.decrypt(data)
|
||||
&& let Ok((rh, segment, hashmap)) =
|
||||
rns_protocol::resource::parse_hashmap_update(&plaintext)
|
||||
&& let Some(transfer) = active.inbound_resources.get_mut(&rh)
|
||||
{
|
||||
if let Some(transfer) = active.inbound_resources.get_mut(&rh) {
|
||||
let action = transfer.hashmap_update(segment, &hashmap);
|
||||
let cancelled = matches!(
|
||||
action,
|
||||
TransferAction::SendCancel(
|
||||
rns_protocol::resource::CancelType::Rcl,
|
||||
_
|
||||
)
|
||||
TransferAction::SendCancel(rns_protocol::resource::CancelType::Rcl, _)
|
||||
);
|
||||
// A solicited HMU may either request the next parts or
|
||||
// cancel the transfer (RESOURCE_RCL) on an empty/invalid
|
||||
@@ -3529,8 +3525,7 @@ impl LinkManager {
|
||||
action,
|
||||
);
|
||||
if cancelled {
|
||||
let resource_id =
|
||||
Self::inbound_resource_identity(active, &rh).0;
|
||||
let resource_id = Self::inbound_resource_identity(active, &rh).0;
|
||||
Self::conclude_inbound_failure(
|
||||
active,
|
||||
&mut self.active_inbound_lifecycles,
|
||||
@@ -3540,16 +3535,13 @@ impl LinkManager {
|
||||
link_id,
|
||||
resource_id,
|
||||
LinkResourceConclusion::Failed(
|
||||
"sender returned an invalid Resource hashmap update"
|
||||
.into(),
|
||||
"sender returned an invalid Resource hashmap update".into(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rns_wire::context::PacketContext::ResourcePrf => {
|
||||
if let Some(active) = self.active_links.get_mut(&link_id) {
|
||||
active.link.record_inbound();
|
||||
@@ -4103,8 +4095,7 @@ impl LinkManager {
|
||||
}
|
||||
|
||||
self.backchannel_links.retain(|_, lid| *lid != link_id);
|
||||
if !endpoint_closing {
|
||||
if let Some(ownership) = ownership {
|
||||
if !endpoint_closing && let Some(ownership) = ownership {
|
||||
if let Some(tombstone) = self.endpoint_tombstones.get_mut(&link_id) {
|
||||
tombstone.kind = EndpointCleanupKind::Explicit;
|
||||
}
|
||||
@@ -4116,18 +4107,16 @@ impl LinkManager {
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Ok(mut ids) = self.link_identities.lock() {
|
||||
ids.remove(&link_id);
|
||||
}
|
||||
if let Some(ref tx) = self.accounting_event_tx {
|
||||
if tx
|
||||
if let Some(ref tx) = self.accounting_event_tx
|
||||
&& tx
|
||||
.send(LinkManagerAccountingEvent::LinkClosed { link_id })
|
||||
.is_err()
|
||||
{
|
||||
tracing::debug!("Link accounting event receiver is closed");
|
||||
}
|
||||
}
|
||||
Self::stage_legacy_terminal_notification(
|
||||
&self.link_packet_proof_tx,
|
||||
&self.outbound_resource_proof_tx,
|
||||
@@ -4391,16 +4380,14 @@ impl LinkManager {
|
||||
accounting_event_tx: &Option<mpsc::UnboundedSender<LinkManagerAccountingEvent>>,
|
||||
event: LinkResourceEvent,
|
||||
) {
|
||||
if !matches!(&event, LinkResourceEvent::Progress { .. }) {
|
||||
if let Some(tx) = accounting_event_tx {
|
||||
if tx
|
||||
if !matches!(&event, LinkResourceEvent::Progress { .. })
|
||||
&& let Some(tx) = accounting_event_tx
|
||||
&& tx
|
||||
.send(LinkManagerAccountingEvent::ResourceEvent(event.clone()))
|
||||
.is_err()
|
||||
{
|
||||
tracing::debug!("Link accounting event receiver is closed");
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(tx) = resource_event_tx {
|
||||
let _ = tx.try_send(event);
|
||||
}
|
||||
@@ -4828,8 +4815,9 @@ impl LinkManager {
|
||||
|
||||
let rtt = active.link.rtt_secs();
|
||||
let mut matched_channel_sequence = false;
|
||||
if let Some(channel) = active.channel.as_mut() {
|
||||
if let Some(sequence) = channel.delivered_by_packet_hash(&packet_hash, rtt) {
|
||||
if let Some(channel) = active.channel.as_mut()
|
||||
&& let Some(sequence) = channel.delivered_by_packet_hash(&packet_hash, rtt)
|
||||
{
|
||||
matched_channel_sequence = true;
|
||||
active.link.keepalive.record_proof();
|
||||
tracing::debug!(
|
||||
@@ -4839,20 +4827,18 @@ impl LinkManager {
|
||||
"channel packet delivery proof accepted"
|
||||
);
|
||||
}
|
||||
}
|
||||
if !matched_channel_sequence {
|
||||
let proof = LinkPacketProof {
|
||||
link_id,
|
||||
packet_hash,
|
||||
};
|
||||
if let Some(tx) = &self.accounting_event_tx {
|
||||
if tx
|
||||
if let Some(tx) = &self.accounting_event_tx
|
||||
&& tx
|
||||
.send(LinkManagerAccountingEvent::LinkPacketProof(proof.clone()))
|
||||
.is_err()
|
||||
{
|
||||
tracing::debug!("Link accounting event receiver is closed");
|
||||
}
|
||||
}
|
||||
Self::stage_legacy_terminal_notification(
|
||||
&self.link_packet_proof_tx,
|
||||
&self.outbound_resource_proof_tx,
|
||||
@@ -4953,8 +4939,9 @@ impl LinkManager {
|
||||
.map(|active| active.link.mdu)
|
||||
.unwrap_or_default();
|
||||
if packed_response.len() <= mdu {
|
||||
if let Some(active) = self.active_links.get_mut(&link_id) {
|
||||
if let Ok(encrypted) = active.link.encrypt(&packed_response) {
|
||||
if let Some(active) = self.active_links.get_mut(&link_id)
|
||||
&& let Ok(encrypted) = active.link.encrypt(&packed_response)
|
||||
{
|
||||
let response_header = rns_wire::header::PacketHeader {
|
||||
flags: rns_wire::flags::PacketFlags {
|
||||
header_type: rns_wire::flags::HeaderType::Header1,
|
||||
@@ -4984,7 +4971,6 @@ impl LinkManager {
|
||||
"link request handled — response sent"
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if self
|
||||
.start_response_resource(
|
||||
&link_id,
|
||||
@@ -5025,8 +5011,8 @@ impl LinkManager {
|
||||
);
|
||||
}
|
||||
|
||||
if let Some((data, metadata, auto_compress)) = fetch_spec {
|
||||
if self
|
||||
if let Some((data, metadata, auto_compress)) = fetch_spec
|
||||
&& self
|
||||
.start_resource_transfer_inner(
|
||||
&link_id,
|
||||
ResourceTransferStart {
|
||||
@@ -5046,7 +5032,6 @@ impl LinkManager {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_request_handler<F>(&mut self, handler: F)
|
||||
where
|
||||
@@ -10665,12 +10650,12 @@ mod tests {
|
||||
// Widen the receiver's WINDOW_INITIAL=4 so the blast fits in one shot.
|
||||
let segment_rh = transfer.resource.resource_hash;
|
||||
let total_parts = transfer.resource.parts.len();
|
||||
if let Some(active) = lm.active_links.get_mut(&link_id) {
|
||||
if let Some(in_transfer) = active.inbound_resources.get_mut(&segment_rh) {
|
||||
if let Some(active) = lm.active_links.get_mut(&link_id)
|
||||
&& let Some(in_transfer) = active.inbound_resources.get_mut(&segment_rh)
|
||||
{
|
||||
in_transfer.resource.window.window = total_parts;
|
||||
in_transfer.outstanding_parts = total_parts;
|
||||
}
|
||||
}
|
||||
|
||||
for part in &transfer.resource.parts {
|
||||
let part_header = rns_wire::header::PacketHeader {
|
||||
|
||||
@@ -3686,8 +3686,9 @@ async fn process_destination_event(
|
||||
rns_wire::context::PacketContext::Response => {
|
||||
link.record_inbound();
|
||||
link.record_rx(body.len());
|
||||
if let Ok((request_id, data)) = link.handle_response(body) {
|
||||
if let Some(request) = state.requests.remove(&request_id) {
|
||||
if let Ok((request_id, data)) = link.handle_response(body)
|
||||
&& let Some(request) = state.requests.remove(&request_id)
|
||||
{
|
||||
let response = LinkSessionResponse {
|
||||
request_id,
|
||||
data,
|
||||
@@ -3701,7 +3702,6 @@ async fn process_destination_event(
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
rns_wire::context::PacketContext::None => {
|
||||
link.record_inbound();
|
||||
link.record_rx(body.len());
|
||||
|
||||
@@ -228,13 +228,13 @@ impl DeliveryProofWaiter {
|
||||
Ok(None) => return None,
|
||||
Err(_) => return None,
|
||||
};
|
||||
if let DestinationEvent::DeliveryProof { msg_id, rtt } = ev {
|
||||
if msg_id == self.msg_id {
|
||||
if let DestinationEvent::DeliveryProof { msg_id, rtt } = ev
|
||||
&& msg_id == self.msg_id
|
||||
{
|
||||
return Some(rtt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for DeliveryProofWaiter {
|
||||
@@ -458,13 +458,12 @@ async fn collect_path_meta(tx: &mpsc::Sender<TransportMessage>, dest: [u8; 16])
|
||||
let mut meta = PathMeta::default();
|
||||
if let Ok(TransportQueryResponse::PathTable(entries)) =
|
||||
query(tx, TransportQuery::GetPathTable).await
|
||||
&& let Some(entry) = entries.into_iter().find(|e| e.hash == dest)
|
||||
{
|
||||
if let Some(entry) = entries.into_iter().find(|e| e.hash == dest) {
|
||||
meta.hops = entry.hops;
|
||||
meta.via = entry.via;
|
||||
meta.interface = Some(entry.interface);
|
||||
}
|
||||
}
|
||||
meta
|
||||
}
|
||||
|
||||
|
||||
@@ -1825,17 +1825,14 @@ impl ReticulumHandle {
|
||||
) -> TransportQueryResponse {
|
||||
if self.instance_mode == InstanceMode::Client
|
||||
&& matches!(query, TransportQuery::FirstHopTimeout { .. })
|
||||
{
|
||||
if let Some(bitrate) = self
|
||||
&& let Some(bitrate) = self
|
||||
.config
|
||||
.force_shared_instance_bitrate
|
||||
.filter(|bitrate| *bitrate > 0)
|
||||
&& let TransportQueryResponse::FloatResult(Some(seconds)) = &mut response
|
||||
{
|
||||
if let TransportQueryResponse::FloatResult(Some(seconds)) = &mut response {
|
||||
*seconds += (rns_wire::constants::MTU as f64 * 8.0) / bitrate as f64;
|
||||
}
|
||||
}
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
@@ -2595,11 +2592,11 @@ fn parse_hash16_list(key: &str, list: Option<Vec<String>>) -> Result<Vec<[u8; 16
|
||||
}
|
||||
|
||||
fn expand_home_path(path: &str) -> PathBuf {
|
||||
if path == "~" || path.starts_with("~/") {
|
||||
if let Ok(home) = std::env::var("HOME") {
|
||||
if (path == "~" || path.starts_with("~/"))
|
||||
&& let Ok(home) = std::env::var("HOME")
|
||||
{
|
||||
return PathBuf::from(format!("{home}{}", &path[1..]));
|
||||
}
|
||||
}
|
||||
PathBuf::from(path)
|
||||
}
|
||||
|
||||
@@ -2944,11 +2941,11 @@ pub async fn init_with_policy(
|
||||
// Python defaults the local shared-instance RPC key to a hash of the
|
||||
// PERSISTENT transport identity (internal_identity(), Reticulum.py:352),
|
||||
// so RPC auth stays stable across the per-boot ephemeral rotation.
|
||||
if rc.rpc_key.is_none() {
|
||||
if let Some(private_key) = transport_identity.get_private_key() {
|
||||
if rc.rpc_key.is_none()
|
||||
&& let Some(private_key) = transport_identity.get_private_key()
|
||||
{
|
||||
rc.rpc_key = Some(crate::rpc::derive_rpc_key(&*private_key).to_vec());
|
||||
}
|
||||
}
|
||||
let transport_identity = Arc::new(transport_identity);
|
||||
// Wire-facing identity for runtime consumers (Python Transport.identity):
|
||||
// ephemeral when the non-transport default policy is active.
|
||||
@@ -3547,8 +3544,10 @@ pub async fn init_with_policy(
|
||||
}
|
||||
|
||||
// RPC server runs only on Shared; CLI clients authenticate against `rpc_key`.
|
||||
if instance_mode == InstanceMode::Shared && configured_policy {
|
||||
if let Some(rpc_key) = rc.rpc_key.clone() {
|
||||
if instance_mode == InstanceMode::Shared
|
||||
&& configured_policy
|
||||
&& let Some(rpc_key) = rc.rpc_key.clone()
|
||||
{
|
||||
let rpc_tx = transport_tx.clone();
|
||||
let rpc_shutdown = shutdown.clone();
|
||||
if rc.shared_instance_type == SharedInstanceType::Unix {
|
||||
@@ -3569,15 +3568,13 @@ pub async fn init_with_policy(
|
||||
let rpc_port = rc.control_port;
|
||||
tokio::spawn(async move {
|
||||
if let Err(e) =
|
||||
crate::rpc_server::run_rpc_server(rpc_port, rpc_key, rpc_tx, rpc_shutdown)
|
||||
.await
|
||||
crate::rpc_server::run_rpc_server(rpc_port, rpc_key, rpc_tx, rpc_shutdown).await
|
||||
{
|
||||
tracing::warn!("RPC server error: {}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if instance_mode != InstanceMode::Client && rc.enable_remote_management {
|
||||
// Persist so the destination hash stays stable across restarts.
|
||||
@@ -5093,11 +5090,9 @@ async fn rollback_published_interfaces(
|
||||
.send(TransportMessage::DeregisterInterface { id: interface.id })
|
||||
.await
|
||||
.is_ok();
|
||||
if deregistered {
|
||||
if let Some(registration) = interface.registration.take() {
|
||||
if deregistered && let Some(registration) = interface.registration.take() {
|
||||
registration.release();
|
||||
}
|
||||
}
|
||||
// A closed actor leaves the Pending cancellation tombstone in place;
|
||||
// same-ID reuse is unsafe because the stale registration cannot be
|
||||
// ordered before a replacement.
|
||||
@@ -5328,12 +5323,10 @@ async fn rollback_batch_interfaces(
|
||||
.send(TransportMessage::DeregisterInterface { id: interface.id })
|
||||
.await
|
||||
.is_ok();
|
||||
if safe_to_release {
|
||||
if let Some(registration) = interface.registration.take() {
|
||||
if safe_to_release && let Some(registration) = interface.registration.take() {
|
||||
registration.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn rollback_unreserved_interface(owned: OwnedInterfaceHandle, kind: InterfaceKind) {
|
||||
@@ -5419,11 +5412,11 @@ fn runtime_ifac_post_init(
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
if let Some(size) = ifac.ifac_size {
|
||||
if !(1..=64).contains(&size) {
|
||||
if let Some(size) = ifac.ifac_size
|
||||
&& !(1..=64).contains(&size)
|
||||
{
|
||||
return Err(format!("Invalid IFAC size {size}; expected 1..=64 bytes"));
|
||||
}
|
||||
}
|
||||
|
||||
let network_name = ifac.network_name.filter(|s| !s.is_empty());
|
||||
let passphrase = ifac.passphrase.filter(|s| !s.is_empty());
|
||||
@@ -8022,11 +8015,12 @@ fn clean_cache_dir_at(cache_dir: &Path, ttl: std::time::Duration, now: std::time
|
||||
if file_name.as_encoded_bytes().len() != 32 {
|
||||
continue;
|
||||
}
|
||||
if let Ok(metadata) = entry.metadata() {
|
||||
if metadata.is_file() {
|
||||
if let Ok(modified) = metadata.modified() {
|
||||
if let Ok(age) = now.duration_since(modified) {
|
||||
if age > ttl {
|
||||
if let Ok(metadata) = entry.metadata()
|
||||
&& metadata.is_file()
|
||||
&& let Ok(modified) = metadata.modified()
|
||||
&& let Ok(age) = now.duration_since(modified)
|
||||
&& age > ttl
|
||||
{
|
||||
let path = entry.path();
|
||||
if std::fs::remove_file(&path).is_ok() {
|
||||
tracing::trace!("cleaned cache entry: {}", path.display());
|
||||
@@ -8034,10 +8028,6 @@ fn clean_cache_dir_at(cache_dir: &Path, ttl: std::time::Duration, now: std::time
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn hex_decode(s: &str) -> Option<Vec<u8>> {
|
||||
|
||||
@@ -1307,8 +1307,9 @@ pub async fn rncp_fetch_file(request: RncpFetchRequest<'_>) -> Result<RncpFetchO
|
||||
) else {
|
||||
continue;
|
||||
};
|
||||
if let TransferAction::SendRequest(req_data) = t.request_next() {
|
||||
if let Ok(encrypted) = link.encrypt(&req_data) {
|
||||
if let TransferAction::SendRequest(req_data) = t.request_next()
|
||||
&& let Ok(encrypted) = link.encrypt(&req_data)
|
||||
{
|
||||
let req_raw = build_data_packet(
|
||||
link_id,
|
||||
rns_wire::context::PacketContext::ResourceReq,
|
||||
@@ -1316,7 +1317,6 @@ pub async fn rncp_fetch_file(request: RncpFetchRequest<'_>) -> Result<RncpFetchO
|
||||
);
|
||||
send_endpoint_packet(&transport_tx, link_id, req_raw).await?;
|
||||
}
|
||||
}
|
||||
transfers.insert(adv.resource_hash, t);
|
||||
}
|
||||
rns_wire::context::PacketContext::Resource => {
|
||||
@@ -1456,8 +1456,9 @@ pub async fn rncp_fetch_file(request: RncpFetchRequest<'_>) -> Result<RncpFetchO
|
||||
let Some(t) = transfers.get_mut(&rh) else {
|
||||
continue;
|
||||
};
|
||||
if let TransferAction::SendRequest(req) = t.hashmap_update(segment, &hashmap) {
|
||||
if let Ok(encrypted) = link.encrypt(&req) {
|
||||
if let TransferAction::SendRequest(req) = t.hashmap_update(segment, &hashmap)
|
||||
&& let Ok(encrypted) = link.encrypt(&req)
|
||||
{
|
||||
let req_raw = build_data_packet(
|
||||
link_id,
|
||||
rns_wire::context::PacketContext::ResourceReq,
|
||||
@@ -1466,7 +1467,6 @@ pub async fn rncp_fetch_file(request: RncpFetchRequest<'_>) -> Result<RncpFetchO
|
||||
send_endpoint_packet(&transport_tx, link_id, req_raw).await?;
|
||||
}
|
||||
}
|
||||
}
|
||||
rns_wire::context::PacketContext::LinkClose if link.receive_teardown(body) => {
|
||||
break Err(RncpError::ResourceFailed("link closed".into()));
|
||||
}
|
||||
|
||||
@@ -746,23 +746,23 @@ async fn handle_client_message(
|
||||
RnshMessage::StreamData(stream) => match stream.stream_id {
|
||||
STREAM_ID_STDOUT => {
|
||||
stdout.extend_from_slice(&stream.data);
|
||||
if let Some(tx) = stdout_tx {
|
||||
if !stream.data.is_empty() {
|
||||
tx.send(stream.data).await.map_err(|_| {
|
||||
RnshError::Process("stdout stream receiver closed".into())
|
||||
})?;
|
||||
}
|
||||
if let Some(tx) = stdout_tx
|
||||
&& !stream.data.is_empty()
|
||||
{
|
||||
tx.send(stream.data)
|
||||
.await
|
||||
.map_err(|_| RnshError::Process("stdout stream receiver closed".into()))?;
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
STREAM_ID_STDERR => {
|
||||
stderr.extend_from_slice(&stream.data);
|
||||
if let Some(tx) = stderr_tx {
|
||||
if !stream.data.is_empty() {
|
||||
tx.send(stream.data).await.map_err(|_| {
|
||||
RnshError::Process("stderr stream receiver closed".into())
|
||||
})?;
|
||||
}
|
||||
if let Some(tx) = stderr_tx
|
||||
&& !stream.data.is_empty()
|
||||
{
|
||||
tx.send(stream.data)
|
||||
.await
|
||||
.map_err(|_| RnshError::Process("stderr stream receiver closed".into()))?;
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
@@ -1182,11 +1182,11 @@ async fn handle_listener_channel_message(
|
||||
.await?;
|
||||
return Ok(());
|
||||
}
|
||||
if let Some(stdin) = session.stdin.as_mut() {
|
||||
if !stream.data.is_empty() {
|
||||
if let Some(stdin) = session.stdin.as_mut()
|
||||
&& !stream.data.is_empty()
|
||||
{
|
||||
stdin.write_all(&stream.data).await?;
|
||||
}
|
||||
}
|
||||
if stream.eof {
|
||||
if let Some(stdin) = session.stdin.as_mut() {
|
||||
stdin.eof().await?;
|
||||
@@ -1338,8 +1338,9 @@ async fn start_listener_process(
|
||||
stderr,
|
||||
)));
|
||||
}
|
||||
if let Some(ref pty) = pty {
|
||||
if !pipe_stdout || !pipe_stderr {
|
||||
if let Some(ref pty) = pty
|
||||
&& (!pipe_stdout || !pipe_stderr)
|
||||
{
|
||||
let stream_id = if !pipe_stdout {
|
||||
STREAM_ID_STDOUT
|
||||
} else {
|
||||
@@ -1352,7 +1353,6 @@ async fn start_listener_process(
|
||||
pty_reader_file(pty)?,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
let window = pty.take().map(pty_window_target);
|
||||
let child_pid = if uses_pty { child.id() } else { None };
|
||||
|
||||
@@ -24,11 +24,11 @@ use rns_transport::messages::{OutboundRequest, TransportMessage};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
fn expand_tilde(p: &str) -> PathBuf {
|
||||
if let Some(rest) = p.strip_prefix("~/") {
|
||||
if let Some(home) = std::env::var_os("HOME") {
|
||||
if let Some(rest) = p.strip_prefix("~/")
|
||||
&& let Some(home) = std::env::var_os("HOME")
|
||||
{
|
||||
return PathBuf::from(home).join(rest);
|
||||
}
|
||||
}
|
||||
PathBuf::from(p)
|
||||
}
|
||||
|
||||
@@ -171,8 +171,9 @@ fn load_or_create_identity(
|
||||
)),
|
||||
}
|
||||
} else {
|
||||
if let Some(parent) = path.parent() {
|
||||
if let Err(e) = std::fs::create_dir_all(parent) {
|
||||
if let Some(parent) = path.parent()
|
||||
&& let Err(e) = std::fs::create_dir_all(parent)
|
||||
{
|
||||
return Err((
|
||||
2,
|
||||
format!(
|
||||
@@ -181,7 +182,6 @@ fn load_or_create_identity(
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
||||
let id = Identity::new();
|
||||
if let Err(e) = id.to_file(&path) {
|
||||
return Err((
|
||||
@@ -616,12 +616,12 @@ async fn run_listen(args: Args) -> ! {
|
||||
}
|
||||
|
||||
let fetch_jail = args.jail.as_deref().map(expand_tilde);
|
||||
if let Some(ref jail) = fetch_jail {
|
||||
if !jail.is_dir() {
|
||||
if let Some(ref jail) = fetch_jail
|
||||
&& !jail.is_dir()
|
||||
{
|
||||
eprintln!("Fetch jail directory not found: {}", jail.display());
|
||||
process::exit(3);
|
||||
}
|
||||
}
|
||||
|
||||
let (event_tx, mut event_rx) = tokio::sync::mpsc::channel::<RncpEvent>(64);
|
||||
let cfg = RncpListenerConfig {
|
||||
|
||||
@@ -561,30 +561,28 @@ fn import_private_identity(input: &str) -> Result<Identity, (u8, String)> {
|
||||
|
||||
fn decode_import_identity_data(input: &str, expected_len: usize) -> Option<Vec<u8>> {
|
||||
let path = Path::new(input);
|
||||
if path.is_file() {
|
||||
if let Ok(data) = std::fs::read(path) {
|
||||
if data.len() == expected_len {
|
||||
if path.is_file()
|
||||
&& let Ok(data) = std::fs::read(path)
|
||||
&& data.len() == expected_len
|
||||
{
|
||||
return Some(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if input.len() == expected_len * 2 {
|
||||
if let Ok(data) = hex::decode(input) {
|
||||
if data.len() == expected_len {
|
||||
if input.len() == expected_len * 2
|
||||
&& let Ok(data) = hex::decode(input)
|
||||
&& data.len() == expected_len
|
||||
{
|
||||
return Some(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Ok(data) = decode_base32(input) {
|
||||
if data.len() == expected_len {
|
||||
if let Ok(data) = decode_base32(input)
|
||||
&& data.len() == expected_len
|
||||
{
|
||||
return Some(data);
|
||||
}
|
||||
}
|
||||
if let Ok(data) = URL_SAFE.decode(input) {
|
||||
if data.len() == expected_len {
|
||||
if let Ok(data) = URL_SAFE.decode(input)
|
||||
&& data.len() == expected_len
|
||||
{
|
||||
return Some(data);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
@@ -991,11 +991,11 @@ mod tests {
|
||||
|
||||
impl FrameSession for ScriptedSession {
|
||||
fn send(&mut self, frame: &rnode_admin::AdminFrame) -> Result<(), String> {
|
||||
if let Some((index, message)) = self.fail_send_at {
|
||||
if self.sent.len() == index {
|
||||
if let Some((index, message)) = self.fail_send_at
|
||||
&& self.sent.len() == index
|
||||
{
|
||||
return Err(message.to_string());
|
||||
}
|
||||
}
|
||||
self.sent.push(frame.clone());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -133,33 +133,35 @@ fn validate_wifi_inputs(args: &Args) -> Result<(), String> {
|
||||
_ => return Err("WiFi mode must be OFF, AP or STATION".to_string()),
|
||||
}
|
||||
}
|
||||
if let Some(channel) = args.channel {
|
||||
if !(1..=14).contains(&channel) {
|
||||
if let Some(channel) = args.channel
|
||||
&& !(1..=14).contains(&channel)
|
||||
{
|
||||
return Err("WiFi channel must be in 1..=14".to_string());
|
||||
}
|
||||
}
|
||||
if let Some(ssid) = args.ssid.as_deref() {
|
||||
if !ssid.eq_ignore_ascii_case("none") && ssid.len() > 32 {
|
||||
if let Some(ssid) = args.ssid.as_deref()
|
||||
&& !ssid.eq_ignore_ascii_case("none")
|
||||
&& ssid.len() > 32
|
||||
{
|
||||
return Err("WiFi SSID must be at most 32 bytes".to_string());
|
||||
}
|
||||
}
|
||||
if let Some(psk) = args.psk.as_deref() {
|
||||
if !psk.eq_ignore_ascii_case("none") && !(8..=32).contains(&psk.len()) {
|
||||
if let Some(psk) = args.psk.as_deref()
|
||||
&& !psk.eq_ignore_ascii_case("none")
|
||||
&& !(8..=32).contains(&psk.len())
|
||||
{
|
||||
return Err("WiFi PSK must be 8 to 32 bytes, or NONE".to_string());
|
||||
}
|
||||
}
|
||||
for (name, value) in [
|
||||
("IP address", args.ip.as_deref()),
|
||||
("netmask", args.nm.as_deref()),
|
||||
] {
|
||||
if let Some(value) = value {
|
||||
if !value.eq_ignore_ascii_case("none") {
|
||||
if let Some(value) = value
|
||||
&& !value.eq_ignore_ascii_case("none")
|
||||
{
|
||||
value
|
||||
.parse::<Ipv4Addr>()
|
||||
.map_err(|error| format!("invalid WiFi {name} {value}: {error}"))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -1155,14 +1155,14 @@ async fn run_remote(args: Args) -> ExitCode {
|
||||
};
|
||||
req_args.push(rmpv::Value::Binary(dest.to_vec()));
|
||||
}
|
||||
if args.table {
|
||||
if let Some(m) = args.max {
|
||||
if args.table
|
||||
&& let Some(m) = args.max
|
||||
{
|
||||
if args.destination.is_none() {
|
||||
req_args.push(rmpv::Value::Nil);
|
||||
}
|
||||
req_args.push(rmpv::Value::from(m));
|
||||
}
|
||||
}
|
||||
let req_value = rmpv::Value::Array(req_args);
|
||||
let mut payload = Vec::new();
|
||||
if let Err(e) = rmpv::encode::write_value(&mut payload, &req_value) {
|
||||
|
||||
@@ -535,14 +535,14 @@ fn print_local_human(stats: &[rpc::InterfaceStatEntry], link_count: Option<i64>,
|
||||
println!(" IFAC : {} bits", entry.ifac_size * 8);
|
||||
}
|
||||
if args.announce_stats {
|
||||
if let Some(queued) = entry.announce_queue {
|
||||
if queued > 0 {
|
||||
if let Some(queued) = entry.announce_queue
|
||||
&& queued > 0
|
||||
{
|
||||
println!(
|
||||
" Queued : {queued} announce{}",
|
||||
if queued == 1 { "" } else { "s" }
|
||||
);
|
||||
}
|
||||
}
|
||||
if entry.held_announces > 0 {
|
||||
println!(
|
||||
" Held : {} announce{}",
|
||||
@@ -1199,14 +1199,14 @@ fn print_remote_status(bytes: &[u8], args: &Args) -> ExitCode {
|
||||
println!(" Blocked : {blocked}");
|
||||
}
|
||||
if args.announce_stats {
|
||||
if let Some(queued) = iface.announce_queue {
|
||||
if queued > 0 {
|
||||
if let Some(queued) = iface.announce_queue
|
||||
&& queued > 0
|
||||
{
|
||||
println!(
|
||||
" Queued : {queued} announce{}",
|
||||
if queued == 1 { "" } else { "s" }
|
||||
);
|
||||
}
|
||||
}
|
||||
if iface.held_announces > 0 {
|
||||
println!(
|
||||
" Held : {} announce{}",
|
||||
|
||||
@@ -350,8 +350,9 @@ impl TransportActor {
|
||||
// Cancel our queued rebroadcast when a neighbor already carried it.
|
||||
// Same-hop neighbor rebroadcast counts toward the local cap;
|
||||
// strict hops+1 forward drops our queued copy outright.
|
||||
if self.is_transport_enabled {
|
||||
if let Some(existing) = self.announce_table.get(&header.destination_hash) {
|
||||
if self.is_transport_enabled
|
||||
&& let Some(existing) = self.announce_table.get(&header.destination_hash)
|
||||
{
|
||||
let existing_hops = existing.hops;
|
||||
let existing_retries = existing.retries;
|
||||
if header.hops > 0 && header.hops - 1 == existing_hops && existing_retries > 0 {
|
||||
@@ -368,8 +369,9 @@ impl TransportActor {
|
||||
}
|
||||
if header.hops > 0 && header.hops - 1 == existing_hops + 1 && existing_retries > 0 {
|
||||
let now = now_f64();
|
||||
if let Some(ae) = self.announce_table.get(&header.destination_hash) {
|
||||
if now < ae.retransmit_timeout {
|
||||
if let Some(ae) = self.announce_table.get(&header.destination_hash)
|
||||
&& now < ae.retransmit_timeout
|
||||
{
|
||||
debug!(
|
||||
dest = hex::encode(header.destination_hash),
|
||||
"announce dedup: passed on by another node, cancelling rebroadcast"
|
||||
@@ -378,8 +380,6 @@ impl TransportActor {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut random_blobs = self
|
||||
.path_table
|
||||
@@ -489,12 +489,12 @@ impl TransportActor {
|
||||
if self
|
||||
.discovery_path_requests
|
||||
.contains_key(&header.destination_hash)
|
||||
{
|
||||
if let Some(response) = self.path_response_from_cached_announce(
|
||||
&& let Some(response) = self.path_response_from_cached_announce(
|
||||
raw,
|
||||
header.destination_hash,
|
||||
header.hops,
|
||||
) {
|
||||
)
|
||||
{
|
||||
self.finish_recursive_discovery(
|
||||
header.destination_hash,
|
||||
&response,
|
||||
@@ -502,7 +502,6 @@ impl TransportActor {
|
||||
now_f64(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
debug!(
|
||||
dest = hex::encode(header.destination_hash),
|
||||
@@ -562,21 +561,16 @@ impl TransportActor {
|
||||
}
|
||||
}
|
||||
|
||||
if is_from_local_client && header.context == rns_wire::context::PacketContext::PathResponse
|
||||
{
|
||||
if let Some(waiting_interface) = self
|
||||
if is_from_local_client
|
||||
&& header.context == rns_wire::context::PacketContext::PathResponse
|
||||
&& let Some(waiting_interface) = self
|
||||
.pending_local_path_requests
|
||||
.remove(&header.destination_hash)
|
||||
&& let Some(response) =
|
||||
self.path_response_from_cached_announce(raw, header.destination_hash, header.hops)
|
||||
{
|
||||
if let Some(response) = self.path_response_from_cached_announce(
|
||||
raw,
|
||||
header.destination_hash,
|
||||
header.hops,
|
||||
) {
|
||||
self.send_to_interface(waiting_interface, &response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.send_announce_to_local_clients(
|
||||
raw,
|
||||
@@ -776,17 +770,17 @@ impl TransportActor {
|
||||
"data packet routing"
|
||||
);
|
||||
if self.local_destinations.contains(&header.destination_hash) {
|
||||
if let Some(tx) = self.destination_channels.get(&header.destination_hash) {
|
||||
if let Err(e) = tx.try_send(crate::link_messages::DestinationEvent::InboundPacket {
|
||||
if let Some(tx) = self.destination_channels.get(&header.destination_hash)
|
||||
&& let Err(e) = tx.try_send(crate::link_messages::DestinationEvent::InboundPacket {
|
||||
raw: raw.clone(),
|
||||
interface_id,
|
||||
metrics,
|
||||
}) {
|
||||
})
|
||||
{
|
||||
self.channel_drops += 1;
|
||||
warn!(dest = hex::encode(header.destination_hash), drops = self.channel_drops, err = %e,
|
||||
"failed to deliver InboundPacket to local destination (channel full)");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -837,17 +831,17 @@ impl TransportActor {
|
||||
// on_inbound already established transport ownership (or the exact
|
||||
// attached shared-owner ingress) before admitting this packet's hash.
|
||||
if self.local_destinations.contains(&header.destination_hash) {
|
||||
if let Some(tx) = self.destination_channels.get(&header.destination_hash) {
|
||||
if let Err(e) = tx.try_send(crate::link_messages::DestinationEvent::LinkRequest {
|
||||
if let Some(tx) = self.destination_channels.get(&header.destination_hash)
|
||||
&& let Err(e) = tx.try_send(crate::link_messages::DestinationEvent::LinkRequest {
|
||||
raw: raw.clone(),
|
||||
interface_id,
|
||||
metrics,
|
||||
}) {
|
||||
})
|
||||
{
|
||||
self.channel_drops += 1;
|
||||
error!(dest = hex::encode(header.destination_hash), drops = self.channel_drops, err = %e,
|
||||
"failed to deliver LinkRequest; link establishment will fail");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1072,11 +1066,11 @@ impl TransportActor {
|
||||
.receipt_table
|
||||
.get_mut(&header.destination_hash)
|
||||
.expect("receipt existence checked above");
|
||||
if receipt.destination_public_key.is_none() {
|
||||
if let Some(destination_hash) = receipt.destination_hash {
|
||||
if receipt.destination_public_key.is_none()
|
||||
&& let Some(destination_hash) = receipt.destination_hash
|
||||
{
|
||||
receipt.set_destination_identity(destination_hash, recalled_public_key);
|
||||
}
|
||||
}
|
||||
let validated = receipt.validate_proof_from_destination(proof);
|
||||
(validated, receipt.get_rtt())
|
||||
};
|
||||
@@ -1144,8 +1138,9 @@ impl TransportActor {
|
||||
// receive rule, so the proof must equal the remaining hops recorded
|
||||
// when the request was forwarded.
|
||||
if header.context == rns_wire::context::PacketContext::Lrproof {
|
||||
if self.is_transport_enabled || from_local_client || for_local_client_link {
|
||||
if let Some(link_entry) = self.link_table.get(&header.destination_hash) {
|
||||
if (self.is_transport_enabled || from_local_client || for_local_client_link)
|
||||
&& let Some(link_entry) = self.link_table.get(&header.destination_hash)
|
||||
{
|
||||
if !link_entry.validated
|
||||
&& (now_f64() >= link_entry.proof_timeout
|
||||
|| !link_entry.proof_timeout.is_finite())
|
||||
@@ -1159,8 +1154,7 @@ impl TransportActor {
|
||||
let destination_hash = link_entry.destination_hash;
|
||||
// Python 1.3.8 Transport.py:1552/2222: instance-local
|
||||
// links are exempt from delta mangling (1.3.7 eacff56f).
|
||||
let instance_local_link = self
|
||||
.is_local_client_interface(link_entry.interface_id)
|
||||
let instance_local_link = self.is_local_client_interface(link_entry.interface_id)
|
||||
&& self.is_local_client_interface(link_entry.receiving_interface);
|
||||
|
||||
// Require that the proof arrived on the same interface we
|
||||
@@ -1220,7 +1214,6 @@ impl TransportActor {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fall through to local-pending-link delivery when link_table
|
||||
// didn't claim the proof.
|
||||
@@ -1300,18 +1293,18 @@ impl TransportActor {
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(tx) = self.destination_channels.get(&header.destination_hash) {
|
||||
if let Err(e) = tx.try_send(crate::link_messages::DestinationEvent::InboundPacket {
|
||||
if let Some(tx) = self.destination_channels.get(&header.destination_hash)
|
||||
&& let Err(e) = tx.try_send(crate::link_messages::DestinationEvent::InboundPacket {
|
||||
raw: raw.clone(),
|
||||
interface_id: _interface_id,
|
||||
metrics,
|
||||
}) {
|
||||
})
|
||||
{
|
||||
self.channel_drops += 1;
|
||||
error!(dest = hex::encode(header.destination_hash), drops = self.channel_drops, err = %e,
|
||||
"failed to deliver link proof to local link");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn route_link_packet_via_link_table(
|
||||
&mut self,
|
||||
|
||||
@@ -99,11 +99,11 @@ impl TransportActor {
|
||||
let interface_id = self.link_endpoints[&key].binding.interface_id;
|
||||
// Give previously admitted packets first claim on newly available
|
||||
// interface capacity before considering the new packet.
|
||||
if !self.link_endpoints[&key].egress.is_empty() {
|
||||
if let Err(reason) = self.drain_one_link_endpoint(key) {
|
||||
if !self.link_endpoints[&key].egress.is_empty()
|
||||
&& let Err(reason) = self.drain_one_link_endpoint(key)
|
||||
{
|
||||
return LinkEndpointSendResult::Terminated(reason);
|
||||
}
|
||||
}
|
||||
|
||||
if self.link_endpoints[&key].egress.len() >= LINK_ENDPOINT_EGRESS_QUEUE_CAPACITY {
|
||||
self.terminate_link_endpoint(key, LinkEndpointTerminalReason::EgressQueueExhausted, 0);
|
||||
|
||||
@@ -56,8 +56,8 @@ impl TransportActor {
|
||||
let mut queued_dests = HashSet::new();
|
||||
for expired_link in expired_links {
|
||||
if let Some(request) = self.rediscovery_request_for_expired_link(expired_link, now)
|
||||
&& queued_dests.insert(request.destination_hash)
|
||||
{
|
||||
if queued_dests.insert(request.destination_hash) {
|
||||
self.queue_discovery_path_request(
|
||||
request.destination_hash,
|
||||
request.blocked_interface,
|
||||
@@ -65,7 +65,6 @@ impl TransportActor {
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cull may have removed path/tunnel entries — flag for save so
|
||||
// the on-disk file reflects the current routing state. False
|
||||
@@ -631,9 +630,9 @@ impl TransportActor {
|
||||
}
|
||||
|
||||
for dest_hash in &voided_destinations {
|
||||
if self.local_destinations.contains(dest_hash) {
|
||||
if let Some(tx) = self.destination_channels.get(dest_hash) {
|
||||
if let Err(e) =
|
||||
if self.local_destinations.contains(dest_hash)
|
||||
&& let Some(tx) = self.destination_channels.get(dest_hash)
|
||||
&& let Err(e) =
|
||||
tx.try_send(crate::link_messages::DestinationEvent::AnnounceRequested(
|
||||
crate::link_messages::AnnounceRequest::normal(String::new()),
|
||||
))
|
||||
@@ -644,8 +643,6 @@ impl TransportActor {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1119,8 +1119,7 @@ impl TransportActor {
|
||||
header: &rns_wire::header::PacketHeader,
|
||||
transport_insert: bool,
|
||||
) -> Vec<u8> {
|
||||
if transport_insert {
|
||||
if let Some(transport_id) = self.transport_identity_hash {
|
||||
if transport_insert && let Some(transport_id) = self.transport_identity_hash {
|
||||
let mut flags = header.flags;
|
||||
flags.header_type = rns_wire::flags::HeaderType::Header2;
|
||||
flags.transport_type = rns_wire::flags::TransportType::Transport;
|
||||
@@ -1135,7 +1134,6 @@ impl TransportActor {
|
||||
out.extend_from_slice(&raw[header.size()..]);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
let mut out = raw.to_vec();
|
||||
out[1] = self.local_hops_delta;
|
||||
out
|
||||
@@ -1783,11 +1781,9 @@ impl TransportActor {
|
||||
}
|
||||
_ => self.send_to_interface(id, raw),
|
||||
};
|
||||
if sent {
|
||||
if let Some(entry) = self.interfaces.get_mut(&id) {
|
||||
if sent && let Some(entry) = self.interfaces.get_mut(&id) {
|
||||
entry.ingress.sent_announce();
|
||||
}
|
||||
}
|
||||
accepted |= sent;
|
||||
}
|
||||
accepted
|
||||
|
||||
@@ -174,12 +174,11 @@ impl TransportActor {
|
||||
|
||||
// Touch the path so an actively-used route isn't culled
|
||||
// for staleness while traffic is still flowing on it.
|
||||
if sent {
|
||||
if let Some(path) = self.path_table.get_live_mut(&request.destination_hash)
|
||||
if sent
|
||||
&& let Some(path) = self.path_table.get_live_mut(&request.destination_hash)
|
||||
{
|
||||
path.touch();
|
||||
}
|
||||
}
|
||||
sent
|
||||
} else {
|
||||
let iface_names: Vec<&str> = self
|
||||
@@ -241,11 +240,12 @@ impl TransportActor {
|
||||
} else {
|
||||
self.send_to_interface(interface_id, &request.raw)
|
||||
};
|
||||
if sent && parsed.flags.packet_type == rns_wire::flags::PacketType::Announce {
|
||||
if let Some(entry) = self.interfaces.get_mut(&interface_id) {
|
||||
if sent
|
||||
&& parsed.flags.packet_type == rns_wire::flags::PacketType::Announce
|
||||
&& let Some(entry) = self.interfaces.get_mut(&interface_id)
|
||||
{
|
||||
entry.ingress.sent_announce();
|
||||
}
|
||||
}
|
||||
sent
|
||||
} else {
|
||||
false
|
||||
@@ -505,12 +505,12 @@ impl TransportActor {
|
||||
let mut unique_tag = Vec::with_capacity(32);
|
||||
unique_tag.extend_from_slice(&requested_dest);
|
||||
unique_tag.extend_from_slice(tag);
|
||||
if let Some(last) = self.discovery_pr_tags.get(&unique_tag) {
|
||||
if now - last < PATH_REQUEST_GATE_TIMEOUT {
|
||||
if let Some(last) = self.discovery_pr_tags.get(&unique_tag)
|
||||
&& now - last < PATH_REQUEST_GATE_TIMEOUT
|
||||
{
|
||||
trace!(dest = %hex::encode(requested_dest), "ignoring duplicate path request");
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.discovery_pr_tags.insert(unique_tag, now);
|
||||
|
||||
if self.local_destinations.contains(&requested_dest) {
|
||||
@@ -518,8 +518,8 @@ impl TransportActor {
|
||||
dest = %hex::encode(requested_dest),
|
||||
"answering path request — destination is local"
|
||||
);
|
||||
if let Some(tx) = self.destination_channels.get(&requested_dest) {
|
||||
if let Err(e) =
|
||||
if let Some(tx) = self.destination_channels.get(&requested_dest)
|
||||
&& let Err(e) =
|
||||
tx.try_send(crate::link_messages::DestinationEvent::AnnounceRequested(
|
||||
crate::link_messages::AnnounceRequest {
|
||||
app_name: String::new(),
|
||||
@@ -533,19 +533,17 @@ impl TransportActor {
|
||||
warn!(dest = hex::encode(requested_dest), drops = self.channel_drops, err = %e,
|
||||
"failed to send AnnounceRequested for local path request");
|
||||
}
|
||||
}
|
||||
self.fire_path_waiters(&requested_dest);
|
||||
return;
|
||||
}
|
||||
|
||||
if !is_from_local_client {
|
||||
if let Some(path) = self.path_table.get_live(&requested_dest) {
|
||||
if self.is_local_client_interface(path.interface_id) {
|
||||
if !is_from_local_client
|
||||
&& let Some(path) = self.path_table.get_live(&requested_dest)
|
||||
&& self.is_local_client_interface(path.interface_id)
|
||||
{
|
||||
self.pending_local_path_requests
|
||||
.insert(requested_dest, interface_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Python Transport.py: local shared clients are allowed to use the
|
||||
// shared instance's path cache even when the instance is not a transport
|
||||
@@ -686,11 +684,11 @@ impl TransportActor {
|
||||
fn build_path_request_packet(&self, destination_hash: [u8; 16], tag: Option<&[u8]>) -> Vec<u8> {
|
||||
let mut request_data = Vec::with_capacity(48);
|
||||
request_data.extend_from_slice(&destination_hash);
|
||||
if self.is_transport_enabled {
|
||||
if let Some(identity_hash) = self.transport_identity_hash {
|
||||
if self.is_transport_enabled
|
||||
&& let Some(identity_hash) = self.transport_identity_hash
|
||||
{
|
||||
request_data.extend_from_slice(&identity_hash);
|
||||
}
|
||||
}
|
||||
if let Some(tag) = tag {
|
||||
request_data.extend_from_slice(&tag[..tag.len().min(16)]);
|
||||
} else {
|
||||
@@ -790,11 +788,11 @@ impl TransportActor {
|
||||
if self.path_table.has_path(&destination_hash) {
|
||||
return;
|
||||
}
|
||||
if let Some(last) = self.path_requests.get(&destination_hash) {
|
||||
if now_f64() - last < PATH_REQUEST_MI {
|
||||
if let Some(last) = self.path_requests.get(&destination_hash)
|
||||
&& now_f64() - last < PATH_REQUEST_MI
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
self.broadcast_path_request(destination_hash);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +99,8 @@ impl TransportActor {
|
||||
return;
|
||||
};
|
||||
let route = RouteVersion::from_path(path);
|
||||
if self.local_link_route_attempts.len() >= MAX_LOCAL_LINK_ROUTES {
|
||||
if let Some(oldest) = self
|
||||
if self.local_link_route_attempts.len() >= MAX_LOCAL_LINK_ROUTES
|
||||
&& let Some(oldest) = self
|
||||
.local_link_route_attempts
|
||||
.iter()
|
||||
.min_by(|a, b| a.1.observed_at.total_cmp(&b.1.observed_at))
|
||||
@@ -108,7 +108,6 @@ impl TransportActor {
|
||||
{
|
||||
self.local_link_route_attempts.remove(&oldest);
|
||||
}
|
||||
}
|
||||
self.local_link_route_attempts.insert(
|
||||
link_id,
|
||||
LocalLinkRouteAttempt {
|
||||
|
||||
@@ -27,8 +27,8 @@ fn recent_announce_from_cached_packet(
|
||||
name_hash: [0u8; 10],
|
||||
};
|
||||
|
||||
if let Ok((header, offset)) = rns_wire::header::PacketHeader::unpack(&raw_packet) {
|
||||
if header.flags.packet_type == rns_wire::flags::PacketType::Announce
|
||||
if let Ok((header, offset)) = rns_wire::header::PacketHeader::unpack(&raw_packet)
|
||||
&& header.flags.packet_type == rns_wire::flags::PacketType::Announce
|
||||
&& header.destination_hash == dest_hash
|
||||
&& raw_packet.len() >= offset
|
||||
{
|
||||
@@ -36,8 +36,7 @@ fn recent_announce_from_cached_packet(
|
||||
&raw_packet,
|
||||
header.flags.header_type,
|
||||
));
|
||||
recent.is_path_response =
|
||||
header.context == rns_wire::context::PacketContext::PathResponse;
|
||||
recent.is_path_response = header.context == rns_wire::context::PacketContext::PathResponse;
|
||||
if let Ok(announce) = rns_identity::announce::AnnounceData::unpack(
|
||||
&raw_packet[offset..],
|
||||
header.flags.context_flag,
|
||||
@@ -48,7 +47,6 @@ fn recent_announce_from_cached_packet(
|
||||
recent.name_hash = announce.name_hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recent
|
||||
}
|
||||
@@ -60,12 +58,13 @@ fn python_announce_cache_index(
|
||||
Ok(entries) => {
|
||||
let mut names = std::collections::HashSet::new();
|
||||
for entry in entries.flatten() {
|
||||
if let Some(name) = entry.file_name().to_str() {
|
||||
if name.len() == 64 && name.as_bytes().iter().all(u8::is_ascii_hexdigit) {
|
||||
if let Some(name) = entry.file_name().to_str()
|
||||
&& name.len() == 64
|
||||
&& name.as_bytes().iter().all(u8::is_ascii_hexdigit)
|
||||
{
|
||||
names.insert(name.to_ascii_lowercase());
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(names)
|
||||
}
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {
|
||||
|
||||
@@ -599,12 +599,12 @@ impl TransportActor {
|
||||
}
|
||||
TransportQuery::ResolveIdentityHash { input } => {
|
||||
// First treat input as a destination hash.
|
||||
if let Some(entry) = self.recent_announces.get(&input) {
|
||||
if let Some(public_key) = entry.public_key {
|
||||
if let Some(entry) = self.recent_announces.get(&input)
|
||||
&& let Some(public_key) = entry.public_key
|
||||
{
|
||||
let id_hash = rns_crypto::sha::truncated_hash(&public_key);
|
||||
return TransportQueryResponse::HashResult(Some(id_hash));
|
||||
}
|
||||
}
|
||||
// Fall back to treating input as an identity hash already.
|
||||
for entry in self.recent_announces.values() {
|
||||
let Some(public_key) = entry.public_key else {
|
||||
|
||||
@@ -305,11 +305,11 @@ pub fn decode_info(packed: &[u8]) -> Result<DiscoveryInfo, AppDataError> {
|
||||
if !DISCOVERABLE_INTERFACE_TYPES.contains(&info.interface_type.as_str()) {
|
||||
return Err(AppDataError::UnsupportedInterfaceType(info.interface_type));
|
||||
}
|
||||
if let Some(reachable_on) = info.reachable_on.as_deref() {
|
||||
if !valid_reachable_on(reachable_on) {
|
||||
if let Some(reachable_on) = info.reachable_on.as_deref()
|
||||
&& !valid_reachable_on(reachable_on)
|
||||
{
|
||||
return Err(AppDataError::InvalidReachableOn(reachable_on.to_string()));
|
||||
}
|
||||
}
|
||||
Ok(info)
|
||||
}
|
||||
|
||||
|
||||
@@ -92,11 +92,11 @@ pub fn build_local_manifest(
|
||||
if entry.source.is_some() {
|
||||
continue;
|
||||
}
|
||||
if let Some(set) = verified_ids {
|
||||
if !set.contains(hash.as_bytes()) {
|
||||
if let Some(set) = verified_ids
|
||||
&& !set.contains(hash.as_bytes())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let until = entry.ttl.map(|ttl| entry.created + ttl);
|
||||
let wire_entry = encode_entry_map(until, entry.reason_str(), our_identity_hash);
|
||||
map.push((Value::Binary(hash.as_bytes().to_vec()), wire_entry));
|
||||
@@ -228,20 +228,19 @@ pub fn apply_manifest(
|
||||
) -> usize {
|
||||
let mut applied = 0usize;
|
||||
for (id_hash, entry) in manifest {
|
||||
if let Some(until) = entry.until {
|
||||
if until <= now {
|
||||
if let Some(until) = entry.until
|
||||
&& until <= now
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if let Some(existing) = table
|
||||
.iter_entries()
|
||||
.find(|(h, _)| h.as_bytes() == id_hash)
|
||||
.map(|(_, e)| e.clone())
|
||||
&& existing.source.is_none()
|
||||
{
|
||||
if existing.source.is_none() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let ttl = entry.until.map(|u| (u - now).max(0.0));
|
||||
let reason = BlackholeReason::parse(&entry.reason);
|
||||
|
||||
@@ -411,11 +411,11 @@ impl ReceiverConfig {
|
||||
stamp_value,
|
||||
} = material;
|
||||
let announced_identity = event.identity_hash.unwrap_or(info.transport_id);
|
||||
if let Some(sources) = self.discovery_sources.as_ref() {
|
||||
if !sources.iter().any(|s| s == &announced_identity) {
|
||||
if let Some(sources) = self.discovery_sources.as_ref()
|
||||
&& !sources.iter().any(|s| s == &announced_identity)
|
||||
{
|
||||
return Outcome::Rejected(Reason::UnauthorizedSource);
|
||||
}
|
||||
}
|
||||
|
||||
let now = now_unix();
|
||||
let record = DiscoveredInterface {
|
||||
|
||||
@@ -184,11 +184,11 @@ impl DiscoveryStore {
|
||||
|
||||
let heard_delta = now.saturating_sub(rec.last_heard);
|
||||
let mut should_remove = heard_delta > THRESHOLD_REMOVE_SECS;
|
||||
if let Some(sources) = discovery_sources {
|
||||
if !sources.iter().any(|s| s == &rec.network_id) {
|
||||
if let Some(sources) = discovery_sources
|
||||
&& !sources.iter().any(|s| s == &rec.network_id)
|
||||
{
|
||||
should_remove = true;
|
||||
}
|
||||
}
|
||||
if should_remove {
|
||||
let _ = std::fs::remove_file(&path);
|
||||
continue;
|
||||
|
||||
@@ -161,11 +161,11 @@ impl LinkEndpointDispatchBindReceipt {
|
||||
/// consumes it. Dropping even a ready receipt still retires an unpublished
|
||||
/// binding, so cancellation between readiness and processing is safe.
|
||||
pub fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<()> {
|
||||
if self.ready.is_none() {
|
||||
if let Poll::Ready(result) = Pin::new(&mut self.result_rx).poll(cx) {
|
||||
if self.ready.is_none()
|
||||
&& let Poll::Ready(result) = Pin::new(&mut self.result_rx).poll(cx)
|
||||
{
|
||||
self.ready = Some(result);
|
||||
}
|
||||
}
|
||||
if self.ready.is_some() {
|
||||
Poll::Ready(())
|
||||
} else {
|
||||
|
||||
@@ -1001,11 +1001,11 @@ pub fn migrate_legacy_announce_entries(
|
||||
.map(|e| {
|
||||
let mut packet_hash = None;
|
||||
let mut is_path_response = false;
|
||||
if !e.raw_packet.is_empty() {
|
||||
if let Ok((header, _)) = rns_wire::header::PacketHeader::unpack(&e.raw_packet) {
|
||||
if !e.raw_packet.is_empty()
|
||||
&& let Ok((header, _)) = rns_wire::header::PacketHeader::unpack(&e.raw_packet)
|
||||
{
|
||||
let hash = rns_wire::hash::packet_hash(&e.raw_packet, header.flags.header_type);
|
||||
is_path_response =
|
||||
header.context == rns_wire::context::PacketContext::PathResponse;
|
||||
is_path_response = header.context == rns_wire::context::PacketContext::PathResponse;
|
||||
if write_python_cached_announce_if_absent(
|
||||
announce_cache_dir,
|
||||
&hash,
|
||||
@@ -1017,7 +1017,6 @@ pub fn migrate_legacy_announce_entries(
|
||||
packet_hash = Some(hash.to_vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
PersistedAnnounceEntry {
|
||||
destination_hash: e.destination_hash,
|
||||
hops: e.hops,
|
||||
|
||||
@@ -11,7 +11,7 @@ from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
EXPECTED_RUST_VERSION = "1.87"
|
||||
EXPECTED_RUST_VERSION = "1.89"
|
||||
SHA_PATTERN = re.compile(r"^[0-9a-f]{40}$")
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ def check_workflow_actions() -> None:
|
||||
def check_release_workflow() -> None:
|
||||
workflow = (ROOT / ".github/workflows/release.yml").read_text()
|
||||
|
||||
if not re.search(r"^\s*toolchain:\s*1\.87\.0\s*$", workflow, re.MULTILINE):
|
||||
fail("release workflow does not select Rust 1.87.0")
|
||||
if not re.search(r"^\s*toolchain:\s*1\.89\.0\s*$", workflow, re.MULTILINE):
|
||||
fail("release workflow does not select Rust 1.89.0")
|
||||
if "ref: ${{ env.RELEASE_TAG }}" not in workflow:
|
||||
fail("release workflow does not check out RELEASE_TAG")
|
||||
|
||||
|
||||
Reference in new issue
Block a user