Skip to content

Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.

Add nectarlink-core: identity, trust store, pairing and sessions

Bee10be719f6064
diff --git a/Cargo.lock b/Cargo.lock
index ebd6790..73e018e 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2,6 +2,178 @@
# It is not intended for manual editing.
version = 4
+[[package]]
+name = "acto"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "598381761ee991bf2f1455f700380e2191fb370dc9df1ee764f348b7f089d8b6"
+dependencies = [
+ "parking_lot",
+ "pin-project-lite",
+ "rustc_version",
+ "smol_str",
+ "sync_wrapper",
+ "tokio",
+ "tracing",
+]
+
+[[package]]
+name = "aead"
+version = "0.5.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0"
+dependencies = [
+ "crypto-common 0.1.7",
+ "generic-array",
+]
+
+[[package]]
+name = "aes"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
+dependencies = [
+ "cfg-if",
+ "cipher",
+ "cpufeatures 0.2.17",
+]
+
+[[package]]
+name = "aes-gcm"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1"
+dependencies = [
+ "aead",
+ "aes",
+ "cipher",
+ "ctr",
+ "ghash",
+ "subtle",
+]
+
+[[package]]
+name = "aho-corasick"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "android_system_properties"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc"
+dependencies = [
+ "libc",
+]
+
+[[package]]
+name = "arc-swap"
+version = "1.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c049c0be4daef0b145cb3555416b3b8ef5b7888a38aea1a3a155801fe7b0810b"
+dependencies = [
+ "rustversion",
+]
+
+[[package]]
+name = "arrayvec"
+version = "0.7.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
+
+[[package]]
+name = "async_io_stream"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6d7b9decdf35d8908a7e3ef02f64c5e9b1695e230154c0e8de3969142d9b94c"
+dependencies = [
+ "futures",
+ "pharos",
+ "rustc_version",
+]
+
+[[package]]
+name = "atomic-waker"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
+
+[[package]]
+name = "attohttpc"
+version = "0.30.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16e2cdb6d5ed835199484bb92bb8b3edd526effe995c61732580439c1a67e2e9"
+dependencies = [
+ "base64 0.22.1",
+ "http",
+ "log",
+ "url",
+]
+
+[[package]]
+name = "autocfg"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
+
+[[package]]
+name = "backon"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef"
+dependencies = [
+ "fastrand",
+ "gloo-timers",
+ "tokio",
+]
+
+[[package]]
+name = "base16ct"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6"
+
+[[package]]
+name = "base64"
+version = "0.22.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
+
+[[package]]
+name = "base64"
+version = "0.23.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
+
+[[package]]
+name = "base64ct"
+version = "1.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
+
+[[package]]
+name = "bitflags"
+version = "2.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
+
+[[package]]
+name = "blake3"
+version = "1.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d9e454fc11f76977dc803893aff6304ed33d6a26efae8696573bea74baa27ae"
+dependencies = [
+ "arrayvec",
+ "cc",
+ "cfg-if",
+ "constant_time_eq",
+ "cpufeatures 0.3.1",
+]
+
[[package]]
name = "block-buffer"
version = "0.12.1"
@@ -11,18 +183,78 @@ dependencies = [
"hybrid-array",
]
+[[package]]
+name = "block2"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"
+dependencies = [
+ "objc2",
+]
+
+[[package]]
+name = "bumpalo"
+version = "3.20.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
+
[[package]]
name = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
+[[package]]
+name = "cc"
+version = "1.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630"
+dependencies = [
+ "find-msvc-tools",
+ "shlex",
+]
+
+[[package]]
+name = "cesu8"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
+
[[package]]
name = "cfg-if"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
+[[package]]
+name = "cfg_aliases"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
+
+[[package]]
+name = "chacha20"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "rand_core",
+]
+
+[[package]]
+name = "chrono"
+version = "0.4.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327"
+dependencies = [
+ "iana-time-zone",
+ "num-traits",
+ "serde",
+ "windows-link",
+]
+
[[package]]
name = "ciborium"
version = "0.2.2"
@@ -50,18 +282,97 @@ dependencies = [
"half",
]
+[[package]]
+name = "cipher"
+version = "0.4.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
+dependencies = [
+ "crypto-common 0.1.7",
+ "inout",
+]
+
[[package]]
name = "cmov"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a"
+[[package]]
+name = "cobs"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1"
+dependencies = [
+ "thiserror 2.0.21",
+]
+
+[[package]]
+name = "combine"
+version = "4.6.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfc320937d09e6de266b31b9afb480f197d7a861be86be7cb2ea7e5d1bfffc5e"
+dependencies = [
+ "bytes",
+ "memchr",
+]
+
[[package]]
name = "const-oid"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
+[[package]]
+name = "constant_time_eq"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b"
+
+[[package]]
+name = "convert_case"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9"
+dependencies = [
+ "unicode-segmentation",
+]
+
+[[package]]
+name = "cordyceps"
+version = "0.3.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b9ab7e0ca1d179628fa0172b2b97203c7fa0cd81be2448bd446fb9559ca9261"
+dependencies = [
+ "loom",
+ "tracing",
+]
+
+[[package]]
+name = "core-foundation"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "core-foundation-sys"
+version = "0.8.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+
+[[package]]
+name = "cpufeatures"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280"
+dependencies = [
+ "libc",
+]
+
[[package]]
name = "cpufeatures"
version = "0.3.1"
@@ -71,12 +382,28 @@ dependencies = [
"libc",
]
+[[package]]
+name = "critical-section"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b"
+
[[package]]
name = "crunchy"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5"
+[[package]]
+name = "crypto-common"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a"
+dependencies = [
+ "generic-array",
+ "typenum",
+]
+
[[package]]
name = "crypto-common"
version = "0.2.2"
@@ -84,6 +411,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453"
dependencies = [
"hybrid-array",
+ "rand_core",
+]
+
+[[package]]
+name = "ctr"
+version = "0.9.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835"
+dependencies = [
+ "cipher",
]
[[package]]
@@ -96,433 +433,3509 @@ dependencies = [
]
[[package]]
-name = "data-encoding"
-version = "2.11.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
-
-[[package]]
-name = "digest"
-version = "0.11.3"
+name = "curve25519-dalek"
+version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
+checksum = "b5eed333089e2e1c1ac8c6c0398e5e2497b4c9926ca6d0365ed1e099afa5bc23"
dependencies = [
- "block-buffer",
- "const-oid",
- "crypto-common",
- "ctutils",
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "curve25519-dalek-derive",
+ "digest",
+ "fiat-crypto",
+ "rand_core",
+ "rustc_version",
+ "serde",
+ "subtle",
+ "zeroize",
]
[[package]]
-name = "displaydoc"
-version = "0.2.7"
+name = "curve25519-dalek-derive"
+version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
+checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3"
dependencies = [
"proc-macro2",
"quote",
- "syn 3.0.6",
+ "syn 2.0.119",
]
[[package]]
-name = "form_urlencoded"
-version = "1.2.2"
+name = "data-encoding"
+version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
-dependencies = [
- "percent-encoding",
-]
+checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
[[package]]
-name = "half"
-version = "2.7.1"
+name = "data-encoding-macro"
+version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
+checksum = "c6a127ecbb3c4632e1525380e04c0c3fcf8dcb44d32a79ea290d8a36906edcd8"
dependencies = [
- "cfg-if",
- "crunchy",
- "zerocopy",
+ "data-encoding",
+ "data-encoding-macro-internal",
]
[[package]]
-name = "hmac"
-version = "0.13.0"
+name = "data-encoding-macro-internal"
+version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
+checksum = "c54e03a951783e8b327515db3f2a2fd0e3bed362a96b066f341ce66ed49b4ead"
dependencies = [
- "digest",
+ "data-encoding",
+ "syn 3.0.6",
]
[[package]]
-name = "hybrid-array"
-version = "0.4.15"
+name = "der"
+version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
+checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a"
dependencies = [
- "typenum",
+ "const-oid",
+ "pem-rfc7468",
+ "zeroize",
]
[[package]]
-name = "icu_collections"
-version = "2.3.0"
+name = "deranged"
+version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513"
+checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c"
+
+[[package]]
+name = "derive_more"
+version = "2.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d751e9e49156b02b44f9c1815bcb94b984cdcc4396ecc32521c739452808b134"
dependencies = [
- "displaydoc",
- "potential_utf",
- "utf8_iter",
- "yoke",
- "zerofrom",
- "zerovec",
+ "derive_more-impl",
]
[[package]]
-name = "icu_locale_core"
-version = "2.3.0"
+name = "derive_more-impl"
+version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb"
+checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb"
dependencies = [
- "displaydoc",
- "litemap",
- "tinystr",
- "writeable",
- "zerovec",
+ "convert_case",
+ "proc-macro2",
+ "quote",
+ "rustc_version",
+ "syn 2.0.119",
+ "unicode-xid",
]
[[package]]
-name = "icu_normalizer"
-version = "2.3.0"
+name = "diatomic-waker"
+version = "0.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab03c107fafeb3ee9f5925686dbb7a73bc76e3932abb0d2b365cb64b169cf04c"
+
+[[package]]
+name = "digest"
+version = "0.11.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2"
+dependencies = [
+ "block-buffer",
+ "const-oid",
+ "crypto-common 0.2.2",
+ "ctutils",
+]
+
+[[package]]
+name = "dispatch2"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
+dependencies = [
+ "bitflags",
+ "block2",
+ "libc",
+ "objc2",
+]
+
+[[package]]
+name = "displaydoc"
+version = "0.2.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "dlopen2"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5e2c5bd4158e66d1e215c49b837e11d62f3267b30c92f1d171c4d3105e3dc4d4"
+dependencies = [
+ "libc",
+ "once_cell",
+ "winapi",
+]
+
+[[package]]
+name = "ed25519"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29fcf32e6c73d1079f83ab4d782de2d81620346a5f38c6237a86a22f8368980a"
+dependencies = [
+ "pkcs8",
+ "serdect",
+ "signature",
+]
+
+[[package]]
+name = "ed25519-dalek"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ebaa1a2bf1290ab3bfe5a7b771d050ebffab2711c19a81691c683a5144a25de"
+dependencies = [
+ "curve25519-dalek",
+ "ed25519",
+ "rand_core",
+ "serde",
+ "sha2",
+ "signature",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "embedded-io"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced"
+
+[[package]]
+name = "embedded-io"
+version = "0.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
+
+[[package]]
+name = "enum-assoc"
+version = "1.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0590c4a94da3372e83493b956755a6e2266830b6e4e3b101afe66e3f39477b91"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "equivalent"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
+
+[[package]]
+name = "errno"
+version = "0.3.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "fallible-iterator"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649"
+
+[[package]]
+name = "fallible-streaming-iterator"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a"
+
+[[package]]
+name = "fastrand"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
+
+[[package]]
+name = "fiat-crypto"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "64cd1e32ddd350061ae6edb1b082d7c54915b5c672c389143b9a63403a109f24"
+
+[[package]]
+name = "find-msvc-tools"
+version = "0.1.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"
+
+[[package]]
+name = "fnv"
+version = "1.0.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
+
+[[package]]
+name = "foldhash"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
+
+[[package]]
+name = "form_urlencoded"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
+dependencies = [
+ "percent-encoding",
+]
+
+[[package]]
+name = "futures"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-executor",
+ "futures-io",
+ "futures-sink",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-buffered"
+version = "0.2.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4421cb78ee172b6b06080093479d3c50f058e7c81b7d577bbb8d118d551d4cd5"
+dependencies = [
+ "cordyceps",
+ "diatomic-waker",
+ "futures-core",
+ "pin-project-lite",
+ "spin",
+]
+
+[[package]]
+name = "futures-channel"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
+dependencies = [
+ "futures-core",
+ "futures-sink",
+]
+
+[[package]]
+name = "futures-core"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
+
+[[package]]
+name = "futures-executor"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432"
+dependencies = [
+ "futures-core",
+ "futures-task",
+ "futures-util",
+]
+
+[[package]]
+name = "futures-io"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
+
+[[package]]
+name = "futures-lite"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"
+dependencies = [
+ "fastrand",
+ "futures-core",
+ "futures-io",
+ "parking",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "futures-macro"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "futures-sink"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"
+
+[[package]]
+name = "futures-task"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
+
+[[package]]
+name = "futures-util"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "futures-io",
+ "futures-macro",
+ "futures-sink",
+ "futures-task",
+ "memchr",
+ "pin-project-lite",
+ "slab",
+]
+
+[[package]]
+name = "generator"
+version = "0.8.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54ade96dc9003043bce7c035c85a9df5a858bfb2039c5a2e6fdf00f324f6c551"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "libc",
+ "log",
+ "rustversion",
+ "windows-link",
+ "windows-result",
+]
+
+[[package]]
+name = "generic-array"
+version = "0.14.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
+dependencies = [
+ "typenum",
+ "version_check",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "libc",
+ "wasi",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "js-sys",
+ "libc",
+ "r-efi",
+ "rand_core",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "ghash"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1"
+dependencies = [
+ "opaque-debug",
+ "polyval",
+]
+
+[[package]]
+name = "gloo-timers"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994"
+dependencies = [
+ "futures-channel",
+ "futures-core",
+ "js-sys",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "h2"
+version = "0.4.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef8e5e5a340588f4452631496976cf8636d4a7ecf600239fdc27615d2530bc16"
+dependencies = [
+ "atomic-waker",
+ "bytes",
+ "fnv",
+ "futures-core",
+ "futures-sink",
+ "http",
+ "indexmap",
+ "slab",
+ "tokio",
+ "tokio-util",
+ "tracing",
+]
+
+[[package]]
+name = "half"
+version = "2.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
+dependencies = [
+ "cfg-if",
+ "crunchy",
+ "zerocopy",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.16.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
+dependencies = [
+ "foldhash",
+]
+
+[[package]]
+name = "hashbrown"
+version = "0.17.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
+dependencies = [
+ "foldhash",
+]
+
+[[package]]
+name = "hashlink"
+version = "0.12.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a596f1b20ed2cc5ecac41a164aaebc7258057060f06c0cf7a2ba3991ee7990fb"
+dependencies = [
+ "hashbrown 0.17.1",
+]
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "hickory-proto"
+version = "0.26.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "12b92608f679a6fa515dd1d15c1ff89443026e391200a2c840c7afcba482893d"
+dependencies = [
+ "data-encoding",
+ "idna",
+ "ipnet",
+ "jni 0.22.4",
+ "once_cell",
+ "rand",
+ "thiserror 2.0.21",
+ "tinyvec",
+ "tracing",
+ "url",
+]
+
+[[package]]
+name = "hmac"
+version = "0.13.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f"
+dependencies = [
+ "digest",
+]
+
+[[package]]
+name = "http"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0"
+dependencies = [
+ "bytes",
+ "itoa",
+]
+
+[[package]]
+name = "http-body"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c"
+dependencies = [
+ "bytes",
+ "http",
+]
+
+[[package]]
+name = "http-body-util"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "http",
+ "http-body",
+ "pin-project-lite",
+]
+
+[[package]]
+name = "httparse"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"
+
+[[package]]
+name = "httpdate"
+version = "1.0.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
+
+[[package]]
+name = "hybrid-array"
+version = "0.4.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17"
+dependencies = [
+ "typenum",
+]
+
+[[package]]
+name = "hyper"
+version = "1.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27b501faa50e7a26c3d3560ca625132f4078a17771f4810baf70475ae48cbe43"
+dependencies = [
+ "atomic-waker",
+ "bytes",
+ "futures-channel",
+ "futures-core",
+ "h2",
+ "http",
+ "http-body",
+ "httparse",
+ "httpdate",
+ "itoa",
+ "pin-project-lite",
+ "smallvec",
+ "tokio",
+ "want",
+]
+
+[[package]]
+name = "hyper-rustls"
+version = "0.27.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53"
+dependencies = [
+ "http",
+ "hyper",
+ "hyper-util",
+ "rustls",
+ "tokio",
+ "tokio-rustls",
+ "tower-service",
+]
+
+[[package]]
+name = "hyper-util"
+version = "0.1.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff"
+dependencies = [
+ "base64 0.23.1",
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "http",
+ "http-body",
+ "httparse",
+ "hyper",
+ "ipnet",
+ "libc",
+ "percent-encoding",
+ "pin-project-lite",
+ "socket2",
+ "tokio",
+ "tower-service",
+ "tracing",
+]
+
+[[package]]
+name = "iana-time-zone"
+version = "0.1.65"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
+dependencies = [
+ "android_system_properties",
+ "core-foundation-sys",
+ "iana-time-zone-haiku",
+ "js-sys",
+ "log",
+ "wasm-bindgen",
+ "windows-core",
+]
+
+[[package]]
+name = "iana-time-zone-haiku"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
+dependencies = [
+ "cc",
+]
+
+[[package]]
+name = "icu_collections"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513"
+dependencies = [
+ "displaydoc",
+ "potential_utf",
+ "utf8_iter",
+ "yoke",
+ "zerofrom",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_locale_core"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb"
+dependencies = [
+ "displaydoc",
+ "litemap",
+ "tinystr",
+ "writeable",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer"
+version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f"
dependencies = [
- "icu_collections",
- "icu_normalizer_data",
- "icu_properties",
- "icu_provider",
- "smallvec",
- "zerovec",
+ "icu_collections",
+ "icu_normalizer_data",
+ "icu_properties",
+ "icu_provider",
+ "smallvec",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_normalizer_data"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0"
+
+[[package]]
+name = "icu_properties"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148"
+dependencies = [
+ "displaydoc",
+ "icu_collections",
+ "icu_locale_core",
+ "icu_properties_data",
+ "icu_provider",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "icu_properties_data"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa"
+
+[[package]]
+name = "icu_provider"
+version = "2.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73"
+dependencies = [
+ "displaydoc",
+ "icu_locale_core",
+ "writeable",
+ "yoke",
+ "zerofrom",
+ "zerotrie",
+ "zerovec",
+]
+
+[[package]]
+name = "identity-hash"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dfdd7caa900436d8f13b2346fe10257e0c05c1f1f9e351f4f5d57c03bd5f45da"
+
+[[package]]
+name = "idna"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
+dependencies = [
+ "idna_adapter",
+ "smallvec",
+ "utf8_iter",
+]
+
+[[package]]
+name = "idna_adapter"
+version = "1.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
+dependencies = [
+ "icu_normalizer",
+ "icu_properties",
+]
+
+[[package]]
+name = "igd-next"
+version = "0.17.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "de7238d487a9aff61f81b5ab41c0a841532a115a398b5fa92a2fadd0885e2581"
+dependencies = [
+ "attohttpc",
+ "bytes",
+ "futures",
+ "http",
+ "http-body-util",
+ "hyper",
+ "hyper-util",
+ "log",
+ "rand",
+ "tokio",
+ "url",
+ "xmltree",
+]
+
+[[package]]
+name = "indexmap"
+version = "2.14.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
+dependencies = [
+ "equivalent",
+ "hashbrown 0.17.1",
+]
+
+[[package]]
+name = "inout"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01"
+dependencies = [
+ "generic-array",
+]
+
+[[package]]
+name = "ipconfig"
+version = "0.3.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4d40460c0ce33d6ce4b0630ad68ff63d6661961c48b6dba35e5a4d81cfb48222"
+dependencies = [
+ "socket2",
+ "widestring",
+ "windows-registry",
+ "windows-result",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "ipnet"
+version = "2.12.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0"
+
+[[package]]
+name = "iroh"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "885787b892b5e2507c701f132ecbd45d2bad4bbb75157a19427087c16dadb833"
+dependencies = [
+ "backon",
+ "blake3",
+ "bytes",
+ "cfg_aliases",
+ "ctutils",
+ "data-encoding",
+ "derive_more",
+ "ed25519-dalek",
+ "futures-util",
+ "getrandom 0.4.3",
+ "http",
+ "ipnet",
+ "iroh-base",
+ "iroh-dns",
+ "iroh-metrics",
+ "iroh-relay",
+ "n0-error",
+ "n0-future",
+ "n0-watcher",
+ "netwatch",
+ "noq",
+ "noq-proto",
+ "noq-udp",
+ "papaya",
+ "pin-project",
+ "portable-atomic",
+ "portmapper",
+ "rand",
+ "reqwest",
+ "rustc-hash",
+ "rustls",
+ "rustls-pki-types",
+ "serde",
+ "smallvec",
+ "strum",
+ "time",
+ "tokio",
+ "tokio-stream",
+ "tokio-util",
+ "tracing",
+ "url",
+ "wasm-bindgen-futures",
+]
+
+[[package]]
+name = "iroh-base"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ae9092be76c9f5429776ab3394f5a5a78dc19dc2524267e884a5b9781546c3f"
+dependencies = [
+ "curve25519-dalek",
+ "data-encoding",
+ "data-encoding-macro",
+ "derive_more",
+ "ed25519-dalek",
+ "getrandom 0.4.3",
+ "n0-error",
+ "rand",
+ "serde",
+ "url",
+ "zeroize",
+]
+
+[[package]]
+name = "iroh-dns"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80276761b56e904e26ea71d0863beef0bb8d5ab6b639cbd1338e4b615209e3a1"
+dependencies = [
+ "arc-swap",
+ "cfg_aliases",
+ "derive_more",
+ "iroh-base",
+ "n0-dns-resolver",
+ "n0-error",
+ "n0-future",
+ "portable-atomic",
+ "rand",
+ "rustls",
+ "simple-dns",
+ "strum",
+ "tokio",
+ "tracing",
+ "url",
+]
+
+[[package]]
+name = "iroh-mdns-address-lookup"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7afb03c296022fcb724a7bb76dbb8dcca6aac4f4eb65df161e084b7276c93d8c"
+dependencies = [
+ "data-encoding",
+ "derive_more",
+ "futures-util",
+ "iroh",
+ "iroh-base",
+ "n0-error",
+ "n0-future",
+ "n0-watcher",
+ "swarm-discovery",
+ "tokio",
+ "tokio-stream",
+ "tracing",
+]
+
+[[package]]
+name = "iroh-metrics"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ede55536349842337f7cdc63012ec33dc637945f3259c98a0763aac364cdf09"
+dependencies = [
+ "iroh-metrics-derive",
+ "itoa",
+ "n0-error",
+ "portable-atomic",
+ "ryu",
+ "serde",
+ "tracing",
+]
+
+[[package]]
+name = "iroh-metrics-derive"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ae5f0c4405d1fbc9fb16ff422ca40620e93dc36c30ecaba0c2aee3992b7bd48"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "iroh-relay"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee116a8233f84980574bb8d11e4517503080cd2c3605bafca04ee9c35d708bd9"
+dependencies = [
+ "blake3",
+ "bytes",
+ "cfg_aliases",
+ "data-encoding",
+ "derive_more",
+ "getrandom 0.4.3",
+ "http",
+ "http-body-util",
+ "hyper",
+ "hyper-util",
+ "iroh-base",
+ "iroh-dns",
+ "iroh-metrics",
+ "lru",
+ "n0-error",
+ "n0-future",
+ "noq",
+ "noq-proto",
+ "num_enum",
+ "pin-project",
+ "postcard",
+ "rand",
+ "reqwest",
+ "rustls",
+ "rustls-pki-types",
+ "serde",
+ "serde_bytes",
+ "strum",
+ "tokio",
+ "tokio-rustls",
+ "tokio-util",
+ "tokio-websockets",
+ "tracing",
+ "url",
+ "webpki-roots",
+ "ws_stream_wasm",
+]
+
+[[package]]
+name = "itoa"
+version = "1.0.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
+
+[[package]]
+name = "jni"
+version = "0.21.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
+dependencies = [
+ "cesu8",
+ "cfg-if",
+ "combine",
+ "jni-sys 0.3.1",
+ "log",
+ "thiserror 1.0.69",
+ "walkdir",
+ "windows-sys 0.45.0",
+]
+
+[[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.21",
+ "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"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258"
+dependencies = [
+ "jni-sys 0.4.1",
+]
+
+[[package]]
+name = "jni-sys"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2"
+dependencies = [
+ "jni-sys-macros",
+]
+
+[[package]]
+name = "jni-sys-macros"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264"
+dependencies = [
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "js-sys"
+version = "0.3.106"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
+dependencies = [
+ "cfg-if",
+ "futures-util",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "lazy_static"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
+
+[[package]]
+name = "libc"
+version = "0.2.190"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
+
+[[package]]
+name = "libsqlite3-sys"
+version = "0.38.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f1d20bef17f513b9b3004532233187769cd072d790971f4e4da0e346eb6401e8"
+dependencies = [
+ "cc",
+ "pkg-config",
+ "vcpkg",
+]
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+
+[[package]]
+name = "litemap"
+version = "0.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
+
+[[package]]
+name = "lock_api"
+version = "0.4.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
+dependencies = [
+ "scopeguard",
+]
+
+[[package]]
+name = "log"
+version = "0.4.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
+
+[[package]]
+name = "loom"
+version = "0.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca"
+dependencies = [
+ "cfg-if",
+ "generator",
+ "scoped-tls",
+ "tracing",
+ "tracing-subscriber",
+]
+
+[[package]]
+name = "lru"
+version = "0.18.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef9ac18847474e638e3702b76c65d4eb93428471a74778ef0f1be711717f89b5"
+dependencies = [
+ "hashbrown 0.17.1",
+]
+
+[[package]]
+name = "lru-slab"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"
+
+[[package]]
+name = "mac-addr"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d3d25b0e0b648a86960ac23b7ad4abb9717601dec6f66c165f5b037f3f03065f"
+
+[[package]]
+name = "matchers"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9"
+dependencies = [
+ "regex-automata",
+]
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "mio"
+version = "1.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
+dependencies = [
+ "libc",
+ "wasi",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "n0-dns-resolver"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "535c99c9a786bee714155d2ee4fc2477405c2c43536e1bc6a51de09a0d1448f7"
+dependencies = [
+ "derive_more",
+ "ipconfig",
+ "jni 0.22.4",
+ "lru",
+ "n0-error",
+ "n0-future",
+ "ndk-context",
+ "rand",
+ "reqwest",
+ "rustc-hash",
+ "rustls",
+ "simple-dns",
+ "system-configuration",
+ "tokio",
+ "tokio-rustls",
+ "tracing",
+ "webpki-roots",
+]
+
+[[package]]
+name = "n0-error"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26c59ea174675ce6bc196878851e5049e11b8b1f9af3ba87e4d6df8d828bb001"
+dependencies = [
+ "n0-error-macros",
+ "spez",
+]
+
+[[package]]
+name = "n0-error-macros"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4412346410d6616f3668c40e53c298e5320c7b856f7a960e5914e442601be79f"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "n0-future"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2ab99dfb861450e68853d34ae665243a88b8c493d01ba957321a1e9b2312bbe"
+dependencies = [
+ "cfg_aliases",
+ "derive_more",
+ "futures-buffered",
+ "futures-lite",
+ "futures-util",
+ "js-sys",
+ "pin-project",
+ "send_wrapper",
+ "tokio",
+ "tokio-util",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-time",
+]
+
+[[package]]
+name = "n0-watcher"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbc618745ad0b7414b149d0517ad8b5573b2fb4d4e2717add3d2446ce1fdd826"
+dependencies = [
+ "derive_more",
+ "n0-error",
+ "n0-future",
+]
+
+[[package]]
+name = "ndk-context"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
+
+[[package]]
+name = "nectarlink-cli"
+version = "0.0.1"
+dependencies = [
+ "nectarlink-core",
+]
+
+[[package]]
+name = "nectarlink-core"
+version = "0.0.1"
+dependencies = [
+ "iroh",
+ "iroh-mdns-address-lookup",
+ "n0-future",
+ "nectarlink-protocol",
+ "rand",
+ "rusqlite",
+ "serde",
+ "tempfile",
+ "thiserror 2.0.21",
+ "tokio",
+ "tokio-util",
+ "tracing",
+ "tracing-subscriber",
+ "windows",
+]
+
+[[package]]
+name = "nectarlink-protocol"
+version = "0.0.1"
+dependencies = [
+ "ciborium",
+ "data-encoding",
+ "hmac",
+ "serde",
+ "serde_bytes",
+ "sha2",
+ "thiserror 2.0.21",
+ "tokio",
+ "url",
+]
+
+[[package]]
+name = "netdev"
+version = "0.45.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "096c44b66a9b09b99b4dd36b1c295ff3a492039ccecaf55466bd6ddcdba59968"
+dependencies = [
+ "block2",
+ "dispatch2",
+ "dlopen2",
+ "ipnet",
+ "jni 0.21.1",
+ "libc",
+ "mac-addr",
+ "ndk-context",
+ "netlink-packet-core 0.8.2",
+ "netlink-packet-route 0.31.0",
+ "netlink-sys 0.8.8",
+ "objc2",
+ "objc2-core-foundation",
+ "objc2-core-wlan",
+ "objc2-foundation",
+ "objc2-system-configuration",
+ "once_cell",
+ "plist",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "netdev"
+version = "0.46.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3c52c2584961c68f5a6e3356797344061f818c93b8acc9cd6d7e284795e563e"
+dependencies = [
+ "block2",
+ "dispatch2",
+ "dlopen2",
+ "ipnet",
+ "jni 0.21.1",
+ "libc",
+ "mac-addr",
+ "ndk-context",
+ "netlink-packet-core 0.9.0",
+ "netlink-packet-route 0.33.0",
+ "netlink-sys 0.9.0",
+ "objc2-core-foundation",
+ "objc2-system-configuration",
+ "once_cell",
+ "plist",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "netlink-packet-core"
+version = "0.8.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b897d7bd4f0af82e68d40d0344cf37e97f9c97ddf74a098de3e4da05e96ca395"
+dependencies = [
+ "paste",
+]
+
+[[package]]
+name = "netlink-packet-core"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2d6e2daf9a8c2e21302714706860a0e6be02e03d17294ecc66b354ea7d4059dd"
+
+[[package]]
+name = "netlink-packet-route"
+version = "0.31.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e2288fcb784eb3defd5fb16f4c4160d5f477de192eac730f43e1d11c24d9a007"
+dependencies = [
+ "bitflags",
+ "libc",
+ "log",
+ "netlink-packet-core 0.8.2",
+]
+
+[[package]]
+name = "netlink-packet-route"
+version = "0.33.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "59d48ffc8b73a506e1ff0878528c72668f2bfbc3d875b6be890a96be5d0d5576"
+dependencies = [
+ "bitflags",
+ "libc",
+ "log",
+ "netlink-packet-core 0.9.0",
+ "zerocopy",
+]
+
+[[package]]
+name = "netlink-proto"
+version = "0.12.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93af8261786086024cd5e96e0a991dd65ced07bbf7c233a487bbc96b971d5539"
+dependencies = [
+ "bytes",
+ "futures-channel",
+ "futures-util",
+ "log",
+ "netlink-packet-core 0.8.2",
+ "netlink-sys 0.8.8",
+ "thiserror 2.0.21",
+]
+
+[[package]]
+name = "netlink-sys"
+version = "0.8.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd6c30ed10fa69cc491d491b85cc971f6bdeb8e7367b7cde2ee6cc878d583fae"
+dependencies = [
+ "bytes",
+ "futures-util",
+ "libc",
+ "log",
+ "tokio",
+]
+
+[[package]]
+name = "netlink-sys"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c99d38e00b420df49e940fe0826e667c3dad82ac68eb4c2bbf754c1c14a83a10"
+dependencies = [
+ "bytes",
+ "libc",
+ "log",
+]
+
+[[package]]
+name = "netwatch"
+version = "0.19.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "39da9cad5f23aa43401f09497d3b280e51b5feba115d9ffbf38ca35d6ff95e96"
+dependencies = [
+ "atomic-waker",
+ "bytes",
+ "cfg_aliases",
+ "derive_more",
+ "ipnet",
+ "js-sys",
+ "libc",
+ "n0-error",
+ "n0-future",
+ "n0-watcher",
+ "netdev 0.45.1",
+ "netdev 0.46.3",
+ "netlink-packet-core 0.8.2",
+ "netlink-packet-route 0.31.0",
+ "netlink-proto",
+ "netlink-sys 0.8.8",
+ "noq-udp",
+ "objc2-core-foundation",
+ "objc2-system-configuration",
+ "pin-project-lite",
+ "serde",
+ "socket2",
+ "time",
+ "tokio",
+ "tokio-util",
+ "tracing",
+ "web-sys",
+ "windows",
+ "windows-result",
+ "wmi",
+]
+
+[[package]]
+name = "noq"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b78be567e796cfa74bb9bdc4117790af2d505eb887019cf8803244353eb09d89"
+dependencies = [
+ "bytes",
+ "cfg_aliases",
+ "derive_more",
+ "noq-proto",
+ "noq-udp",
+ "pin-project-lite",
+ "rustc-hash",
+ "rustls",
+ "socket2",
+ "thiserror 2.0.21",
+ "tokio",
+ "tokio-stream",
+ "tracing",
+ "web-time",
+]
+
+[[package]]
+name = "noq-proto"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c1e5b6fe668491eca022f745a0a9402585626c73a7b839b3424ace15d6a9c8f"
+dependencies = [
+ "aes-gcm",
+ "bytes",
+ "derive_more",
+ "enum-assoc",
+ "getrandom 0.4.3",
+ "identity-hash",
+ "lru-slab",
+ "rand",
+ "rand_pcg",
+ "ring",
+ "rustc-hash",
+ "rustls",
+ "rustls-pki-types",
+ "slab",
+ "sorted-index-buffer",
+ "thiserror 2.0.21",
+ "tinyvec",
+ "tracing",
+ "web-time",
+]
+
+[[package]]
+name = "noq-udp"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4dc50afea61aff926e150a36c31f06094608848e114a3fe667d76ec233163b1c"
+dependencies = [
+ "cfg_aliases",
+ "libc",
+ "socket2",
+ "tracing",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "nu-ansi-term"
+version = "0.50.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "num-conv"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441"
+
+[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
+name = "num_enum"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26"
+dependencies = [
+ "num_enum_derive",
+ "rustversion",
+]
+
+[[package]]
+name = "num_enum_derive"
+version = "0.7.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8"
+dependencies = [
+ "proc-macro-crate",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "objc2"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f"
+dependencies = [
+ "objc2-encode",
+]
+
+[[package]]
+name = "objc2-core-foundation"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"
+dependencies = [
+ "bitflags",
+ "block2",
+ "dispatch2",
+ "libc",
+ "objc2",
+]
+
+[[package]]
+name = "objc2-core-wlan"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c71e34919aba0d701380d911702455038a8a3587467fe0141d6a71501e7ffe48"
+dependencies = [
+ "bitflags",
+ "objc2",
+ "objc2-core-foundation",
+ "objc2-foundation",
+ "objc2-security",
+ "objc2-security-foundation",
+]
+
+[[package]]
+name = "objc2-encode"
+version = "4.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33"
+
+[[package]]
+name = "objc2-foundation"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272"
+dependencies = [
+ "bitflags",
+ "block2",
+ "libc",
+ "objc2",
+ "objc2-core-foundation",
+]
+
+[[package]]
+name = "objc2-security"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a"
+dependencies = [
+ "bitflags",
+ "objc2",
+ "objc2-core-foundation",
+]
+
+[[package]]
+name = "objc2-security-foundation"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ef76382e9cedd18123099f17638715cc3d81dba3637d4c0d39ab69df2ef345a5"
+dependencies = [
+ "objc2",
+ "objc2-foundation",
+]
+
+[[package]]
+name = "objc2-system-configuration"
+version = "0.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7216bd11cbda54ccabcab84d523dc93b858ec75ecfb3a7d89513fa22464da396"
+dependencies = [
+ "bitflags",
+ "dispatch2",
+ "libc",
+ "objc2",
+ "objc2-core-foundation",
+ "objc2-security",
+]
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+dependencies = [
+ "critical-section",
+ "portable-atomic",
+]
+
+[[package]]
+name = "opaque-debug"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
+
+[[package]]
+name = "openssl-probe"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe"
+
+[[package]]
+name = "papaya"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da2442474a9404698c42509b8967f437249dbc7b50493e83020333d3943ec0ae"
+dependencies = [
+ "equivalent",
+ "seize",
+]
+
+[[package]]
+name = "parking"
+version = "2.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
+
+[[package]]
+name = "parking_lot"
+version = "0.12.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a"
+dependencies = [
+ "lock_api",
+ "parking_lot_core",
+]
+
+[[package]]
+name = "parking_lot_core"
+version = "0.9.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "redox_syscall",
+ "smallvec",
+ "windows-link",
+]
+
+[[package]]
+name = "paste"
+version = "1.0.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
+
+[[package]]
+name = "pem-rfc7468"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9"
+dependencies = [
+ "base64ct",
+]
+
+[[package]]
+name = "percent-encoding"
+version = "2.3.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+
+[[package]]
+name = "pharos"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e9567389417feee6ce15dd6527a8a1ecac205ef62c2932bcf3d9f6fc5b78b414"
+dependencies = [
+ "futures",
+ "rustc_version",
+]
+
+[[package]]
+name = "pin-project"
+version = "1.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924"
+dependencies = [
+ "pin-project-internal",
+]
+
+[[package]]
+name = "pin-project-internal"
+version = "1.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "pin-project-lite"
+version = "0.2.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
+
+[[package]]
+name = "pkcs8"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7"
+dependencies = [
+ "der",
+ "spki",
+]
+
+[[package]]
+name = "pkg-config"
+version = "0.3.34"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
+
+[[package]]
+name = "plist"
+version = "1.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2896bade328c13f7042a297ea5ac5b0951f6cf989dea5f32c2fd98da398195cb"
+dependencies = [
+ "base64 0.23.1",
+ "indexmap",
+ "quick-xml",
+ "serde",
+ "time",
+]
+
+[[package]]
+name = "polyval"
+version = "0.6.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.2.17",
+ "opaque-debug",
+ "universal-hash",
+]
+
+[[package]]
+name = "portable-atomic"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
+dependencies = [
+ "serde",
+]
+
+[[package]]
+name = "portmapper"
+version = "0.19.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ca97242f016e090a25330613bc2382aab65eb22f9149dbe84d8f8e711d49a530"
+dependencies = [
+ "base64 0.22.1",
+ "bytes",
+ "derive_more",
+ "hyper-util",
+ "igd-next",
+ "iroh-metrics",
+ "libc",
+ "n0-error",
+ "n0-future",
+ "netwatch",
+ "num_enum",
+ "rand",
+ "serde",
+ "smallvec",
+ "socket2",
+ "time",
+ "tokio",
+ "tokio-util",
+ "tower-layer",
+ "tracing",
+ "url",
+]
+
+[[package]]
+name = "postcard"
+version = "1.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24"
+dependencies = [
+ "cobs",
+ "embedded-io 0.4.0",
+ "embedded-io 0.6.1",
+ "postcard-derive",
+ "serde",
+]
+
+[[package]]
+name = "postcard-derive"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0232bd009a197ceec9cc881ba46f727fcd8060a2d8d6a9dde7a69030a6fe2bb"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "potential_utf"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"
+dependencies = [
+ "zerovec",
+]
+
+[[package]]
+name = "powerfmt"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
+
+[[package]]
+name = "proc-macro-crate"
+version = "3.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
+dependencies = [
+ "toml_edit",
+]
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quick-xml"
+version = "0.42.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41b1177fdf999d2321d3fb46ff47159d9c1fb9ad66a4879f8c50a0b504615e9b"
+dependencies = [
+ "memchr",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "rand"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"
+dependencies = [
+ "chacha20",
+ "getrandom 0.4.3",
+ "rand_core",
+]
+
+[[package]]
+name = "rand_core"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
+
+[[package]]
+name = "rand_pcg"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a"
+dependencies = [
+ "rand_core",
+]
+
+[[package]]
+name = "redox_syscall"
+version = "0.5.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "regex-automata"
+version = "0.4.18"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
+dependencies = [
+ "aho-corasick",
+ "memchr",
+ "regex-syntax",
+]
+
+[[package]]
+name = "regex-syntax"
+version = "0.8.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
+
+[[package]]
+name = "reqwest"
+version = "0.13.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "16a1cfa75cc186dd73d5818e510e042e40927bccc9c236b061cea97e1eb08029"
+dependencies = [
+ "base64 0.23.1",
+ "bytes",
+ "futures-core",
+ "futures-util",
+ "http",
+ "http-body",
+ "http-body-util",
+ "hyper",
+ "hyper-rustls",
+ "hyper-util",
+ "js-sys",
+ "log",
+ "percent-encoding",
+ "pin-project-lite",
+ "rustls",
+ "rustls-pki-types",
+ "rustls-platform-verifier",
+ "sync_wrapper",
+ "tokio",
+ "tokio-rustls",
+ "tokio-util",
+ "tower",
+ "tower-http",
+ "tower-service",
+ "url",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "wasm-streams",
+ "web-sys",
+]
+
+[[package]]
+name = "ring"
+version = "0.17.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
+dependencies = [
+ "cc",
+ "cfg-if",
+ "getrandom 0.2.17",
+ "libc",
+ "untrusted",
+ "windows-sys 0.52.0",
+]
+
+[[package]]
+name = "rsqlite-vfs"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c51c9ae4df8a7fba42103df5c621fa3c37eccf3a3c650879e90fc48b11cc192c"
+dependencies = [
+ "hashbrown 0.16.1",
+ "thiserror 2.0.21",
+]
+
+[[package]]
+name = "rusqlite"
+version = "0.40.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23f2a97da3e3873c73cb2a2e71b35c40ff95e0b1eefa8d72d8499a6928c3b5b3"
+dependencies = [
+ "bitflags",
+ "fallible-iterator",
+ "fallible-streaming-iterator",
+ "hashlink",
+ "libsqlite3-sys",
+ "smallvec",
+ "sqlite-wasm-rs",
+]
+
+[[package]]
+name = "rustc-hash"
+version = "2.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
+
+[[package]]
+name = "rustc_version"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
+dependencies = [
+ "semver",
+]
+
+[[package]]
+name = "rustix"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "rustls"
+version = "0.23.45"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634"
+dependencies = [
+ "log",
+ "once_cell",
+ "ring",
+ "rustls-pki-types",
+ "rustls-webpki",
+ "subtle",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-native-certs"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d"
+dependencies = [
+ "openssl-probe",
+ "rustls-pki-types",
+ "schannel",
+ "security-framework",
+]
+
+[[package]]
+name = "rustls-pki-types"
+version = "1.15.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"
+dependencies = [
+ "web-time",
+ "zeroize",
+]
+
+[[package]]
+name = "rustls-platform-verifier"
+version = "0.7.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98"
+dependencies = [
+ "core-foundation",
+ "core-foundation-sys",
+ "jni 0.22.4",
+ "log",
+ "once_cell",
+ "rustls",
+ "rustls-native-certs",
+ "rustls-platform-verifier-android",
+ "rustls-webpki",
+ "security-framework",
+ "security-framework-sys",
+ "webpki-root-certs",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "rustls-platform-verifier-android"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eec689c0bc40ff2458a5977b6619cb718087084a18e02a131c599b62d05e1a5f"
+
+[[package]]
+name = "rustls-webpki"
+version = "0.103.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"
+dependencies = [
+ "ring",
+ "rustls-pki-types",
+ "untrusted",
+]
+
+[[package]]
+name = "rustversion"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
+
+[[package]]
+name = "ryu"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
+
+[[package]]
+name = "same-file"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
+dependencies = [
+ "winapi-util",
+]
+
+[[package]]
+name = "schannel"
+version = "0.1.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939"
+dependencies = [
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "scoped-tls"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"
+
+[[package]]
+name = "scopeguard"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
+
+[[package]]
+name = "security-framework"
+version = "3.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"
+dependencies = [
+ "bitflags",
+ "core-foundation",
+ "core-foundation-sys",
+ "libc",
+ "security-framework-sys",
+]
+
+[[package]]
+name = "security-framework-sys"
+version = "2.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "seize"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5b55fb86dfd3a2f5f76ea78310a88f96c4ea21a3031f8d212443d56123fd0521"
+
+[[package]]
+name = "semver"
+version = "1.0.28"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
+
+[[package]]
+name = "send_wrapper"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_bytes"
+version = "0.11.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
+dependencies = [
+ "serde",
+ "serde_core",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "serdect"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e"
+dependencies = [
+ "base16ct",
+ "serde",
+]
+
+[[package]]
+name = "sha1_smol"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d"
+
+[[package]]
+name = "sha2"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
+dependencies = [
+ "cfg-if",
+ "cpufeatures 0.3.1",
+ "digest",
+]
+
+[[package]]
+name = "sharded-slab"
+version = "0.1.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
+dependencies = [
+ "lazy_static",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "signal-hook-registry"
+version = "1.4.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
+dependencies = [
+ "errno",
+ "libc",
+]
+
+[[package]]
+name = "signature"
+version = "3.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5"
+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 = "simple-dns"
+version = "0.12.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2b6f884fa9a8d48101774bfbd3aeb81e968dd22cffd19a372da69f183db22c1a"
+dependencies = [
+ "bitflags",
+]
+
+[[package]]
+name = "slab"
+version = "0.4.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
+
+[[package]]
+name = "smallvec"
+version = "1.16.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
+
+[[package]]
+name = "smol_str"
+version = "0.1.24"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9"
+
+[[package]]
+name = "socket2"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "sorted-index-buffer"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea06cc588e43c632923a55450401b8f25e628131571d4e1baea1bdfdb2b5ed06"
+
+[[package]]
+name = "spez"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c87e960f4dca2788eeb86bbdde8dd246be8948790b7618d656e68f9b720a86e8"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "spin"
+version = "0.10.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3"
+
+[[package]]
+name = "spki"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d9efca8738c78ee9484207732f728b1ef517bbb1833d6fc0879ca898a522f6f"
+dependencies = [
+ "base64ct",
+ "der",
+]
+
+[[package]]
+name = "sqlite-wasm-rs"
+version = "0.5.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc3efc0da82635d7e1ced0053bbbfa8c7ab9645d0bf36ceb4f7127bb85315d75"
+dependencies = [
+ "cc",
+ "js-sys",
+ "rsqlite-vfs",
+ "wasm-bindgen",
+]
+
+[[package]]
+name = "stable_deref_trait"
+version = "1.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
+
+[[package]]
+name = "strum"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9628de9b8791db39ceda2b119bbe13134770b56c138ec1d3af810d045c04f9bd"
+dependencies = [
+ "strum_macros",
+]
+
+[[package]]
+name = "strum_macros"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab85eea0270ee17587ed4156089e10b9e6880ee688791d45a905f5b1ca36f664"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "subtle"
+version = "2.6.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
+
+[[package]]
+name = "swarm-discovery"
+version = "0.6.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b4877f20f064de34b77d79237c9caa37c393590af8ef5a2f3253d59be5a338b"
+dependencies = [
+ "acto",
+ "hickory-proto",
+ "rand",
+ "socket2",
+ "thiserror 2.0.21",
+ "tokio",
+ "tracing",
+]
+
+[[package]]
+name = "syn"
+version = "2.0.119"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "syn"
+version = "3.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "sync_wrapper"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
+dependencies = [
+ "futures-core",
+]
+
+[[package]]
+name = "synstructure"
+version = "0.14.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "system-configuration"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "501336eb7ba9e417300a6a0fa985721065467aa83a6dcf0422a8e43e4c0328fa"
+dependencies = [
+ "bitflags",
+ "core-foundation",
+ "system-configuration-sys",
+]
+
+[[package]]
+name = "system-configuration-sys"
+version = "0.6.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
+dependencies = [
+ "core-foundation-sys",
+ "libc",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
+dependencies = [
+ "fastrand",
+ "getrandom 0.4.3",
+ "once_cell",
+ "rustix",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "thiserror"
+version = "1.0.69"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
+dependencies = [
+ "thiserror-impl 1.0.69",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
+dependencies = [
+ "thiserror-impl 2.0.21",
]
[[package]]
-name = "icu_normalizer_data"
-version = "2.3.0"
+name = "thiserror-impl"
+version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0"
+checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
[[package]]
-name = "icu_properties"
-version = "2.3.0"
+name = "thiserror-impl"
+version = "2.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148"
+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "thread_local"
+version = "1.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
+dependencies = [
+ "cfg-if",
+]
+
+[[package]]
+name = "time"
+version = "0.3.55"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134"
+dependencies = [
+ "deranged",
+ "js-sys",
+ "num-conv",
+ "powerfmt",
+ "serde_core",
+ "time-core",
+ "time-macros",
+]
+
+[[package]]
+name = "time-core"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109"
+
+[[package]]
+name = "time-macros"
+version = "0.2.32"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85"
+dependencies = [
+ "num-conv",
+ "time-core",
+]
+
+[[package]]
+name = "tinystr"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643"
dependencies = [
"displaydoc",
- "icu_collections",
- "icu_locale_core",
- "icu_properties_data",
- "icu_provider",
- "zerotrie",
"zerovec",
]
[[package]]
-name = "icu_properties_data"
-version = "2.3.0"
+name = "tinyvec"
+version = "1.13.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa"
+checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"
+
+[[package]]
+name = "tokio"
+version = "1.53.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044"
+dependencies = [
+ "bytes",
+ "libc",
+ "mio",
+ "pin-project-lite",
+ "signal-hook-registry",
+ "socket2",
+ "tokio-macros",
+ "windows-sys 0.61.2",
+]
+
+[[package]]
+name = "tokio-macros"
+version = "2.7.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+]
+
+[[package]]
+name = "tokio-rustls"
+version = "0.26.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db"
+dependencies = [
+ "rustls",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-stream"
+version = "0.1.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3d06f0b082ba57c26b79407372e57cf2a1e28124f78e9479fe80322cf53420b"
+dependencies = [
+ "futures-core",
+ "pin-project-lite",
+ "tokio",
+ "tokio-util",
+]
+
+[[package]]
+name = "tokio-util"
+version = "0.7.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52"
+dependencies = [
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "futures-util",
+ "libc",
+ "pin-project-lite",
+ "tokio",
+]
+
+[[package]]
+name = "tokio-websockets"
+version = "0.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d52efb639344a7c6adb8e62c6f3d2c19c001ff1b79a5041ba1c6ed42e19c6aa5"
+dependencies = [
+ "base64 0.22.1",
+ "bytes",
+ "futures-core",
+ "futures-sink",
+ "getrandom 0.4.3",
+ "http",
+ "httparse",
+ "rand",
+ "ring",
+ "rustls-pki-types",
+ "sha1_smol",
+ "simdutf8",
+ "tokio",
+ "tokio-rustls",
+ "tokio-util",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "1.1.1+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "toml_edit"
+version = "0.25.15+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1340ea94a5856333492c9064b02c778b191dd2c853778d9609debdcdfea3a614"
+dependencies = [
+ "indexmap",
+ "toml_datetime",
+ "toml_parser",
+ "winnow",
+]
+
+[[package]]
+name = "toml_parser"
+version = "1.1.3+spec-1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56"
+dependencies = [
+ "winnow",
+]
+
+[[package]]
+name = "tower"
+version = "0.5.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4"
+dependencies = [
+ "futures-core",
+ "futures-util",
+ "pin-project-lite",
+ "sync_wrapper",
+ "tokio",
+ "tower-layer",
+ "tower-service",
+]
+
+[[package]]
+name = "tower-http"
+version = "0.6.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840"
+dependencies = [
+ "bitflags",
+ "bytes",
+ "futures-util",
+ "http",
+ "http-body",
+ "pin-project-lite",
+ "tower",
+ "tower-layer",
+ "tower-service",
+ "url",
+]
+
+[[package]]
+name = "tower-layer"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
+
+[[package]]
+name = "tower-service"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"
+
+[[package]]
+name = "tracing"
+version = "0.1.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
+dependencies = [
+ "log",
+ "pin-project-lite",
+ "tracing-attributes",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-attributes"
+version = "0.1.31"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
+[[package]]
+name = "tracing-core"
+version = "0.1.36"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
+dependencies = [
+ "once_cell",
+ "valuable",
+]
+
+[[package]]
+name = "tracing-log"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
+dependencies = [
+ "log",
+ "once_cell",
+ "tracing-core",
+]
+
+[[package]]
+name = "tracing-subscriber"
+version = "0.3.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319"
+dependencies = [
+ "matchers",
+ "nu-ansi-term",
+ "once_cell",
+ "regex-automata",
+ "sharded-slab",
+ "smallvec",
+ "thread_local",
+ "tracing",
+ "tracing-core",
+ "tracing-log",
+]
+
+[[package]]
+name = "try-lock"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
+
+[[package]]
+name = "typenum"
+version = "1.20.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
+
+[[package]]
+name = "unicode-segmentation"
+version = "1.13.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8"
+
+[[package]]
+name = "unicode-xid"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853"
+
+[[package]]
+name = "universal-hash"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea"
+dependencies = [
+ "crypto-common 0.1.7",
+ "subtle",
+]
+
+[[package]]
+name = "untrusted"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
+
+[[package]]
+name = "url"
+version = "2.5.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
+dependencies = [
+ "form_urlencoded",
+ "idna",
+ "percent-encoding",
+ "serde",
+ "serde_derive",
+]
+
+[[package]]
+name = "utf8_iter"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
+
+[[package]]
+name = "valuable"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
+
+[[package]]
+name = "vcpkg"
+version = "0.2.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
+
+[[package]]
+name = "version_check"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
+
+[[package]]
+name = "walkdir"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
+dependencies = [
+ "same-file",
+ "winapi-util",
+]
+
+[[package]]
+name = "want"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"
+dependencies = [
+ "try-lock",
+]
+
+[[package]]
+name = "wasi"
+version = "0.11.1+wasi-snapshot-preview1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
+
+[[package]]
+name = "wasm-bindgen"
+version = "0.2.129"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
+dependencies = [
+ "cfg-if",
+ "once_cell",
+ "rustversion",
+ "wasm-bindgen-macro",
+ "wasm-bindgen-shared",
+]
[[package]]
-name = "icu_provider"
-version = "2.3.1"
+name = "wasm-bindgen-futures"
+version = "0.4.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73"
+checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e"
dependencies = [
- "displaydoc",
- "icu_locale_core",
- "writeable",
- "yoke",
- "zerofrom",
- "zerotrie",
- "zerovec",
+ "js-sys",
+ "tokio",
+ "wasm-bindgen",
]
[[package]]
-name = "idna"
-version = "1.1.0"
+name = "wasm-bindgen-macro"
+version = "0.2.129"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
+checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
dependencies = [
- "idna_adapter",
- "smallvec",
- "utf8_iter",
+ "quote",
+ "wasm-bindgen-macro-support",
]
[[package]]
-name = "idna_adapter"
-version = "1.2.2"
+name = "wasm-bindgen-macro-support"
+version = "0.2.129"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
+checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
dependencies = [
- "icu_normalizer",
- "icu_properties",
+ "bumpalo",
+ "proc-macro2",
+ "quote",
+ "syn 3.0.6",
+ "wasm-bindgen-shared",
]
[[package]]
-name = "libc"
-version = "0.2.190"
+name = "wasm-bindgen-shared"
+version = "0.2.129"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
+checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
+dependencies = [
+ "unicode-ident",
+]
[[package]]
-name = "litemap"
-version = "0.8.3"
+name = "wasm-streams"
+version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
+checksum = "9d1ec4f6517c9e11ae630e200b2b65d193279042e28edd4a2cda233e46670bbb"
+dependencies = [
+ "futures-util",
+ "js-sys",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+]
[[package]]
-name = "nectarlink-cli"
-version = "0.0.1"
+name = "web-sys"
+version = "0.3.106"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4"
dependencies = [
- "nectarlink-core",
+ "js-sys",
+ "wasm-bindgen",
]
[[package]]
-name = "nectarlink-core"
-version = "0.0.1"
+name = "web-time"
+version = "1.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
- "nectarlink-protocol",
+ "js-sys",
+ "wasm-bindgen",
]
[[package]]
-name = "nectarlink-protocol"
-version = "0.0.1"
+name = "webpki-root-certs"
+version = "1.0.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b96554aa2acc8ccdb7e1c9a58a7a68dd5d13bccc69cd124cb09406db612a1c9b"
dependencies = [
- "ciborium",
- "data-encoding",
- "hmac",
- "serde",
- "serde_bytes",
- "sha2",
- "thiserror",
- "tokio",
- "url",
+ "rustls-pki-types",
]
[[package]]
-name = "percent-encoding"
-version = "2.3.2"
+name = "webpki-roots"
+version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
+checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"
+dependencies = [
+ "rustls-pki-types",
+]
[[package]]
-name = "pin-project-lite"
-version = "0.2.17"
+name = "widestring"
+version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
+checksum = "72069c3113ab32ab29e5584db3c6ec55d416895e60715417b5b883a357c3e471"
[[package]]
-name = "potential_utf"
-version = "0.1.6"
+name = "winapi"
+version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"
+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
- "zerovec",
+ "winapi-i686-pc-windows-gnu",
+ "winapi-x86_64-pc-windows-gnu",
]
[[package]]
-name = "proc-macro2"
-version = "1.0.107"
+name = "winapi-i686-pc-windows-gnu"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
+
+[[package]]
+name = "winapi-util"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
- "unicode-ident",
+ "windows-sys 0.61.2",
]
[[package]]
-name = "quote"
-version = "1.0.47"
+name = "winapi-x86_64-pc-windows-gnu"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+
+[[package]]
+name = "windows"
+version = "0.62.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"
dependencies = [
- "proc-macro2",
+ "windows-collections",
+ "windows-core",
+ "windows-future",
+ "windows-numerics",
]
[[package]]
-name = "serde"
-version = "1.0.229"
+name = "windows-collections"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610"
dependencies = [
- "serde_core",
- "serde_derive",
+ "windows-core",
]
[[package]]
-name = "serde_bytes"
-version = "0.11.19"
+name = "windows-core"
+version = "0.62.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a5d440709e79d88e51ac01c4b72fc6cb7314017bb7da9eeff678aa94c10e3ea8"
+checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb"
dependencies = [
- "serde",
- "serde_core",
+ "windows-implement",
+ "windows-interface",
+ "windows-link",
+ "windows-result",
+ "windows-strings",
]
[[package]]
-name = "serde_core"
-version = "1.0.229"
+name = "windows-future"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"
dependencies = [
- "serde_derive",
+ "windows-core",
+ "windows-link",
+ "windows-threading",
]
[[package]]
-name = "serde_derive"
-version = "1.0.229"
+name = "windows-implement"
+version = "0.60.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf"
dependencies = [
"proc-macro2",
"quote",
- "syn 3.0.6",
+ "syn 2.0.119",
]
[[package]]
-name = "sha2"
-version = "0.11.0"
+name = "windows-interface"
+version = "0.59.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
+checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358"
dependencies = [
- "cfg-if",
- "cpufeatures",
- "digest",
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
]
[[package]]
-name = "smallvec"
-version = "1.16.2"
+name = "windows-link"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
[[package]]
-name = "stable_deref_trait"
-version = "1.2.1"
+name = "windows-numerics"
+version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
+checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26"
+dependencies = [
+ "windows-core",
+ "windows-link",
+]
[[package]]
-name = "syn"
-version = "2.0.119"
+name = "windows-registry"
+version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
+checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720"
dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
+ "windows-link",
+ "windows-result",
+ "windows-strings",
]
[[package]]
-name = "syn"
-version = "3.0.6"
+name = "windows-result"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"
dependencies = [
- "proc-macro2",
- "quote",
- "unicode-ident",
+ "windows-link",
]
[[package]]
-name = "synstructure"
-version = "0.14.0"
+name = "windows-strings"
+version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"
dependencies = [
- "proc-macro2",
- "quote",
- "syn 3.0.6",
+ "windows-link",
]
[[package]]
-name = "thiserror"
-version = "2.0.21"
+name = "windows-sys"
+version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
+checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
- "thiserror-impl",
+ "windows-targets 0.42.2",
]
[[package]]
-name = "thiserror-impl"
-version = "2.0.21"
+name = "windows-sys"
+version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
- "proc-macro2",
- "quote",
- "syn 3.0.6",
+ "windows-targets 0.52.6",
]
[[package]]
-name = "tinystr"
-version = "0.8.4"
+name = "windows-sys"
+version = "0.61.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
dependencies = [
- "displaydoc",
- "zerovec",
+ "windows-link",
]
[[package]]
-name = "tokio"
-version = "1.53.2"
+name = "windows-targets"
+version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044"
+checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
dependencies = [
- "bytes",
- "pin-project-lite",
- "tokio-macros",
+ "windows_aarch64_gnullvm 0.42.2",
+ "windows_aarch64_msvc 0.42.2",
+ "windows_i686_gnu 0.42.2",
+ "windows_i686_msvc 0.42.2",
+ "windows_x86_64_gnu 0.42.2",
+ "windows_x86_64_gnullvm 0.42.2",
+ "windows_x86_64_msvc 0.42.2",
]
[[package]]
-name = "tokio-macros"
-version = "2.7.2"
+name = "windows-targets"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
- "proc-macro2",
- "quote",
- "syn 3.0.6",
+ "windows_aarch64_gnullvm 0.52.6",
+ "windows_aarch64_msvc 0.52.6",
+ "windows_i686_gnu 0.52.6",
+ "windows_i686_gnullvm",
+ "windows_i686_msvc 0.52.6",
+ "windows_x86_64_gnu 0.52.6",
+ "windows_x86_64_gnullvm 0.52.6",
+ "windows_x86_64_msvc 0.52.6",
]
[[package]]
-name = "typenum"
-version = "1.20.1"
+name = "windows-threading"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
+checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"
+dependencies = [
+ "windows-link",
+]
[[package]]
-name = "unicode-ident"
-version = "1.0.26"
+name = "windows_aarch64_gnullvm"
+version = "0.42.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
[[package]]
-name = "url"
-version = "2.5.8"
+name = "windows_aarch64_gnullvm"
+version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
+
+[[package]]
+name = "windows_aarch64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
+
+[[package]]
+name = "windows_i686_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
+
+[[package]]
+name = "windows_i686_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
+
+[[package]]
+name = "windows_i686_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
+
+[[package]]
+name = "windows_x86_64_gnu"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
+
+[[package]]
+name = "windows_x86_64_gnullvm"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
+
+[[package]]
+name = "windows_x86_64_msvc"
+version = "0.52.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
+
+[[package]]
+name = "winnow"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81"
dependencies = [
- "form_urlencoded",
- "idna",
- "percent-encoding",
- "serde",
+ "memchr",
]
[[package]]
-name = "utf8_iter"
-version = "1.0.4"
+name = "wmi"
+version = "0.18.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
+checksum = "7c81b85c57a57500e56669586496bf2abd5cf082b9d32995251185d105208b64"
+dependencies = [
+ "chrono",
+ "futures",
+ "log",
+ "serde",
+ "thiserror 2.0.21",
+ "windows",
+ "windows-core",
+]
[[package]]
name = "writeable"
@@ -530,6 +3943,40 @@ version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"
+[[package]]
+name = "ws_stream_wasm"
+version = "0.7.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6c173014acad22e83f16403ee360115b38846fe754e735c5d9d3803fe70c6abc"
+dependencies = [
+ "async_io_stream",
+ "futures",
+ "js-sys",
+ "log",
+ "pharos",
+ "rustc_version",
+ "send_wrapper",
+ "thiserror 2.0.21",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+]
+
+[[package]]
+name = "xml-rs"
+version = "0.8.29"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7"
+
+[[package]]
+name = "xmltree"
+version = "0.10.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb"
+dependencies = [
+ "xml-rs",
+]
+
[[package]]
name = "yoke"
version = "0.8.3"
@@ -594,6 +4041,26 @@ dependencies = [
"synstructure",
]
+[[package]]
+name = "zeroize"
+version = "1.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"
+dependencies = [
+ "zeroize_derive",
+]
+
+[[package]]
+name = "zeroize_derive"
+version = "1.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3c50655cbb0fe3fc43170059e702f1ce5e19b84cec58dc87b037a09935c2f328"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.119",
+]
+
[[package]]
name = "zerotrie"
version = "0.2.5"
diff --git a/Cargo.toml b/Cargo.toml
index 2aa8ba1..fd791bd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,6 +23,8 @@ clap = { version = "4.6", features = ["derive"] }
data-encoding = "2.11"
hmac = "0.13"
iroh = "1.3"
+iroh-mdns-address-lookup = "0.6"
+n0-future = "0.3"
rand = "0.10"
rusqlite = { version = "0.40", features = ["bundled"] }
serde = { version = "1", features = ["derive"] }
@@ -30,10 +32,12 @@ serde_bytes = "0.11"
sha2 = "0.11"
tempfile = "3"
thiserror = "2"
+tokio-util = "0.7"
tokio = { version = "1.53", features = ["rt-multi-thread", "macros", "io-util", "sync", "time", "fs"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
url = "2.5"
+windows = "0.62"
[workspace.lints.rust]
unsafe_code = "deny"
diff --git a/core/nectarlink-core/Cargo.toml b/core/nectarlink-core/Cargo.toml
index 2868acd..03fc9fc 100644
--- a/core/nectarlink-core/Cargo.toml
+++ b/core/nectarlink-core/Cargo.toml
@@ -10,6 +10,23 @@ repository.workspace = true
[dependencies]
nectarlink-protocol.workspace = true
+iroh.workspace = true
+iroh-mdns-address-lookup.workspace = true
+n0-future.workspace = true
+rand.workspace = true
+rusqlite.workspace = true
+serde.workspace = true
+thiserror.workspace = true
+tokio.workspace = true
+tokio-util.workspace = true
+tracing.workspace = true
+
+[target.'cfg(windows)'.dependencies]
+windows = { workspace = true, features = ["Win32_Foundation", "Win32_Security_Cryptography"] }
+
+[dev-dependencies]
+tempfile.workspace = true
+tracing-subscriber.workspace = true
[lints]
workspace = true
diff --git a/core/nectarlink-core/src/config.rs b/core/nectarlink-core/src/config.rs
new file mode 100644
index 0000000..4120a43
--- /dev/null
+++ b/core/nectarlink-core/src/config.rs
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: MPL-2.0
+use std::{fmt, path::PathBuf};
+
+use nectarlink_protocol::messages::{DeviceInfo, PowerLevel};
+
+use crate::identity::KeyProtector;
+
+/// Configuration for starting a [`Node`](crate::Node).
+#[derive(Clone)]
+pub struct NodeConfig {
+ /// Directory for the device key, trust store and caches.
+ pub data_dir: PathBuf,
+ /// This device's description, sent to peers.
+ pub device: DeviceInfo,
+ /// The app version, e.g. "0.1.0".
+ pub app_version: String,
+ /// This device's power level (phones) or [`PowerLevel::NotApplicable`].
+ pub power: PowerLevel,
+ /// Allow connections through relay servers ("Reach my phone away from
+ /// home"). Off by default: LAN only.
+ pub away_mode: bool,
+ /// Discover and announce on the local network via mDNS.
+ pub lan_discovery: bool,
+ /// Fixed UDP port to listen on (0 = any). A fixed port makes firewall
+ /// rules simpler on the desktop.
+ pub port: u16,
+ /// How the device key is protected at rest. `None` uses the platform
+ /// default (DPAPI on Windows).
+ pub key_protector: Option<std::sync::Arc<dyn KeyProtector>>,
+}
+
+impl NodeConfig {
+ pub fn new(data_dir: impl Into<PathBuf>, device: DeviceInfo, app_version: impl Into<String>) -> Self {
+ NodeConfig {
+ data_dir: data_dir.into(),
+ device,
+ app_version: app_version.into(),
+ power: PowerLevel::NotApplicable,
+ away_mode: false,
+ lan_discovery: true,
+ port: 0,
+ key_protector: None,
+ }
+ }
+}
+
+impl fmt::Debug for NodeConfig {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ f.debug_struct("NodeConfig")
+ .field("data_dir", &self.data_dir)
+ .field("device", &self.device)
+ .field("app_version", &self.app_version)
+ .field("power", &self.power)
+ .field("away_mode", &self.away_mode)
+ .field("lan_discovery", &self.lan_discovery)
+ .field("port", &self.port)
+ .finish_non_exhaustive()
+ }
+}
+
+/// Platform services the app provides to the core.
+///
+/// Implemented by each app (Windows, Android). Calls may come from any
+/// thread and must not block for long.
+pub trait Platform: Send + Sync + 'static {
+ /// Start ringing loudly (find my device), even on silent.
+ fn start_ringing(&self) {}
+ /// Stop ringing.
+ fn stop_ringing(&self) {}
+}
+
+/// A platform that does nothing; useful for tests and headless tools.
+#[derive(Debug, Default, Clone, Copy)]
+pub struct NoopPlatform;
+
+impl Platform for NoopPlatform {}
diff --git a/core/nectarlink-core/src/error.rs b/core/nectarlink-core/src/error.rs
new file mode 100644
index 0000000..4af5424
--- /dev/null
+++ b/core/nectarlink-core/src/error.rs
@@ -0,0 +1,73 @@
+// SPDX-License-Identifier: MPL-2.0
+use nectarlink_protocol::{ErrorCode, ProtocolError, pairing::PairingUriError};
+
+/// Which side of a connection an issue is on.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Side {
+ Local,
+ Remote,
+}
+
+/// Errors returned by the core. Variants are chosen so the UI can act on
+/// them; details are for logs and never contain personal content.
+#[derive(Debug, thiserror::Error)]
+pub enum Error {
+ #[error("device is not paired")]
+ NotPaired,
+ #[error("device is offline")]
+ Offline,
+ #[error("the operation was denied")]
+ Denied,
+ #[error("declined on this device")]
+ Declined,
+ #[error("the operation timed out")]
+ Timeout,
+ #[error("the {side:?} app is too old for this connection")]
+ VersionTooOld { side: Side },
+ #[error("not supported by the other device")]
+ Unsupported,
+ #[error("no pairing in progress")]
+ NotPairing,
+ #[error("invalid pairing link: {0}")]
+ InvalidPairingLink(#[from] PairingUriError),
+ #[error("protocol error: {0}")]
+ Protocol(String),
+ #[error("network error: {0}")]
+ Network(String),
+ #[error("storage error: {0}")]
+ Storage(String),
+ #[error("i/o error: {0}")]
+ Io(#[from] std::io::Error),
+ #[error("internal error: {0}")]
+ Internal(String),
+}
+
+pub type Result<T, E = Error> = std::result::Result<T, E>;
+
+impl From<ProtocolError> for Error {
+ fn from(err: ProtocolError) -> Self {
+ match err {
+ ProtocolError::Remote { code, msg } => match code {
+ ErrorCode::Denied => Error::Denied,
+ ErrorCode::Unpaired => Error::NotPaired,
+ ErrorCode::Unsupported => Error::Unsupported,
+ ErrorCode::VersionTooOld => Error::VersionTooOld { side: Side::Local },
+ other => Error::Protocol(format!("{other}: {msg}")),
+ },
+ ProtocolError::Io(e) => Error::Network(e.to_string()),
+ ProtocolError::Closed => Error::Offline,
+ other => Error::Protocol(other.to_string()),
+ }
+ }
+}
+
+impl From<rusqlite::Error> for Error {
+ fn from(err: rusqlite::Error) -> Self {
+ Error::Storage(err.to_string())
+ }
+}
+
+/// Converts any network-layer error into [`Error::Network`].
+pub(crate) fn net(err: impl std::fmt::Display) -> Error {
+ Error::Network(err.to_string())
+}
diff --git a/core/nectarlink-core/src/events.rs b/core/nectarlink-core/src/events.rs
new file mode 100644
index 0000000..b0b9b37
--- /dev/null
+++ b/core/nectarlink-core/src/events.rs
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: MPL-2.0
+//! Events the core pushes to the UI. UIs render from these; they never poll.
+
+use nectarlink_protocol::{
+ DeviceId,
+ messages::{Battery, DeviceInfo, PowerLevel},
+};
+
+/// How a session is currently carried.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum ConnectionPath {
+ /// A direct connection on the local network.
+ Lan,
+ /// Through a relay server (away mode).
+ Relay,
+}
+
+/// Connection state of a paired device.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum LinkState {
+ Offline { last_seen: Option<i64> },
+ Connecting,
+ Online { path: ConnectionPath, rtt_ms: u32 },
+}
+
+/// A device this device is paired with.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct PairedDevice {
+ pub id: DeviceId,
+ pub info: DeviceInfo,
+ /// Unix seconds.
+ pub paired_at: i64,
+ pub link: LinkState,
+}
+
+/// A device found on the local network that could be paired with.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct DiscoveredDevice {
+ pub id: DeviceId,
+ /// The name it announces, if any.
+ pub name: Option<String>,
+}
+
+/// Why pairing failed.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum PairingFailure {
+ /// The pairing code, proof or confirmation didn't match.
+ Rejected,
+ /// The user (on either device) declined.
+ Declined,
+ /// Pairing mode expired before anyone connected.
+ Expired,
+ /// The other device couldn't be reached.
+ Unreachable,
+ /// Anything else; the string is for logs.
+ Other(String),
+}
+
+/// Progress of a pairing ceremony.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum PairingEvent {
+ /// Show this 6-digit code and ask the user to confirm it matches.
+ SasCode {
+ peer: DeviceId,
+ code: String,
+ },
+ Paired(PairedDevice),
+ Failed(PairingFailure),
+}
+
+/// Everything the UI needs to know about.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub enum NodeEvent {
+ DeviceAdded(PairedDevice),
+ DeviceRemoved(DeviceId),
+ LinkChanged { device: DeviceId, link: LinkState },
+ PeerInfoChanged { device: DeviceId, info: DeviceInfo },
+ PeerPowerChanged { device: DeviceId, power: PowerLevel },
+ Battery { device: DeviceId, battery: Battery },
+ Ring { device: DeviceId, on: bool },
+ Discovered(DiscoveredDevice),
+ DiscoveryExpired(DeviceId),
+ Pairing(PairingEvent),
+}
diff --git a/core/nectarlink-core/src/identity.rs b/core/nectarlink-core/src/identity.rs
new file mode 100644
index 0000000..dcb658d
--- /dev/null
+++ b/core/nectarlink-core/src/identity.rs
@@ -0,0 +1,238 @@
+// SPDX-License-Identifier: MPL-2.0
+//! The device key: created on first launch, stored encrypted at rest.
+
+use std::{
+ fs,
+ io::{self, Write},
+ path::Path,
+ sync::Arc,
+};
+
+use iroh::SecretKey;
+
+use crate::{Error, Result};
+
+const FILE_NAME: &str = "identity.key";
+const MAGIC: &[u8; 4] = b"NLK1";
+
+/// Protects the device key at rest. Each platform provides one: DPAPI on
+/// Windows, Android Keystore wrapping on Android (injected by the app).
+pub trait KeyProtector: Send + Sync {
+ /// A stable one-byte identifier written into the key file.
+ fn id(&self) -> u8;
+ fn protect(&self, plaintext: &[u8]) -> io::Result<Vec<u8>>;
+ fn unprotect(&self, ciphertext: &[u8]) -> io::Result<Vec<u8>>;
+}
+
+/// No protection. Only used where no platform protector exists (tests,
+/// headless tools); a warning is logged when it is used for a real key.
+#[derive(Debug, Default, Clone, Copy)]
+pub struct PlainKeyProtector;
+
+impl KeyProtector for PlainKeyProtector {
+ fn id(&self) -> u8 {
+ 0
+ }
+ fn protect(&self, plaintext: &[u8]) -> io::Result<Vec<u8>> {
+ Ok(plaintext.to_vec())
+ }
+ fn unprotect(&self, ciphertext: &[u8]) -> io::Result<Vec<u8>> {
+ Ok(ciphertext.to_vec())
+ }
+}
+
+/// The best protector available on this platform.
+pub fn default_protector() -> Arc<dyn KeyProtector> {
+ #[cfg(windows)]
+ {
+ Arc::new(dpapi::DpapiKeyProtector)
+ }
+ #[cfg(not(windows))]
+ {
+ Arc::new(PlainKeyProtector)
+ }
+}
+
+/// Loads the device key from `dir`, creating and saving a new one on first
+/// launch.
+pub(crate) fn load_or_create(dir: &Path, protector: &dyn KeyProtector) -> Result<SecretKey> {
+ let path = dir.join(FILE_NAME);
+ match fs::read(&path) {
+ Ok(bytes) => decode(&bytes, protector),
+ Err(e) if e.kind() == io::ErrorKind::NotFound => {
+ let key = SecretKey::generate();
+ if protector.id() == 0 {
+ tracing::warn!("device key is stored without platform protection");
+ }
+ write_atomically(&path, &encode(&key, protector)?)?;
+ tracing::info!(device = %crate::device_id(&key.public()).short(), "created device identity");
+ Ok(key)
+ }
+ Err(e) => Err(e.into()),
+ }
+}
+
+fn encode(key: &SecretKey, protector: &dyn KeyProtector) -> Result<Vec<u8>> {
+ let sealed = protector.protect(&key.to_bytes())?;
+ let mut out = Vec::with_capacity(MAGIC.len() + 1 + sealed.len());
+ out.extend_from_slice(MAGIC);
+ out.push(protector.id());
+ out.extend_from_slice(&sealed);
+ Ok(out)
+}
+
+fn decode(bytes: &[u8], protector: &dyn KeyProtector) -> Result<SecretKey> {
+ let corrupt = || Error::Storage("the device key file is corrupt".into());
+ let rest = bytes.strip_prefix(MAGIC.as_slice()).ok_or_else(corrupt)?;
+ let (&method, sealed) = rest.split_first().ok_or_else(corrupt)?;
+ if method != protector.id() {
+ return Err(Error::Storage(format!(
+ "the device key is protected with method {method}, but this build uses {}",
+ protector.id()
+ )));
+ }
+ let plain =
+ protector.unprotect(sealed).map_err(|e| Error::Storage(format!("cannot unlock device key: {e}")))?;
+ let bytes: [u8; 32] = plain.as_slice().try_into().map_err(|_| corrupt())?;
+ Ok(SecretKey::from_bytes(&bytes))
+}
+
+/// Writes via a temporary file and rename, so a crash never leaves a
+/// half-written key behind.
+fn write_atomically(path: &Path, data: &[u8]) -> io::Result<()> {
+ let tmp = path.with_extension("tmp");
+ {
+ let mut file = fs::File::create(&tmp)?;
+ file.write_all(data)?;
+ file.sync_all()?;
+ }
+ fs::rename(&tmp, path)
+}
+
+#[cfg(windows)]
+#[allow(unsafe_code)]
+mod dpapi {
+ //! Windows Data Protection API: encrypts with a key tied to the current
+ //! Windows user account.
+
+ use std::{io, ptr, slice};
+
+ use windows::Win32::{
+ Foundation::{HLOCAL, LocalFree},
+ Security::Cryptography::{
+ CRYPT_INTEGER_BLOB, CRYPTPROTECT_UI_FORBIDDEN, CryptProtectData, CryptUnprotectData,
+ },
+ };
+
+ use super::KeyProtector;
+
+ /// Extra entropy so other apps of the same user can't trivially decrypt
+ /// our blob with a bare `CryptUnprotectData` call.
+ const ENTROPY: &[u8] = b"nectarlink/identity/v1";
+
+ #[derive(Debug, Default, Clone, Copy)]
+ pub struct DpapiKeyProtector;
+
+ fn blob(data: &[u8]) -> CRYPT_INTEGER_BLOB {
+ CRYPT_INTEGER_BLOB { cbData: data.len() as u32, pbData: data.as_ptr() as *mut u8 }
+ }
+
+ /// Copies a DPAPI output blob into a Vec and frees the original.
+ ///
+ /// # Safety
+ /// `out` must have been filled by a successful DPAPI call.
+ unsafe fn take(out: CRYPT_INTEGER_BLOB) -> Vec<u8> {
+ // SAFETY: DPAPI returns a valid buffer of `cbData` bytes allocated with LocalAlloc.
+ let data = unsafe { slice::from_raw_parts(out.pbData, out.cbData as usize) }.to_vec();
+ // SAFETY: the buffer was allocated by DPAPI with LocalAlloc and is freed exactly once.
+ unsafe { LocalFree(Some(HLOCAL(out.pbData.cast()))) };
+ data
+ }
+
+ impl KeyProtector for DpapiKeyProtector {
+ fn id(&self) -> u8 {
+ 1
+ }
+
+ fn protect(&self, plaintext: &[u8]) -> io::Result<Vec<u8>> {
+ let input = blob(plaintext);
+ let entropy = blob(ENTROPY);
+ let mut out = CRYPT_INTEGER_BLOB { cbData: 0, pbData: ptr::null_mut() };
+ // SAFETY: all pointers reference live buffers for the duration of the call.
+ unsafe {
+ CryptProtectData(
+ &input,
+ windows::core::w!("Nectarlink device key"),
+ Some(&entropy),
+ None,
+ None,
+ CRYPTPROTECT_UI_FORBIDDEN,
+ &mut out,
+ )
+ }
+ .map_err(io::Error::other)?;
+ // SAFETY: the call succeeded, so `out` holds a DPAPI-allocated buffer.
+ Ok(unsafe { take(out) })
+ }
+
+ fn unprotect(&self, ciphertext: &[u8]) -> io::Result<Vec<u8>> {
+ let input = blob(ciphertext);
+ let entropy = blob(ENTROPY);
+ let mut out = CRYPT_INTEGER_BLOB { cbData: 0, pbData: ptr::null_mut() };
+ // SAFETY: all pointers reference live buffers for the duration of the call.
+ unsafe {
+ CryptUnprotectData(
+ &input,
+ None,
+ Some(&entropy),
+ None,
+ None,
+ CRYPTPROTECT_UI_FORBIDDEN,
+ &mut out,
+ )
+ }
+ .map_err(io::Error::other)?;
+ // SAFETY: the call succeeded, so `out` holds a DPAPI-allocated buffer.
+ Ok(unsafe { take(out) })
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn creates_then_reloads_the_same_key() {
+ let dir = tempfile::tempdir().unwrap();
+ let protector = default_protector();
+ let first = load_or_create(dir.path(), protector.as_ref()).unwrap();
+ let second = load_or_create(dir.path(), protector.as_ref()).unwrap();
+ assert_eq!(first.public(), second.public());
+ }
+
+ #[test]
+ fn key_file_does_not_contain_the_plain_key_when_protected() {
+ let dir = tempfile::tempdir().unwrap();
+ let protector = default_protector();
+ let key = load_or_create(dir.path(), protector.as_ref()).unwrap();
+ let file = fs::read(dir.path().join(FILE_NAME)).unwrap();
+ if protector.id() != 0 {
+ let raw = key.to_bytes();
+ assert!(!file.windows(raw.len()).any(|w| w == raw), "plaintext key found on disk");
+ }
+ }
+
+ #[test]
+ fn rejects_corrupt_and_mismatched_files() {
+ let dir = tempfile::tempdir().unwrap();
+ fs::write(dir.path().join(FILE_NAME), b"garbage").unwrap();
+ assert!(matches!(load_or_create(dir.path(), &PlainKeyProtector), Err(Error::Storage(_))));
+
+ let mut wrong_method = MAGIC.to_vec();
+ wrong_method.push(42);
+ wrong_method.extend_from_slice(&[0; 32]);
+ fs::write(dir.path().join(FILE_NAME), wrong_method).unwrap();
+ assert!(matches!(load_or_create(dir.path(), &PlainKeyProtector), Err(Error::Storage(_))));
+ }
+}
diff --git a/core/nectarlink-core/src/lib.rs b/core/nectarlink-core/src/lib.rs
index f3d2e70..969f4ba 100644
--- a/core/nectarlink-core/src/lib.rs
+++ b/core/nectarlink-core/src/lib.rs
@@ -1,2 +1,44 @@
// SPDX-License-Identifier: MPL-2.0
-//! Nectarlink engine (work in progress).
+//! The Nectarlink engine: device identity, pairing, sessions with paired
+//! devices, and storage. Shared by the Windows and Android apps.
+//!
+//! The entry point is [`Node`]. Commands are async methods; everything that
+//! changes is reported as a [`NodeEvent`]. See
+//! `docs/architecture/core-api.md` for the design.
+
+mod config;
+mod error;
+mod events;
+mod identity;
+mod node;
+mod pairing;
+mod session;
+mod store;
+
+pub use config::{NodeConfig, NoopPlatform, Platform};
+pub use error::{Error, Result, Side};
+pub use events::{
+ ConnectionPath, DiscoveredDevice, LinkState, NodeEvent, PairedDevice, PairingEvent, PairingFailure,
+};
+pub use identity::{KeyProtector, PlainKeyProtector, default_protector};
+pub use nectarlink_protocol::{
+ DeviceId,
+ messages::{Battery, DeviceInfo, DeviceKind, PowerLevel},
+ pairing::PairingUri,
+};
+pub use node::Node;
+
+pub(crate) fn device_id(key: &iroh::PublicKey) -> DeviceId {
+ DeviceId(*key.as_bytes())
+}
+
+pub(crate) fn public_key(id: &DeviceId) -> Result<iroh::PublicKey> {
+ iroh::PublicKey::from_bytes(id.as_bytes()).map_err(|_| Error::Protocol("invalid device ID".into()))
+}
+
+pub(crate) fn now_unix() -> i64 {
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .map(|d| d.as_secs() as i64)
+ .unwrap_or_default()
+}
diff --git a/core/nectarlink-core/src/node.rs b/core/nectarlink-core/src/node.rs
new file mode 100644
index 0000000..761666b
--- /dev/null
+++ b/core/nectarlink-core/src/node.rs
@@ -0,0 +1,715 @@
+// SPDX-License-Identifier: MPL-2.0
+//! [`Node`]: the core's entry point. Owns the network endpoint, the trust
+//! store, live sessions and one reconnect supervisor per paired device.
+
+use std::{
+ collections::HashMap,
+ net::SocketAddr,
+ sync::{Arc, Mutex, RwLock, Weak},
+ time::Duration,
+};
+
+use iroh::{
+ Endpoint, EndpointAddr, RelayMode,
+ address_lookup::{DnsAddressLookup, MemoryLookup, PkarrPublisher, PkarrResolver},
+ endpoint::{Connection, VarInt, presets},
+ endpoint_info::{EndpointInfo, UserData},
+ protocol::{AcceptError, ProtocolHandler, Router},
+};
+use iroh_mdns_address_lookup::{DiscoveryEvent, MdnsAddressLookup};
+use nectarlink_protocol::{
+ ALPN_PAIR, ALPN_SESSION, DeviceId, Envelope, ErrorCode,
+ messages::{Battery, DeviceInfo, HelloUpdate, PowerLevel, Ring, types},
+ pairing::PairingUri,
+};
+use tokio::sync::{Notify, broadcast};
+use tokio_util::sync::CancellationToken;
+
+use crate::{
+ Error, NodeConfig, Platform, Result,
+ events::{DiscoveredDevice, LinkState, NodeEvent, PairedDevice, PairingEvent},
+ identity,
+ pairing::{self, PairingState},
+ session::{self, CLOSE_DUPLICATE, CLOSE_NORMAL, REQUEST_TIMEOUT, Session},
+ store::Store,
+};
+
+const DIAL_TIMEOUT: Duration = Duration::from_secs(15);
+const BACKOFF_MIN: Duration = Duration::from_secs(1);
+const BACKOFF_MAX: Duration = Duration::from_secs(30);
+/// How long the device with the higher ID waits before dialing (see `maintain`).
+const DEFER_DIAL: Duration = Duration::from_millis(750);
+const EVENT_CAPACITY: usize = 512;
+
+/// Capabilities every build offers.
+const BASE_CAPABILITIES: &[&str] = &["core.ping", "device.battery", "device.ring"];
+
+/// This device's mutable description, sent to peers.
+#[derive(Debug, Clone)]
+pub(crate) struct LocalState {
+ pub app_version: String,
+ pub device: DeviceInfo,
+ pub power: PowerLevel,
+ pub extra_capabilities: Vec<String>,
+ pub battery: Option<Battery>,
+}
+
+impl LocalState {
+ pub fn capabilities(&self) -> Vec<String> {
+ let mut caps: Vec<String> = BASE_CAPABILITIES.iter().map(|c| (*c).to_owned()).collect();
+ for cap in &self.extra_capabilities {
+ if !caps.contains(cap) {
+ caps.push(cap.clone());
+ }
+ }
+ caps
+ }
+}
+
+struct Supervisor {
+ wake: Arc<Notify>,
+ cancel: CancellationToken,
+}
+
+/// State shared by the node, its sessions and background tasks.
+pub(crate) struct Shared {
+ pub id: DeviceId,
+ pub endpoint: Endpoint,
+ pub store: Store,
+ pub platform: Arc<dyn Platform>,
+ pub local: RwLock<LocalState>,
+ pub pairing: PairingState,
+ pub cancel: CancellationToken,
+ events: broadcast::Sender<NodeEvent>,
+ sessions: Mutex<HashMap<DeviceId, Arc<Session>>>,
+ links: Mutex<HashMap<DeviceId, LinkState>>,
+ supervisors: Mutex<HashMap<DeviceId, Supervisor>>,
+ discovered: Mutex<HashMap<DeviceId, DiscoveredDevice>>,
+ memory: MemoryLookup,
+}
+
+impl std::fmt::Debug for Shared {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("Shared").field("id", &self.id).finish_non_exhaustive()
+ }
+}
+
+fn lock<T>(m: &Mutex<T>) -> std::sync::MutexGuard<'_, T> {
+ m.lock().unwrap_or_else(|e| e.into_inner())
+}
+
+impl Shared {
+ pub fn emit(&self, event: NodeEvent) {
+ // No subscribers is fine; events are a UI convenience.
+ let _ = self.events.send(event);
+ }
+
+ pub fn session(&self, peer: &DeviceId) -> Option<Arc<Session>> {
+ lock(&self.sessions).get(peer).filter(|s| s.is_alive()).cloned()
+ }
+
+ fn set_link(&self, peer: DeviceId, link: LinkState) {
+ let changed = lock(&self.links).insert(peer, link.clone()).as_ref() != Some(&link);
+ if changed {
+ self.emit(NodeEvent::LinkChanged { device: peer, link });
+ }
+ }
+
+ pub fn link(&self, peer: &DeviceId, last_seen: Option<i64>) -> LinkState {
+ lock(&self.links).get(peer).cloned().unwrap_or(LinkState::Offline { last_seen })
+ }
+
+ /// Publishes the session's current path and round-trip time.
+ pub fn publish_online(&self, session: &Session) {
+ self.set_link(session.peer, LinkState::Online { path: session.path(), rtt_ms: session.rtt_ms() });
+ }
+
+ /// Our direct addresses, for pairing links. Waits briefly for the
+ /// endpoint to learn them right after startup.
+ pub async fn direct_addrs(&self) -> Vec<SocketAddr> {
+ let deadline = tokio::time::Instant::now() + Duration::from_secs(2);
+ loop {
+ let addrs: Vec<SocketAddr> = self.endpoint.addr().ip_addrs().copied().collect();
+ if !addrs.is_empty() || tokio::time::Instant::now() >= deadline {
+ return addrs;
+ }
+ tokio::time::sleep(Duration::from_millis(50)).await;
+ }
+ }
+
+ /// Feeds known addresses of a peer into address lookup.
+ pub fn remember_addrs(&self, peer: &DeviceId, addrs: &[SocketAddr]) {
+ if addrs.is_empty() {
+ return;
+ }
+ if let Ok(key) = crate::public_key(peer) {
+ self.memory.add_endpoint_info(EndpointInfo::new(key).with_ip_addrs(addrs.to_vec()));
+ }
+ }
+
+ /// Stores a newly paired device and starts keeping it connected.
+ pub async fn complete_pairing(self: &Arc<Self>, peer: DeviceId, info: DeviceInfo) -> Result<()> {
+ let paired_at = crate::now_unix();
+ self.store.upsert_peer(&peer, &info, paired_at)?;
+ tracing::info!(peer = %peer.short(), "paired");
+ let device = PairedDevice { id: peer, info, paired_at, link: LinkState::Offline { last_seen: None } };
+ self.emit(NodeEvent::DeviceAdded(device.clone()));
+ self.emit(NodeEvent::Pairing(PairingEvent::Paired(device)));
+ lock(&self.discovered).remove(&peer);
+ self.start_supervisor(peer);
+ Ok(())
+ }
+
+ /// Removes a paired device locally (after we or the peer unpaired).
+ pub async fn forget_peer(&self, peer: &DeviceId) -> Result<()> {
+ let existed = self.store.remove_peer(peer)?;
+ if let Some(sup) = lock(&self.supervisors).remove(peer) {
+ sup.cancel.cancel();
+ }
+ if let Some(session) = lock(&self.sessions).remove(peer) {
+ session.close(CLOSE_NORMAL, b"unpaired");
+ }
+ lock(&self.links).remove(peer);
+ if existed {
+ self.emit(NodeEvent::DeviceRemoved(*peer));
+ }
+ Ok(())
+ }
+
+ /// Registers an established session, resolving duplicates: if both
+ /// devices dialed at once, the connection opened by the device with the
+ /// lower ID wins on both sides.
+ fn register_session(
+ self: &Arc<Self>,
+ conn: Connection,
+ dialer: DeviceId,
+ streams: (iroh::endpoint::SendStream, iroh::endpoint::RecvStream),
+ remote: nectarlink_protocol::messages::Hello,
+ ) -> Option<Arc<Session>> {
+ let peer = crate::device_id(&conn.remote_id());
+ let mut sessions = lock(&self.sessions);
+ if let Some(existing) = sessions.get(&peer).filter(|s| s.is_alive()) {
+ let keep_existing = existing.dialer != dialer && existing.dialer < dialer;
+ if keep_existing {
+ drop(sessions);
+ conn.close(VarInt::from_u32(CLOSE_DUPLICATE), b"duplicate");
+ return None;
+ }
+ existing.close(CLOSE_DUPLICATE, b"duplicate");
+ }
+
+ let weak = Arc::downgrade(self);
+ let session = Session::spawn(self, conn, dialer, streams, move |ended| {
+ if let Some(shared) = weak.upgrade() {
+ shared.on_session_end(&ended);
+ }
+ });
+ sessions.insert(peer, session.clone());
+ drop(sessions);
+
+ tracing::info!(peer = %peer.short(), path = ?session.path(), "connected");
+ let addrs = session.remote_ip_addrs();
+ if let Err(e) = self.store.record_seen(&peer, crate::now_unix(), &addrs) {
+ tracing::warn!(error = %e, "failed to record peer addresses");
+ }
+ self.remember_addrs(&peer, &addrs);
+ if let Err(e) = self.store.update_info(&peer, &remote.device) {
+ tracing::warn!(error = %e, "failed to update peer info");
+ }
+ self.emit(NodeEvent::PeerInfoChanged { device: peer, info: remote.device });
+ self.emit(NodeEvent::PeerPowerChanged { device: peer, power: remote.power.effective() });
+ self.publish_online(&session);
+
+ // Bring the peer up to date with state it may have missed.
+ let battery = self.local.read().unwrap_or_else(|e| e.into_inner()).battery.clone();
+ if let Some(battery) = battery {
+ let s = session.clone();
+ tokio::spawn(async move {
+ if let Ok(env) = Envelope::new(types::EVENT_BATTERY, &battery) {
+ let _ = s.send(env).await;
+ }
+ });
+ }
+ Some(session)
+ }
+
+ fn on_session_end(&self, ended: &Arc<Session>) {
+ let removed = {
+ let mut sessions = lock(&self.sessions);
+ match sessions.get(&ended.peer) {
+ Some(current) if Arc::ptr_eq(current, ended) => sessions.remove(&ended.peer).is_some(),
+ _ => false,
+ }
+ };
+ if removed && self.store.is_paired(&ended.peer).unwrap_or(false) {
+ tracing::info!(peer = %ended.peer.short(), "disconnected");
+ self.set_link(ended.peer, LinkState::Offline { last_seen: Some(crate::now_unix()) });
+ }
+ }
+
+ fn start_supervisor(self: &Arc<Self>, peer: DeviceId) {
+ let mut supervisors = lock(&self.supervisors);
+ if supervisors.contains_key(&peer) {
+ return;
+ }
+ let wake = Arc::new(Notify::new());
+ let cancel = self.cancel.child_token();
+ supervisors.insert(peer, Supervisor { wake: wake.clone(), cancel: cancel.clone() });
+ tokio::spawn(maintain(Arc::downgrade(self), peer, wake, cancel));
+ }
+
+ fn wake_supervisor(&self, peer: &DeviceId) {
+ if let Some(sup) = lock(&self.supervisors).get(peer) {
+ sup.wake.notify_one();
+ }
+ }
+
+ /// Dials a paired device and runs the handshake.
+ async fn dial(self: &Arc<Self>, peer: DeviceId) -> Result<Arc<Session>> {
+ let addr = EndpointAddr::new(crate::public_key(&peer)?);
+ let conn = tokio::time::timeout(DIAL_TIMEOUT, self.endpoint.connect(addr, ALPN_SESSION))
+ .await
+ .map_err(|_| Error::Timeout)?
+ .map_err(crate::error::net)?;
+ let hello = session::local_hello(self);
+ let (send, recv, remote) = session::handshake_dialer(&conn, &hello).await?;
+ self.register_session(conn, self.id, (send, recv), remote)
+ .or_else(|| self.session(&peer))
+ .ok_or(Error::Offline)
+ }
+
+ /// Sends a message to every connected device.
+ async fn broadcast(&self, env: Envelope) {
+ let sessions: Vec<_> = lock(&self.sessions).values().filter(|s| s.is_alive()).cloned().collect();
+ for session in sessions {
+ if let Err(e) = session.send(env.clone()).await {
+ tracing::debug!(peer = %session.peer.short(), error = %e, "broadcast failed");
+ }
+ }
+ }
+}
+
+/// Keeps one paired device connected: waits while a session is alive,
+/// otherwise dials with exponential backoff. Woken early by LAN discovery.
+async fn maintain(shared: Weak<Shared>, peer: DeviceId, wake: Arc<Notify>, cancel: CancellationToken) {
+ let mut backoff = BACKOFF_MIN;
+ loop {
+ let Some(node) = shared.upgrade() else { return };
+ if cancel.is_cancelled() {
+ return;
+ }
+ if let Some(session) = node.session(&peer) {
+ drop(node);
+ tokio::select! {
+ _ = session.cancel.cancelled() => {}
+ _ = cancel.cancelled() => return,
+ }
+ backoff = BACKOFF_MIN;
+ continue;
+ }
+ // When both devices come up together they'd dial each other at once and
+ // one connection would be dropped. The higher ID briefly defers so the
+ // lower one usually wins; it still dials in case the other can't reach it.
+ if node.id > peer && backoff == BACKOFF_MIN {
+ drop(node);
+ tokio::select! {
+ _ = tokio::time::sleep(DEFER_DIAL) => {}
+ _ = cancel.cancelled() => return,
+ }
+ let Some(again) = shared.upgrade() else { return };
+ if again.session(&peer).is_some() {
+ continue;
+ }
+ let result = again.dial(peer).await;
+ drop(again);
+ if handle_dial_result(result, peer, &mut backoff) {
+ continue;
+ }
+ } else {
+ let result = node.dial(peer).await;
+ drop(node);
+ if handle_dial_result(result, peer, &mut backoff) {
+ continue;
+ }
+ }
+ // Up to 20% jitter so many devices don't retry in lockstep.
+ let jitter = backoff.mul_f64(rand::random::<f64>() * 0.2);
+ tokio::select! {
+ _ = tokio::time::sleep(backoff + jitter) => {}
+ _ = wake.notified() => {}
+ _ = cancel.cancelled() => return,
+ }
+ backoff = (backoff * 2).min(BACKOFF_MAX);
+ }
+}
+
+/// Returns true if the dial succeeded (and resets the backoff).
+fn handle_dial_result(result: Result<Arc<Session>>, peer: DeviceId, backoff: &mut Duration) -> bool {
+ match result {
+ Ok(_) => {
+ *backoff = BACKOFF_MIN;
+ true
+ }
+ Err(e) => {
+ tracing::debug!(peer = %peer.short(), error = %e, retry_in = ?backoff, "dial failed");
+ false
+ }
+ }
+}
+
+/// Accepts `nectarlink/0` sessions from paired devices.
+#[derive(Debug, Clone)]
+struct SessionProtocol(Weak<Shared>);
+
+impl ProtocolHandler for SessionProtocol {
+ async fn accept(&self, conn: Connection) -> Result<(), AcceptError> {
+ let Some(shared) = self.0.upgrade() else { return Err(AcceptError::from_err(Error::Offline)) };
+ let peer = crate::device_id(&conn.remote_id());
+ if !shared.store.is_paired(&peer).unwrap_or(false) {
+ tracing::debug!(peer = %peer.short(), "refusing session from unpaired device");
+ conn.close(VarInt::from_u32(ErrorCode::Unpaired.close_code()), b"unpaired");
+ return Err(AcceptError::from_err(Error::NotPaired));
+ }
+ let hello = session::local_hello(&shared);
+ match session::handshake_listener(&conn, &hello).await {
+ Ok((send, recv, remote)) => {
+ shared.register_session(conn, peer, (send, recv), remote);
+ Ok(())
+ }
+ Err(e) => {
+ tracing::debug!(peer = %peer.short(), error = %e, "incoming handshake failed");
+ Err(AcceptError::from_err(e))
+ }
+ }
+ }
+}
+
+/// Accepts `nectarlink-pair/0` connections while pairing.
+#[derive(Debug, Clone)]
+struct PairProtocol(Weak<Shared>);
+
+impl ProtocolHandler for PairProtocol {
+ async fn accept(&self, conn: Connection) -> Result<(), AcceptError> {
+ let Some(shared) = self.0.upgrade() else { return Err(AcceptError::from_err(Error::Offline)) };
+ pairing::accept(shared, conn).await;
+ Ok(())
+ }
+}
+
+/// The Nectarlink engine. One per app.
+///
+/// Commands are async methods; everything that changes is reported through
+/// [`Node::events`]. Cheap to clone.
+#[derive(Clone)]
+pub struct Node {
+ shared: Arc<Shared>,
+ router: Arc<Router>,
+}
+
+impl std::fmt::Debug for Node {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("Node").field("id", &self.shared.id).finish_non_exhaustive()
+ }
+}
+
+impl Node {
+ /// Loads or creates the device identity and trust store, starts
+ /// networking, and begins reconnecting to paired devices.
+ pub async fn start(config: NodeConfig, platform: Arc<dyn Platform>) -> Result<Node> {
+ std::fs::create_dir_all(&config.data_dir)?;
+ let protector = config.key_protector.clone().unwrap_or_else(identity::default_protector);
+ let secret = identity::load_or_create(&config.data_dir, protector.as_ref())?;
+ let store = Store::open(&config.data_dir)?;
+
+ let mut builder = Endpoint::builder(presets::Minimal)
+ .secret_key(secret)
+ .alpns(vec![ALPN_SESSION.to_vec(), ALPN_PAIR.to_vec()]);
+ builder = if config.away_mode {
+ builder
+ .relay_mode(RelayMode::Default)
+ .address_lookup(PkarrPublisher::n0_dns())
+ .address_lookup(PkarrResolver::n0_dns())
+ .address_lookup(DnsAddressLookup::n0_dns())
+ } else {
+ // LAN only: no relays, nothing published outside the network.
+ builder.relay_mode(RelayMode::Disabled)
+ };
+ if config.port != 0 {
+ builder = builder
+ .clear_ip_transports()
+ .bind_addr(SocketAddr::from(([0, 0, 0, 0], config.port)))
+ .map_err(crate::error::net)?
+ .bind_addr(SocketAddr::from(([0u16; 8], config.port)))
+ .map_err(crate::error::net)?;
+ }
+ let endpoint = builder.bind().await.map_err(crate::error::net)?;
+ let id = crate::device_id(&endpoint.id());
+
+ let lookups = endpoint.address_lookup().map_err(crate::error::net)?;
+ let memory = MemoryLookup::new();
+ lookups.add(memory.clone());
+
+ let (events, _) = broadcast::channel(EVENT_CAPACITY);
+ let shared = Arc::new(Shared {
+ id,
+ endpoint: endpoint.clone(),
+ store,
+ platform,
+ local: RwLock::new(LocalState {
+ app_version: config.app_version.clone(),
+ device: config.device.clone(),
+ power: config.power,
+ extra_capabilities: Vec::new(),
+ battery: None,
+ }),
+ pairing: PairingState::default(),
+ cancel: CancellationToken::new(),
+ events,
+ sessions: Mutex::new(HashMap::new()),
+ links: Mutex::new(HashMap::new()),
+ supervisors: Mutex::new(HashMap::new()),
+ discovered: Mutex::new(HashMap::new()),
+ memory,
+ });
+
+ if config.lan_discovery {
+ start_lan_discovery(&shared, &config.device.name)?;
+ }
+
+ let router = Router::builder(endpoint)
+ .accept(ALPN_SESSION, SessionProtocol(Arc::downgrade(&shared)))
+ .accept(ALPN_PAIR, PairProtocol(Arc::downgrade(&shared)))
+ .spawn();
+
+ for peer in shared.store.list_peers()? {
+ shared.remember_addrs(&peer.id, &peer.last_addrs);
+ shared.start_supervisor(peer.id);
+ }
+ tracing::info!(device = %id.short(), lan = config.lan_discovery, away = config.away_mode, "node started");
+ Ok(Node { shared, router: Arc::new(router) })
+ }
+
+ /// Stops all sessions and networking.
+ pub async fn shutdown(&self) {
+ self.shared.cancel.cancel();
+ let sessions: Vec<_> = lock(&self.shared.sessions).drain().map(|(_, s)| s).collect();
+ for session in sessions {
+ session.close(CLOSE_NORMAL, b"shutdown");
+ }
+ if let Err(e) = self.router.shutdown().await {
+ tracing::warn!(error = %e, "router shutdown failed");
+ }
+ self.shared.endpoint.close().await;
+ }
+
+ pub fn device_id(&self) -> DeviceId {
+ self.shared.id
+ }
+
+ /// Subscribes to node events. Each subscriber gets its own stream.
+ pub fn events(&self) -> broadcast::Receiver<NodeEvent> {
+ self.shared.events.subscribe()
+ }
+
+ /// This device's direct addresses (for diagnostics and tests).
+ pub async fn direct_addrs(&self) -> Vec<SocketAddr> {
+ self.shared.direct_addrs().await
+ }
+
+ // ---- Pairing ----
+
+ /// Enters pairing mode and returns the link to show as a QR code.
+ pub async fn pairing_start_qr(&self) -> Result<PairingUri> {
+ pairing::start_host(&self.shared).await
+ }
+
+ /// Pairs with the device whose pairing link was scanned.
+ pub async fn pairing_join(&self, uri: &str) -> Result<()> {
+ let uri = PairingUri::parse(uri)?;
+ if uri.id == self.shared.id {
+ return Err(Error::Protocol("cannot pair a device with itself".into()));
+ }
+ pairing::join_qr(&self.shared, &uri).await
+ }
+
+ /// Starts nearby pairing with a discovered device. The other device must
+ /// be in pairing mode (showing its pairing screen). The 6-digit code
+ /// arrives as [`PairingEvent::SasCode`] on both devices.
+ pub async fn pairing_start_nearby(&self, peer: DeviceId) -> Result<()> {
+ pairing::start_nearby(&self.shared, peer).await
+ }
+
+ /// Answers the 6-digit code comparison shown via
+ /// [`PairingEvent::SasCode`].
+ pub fn pairing_confirm(&self, codes_match: bool) -> Result<()> {
+ self.shared.pairing.decide(codes_match)
+ }
+
+ /// Leaves pairing mode and abandons any code comparison.
+ pub fn pairing_cancel(&self) {
+ pairing::cancel(&self.shared);
+ }
+
+ /// Whether this device is currently showing a pairing code.
+ pub fn is_pairing(&self) -> bool {
+ self.shared.pairing.is_hosting()
+ }
+
+ /// Adds addresses where a device can be reached. Used for "connect by IP"
+ /// when local discovery is blocked (some routers and VPNs filter mDNS).
+ pub fn add_known_addrs(&self, peer: DeviceId, addrs: &[SocketAddr]) {
+ self.shared.remember_addrs(&peer, addrs);
+ self.shared.wake_supervisor(&peer);
+ }
+
+ /// Devices discovered on the local network that aren't paired yet.
+ pub fn discovered_devices(&self) -> Vec<DiscoveredDevice> {
+ lock(&self.shared.discovered).values().cloned().collect()
+ }
+
+ // ---- Paired devices ----
+
+ pub fn paired_devices(&self) -> Result<Vec<PairedDevice>> {
+ Ok(self
+ .shared
+ .store
+ .list_peers()?
+ .into_iter()
+ .map(|p| PairedDevice {
+ link: self.shared.link(&p.id, p.last_seen),
+ id: p.id,
+ info: p.info,
+ paired_at: p.paired_at,
+ })
+ .collect())
+ }
+
+ /// Unpairs a device, telling it if it's connected.
+ pub async fn unpair(&self, peer: DeviceId) -> Result<()> {
+ if !self.shared.store.is_paired(&peer)? {
+ return Err(Error::NotPaired);
+ }
+ if let Some(session) = self.shared.session(&peer) {
+ let _ = session.send(Envelope::empty(types::PAIR_REVOKE)).await;
+ // Let the revoke reach the peer before the connection closes.
+ tokio::time::sleep(Duration::from_millis(150)).await;
+ }
+ self.shared.forget_peer(&peer).await
+ }
+
+ /// Asks a device to start or stop ringing.
+ pub async fn ring(&self, peer: DeviceId, on: bool) -> Result<()> {
+ let reply = self.request(peer, Envelope::new(types::DEVICE_RING, &Ring { on })?).await?;
+ reply.expect(types::OK)?;
+ Ok(())
+ }
+
+ /// Sends a request to a connected device. If the connection is replaced
+ /// mid-request (e.g. a duplicate connection was resolved), retries once
+ /// on the new one, so requests must be idempotent.
+ async fn request(&self, peer: DeviceId, env: Envelope) -> Result<Envelope> {
+ let first = self.connected(&peer)?;
+ match first.request(env.clone(), REQUEST_TIMEOUT).await {
+ Err(Error::Offline) => match self.shared.session(&peer) {
+ Some(next) if !Arc::ptr_eq(&next, &first) => next.request(env, REQUEST_TIMEOUT).await,
+ _ => Err(Error::Offline),
+ },
+ other => other,
+ }
+ }
+
+ fn connected(&self, peer: &DeviceId) -> Result<Arc<Session>> {
+ if !self.shared.store.is_paired(peer)? {
+ return Err(Error::NotPaired);
+ }
+ self.shared.session(peer).ok_or(Error::Offline)
+ }
+
+ // ---- Local state reported by the app ----
+
+ /// Reports this device's battery; forwarded to connected devices.
+ pub async fn update_battery(&self, battery: Battery) {
+ self.shared.local.write().unwrap_or_else(|e| e.into_inner()).battery = Some(battery.clone());
+ if let Ok(env) = Envelope::new(types::EVENT_BATTERY, &battery) {
+ self.shared.broadcast(env).await;
+ }
+ }
+
+ /// Updates this device's description (e.g. after a rename).
+ pub async fn update_device_info(&self, device: DeviceInfo) {
+ self.shared.local.write().unwrap_or_else(|e| e.into_inner()).device = device.clone();
+ let update = HelloUpdate { device: Some(device), ..Default::default() };
+ if let Ok(env) = Envelope::new(types::HELLO_UPDATE, &update) {
+ self.shared.broadcast(env).await;
+ }
+ }
+
+ /// Updates this device's power level and extra capabilities.
+ pub async fn update_power(&self, power: PowerLevel, extra_capabilities: Vec<String>) {
+ let caps = {
+ let mut local = self.shared.local.write().unwrap_or_else(|e| e.into_inner());
+ local.power = power;
+ local.extra_capabilities = extra_capabilities;
+ local.capabilities()
+ };
+ let update = HelloUpdate { power: Some(power), caps: Some(caps), device: None };
+ if let Ok(env) = Envelope::new(types::HELLO_UPDATE, &update) {
+ self.shared.broadcast(env).await;
+ }
+ }
+}
+
+/// Announces this device on the LAN and watches for others.
+fn start_lan_discovery(shared: &Arc<Shared>, name: &str) -> Result<()> {
+ let mdns = MdnsAddressLookup::builder()
+ .service_name("nectarlink")
+ .build(shared.endpoint.id())
+ .map_err(crate::error::net)?;
+ shared.endpoint.address_lookup().map_err(crate::error::net)?.add(mdns.clone());
+ // Announce our name so nearby pairing can show it; truncate safely.
+ let mut announced = name.to_owned();
+ while announced.len() > UserData::MAX_LENGTH {
+ announced.pop();
+ }
+ if let Ok(data) = UserData::try_from(announced) {
+ shared.endpoint.set_user_data_for_address_lookup(Some(data));
+ }
+
+ let weak = Arc::downgrade(shared);
+ let cancel = shared.cancel.child_token();
+ tokio::spawn(async move {
+ use n0_future::StreamExt;
+ let mut events = mdns.subscribe().await;
+ loop {
+ let event = tokio::select! {
+ _ = cancel.cancelled() => return,
+ event = events.next() => match event { Some(e) => e, None => return },
+ };
+ let Some(shared) = weak.upgrade() else { return };
+ match event {
+ DiscoveryEvent::Discovered { endpoint_info, .. } => {
+ let id = crate::device_id(&endpoint_info.endpoint_id);
+ if shared.store.is_paired(&id).unwrap_or(false) {
+ shared.wake_supervisor(&id);
+ continue;
+ }
+ let device =
+ DiscoveredDevice { id, name: endpoint_info.user_data().map(|d| d.to_string()) };
+ let is_new =
+ lock(&shared.discovered).insert(id, device.clone()).as_ref() != Some(&device);
+ if is_new {
+ shared.emit(NodeEvent::Discovered(device));
+ }
+ }
+ DiscoveryEvent::Expired { endpoint_id } => {
+ let id = crate::device_id(&endpoint_id);
+ if lock(&shared.discovered).remove(&id).is_some() {
+ shared.emit(NodeEvent::DiscoveryExpired(id));
+ }
+ }
+ _ => {}
+ }
+ }
+ });
+ Ok(())
+}
diff --git a/core/nectarlink-core/src/pairing.rs b/core/nectarlink-core/src/pairing.rs
new file mode 100644
index 0000000..85931b8
--- /dev/null
+++ b/core/nectarlink-core/src/pairing.rs
@@ -0,0 +1,389 @@
+// SPDX-License-Identifier: MPL-2.0
+//! The pairing ceremony (protocol §9) over the `nectarlink-pair/0` ALPN.
+//!
+//! Two flows:
+//! - **QR**: the host (PC) shows a pairing link with a one-time secret; the
+//! joiner (phone) proves knowledge of it.
+//! - **Nearby**: numeric comparison. Both screens show a 6-digit code derived
+//! from both identities and committed nonces; both users confirm.
+
+use std::{
+ sync::{Arc, Mutex},
+ time::{Duration, Instant},
+};
+
+use iroh::{
+ EndpointAddr,
+ endpoint::{Connection, RecvStream, SendStream, VarInt},
+};
+use nectarlink_protocol::{
+ ALPN_PAIR, DeviceId, Envelope, ErrorCode,
+ messages::*,
+ pairing::{self as proto, NONCE_LEN, PairingUri, SECRET_LEN},
+ read_frame, write_frame,
+};
+use tokio::sync::oneshot;
+
+use crate::{
+ Error, Result,
+ events::{NodeEvent, PairingEvent, PairingFailure},
+ node::Shared,
+};
+
+/// How long the host stays in pairing mode.
+pub(crate) const PAIRING_TTL: Duration = Duration::from_secs(5 * 60);
+/// How long to wait for the users to compare the 6-digit codes.
+const SAS_DECISION_TIMEOUT: Duration = Duration::from_secs(120);
+/// How long each pairing message may take to arrive.
+const STEP_TIMEOUT: Duration = Duration::from_secs(20);
+/// Wrong proofs tolerated before pairing mode ends.
+const MAX_FAILED_ATTEMPTS: u32 = 5;
+const DIAL_TIMEOUT: Duration = Duration::from_secs(15);
+
+/// Host-side pairing mode, active while a QR code is shown.
+struct HostMode {
+ secret: [u8; SECRET_LEN],
+ expires_at: Instant,
+ failures: u32,
+}
+
+/// Pairing state shared by both flows. Only one ceremony runs at a time.
+#[derive(Default)]
+pub(crate) struct PairingState {
+ host: Mutex<Option<HostMode>>,
+ /// Waiting for the local user to confirm or reject the 6-digit code.
+ sas_decision: Mutex<Option<(DeviceId, oneshot::Sender<bool>)>>,
+}
+
+impl std::fmt::Debug for PairingState {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("PairingState").finish_non_exhaustive()
+ }
+}
+
+impl PairingState {
+ fn host_secret(&self) -> Option<[u8; SECRET_LEN]> {
+ let mut host = self.host.lock().unwrap_or_else(|e| e.into_inner());
+ match host.as_ref() {
+ Some(mode) if mode.expires_at > Instant::now() => Some(mode.secret),
+ Some(_) => {
+ *host = None;
+ None
+ }
+ None => None,
+ }
+ }
+
+ pub(crate) fn is_hosting(&self) -> bool {
+ self.host_secret().is_some()
+ }
+
+ fn end_host(&self) {
+ *self.host.lock().unwrap_or_else(|e| e.into_inner()) = None;
+ }
+
+ /// Records a failed attempt; returns true if pairing mode just ended.
+ fn record_failure(&self) -> bool {
+ let mut host = self.host.lock().unwrap_or_else(|e| e.into_inner());
+ if let Some(mode) = host.as_mut() {
+ mode.failures += 1;
+ if mode.failures >= MAX_FAILED_ATTEMPTS {
+ *host = None;
+ return true;
+ }
+ }
+ false
+ }
+
+ /// Delivers the local user's decision about the 6-digit code.
+ pub(crate) fn decide(&self, matches: bool) -> Result<()> {
+ let slot = self.sas_decision.lock().unwrap_or_else(|e| e.into_inner()).take();
+ match slot {
+ Some((_, tx)) => {
+ let _ = tx.send(matches);
+ Ok(())
+ }
+ None => Err(Error::NotPairing),
+ }
+ }
+
+ fn await_decision(&self, peer: DeviceId) -> oneshot::Receiver<bool> {
+ let (tx, rx) = oneshot::channel();
+ *self.sas_decision.lock().unwrap_or_else(|e| e.into_inner()) = Some((peer, tx));
+ rx
+ }
+
+ fn clear_decision(&self) {
+ *self.sas_decision.lock().unwrap_or_else(|e| e.into_inner()) = None;
+ }
+}
+
+/// Starts host pairing mode and returns the link to show as a QR code.
+pub(crate) async fn start_host(shared: &Arc<Shared>) -> Result<PairingUri> {
+ let secret: [u8; SECRET_LEN] = rand::random();
+ *shared.pairing.host.lock().unwrap_or_else(|e| e.into_inner()) =
+ Some(HostMode { secret, expires_at: Instant::now() + PAIRING_TTL, failures: 0 });
+
+ // Expire quietly; tell the UI if nobody paired in time.
+ let weak = Arc::downgrade(shared);
+ tokio::spawn(async move {
+ tokio::time::sleep(PAIRING_TTL).await;
+ if let Some(shared) = weak.upgrade() {
+ let still_ours = shared
+ .pairing
+ .host
+ .lock()
+ .unwrap_or_else(|e| e.into_inner())
+ .as_ref()
+ .is_some_and(|m| m.secret == secret);
+ if still_ours {
+ shared.pairing.end_host();
+ shared.emit(NodeEvent::Pairing(PairingEvent::Failed(PairingFailure::Expired)));
+ }
+ }
+ });
+
+ let name = shared.local.read().unwrap_or_else(|e| e.into_inner()).device.name.clone();
+ Ok(PairingUri { id: shared.id, secret, name, addrs: shared.direct_addrs().await })
+}
+
+pub(crate) fn cancel(shared: &Shared) {
+ shared.pairing.end_host();
+ shared.pairing.clear_decision();
+}
+
+/// Joins a host by scanning its pairing link (the phone side of the QR flow).
+pub(crate) async fn join_qr(shared: &Arc<Shared>, uri: &PairingUri) -> Result<()> {
+ shared.remember_addrs(&uri.id, &uri.addrs);
+ let conn = dial(shared, &uri.id).await?;
+ let result = async {
+ let (mut send, mut recv) = conn.open_bi().await.map_err(crate::error::net)?;
+ let device = shared.local.read().unwrap_or_else(|e| e.into_inner()).device.clone();
+ let proof = proto::pair_proof(&uri.secret, &shared.id, &uri.id).to_vec();
+ send_env(&mut send, Envelope::new(types::PAIR_REQUEST, &PairRequest { device, proof })?).await?;
+ let accept: PairAccept = recv_env(&mut recv).await?.expect_body(types::PAIR_ACCEPT)?;
+ finish_initiator(&conn, send, recv).await;
+ Ok(accept.device)
+ }
+ .await;
+ conn.close(VarInt::from_u32(0), b"done");
+ match result {
+ Ok(device) => shared.complete_pairing(uri.id, device).await,
+ Err(err) => Err(fail(shared, err)),
+ }
+}
+
+/// Starts the nearby (numeric comparison) flow with a discovered device.
+/// The 6-digit code arrives as [`PairingEvent::SasCode`]; answer with
+/// [`crate::Node::pairing_confirm`].
+pub(crate) async fn start_nearby(shared: &Arc<Shared>, peer: DeviceId) -> Result<()> {
+ let conn = dial(shared, &peer).await?;
+ let result = async {
+ let (mut send, mut recv) = conn.open_bi().await.map_err(crate::error::net)?;
+ let device = shared.local.read().unwrap_or_else(|e| e.into_inner()).device.clone();
+ let n_a: [u8; NONCE_LEN] = rand::random();
+
+ let commit = PairCommit { device, c: proto::commitment(&n_a).to_vec() };
+ send_env(&mut send, Envelope::new(types::PAIR_COMMIT, &commit)?).await?;
+ let nonce: PairNonce = recv_env(&mut recv).await?.expect_body(types::PAIR_NONCE)?;
+ send_env(&mut send, Envelope::new(types::PAIR_REVEAL, &PairReveal { n_a: n_a.to_vec() })?).await?;
+
+ let code = proto::sas_code(&n_a, &nonce.n_b, &shared.id, &peer);
+ compare_codes(shared, peer, code, &mut send, &mut recv).await?;
+ finish_initiator(&conn, send, recv).await;
+ Ok(nonce.device)
+ }
+ .await;
+ conn.close(VarInt::from_u32(0), b"done");
+ match result {
+ Ok(device) => shared.complete_pairing(peer, device).await,
+ Err(err) => Err(fail(shared, err)),
+ }
+}
+
+/// Handles an incoming pairing connection (host side of both flows).
+pub(crate) async fn accept(shared: Arc<Shared>, conn: Connection) {
+ let peer = crate::device_id(&conn.remote_id());
+ if !shared.pairing.is_hosting() {
+ tracing::debug!(peer = %peer.short(), "refusing pairing connection: not in pairing mode");
+ conn.close(VarInt::from_u32(ErrorCode::Denied.close_code()), b"not pairing");
+ return;
+ }
+ let (mut send, mut recv) = match conn.accept_bi().await {
+ Ok(streams) => streams,
+ Err(e) => {
+ tracing::debug!(peer = %peer.short(), error = %e, "pairing connection dropped");
+ return;
+ }
+ };
+ let result = async {
+ let first = recv_env(&mut recv).await?;
+ match first.t.as_str() {
+ types::PAIR_REQUEST => accept_qr(&shared, peer, first, &mut send).await,
+ types::PAIR_COMMIT => {
+ accept_nearby(&shared, peer, first, &mut send, &mut recv).await.map_err(|e| fail(&shared, e))
+ }
+ other => {
+ let reply = Envelope::error(ErrorCode::Unsupported, format!("unexpected {other}"));
+ send_env(&mut send, reply).await?;
+ Err(Error::Protocol(format!("unexpected pairing message {other}")))
+ }
+ }
+ }
+ .await;
+ // Store before closing, so the joiner's first session is accepted.
+ match result {
+ Ok(device) => {
+ if let Err(e) = shared.complete_pairing(peer, device).await {
+ tracing::warn!(error = %e, "failed to store pairing");
+ }
+ }
+ Err(err) => tracing::info!(peer = %peer.short(), error = %err, "pairing attempt failed"),
+ }
+ finish_host(&conn, send).await;
+}
+
+async fn accept_qr(
+ shared: &Arc<Shared>,
+ peer: DeviceId,
+ env: Envelope,
+ send: &mut SendStream,
+) -> Result<DeviceInfo> {
+ let request: PairRequest = env.body()?;
+ let Some(secret) = shared.pairing.host_secret() else {
+ send_env(send, Envelope::error(ErrorCode::Denied, "pairing mode ended")).await?;
+ return Err(Error::NotPairing);
+ };
+ if !proto::verify_pair_proof(&secret, &peer, &shared.id, &request.proof) {
+ send_env(send, Envelope::error(ErrorCode::Denied, "pairing code mismatch")).await?;
+ if shared.pairing.record_failure() {
+ shared.emit(NodeEvent::Pairing(PairingEvent::Failed(PairingFailure::Rejected)));
+ }
+ return Err(Error::Denied);
+ }
+ shared.pairing.end_host();
+ let device = shared.local.read().unwrap_or_else(|e| e.into_inner()).device.clone();
+ send_env(send, Envelope::new(types::PAIR_ACCEPT, &PairAccept { device })?).await?;
+ Ok(request.device)
+}
+
+async fn accept_nearby(
+ shared: &Arc<Shared>,
+ peer: DeviceId,
+ env: Envelope,
+ send: &mut SendStream,
+ recv: &mut RecvStream,
+) -> Result<DeviceInfo> {
+ let commit: PairCommit = env.body()?;
+ let device = shared.local.read().unwrap_or_else(|e| e.into_inner()).device.clone();
+ let n_b: [u8; NONCE_LEN] = rand::random();
+ send_env(send, Envelope::new(types::PAIR_NONCE, &PairNonce { device, n_b: n_b.to_vec() })?).await?;
+
+ let reveal: PairReveal = recv_env(recv).await?.expect_body(types::PAIR_REVEAL)?;
+ if !proto::verify_commitment(&commit.c, &reveal.n_a) {
+ send_env(send, Envelope::error(ErrorCode::Denied, "commitment mismatch")).await?;
+ return Err(Error::Denied);
+ }
+ // The initiator is A, we are B.
+ let code = proto::sas_code(&reveal.n_a, &n_b, &peer, &shared.id);
+ compare_codes(shared, peer, code, send, recv).await?;
+ shared.pairing.end_host();
+ Ok(commit.device)
+}
+
+/// Shows the code, waits for the local decision, exchanges confirmations.
+/// Succeeds only if both users confirmed.
+async fn compare_codes(
+ shared: &Arc<Shared>,
+ peer: DeviceId,
+ code: String,
+ send: &mut SendStream,
+ recv: &mut RecvStream,
+) -> Result<()> {
+ let decision = shared.pairing.await_decision(peer);
+ shared.emit(NodeEvent::Pairing(PairingEvent::SasCode { peer, code }));
+
+ let local_ok = match tokio::time::timeout(SAS_DECISION_TIMEOUT, decision).await {
+ Ok(Ok(ok)) => ok,
+ Ok(Err(_)) => false, // cancelled
+ Err(_) => {
+ shared.pairing.clear_decision();
+ false
+ }
+ };
+ if !local_ok {
+ send_env(send, Envelope::error(ErrorCode::Denied, "codes did not match")).await?;
+ return Err(Error::Declined);
+ }
+ if let Err(err) = send_env(send, Envelope::empty(types::PAIR_CONFIRM)).await {
+ // The peer may already have declined and stopped reading; prefer its reason.
+ if let Ok(Ok(Some(frame))) = tokio::time::timeout(Duration::from_secs(2), read_frame(recv)).await
+ && let Ok(env) = Envelope::from_cbor(&frame)
+ {
+ env.expect(types::PAIR_CONFIRM)?;
+ }
+ return Err(err);
+ }
+
+ let remote =
+ tokio::time::timeout(SAS_DECISION_TIMEOUT, read_frame(recv)).await.map_err(|_| Error::Timeout)??;
+ let remote = Envelope::from_cbor(&remote.ok_or(Error::Offline)?)?;
+ remote.expect(types::PAIR_CONFIRM)?;
+ Ok(())
+}
+
+/// How long to wait for the other side to finish the ceremony cleanly.
+const CLOSE_TIMEOUT: Duration = Duration::from_secs(5);
+
+/// Initiator side: lets the host read our last message and close the
+/// connection. Closing first would discard data the host hasn't read yet.
+async fn finish_initiator(conn: &Connection, mut send: SendStream, mut recv: RecvStream) {
+ let _ = send.finish();
+ let _ = recv.stop(VarInt::from_u32(0));
+ let _ = tokio::time::timeout(CLOSE_TIMEOUT, conn.closed()).await;
+}
+
+/// Host side: waits until the initiator has received everything we sent,
+/// then closes the connection.
+async fn finish_host(conn: &Connection, mut send: SendStream) {
+ let _ = send.finish();
+ let _ = tokio::time::timeout(CLOSE_TIMEOUT, send.stopped()).await;
+ conn.close(VarInt::from_u32(0), b"done");
+}
+
+async fn dial(shared: &Arc<Shared>, peer: &DeviceId) -> Result<Connection> {
+ let addr = EndpointAddr::new(crate::public_key(peer)?);
+ match tokio::time::timeout(DIAL_TIMEOUT, shared.endpoint.connect(addr, ALPN_PAIR)).await {
+ Ok(Ok(conn)) => Ok(conn),
+ Ok(Err(e)) => {
+ shared.emit(NodeEvent::Pairing(PairingEvent::Failed(PairingFailure::Unreachable)));
+ Err(crate::error::net(e))
+ }
+ Err(_) => {
+ shared.emit(NodeEvent::Pairing(PairingEvent::Failed(PairingFailure::Unreachable)));
+ Err(Error::Timeout)
+ }
+ }
+}
+
+async fn send_env(send: &mut SendStream, env: Envelope) -> Result<()> {
+ write_frame(send, &env.to_cbor()).await?;
+ Ok(())
+}
+
+async fn recv_env(recv: &mut RecvStream) -> Result<Envelope> {
+ let frame = tokio::time::timeout(STEP_TIMEOUT, read_frame(recv)).await.map_err(|_| Error::Timeout)??;
+ Ok(Envelope::from_cbor(&frame.ok_or(Error::Offline)?)?)
+}
+
+/// Reports a failed ceremony to the UI and passes the error through.
+fn fail(shared: &Shared, err: Error) -> Error {
+ let failure = match &err {
+ Error::Denied => PairingFailure::Rejected,
+ Error::Declined => PairingFailure::Declined,
+ Error::Timeout | Error::Offline | Error::Network(_) => PairingFailure::Unreachable,
+ other => PairingFailure::Other(other.to_string()),
+ };
+ shared.emit(NodeEvent::Pairing(PairingEvent::Failed(failure)));
+ err
+}
diff --git a/core/nectarlink-core/src/session.rs b/core/nectarlink-core/src/session.rs
new file mode 100644
index 0000000..c578d02
--- /dev/null
+++ b/core/nectarlink-core/src/session.rs
@@ -0,0 +1,356 @@
+// SPDX-License-Identifier: MPL-2.0
+//! One authenticated session with a paired device: the hello handshake, the
+//! control stream, request/response correlation and the heartbeat.
+
+use std::{
+ collections::HashMap,
+ sync::{
+ Arc, Mutex, Weak,
+ atomic::{AtomicU32, AtomicU64, Ordering},
+ },
+ time::{Duration, Instant},
+};
+
+use iroh::endpoint::{Connection, RecvStream, SendStream, VarInt};
+use nectarlink_protocol::{
+ DeviceId, Envelope, ErrorCode, MIN_PROTOCOL_VERSION, PROTOCOL_VERSION, ProtocolError, messages::*,
+ negotiate_version, read_frame, write_frame,
+};
+use tokio::sync::{mpsc, oneshot};
+use tokio_util::sync::CancellationToken;
+
+use crate::{
+ Error, Result,
+ error::Side,
+ events::{ConnectionPath, NodeEvent},
+ node::Shared,
+};
+
+pub(crate) const HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(10);
+pub(crate) const REQUEST_TIMEOUT: Duration = Duration::from_secs(10);
+const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(20);
+const OUTBOX_CAPACITY: usize = 256;
+
+/// QUIC close code used when a duplicate connection is dropped.
+pub(crate) const CLOSE_DUPLICATE: u32 = 100;
+/// QUIC close code for a normal shutdown.
+pub(crate) const CLOSE_NORMAL: u32 = 0;
+
+/// Builds this device's hello from the shared local state.
+pub(crate) fn local_hello(shared: &Shared) -> Hello {
+ let local = shared.local.read().unwrap_or_else(|e| e.into_inner());
+ Hello {
+ proto: PROTOCOL_VERSION,
+ min: MIN_PROTOCOL_VERSION,
+ app: local.app_version.clone(),
+ device: local.device.clone(),
+ caps: local.capabilities(),
+ power: local.power,
+ }
+}
+
+/// Runs the dialer side of the handshake on a fresh connection.
+pub(crate) async fn handshake_dialer(
+ conn: &Connection,
+ hello: &Hello,
+) -> Result<(SendStream, RecvStream, Hello)> {
+ let run = async {
+ let (mut send, mut recv) = conn.open_bi().await.map_err(crate::error::net)?;
+ write_frame(&mut send, &Envelope::new(types::HELLO, hello)?.to_cbor()).await?;
+ let remote = read_hello(&mut recv).await?;
+ check_versions(conn, &mut send, hello, &remote).await?;
+ Ok((send, recv, remote))
+ };
+ tokio::time::timeout(HANDSHAKE_TIMEOUT, run).await.map_err(|_| Error::Timeout)?
+}
+
+/// Runs the listener side of the handshake on an accepted connection.
+pub(crate) async fn handshake_listener(
+ conn: &Connection,
+ hello: &Hello,
+) -> Result<(SendStream, RecvStream, Hello)> {
+ let run = async {
+ let (mut send, mut recv) = conn.accept_bi().await.map_err(crate::error::net)?;
+ let remote = read_hello(&mut recv).await?;
+ check_versions(conn, &mut send, hello, &remote).await?;
+ write_frame(&mut send, &Envelope::new(types::HELLO, hello)?.to_cbor()).await?;
+ Ok((send, recv, remote))
+ };
+ tokio::time::timeout(HANDSHAKE_TIMEOUT, run).await.map_err(|_| Error::Timeout)?
+}
+
+async fn read_hello(recv: &mut RecvStream) -> Result<Hello> {
+ let frame = read_frame(recv).await?.ok_or(Error::Offline)?;
+ Ok(Envelope::from_cbor(&frame)?.expect_body(types::HELLO)?)
+}
+
+async fn check_versions(
+ conn: &Connection,
+ send: &mut SendStream,
+ local: &Hello,
+ remote: &Hello,
+) -> Result<()> {
+ if negotiate_version((local.proto, local.min), (remote.proto, remote.min)).is_some() {
+ return Ok(());
+ }
+ // Tell the peer why before closing; best effort.
+ let msg = format!("protocol {} is not compatible with {}", remote.proto, local.proto);
+ let _ = write_frame(send, &Envelope::error(ErrorCode::VersionTooOld, msg).to_cbor()).await;
+ let side = if remote.proto < local.min { Side::Remote } else { Side::Local };
+ conn.close(VarInt::from_u32(ErrorCode::VersionTooOld.close_code()), b"version");
+ Err(Error::VersionTooOld { side })
+}
+
+/// A live session. Cheap to share; dropping the last handle does not close
+/// the connection (call [`Session::close`]).
+pub(crate) struct Session {
+ pub peer: DeviceId,
+ /// Who opened the connection; used to resolve duplicate connections.
+ pub dialer: DeviceId,
+ pub conn: Connection,
+ outbox: mpsc::Sender<Envelope>,
+ pending: Mutex<HashMap<u64, oneshot::Sender<Envelope>>>,
+ next_id: AtomicU64,
+ rtt_ms: AtomicU32,
+ pub(crate) cancel: CancellationToken,
+}
+
+impl std::fmt::Debug for Session {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("Session")
+ .field("peer", &self.peer)
+ .field("dialer", &self.dialer)
+ .finish_non_exhaustive()
+ }
+}
+
+impl Session {
+ /// Starts the session's tasks. `on_end` runs once when the session ends,
+ /// for any reason.
+ pub(crate) fn spawn(
+ shared: &Arc<Shared>,
+ conn: Connection,
+ dialer: DeviceId,
+ (send, recv): (SendStream, RecvStream),
+ on_end: impl FnOnce(Arc<Session>) + Send + 'static,
+ ) -> Arc<Session> {
+ let peer = crate::device_id(&conn.remote_id());
+ let (outbox, outbox_rx) = mpsc::channel(OUTBOX_CAPACITY);
+ let session = Arc::new(Session {
+ peer,
+ dialer,
+ conn,
+ outbox,
+ pending: Mutex::new(HashMap::new()),
+ next_id: AtomicU64::new(1),
+ rtt_ms: AtomicU32::new(0),
+ cancel: shared.cancel.child_token(),
+ });
+
+ let weak = Arc::downgrade(shared);
+ let s = session.clone();
+ tokio::spawn(async move {
+ let cancel = s.cancel.clone();
+ tokio::select! {
+ _ = cancel.cancelled() => {}
+ _ = writer(send, outbox_rx) => {}
+ _ = reader(&s, recv, &weak) => {}
+ _ = heartbeat(&s, &weak) => {}
+ _ = s.conn.closed() => {}
+ }
+ cancel.cancel();
+ // Fail any requests still waiting for a reply.
+ s.pending.lock().unwrap_or_else(|e| e.into_inner()).clear();
+ tracing::debug!(peer = %s.peer.short(), "session ended");
+ on_end(s);
+ });
+ session
+ }
+
+ pub fn rtt_ms(&self) -> u32 {
+ self.rtt_ms.load(Ordering::Relaxed)
+ }
+
+ /// The path the connection currently uses.
+ pub fn path(&self) -> ConnectionPath {
+ let relayed = self.conn.paths().iter().find(|p| p.is_selected()).is_some_and(|p| p.is_relay());
+ if relayed { ConnectionPath::Relay } else { ConnectionPath::Lan }
+ }
+
+ /// The peer's direct IP addresses currently in use, for reconnecting later.
+ pub fn remote_ip_addrs(&self) -> Vec<std::net::SocketAddr> {
+ self.conn
+ .paths()
+ .iter()
+ .filter_map(|p| match p.remote_addr() {
+ iroh::TransportAddr::Ip(addr) => Some(*addr),
+ _ => None,
+ })
+ .collect()
+ }
+
+ pub fn is_alive(&self) -> bool {
+ !self.cancel.is_cancelled() && self.conn.close_reason().is_none()
+ }
+
+ /// Queues a one-way message.
+ pub async fn send(&self, env: Envelope) -> Result<()> {
+ self.outbox.send(env).await.map_err(|_| Error::Offline)
+ }
+
+ /// Sends a request and waits for the reply with the matching `re`.
+ pub async fn request(&self, env: Envelope, timeout: Duration) -> Result<Envelope> {
+ let id = self.next_id.fetch_add(1, Ordering::Relaxed);
+ let (tx, rx) = oneshot::channel();
+ self.pending.lock().unwrap_or_else(|e| e.into_inner()).insert(id, tx);
+ let result = async {
+ self.send(env.with_id(id)).await?;
+ match tokio::time::timeout(timeout, rx).await {
+ Ok(Ok(reply)) => Ok(reply),
+ Ok(Err(_)) => Err(Error::Offline),
+ Err(_) => Err(Error::Timeout),
+ }
+ }
+ .await;
+ self.pending.lock().unwrap_or_else(|e| e.into_inner()).remove(&id);
+ result
+ }
+
+ /// Closes the connection with an application code.
+ pub fn close(&self, code: u32, reason: &[u8]) {
+ self.conn.close(VarInt::from_u32(code), reason);
+ self.cancel.cancel();
+ }
+
+ fn complete(&self, env: Envelope) -> bool {
+ let Some(re) = env.re else { return false };
+ match self.pending.lock().unwrap_or_else(|e| e.into_inner()).remove(&re) {
+ Some(tx) => {
+ let _ = tx.send(env);
+ true
+ }
+ None => false,
+ }
+ }
+}
+
+async fn writer(mut send: SendStream, mut outbox: mpsc::Receiver<Envelope>) {
+ while let Some(env) = outbox.recv().await {
+ if let Err(e) = write_frame(&mut send, &env.to_cbor()).await {
+ tracing::debug!(error = %e, "control stream write failed");
+ return;
+ }
+ }
+ let _ = send.finish();
+}
+
+async fn reader(session: &Arc<Session>, mut recv: RecvStream, shared: &Weak<Shared>) {
+ loop {
+ let frame = match read_frame(&mut recv).await {
+ Ok(Some(frame)) => frame,
+ Ok(None) => return,
+ Err(ProtocolError::FrameTooLarge(len)) => {
+ tracing::warn!(peer = %session.peer.short(), len, "peer sent an oversized frame");
+ session.close(ErrorCode::FrameTooLarge.close_code(), b"frame too large");
+ return;
+ }
+ Err(e) => {
+ tracing::debug!(peer = %session.peer.short(), error = %e, "control stream read failed");
+ return;
+ }
+ };
+ let env = match Envelope::from_cbor(&frame) {
+ Ok(env) => env,
+ Err(e) => {
+ tracing::warn!(peer = %session.peer.short(), error = %e, "dropping malformed message");
+ continue;
+ }
+ };
+ if session.complete(env.clone()) {
+ continue;
+ }
+ let Some(shared) = shared.upgrade() else { return };
+ if let Err(e) = handle(&shared, session, env).await {
+ tracing::warn!(peer = %session.peer.short(), error = %e, "failed to handle message");
+ }
+ }
+}
+
+/// Handles one incoming message that isn't a reply.
+async fn handle(shared: &Arc<Shared>, session: &Arc<Session>, env: Envelope) -> Result<()> {
+ let peer = session.peer;
+ match env.t.as_str() {
+ types::PING => {
+ let ping: Ping = env.body()?;
+ session.send(Envelope::new(types::PONG, &ping)?.reply_to(env.id)).await?;
+ }
+ types::EVENT_BATTERY => {
+ let battery: Battery = env.body()?;
+ shared.emit(NodeEvent::Battery { device: peer, battery });
+ }
+ types::EVENT_DEVICE => {
+ let info: DeviceInfo = env.body()?;
+ shared.store.update_info(&peer, &info)?;
+ shared.emit(NodeEvent::PeerInfoChanged { device: peer, info });
+ }
+ types::HELLO_UPDATE => {
+ let update: HelloUpdate = env.body()?;
+ if let Some(info) = update.device {
+ shared.store.update_info(&peer, &info)?;
+ shared.emit(NodeEvent::PeerInfoChanged { device: peer, info });
+ }
+ if let Some(power) = update.power {
+ shared.emit(NodeEvent::PeerPowerChanged { device: peer, power: power.effective() });
+ }
+ }
+ types::DEVICE_RING => {
+ let ring: Ring = env.body()?;
+ if ring.on {
+ shared.platform.start_ringing();
+ } else {
+ shared.platform.stop_ringing();
+ }
+ shared.emit(NodeEvent::Ring { device: peer, on: ring.on });
+ session.send(Envelope::empty(types::OK).reply_to(env.id)).await?;
+ }
+ types::PAIR_REVOKE => {
+ tracing::info!(peer = %peer.short(), "peer unpaired this device");
+ shared.forget_peer(&peer).await?;
+ }
+ other => {
+ if env.id.is_some() {
+ let reply = Envelope::error(ErrorCode::Unsupported, format!("unknown message type {other}"));
+ session.send(reply.reply_to(env.id)).await?;
+ }
+ // Unknown one-way messages are ignored (forward compatibility).
+ }
+ }
+ Ok(())
+}
+
+async fn heartbeat(session: &Arc<Session>, shared: &Weak<Shared>) {
+ let started = Instant::now();
+ let mut interval = tokio::time::interval(HEARTBEAT_INTERVAL);
+ interval.set_missed_tick_behavior(tokio::time::MissedTickBehavior::Delay);
+ loop {
+ interval.tick().await;
+ let sent_at = Instant::now();
+ let ts = sent_at.duration_since(started).as_millis() as u64;
+ let Ok(ping) = Envelope::new(types::PING, &Ping { ts }) else { continue };
+ match session.request(ping, REQUEST_TIMEOUT).await {
+ Ok(reply) if reply.t == types::PONG => {
+ let rtt = sent_at.elapsed().as_millis().min(u32::MAX as u128) as u32;
+ let previous = session.rtt_ms.swap(rtt, Ordering::Relaxed);
+ if let Some(shared) = shared.upgrade()
+ && previous.abs_diff(rtt) >= 5
+ {
+ shared.publish_online(session);
+ }
+ }
+ Ok(_) => {}
+ // QUIC keep-alives and idle timeouts detect dead links; a missed
+ // ping is not fatal on its own.
+ Err(e) => tracing::debug!(peer = %session.peer.short(), error = %e, "heartbeat failed"),
+ }
+ }
+}
diff --git a/core/nectarlink-core/src/store.rs b/core/nectarlink-core/src/store.rs
new file mode 100644
index 0000000..4e7ab3f
--- /dev/null
+++ b/core/nectarlink-core/src/store.rs
@@ -0,0 +1,280 @@
+// SPDX-License-Identifier: MPL-2.0
+//! SQLite storage: the trust store of paired devices and their last known
+//! addresses.
+
+use std::{net::SocketAddr, path::Path, sync::Mutex};
+
+use nectarlink_protocol::{
+ DeviceId,
+ messages::{DeviceInfo, DeviceKind},
+};
+use rusqlite::{Connection, OptionalExtension, params};
+
+use crate::{Error, Result};
+
+const FILE_NAME: &str = "nectarlink.db";
+
+/// Schema migrations, applied in order. Index + 1 is the schema version.
+const MIGRATIONS: &[&str] = &[
+ // v1: trust store
+ "CREATE TABLE peers (
+ id BLOB PRIMARY KEY NOT NULL CHECK (length(id) = 32),
+ name TEXT NOT NULL,
+ kind TEXT NOT NULL,
+ os TEXT NOT NULL,
+ os_ver TEXT NOT NULL,
+ model TEXT,
+ accent INTEGER,
+ paired_at INTEGER NOT NULL,
+ last_seen INTEGER,
+ last_addrs TEXT NOT NULL DEFAULT ''
+ ) STRICT;",
+];
+
+/// A paired device as stored on disk.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub(crate) struct PeerRecord {
+ pub id: DeviceId,
+ pub info: DeviceInfo,
+ pub paired_at: i64,
+ pub last_seen: Option<i64>,
+ pub last_addrs: Vec<SocketAddr>,
+}
+
+#[derive(Debug)]
+pub(crate) struct Store {
+ conn: Mutex<Connection>,
+}
+
+impl Store {
+ pub fn open(dir: &Path) -> Result<Self> {
+ Self::init(Connection::open(dir.join(FILE_NAME))?)
+ }
+
+ #[cfg(test)]
+ pub fn in_memory() -> Result<Self> {
+ Self::init(Connection::open_in_memory()?)
+ }
+
+ fn init(conn: Connection) -> Result<Self> {
+ conn.pragma_update(None, "journal_mode", "WAL")?;
+ conn.pragma_update(None, "foreign_keys", "ON")?;
+ migrate(&conn)?;
+ Ok(Store { conn: Mutex::new(conn) })
+ }
+
+ fn with<T>(&self, f: impl FnOnce(&Connection) -> rusqlite::Result<T>) -> Result<T> {
+ let conn = self.conn.lock().map_err(|_| Error::Internal("store lock poisoned".into()))?;
+ f(&conn).map_err(Error::from)
+ }
+
+ /// Adds or replaces a paired device.
+ pub fn upsert_peer(&self, id: &DeviceId, info: &DeviceInfo, paired_at: i64) -> Result<()> {
+ self.with(|c| {
+ c.execute(
+ "INSERT INTO peers (id, name, kind, os, os_ver, model, accent, paired_at)
+ VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8)
+ ON CONFLICT(id) DO UPDATE SET
+ name = excluded.name, kind = excluded.kind, os = excluded.os,
+ os_ver = excluded.os_ver, model = excluded.model, accent = excluded.accent,
+ paired_at = excluded.paired_at",
+ params![
+ id.as_bytes().as_slice(),
+ info.name,
+ kind_to_str(info.kind),
+ info.os,
+ info.os_ver,
+ info.model,
+ info.accent.map(i64::from),
+ paired_at
+ ],
+ )
+ .map(drop)
+ })
+ }
+
+ /// Updates the stored description of a device (e.g. after a rename).
+ pub fn update_info(&self, id: &DeviceId, info: &DeviceInfo) -> Result<()> {
+ self.with(|c| {
+ c.execute(
+ "UPDATE peers SET name = ?2, kind = ?3, os = ?4, os_ver = ?5, model = ?6, accent = ?7
+ WHERE id = ?1",
+ params![
+ id.as_bytes().as_slice(),
+ info.name,
+ kind_to_str(info.kind),
+ info.os,
+ info.os_ver,
+ info.model,
+ info.accent.map(i64::from)
+ ],
+ )
+ .map(drop)
+ })
+ }
+
+ /// Records a successful connection and the peer's current direct addresses.
+ pub fn record_seen(&self, id: &DeviceId, at: i64, addrs: &[SocketAddr]) -> Result<()> {
+ let addrs: Vec<String> = addrs.iter().map(ToString::to_string).collect();
+ self.with(|c| {
+ c.execute(
+ "UPDATE peers SET last_seen = ?2, last_addrs = ?3 WHERE id = ?1",
+ params![id.as_bytes().as_slice(), at, addrs.join(",")],
+ )
+ .map(drop)
+ })
+ }
+
+ /// Removes a device. Returns whether it existed.
+ pub fn remove_peer(&self, id: &DeviceId) -> Result<bool> {
+ self.with(|c| c.execute("DELETE FROM peers WHERE id = ?1", [id.as_bytes().as_slice()]).map(|n| n > 0))
+ }
+
+ pub fn get_peer(&self, id: &DeviceId) -> Result<Option<PeerRecord>> {
+ self.with(|c| {
+ c.query_row(&format!("{SELECT} WHERE id = ?1"), [id.as_bytes().as_slice()], row_to_peer)
+ .optional()
+ })
+ }
+
+ pub fn is_paired(&self, id: &DeviceId) -> Result<bool> {
+ Ok(self.get_peer(id)?.is_some())
+ }
+
+ pub fn list_peers(&self) -> Result<Vec<PeerRecord>> {
+ self.with(|c| {
+ let mut stmt = c.prepare(&format!("{SELECT} ORDER BY paired_at"))?;
+ stmt.query_map([], row_to_peer)?.collect()
+ })
+ }
+}
+
+const SELECT: &str =
+ "SELECT id, name, kind, os, os_ver, model, accent, paired_at, last_seen, last_addrs FROM peers";
+
+fn row_to_peer(row: &rusqlite::Row<'_>) -> rusqlite::Result<PeerRecord> {
+ let id: Vec<u8> = row.get(0)?;
+ let id: [u8; 32] = id
+ .try_into()
+ .map_err(|_| rusqlite::Error::InvalidColumnType(0, "id".into(), rusqlite::types::Type::Blob))?;
+ let kind: String = row.get(2)?;
+ let accent: Option<i64> = row.get(6)?;
+ let addrs: String = row.get(9)?;
+ Ok(PeerRecord {
+ id: DeviceId(id),
+ info: DeviceInfo {
+ name: row.get(1)?,
+ kind: kind_from_str(&kind),
+ os: row.get(3)?,
+ os_ver: row.get(4)?,
+ model: row.get(5)?,
+ accent: accent.and_then(|a| u32::try_from(a).ok()),
+ },
+ paired_at: row.get(7)?,
+ last_seen: row.get(8)?,
+ // Skip entries that no longer parse instead of failing the whole read.
+ last_addrs: addrs.split(',').filter_map(|a| a.parse().ok()).collect(),
+ })
+}
+
+fn kind_to_str(kind: DeviceKind) -> &'static str {
+ match kind {
+ DeviceKind::Phone => "phone",
+ DeviceKind::Tablet => "tablet",
+ DeviceKind::Desktop => "desktop",
+ DeviceKind::Laptop => "laptop",
+ DeviceKind::Unknown => "unknown",
+ }
+}
+
+fn kind_from_str(kind: &str) -> DeviceKind {
+ match kind {
+ "phone" => DeviceKind::Phone,
+ "tablet" => DeviceKind::Tablet,
+ "desktop" => DeviceKind::Desktop,
+ "laptop" => DeviceKind::Laptop,
+ _ => DeviceKind::Unknown,
+ }
+}
+
+fn migrate(conn: &Connection) -> Result<()> {
+ let current: i64 = conn.query_row("PRAGMA user_version", [], |r| r.get(0))?;
+ let current = usize::try_from(current).unwrap_or(usize::MAX);
+ if current > MIGRATIONS.len() {
+ return Err(Error::Storage(format!(
+ "the database was created by a newer Nectarlink (schema {current}); please update"
+ )));
+ }
+ for (index, sql) in MIGRATIONS.iter().enumerate().skip(current) {
+ let version = index + 1;
+ let tx = conn.unchecked_transaction()?;
+ tx.execute_batch(sql)?;
+ tx.pragma_update(None, "user_version", version as i64)?;
+ tx.commit()?;
+ tracing::debug!(version, "applied storage migration");
+ }
+ Ok(())
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn info(name: &str) -> DeviceInfo {
+ DeviceInfo {
+ name: name.into(),
+ kind: DeviceKind::Phone,
+ os: "android".into(),
+ os_ver: "16".into(),
+ model: None,
+ accent: Some(0xFF8A5100),
+ }
+ }
+
+ #[test]
+ fn peer_lifecycle() {
+ let store = Store::in_memory().unwrap();
+ let id = DeviceId([1; 32]);
+ assert!(!store.is_paired(&id).unwrap());
+
+ store.upsert_peer(&id, &info("Pixel"), 100).unwrap();
+ let peer = store.get_peer(&id).unwrap().unwrap();
+ assert_eq!(peer.info, info("Pixel"));
+ assert_eq!(peer.paired_at, 100);
+ assert_eq!(peer.last_seen, None);
+ assert!(peer.last_addrs.is_empty());
+
+ let addrs: Vec<SocketAddr> =
+ vec!["10.0.0.2:41641".parse().unwrap(), "[fe80::2]:41641".parse().unwrap()];
+ store.record_seen(&id, 200, &addrs).unwrap();
+ store.update_info(&id, &info("Pixel 9")).unwrap();
+ let peer = store.get_peer(&id).unwrap().unwrap();
+ assert_eq!(peer.last_seen, Some(200));
+ assert_eq!(peer.last_addrs, addrs);
+ assert_eq!(peer.info.name, "Pixel 9");
+
+ assert!(store.remove_peer(&id).unwrap());
+ assert!(!store.remove_peer(&id).unwrap());
+ assert!(store.list_peers().unwrap().is_empty());
+ }
+
+ #[test]
+ fn lists_in_pairing_order_and_persists() {
+ let dir = tempfile::tempdir().unwrap();
+ {
+ let store = Store::open(dir.path()).unwrap();
+ store.upsert_peer(&DeviceId([2; 32]), &info("second"), 20).unwrap();
+ store.upsert_peer(&DeviceId([1; 32]), &info("first"), 10).unwrap();
+ }
+ let store = Store::open(dir.path()).unwrap();
+ let names: Vec<_> = store.list_peers().unwrap().into_iter().map(|p| p.info.name).collect();
+ assert_eq!(names, ["first", "second"]);
+ }
+
+ #[test]
+ fn refuses_a_database_from_a_newer_version() {
+ let conn = Connection::open_in_memory().unwrap();
+ conn.pragma_update(None, "user_version", 99).unwrap();
+ assert!(matches!(Store::init(conn), Err(Error::Storage(_))));
+ }
+}
diff --git a/core/nectarlink-core/tests/two_devices.rs b/core/nectarlink-core/tests/two_devices.rs
new file mode 100644
index 0000000..a4a933c
--- /dev/null
+++ b/core/nectarlink-core/tests/two_devices.rs
@@ -0,0 +1,327 @@
+// SPDX-License-Identifier: MPL-2.0
+//! End-to-end tests: two real nodes talking over localhost.
+
+use std::{
+ future::Future,
+ net::SocketAddr,
+ sync::{Arc, Mutex},
+ time::Duration,
+};
+
+use nectarlink_core::{
+ Battery, DeviceInfo, DeviceKind, Error, LinkState, Node, NodeConfig, NodeEvent, PairingEvent,
+ PairingFailure, PairingUri, PlainKeyProtector, Platform,
+};
+use tempfile::TempDir;
+use tokio::sync::broadcast::Receiver;
+
+const WAIT: Duration = Duration::from_secs(20);
+
+#[derive(Debug, Default)]
+struct RecordingPlatform {
+ rings: Mutex<Vec<bool>>,
+}
+
+impl Platform for RecordingPlatform {
+ fn start_ringing(&self) {
+ self.rings.lock().unwrap().push(true);
+ }
+ fn stop_ringing(&self) {
+ self.rings.lock().unwrap().push(false);
+ }
+}
+
+struct TestDevice {
+ node: Node,
+ events: Receiver<NodeEvent>,
+ platform: Arc<RecordingPlatform>,
+ dir: TempDir,
+ name: &'static str,
+}
+
+fn info(name: &str, kind: DeviceKind) -> DeviceInfo {
+ DeviceInfo {
+ name: name.into(),
+ kind,
+ os: if kind == DeviceKind::Phone { "android" } else { "windows" }.into(),
+ os_ver: "test".into(),
+ model: None,
+ accent: None,
+ }
+}
+
+fn init_logging() {
+ // Set RUST_LOG=nectarlink_core=debug to see what the nodes are doing.
+ let _ = tracing_subscriber::fmt()
+ .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
+ .with_test_writer()
+ .try_init();
+}
+
+async fn start_in(dir: TempDir, name: &'static str, kind: DeviceKind) -> TestDevice {
+ init_logging();
+ let mut config = NodeConfig::new(dir.path(), info(name, kind), "0.0.1-test");
+ config.lan_discovery = false;
+ config.away_mode = false;
+ config.key_protector = Some(Arc::new(PlainKeyProtector));
+ let platform = Arc::new(RecordingPlatform::default());
+ let node = Node::start(config, platform.clone()).await.expect("node starts");
+ let events = node.events();
+ TestDevice { node, events, platform, dir, name }
+}
+
+async fn device(name: &'static str, kind: DeviceKind) -> TestDevice {
+ start_in(tempfile::tempdir().unwrap(), name, kind).await
+}
+
+/// Waits for the first event matching `pick`, failing the test on timeout.
+async fn wait_for<T>(dev: &mut TestDevice, what: &str, mut pick: impl FnMut(&NodeEvent) -> Option<T>) -> T {
+ let deadline = tokio::time::Instant::now() + WAIT;
+ loop {
+ let remaining = deadline.saturating_duration_since(tokio::time::Instant::now());
+ match tokio::time::timeout(remaining, dev.events.recv()).await {
+ Ok(Ok(event)) => {
+ if let Some(found) = pick(&event) {
+ return found;
+ }
+ }
+ Ok(Err(tokio::sync::broadcast::error::RecvError::Lagged(_))) => continue,
+ Ok(Err(e)) => panic!("{}: event stream ended while waiting for {what}: {e}", dev.name),
+ Err(_) => panic!("{}: timed out waiting for {what}", dev.name),
+ }
+ }
+}
+
+async fn wait_online(dev: &mut TestDevice, peer: nectarlink_core::DeviceId) {
+ wait_for(dev, "peer online", |e| match e {
+ NodeEvent::LinkChanged { device, link: LinkState::Online { .. } } if *device == peer => Some(()),
+ _ => None,
+ })
+ .await
+}
+
+async fn with_timeout<T>(what: &str, fut: impl Future<Output = T>) -> T {
+ tokio::time::timeout(WAIT, fut).await.unwrap_or_else(|_| panic!("timed out: {what}"))
+}
+
+/// Pairs `phone` with `pc` through the QR flow and waits until both are online.
+async fn pair_qr(pc: &mut TestDevice, phone: &mut TestDevice) {
+ let uri = pc.node.pairing_start_qr().await.unwrap();
+ assert!(!uri.addrs.is_empty(), "pairing link should carry direct addresses");
+ with_timeout("join", phone.node.pairing_join(&uri.to_uri())).await.expect("pairing succeeds");
+
+ let (pc_id, phone_id) = (pc.node.device_id(), phone.node.device_id());
+ wait_for(pc, "paired", |e| match e {
+ NodeEvent::Pairing(PairingEvent::Paired(d)) if d.id == phone_id => Some(()),
+ _ => None,
+ })
+ .await;
+ wait_online(phone, pc_id).await;
+ wait_online(pc, phone_id).await;
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn qr_pairing_connects_both_devices() {
+ let mut pc = device("Desktop", DeviceKind::Desktop).await;
+ let mut phone = device("Pixel", DeviceKind::Phone).await;
+ pair_qr(&mut pc, &mut phone).await;
+
+ assert!(!pc.node.is_pairing(), "pairing mode ends after a successful pairing");
+ let pc_peers = pc.node.paired_devices().unwrap();
+ assert_eq!(pc_peers.len(), 1);
+ assert_eq!(pc_peers[0].id, phone.node.device_id());
+ assert_eq!(pc_peers[0].info.name, "Pixel");
+ assert!(matches!(pc_peers[0].link, LinkState::Online { .. }));
+
+ let phone_peers = phone.node.paired_devices().unwrap();
+ assert_eq!(phone_peers.len(), 1);
+ assert_eq!(phone_peers[0].info.name, "Desktop");
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn ring_and_battery_flow_between_devices() {
+ let mut pc = device("Desktop", DeviceKind::Desktop).await;
+ let mut phone = device("Pixel", DeviceKind::Phone).await;
+ pair_qr(&mut pc, &mut phone).await;
+ let (pc_id, phone_id) = (pc.node.device_id(), phone.node.device_id());
+
+ with_timeout("ring", pc.node.ring(phone_id, true)).await.expect("ring succeeds");
+ with_timeout("stop ring", pc.node.ring(phone_id, false)).await.expect("stop succeeds");
+ assert_eq!(*phone.platform.rings.lock().unwrap(), vec![true, false]);
+
+ let battery = Battery { level: 82, charging: true, plugged: Some("usb".into()) };
+ phone.node.update_battery(battery.clone()).await;
+ let received = wait_for(&mut pc, "battery", |e| match e {
+ NodeEvent::Battery { device, battery } if *device == phone_id => Some(battery.clone()),
+ _ => None,
+ })
+ .await;
+ assert_eq!(received, battery);
+
+ let mut renamed = info("Pixel 9 Pro", DeviceKind::Phone);
+ renamed.accent = Some(0xFF65558F);
+ phone.node.update_device_info(renamed.clone()).await;
+ let info = wait_for(&mut pc, "rename", |e| match e {
+ NodeEvent::PeerInfoChanged { device, info } if *device == phone_id && info.name == "Pixel 9 Pro" => {
+ Some(info.clone())
+ }
+ _ => None,
+ })
+ .await;
+ assert_eq!(info, renamed);
+ assert_eq!(pc.node.paired_devices().unwrap()[0].info.name, "Pixel 9 Pro", "rename is persisted");
+ let _ = pc_id;
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn wrong_pairing_secret_is_rejected() {
+ let pc = device("Desktop", DeviceKind::Desktop).await;
+ let phone = device("Pixel", DeviceKind::Phone).await;
+
+ let mut uri = pc.node.pairing_start_qr().await.unwrap();
+ uri.secret[0] ^= 0xFF; // as if an attacker guessed or altered the code
+ let result = with_timeout("join", phone.node.pairing_join(&uri.to_uri())).await;
+ assert!(matches!(result, Err(Error::Denied)), "got {result:?}");
+ assert!(pc.node.paired_devices().unwrap().is_empty());
+ assert!(phone.node.paired_devices().unwrap().is_empty());
+ assert!(pc.node.is_pairing(), "a single wrong attempt doesn't end pairing mode");
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn pairing_requires_pairing_mode() {
+ let pc = device("Desktop", DeviceKind::Desktop).await;
+ let phone = device("Pixel", DeviceKind::Phone).await;
+
+ // A link for the right device, but the PC isn't showing a code.
+ let uri = PairingUri {
+ id: pc.node.device_id(),
+ secret: [1; 16],
+ name: "Desktop".into(),
+ addrs: pc.node.direct_addrs().await,
+ };
+ let result = with_timeout("join", phone.node.pairing_join(&uri.to_uri())).await;
+ assert!(result.is_err(), "pairing without pairing mode must fail");
+ assert!(pc.node.paired_devices().unwrap().is_empty());
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn too_many_wrong_attempts_end_pairing_mode() {
+ let mut pc = device("Desktop", DeviceKind::Desktop).await;
+ let phone = device("Pixel", DeviceKind::Phone).await;
+ let mut uri = pc.node.pairing_start_qr().await.unwrap();
+ uri.secret[3] ^= 1;
+ for _ in 0..5 {
+ let _ = with_timeout("join", phone.node.pairing_join(&uri.to_uri())).await;
+ }
+ wait_for(&mut pc, "pairing failure", |e| match e {
+ NodeEvent::Pairing(PairingEvent::Failed(PairingFailure::Rejected)) => Some(()),
+ _ => None,
+ })
+ .await;
+ assert!(!pc.node.is_pairing());
+}
+
+async fn sas_code(dev: &mut TestDevice) -> String {
+ wait_for(dev, "6-digit code", |e| match e {
+ NodeEvent::Pairing(PairingEvent::SasCode { code, .. }) => Some(code.clone()),
+ _ => None,
+ })
+ .await
+}
+
+async fn start_nearby_setup() -> (TestDevice, TestDevice, Vec<SocketAddr>) {
+ let pc = device("Desktop", DeviceKind::Desktop).await;
+ let phone = device("Pixel", DeviceKind::Phone).await;
+ // The PC shows its pairing screen; the phone picks it from the nearby list.
+ pc.node.pairing_start_qr().await.unwrap();
+ let addrs = pc.node.direct_addrs().await;
+ phone.node.add_known_addrs(pc.node.device_id(), &addrs);
+ (pc, phone, addrs)
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn nearby_pairing_with_matching_codes() {
+ let (mut pc, mut phone, _) = start_nearby_setup().await;
+ let pc_id = pc.node.device_id();
+ let initiator = phone.node.clone();
+ let task = tokio::spawn(async move { initiator.pairing_start_nearby(pc_id).await });
+
+ let (phone_code, pc_code) = (sas_code(&mut phone).await, sas_code(&mut pc).await);
+ assert_eq!(phone_code, pc_code, "both screens show the same code");
+ assert_eq!(phone_code.len(), 6);
+
+ phone.node.pairing_confirm(true).unwrap();
+ pc.node.pairing_confirm(true).unwrap();
+ with_timeout("nearby pairing", task).await.unwrap().expect("pairing succeeds");
+
+ wait_online(&mut phone, pc_id).await;
+ assert_eq!(pc.node.paired_devices().unwrap().len(), 1);
+ assert_eq!(phone.node.paired_devices().unwrap().len(), 1);
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn nearby_pairing_fails_if_either_user_declines() {
+ let (mut pc, mut phone, _) = start_nearby_setup().await;
+ let pc_id = pc.node.device_id();
+ let initiator = phone.node.clone();
+ let task = tokio::spawn(async move { initiator.pairing_start_nearby(pc_id).await });
+
+ sas_code(&mut phone).await;
+ sas_code(&mut pc).await;
+ phone.node.pairing_confirm(true).unwrap();
+ pc.node.pairing_confirm(false).unwrap(); // codes didn't match on the PC
+
+ let result = with_timeout("nearby pairing", task).await.unwrap();
+ assert!(matches!(result, Err(Error::Denied)), "the phone learns the PC rejected: {result:?}");
+ wait_for(&mut pc, "declined", |e| match e {
+ NodeEvent::Pairing(PairingEvent::Failed(PairingFailure::Declined)) => Some(()),
+ _ => None,
+ })
+ .await;
+ assert!(pc.node.paired_devices().unwrap().is_empty());
+ assert!(phone.node.paired_devices().unwrap().is_empty());
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn unpairing_is_mirrored_on_the_other_device() {
+ let mut pc = device("Desktop", DeviceKind::Desktop).await;
+ let mut phone = device("Pixel", DeviceKind::Phone).await;
+ pair_qr(&mut pc, &mut phone).await;
+ let pc_id = pc.node.device_id();
+
+ with_timeout("unpair", phone.node.unpair(pc_id)).await.unwrap();
+ let phone_id = phone.node.device_id();
+ wait_for(&mut pc, "device removed", |e| match e {
+ NodeEvent::DeviceRemoved(id) if *id == phone_id => Some(()),
+ _ => None,
+ })
+ .await;
+ assert!(pc.node.paired_devices().unwrap().is_empty());
+ assert!(phone.node.paired_devices().unwrap().is_empty());
+ assert!(matches!(pc.node.ring(phone_id, true).await, Err(Error::NotPaired)));
+}
+
+#[tokio::test(flavor = "multi_thread")]
+async fn reconnects_after_a_restart() {
+ let mut pc = device("Desktop", DeviceKind::Desktop).await;
+ let mut phone = device("Pixel", DeviceKind::Phone).await;
+ pair_qr(&mut pc, &mut phone).await;
+ let (pc_id, phone_id) = (pc.node.device_id(), phone.node.device_id());
+
+ // The phone restarts (app update, reboot...).
+ phone.node.shutdown().await;
+ wait_for(&mut pc, "peer offline", |e| match e {
+ NodeEvent::LinkChanged { device, link: LinkState::Offline { .. } } if *device == phone_id => Some(()),
+ _ => None,
+ })
+ .await;
+
+ let dir = std::mem::replace(&mut phone.dir, tempfile::tempdir().unwrap());
+ let mut phone = start_in(dir, "Pixel", DeviceKind::Phone).await;
+ assert_eq!(phone.node.device_id(), phone_id, "identity survives the restart");
+ assert_eq!(phone.node.paired_devices().unwrap().len(), 1, "pairing survives the restart");
+
+ wait_online(&mut phone, pc_id).await;
+ wait_online(&mut pc, phone_id).await;
+ with_timeout("ring after reconnect", pc.node.ring(phone_id, true)).await.expect("ring works again");
+}