diff --git a/Cargo.lock b/Cargo.lock index 43194fd7..c20b2cf8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -38,7 +38,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac8202ab55fcbf46ca829833f347a82a2a4ce0596f0304ac322c2d100030cd56" dependencies = [ "bytes", - "crypto-common 0.2.0-rc.4", + "crypto-common", "inout", ] @@ -339,15 +339,6 @@ dependencies = [ "constant_time_eq", ] -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "block-buffer" version = "0.11.0-rc.5" @@ -358,12 +349,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "bounded-integer" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "102dbef1187b1893e6dfe05a774e79fd52265f49f214f6879c8ff49f52c8188b" - [[package]] name = "btparse" version = "0.2.0" @@ -442,7 +427,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-link", + "windows-link 0.1.3", ] [[package]] @@ -451,8 +436,8 @@ version = "0.5.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e12a13eb01ded5d32ee9658d94f553a19e804204f2dc811df69ab4d9e0cb8c7" dependencies = [ - "block-buffer 0.11.0-rc.5", - "crypto-common 0.2.0-rc.4", + "block-buffer", + "crypto-common", "inout", "zeroize", ] @@ -612,21 +597,6 @@ dependencies = [ "libc", ] -[[package]] -name = "crc" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" - [[package]] name = "critical-section" version = "1.2.0" @@ -657,16 +627,6 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - [[package]] name = "crypto-common" version = "0.2.0-rc.4" @@ -718,7 +678,7 @@ dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", - "digest 0.11.0-rc.3", + "digest", "fiat-crypto", "rand_core 0.9.3", "rustc_version", @@ -751,22 +711,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9d8dd2f26c86b27a2a8ea2767ec7f9df7a89516e4794e54ac01ee618dda3aa4" dependencies = [ "const-oid", - "der_derive", "pem-rfc7468", "zeroize", ] -[[package]] -name = "der_derive" -version = "0.8.0-rc.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be645fee2afe89d293b96c19e4456e6ac69520fc9c6b8a58298550138e361ffe" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - [[package]] name = "deranged" version = "0.4.0" @@ -836,25 +784,15 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab03c107fafeb3ee9f5925686dbb7a73bc76e3932abb0d2b365cb64b169cf04c" -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "crypto-common 0.1.6", - "subtle", -] - [[package]] name = "digest" version = "0.11.0-rc.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dac89f8a64533a9b0eaa73a68e424db0fb1fd6271c74cc0125336a05f090568d" dependencies = [ - "block-buffer 0.11.0-rc.5", - "crypto-common 0.2.0-rc.4", + "block-buffer", + "const-oid", + "crypto-common", ] [[package]] @@ -915,7 +853,7 @@ dependencies = [ "ed25519", "rand_core 0.9.3", "serde", - "sha2 0.11.0-rc.2", + "sha2", "signature", "subtle", "zeroize", @@ -945,26 +883,6 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "enumflags2" -version = "0.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" -dependencies = [ - "enumflags2_derive", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.104", -] - [[package]] name = "equivalent" version = "1.0.2" @@ -981,12 +899,6 @@ dependencies = [ "windows-sys 0.60.2", ] -[[package]] -name = "fallible-iterator" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" - [[package]] name = "fastrand" version = "2.3.0" @@ -1177,17 +1089,7 @@ dependencies = [ "libc", "log", "rustversion", - "windows", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", + "windows 0.61.3", ] [[package]] @@ -1223,12 +1125,6 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" -[[package]] -name = "glob" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" - [[package]] name = "gloo-timers" version = "0.3.0" @@ -1359,37 +1255,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "hmac-sha1" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b05da5b9e5d4720bfb691eebb2b9d42da3570745da71eac8a1f5bb7e59aab88" -dependencies = [ - "hmac", - "sha1", -] - -[[package]] -name = "hmac-sha256" -version = "1.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad6880c8d4a9ebf39c6e8b77007ce223f646a4d21ce29d99f70cb16420545425" - -[[package]] -name = "hostname-validator" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f558a64ac9af88b5ba400d99b579451af0d39c6d360980045b91aac966d705e2" - [[package]] name = "http" version = "1.3.1" @@ -1481,7 +1346,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", - "webpki-roots 1.0.2", + "webpki-roots", ] [[package]] @@ -1520,7 +1385,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core", + "windows-core 0.61.2", ] [[package]] @@ -1741,9 +1606,9 @@ dependencies = [ [[package]] name = "iroh" -version = "0.93.0" +version = "0.94.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50369f3db3f3fbc2cc14fc1baab2f3ee16e0abd89eca0b814258d02a6a13040c" +checksum = "b9428cef1eafd2eac584269986d1949e693877ac12065b401dfde69f664b07ac" dependencies = [ "aead", "backon", @@ -1751,10 +1616,8 @@ dependencies = [ "cfg_aliases", "crypto_box", "data-encoding", - "der", "derive_more 2.0.1", "ed25519-dalek", - "futures-buffered", "futures-util", "getrandom 0.3.3", "hickory-resolver", @@ -1767,11 +1630,11 @@ dependencies = [ "iroh-quinn-proto", "iroh-quinn-udp", "iroh-relay", - "n0-future 0.1.3", + "n0-future", "n0-snafu", "n0-watcher", "nested_enum_utils", - "netdev 0.36.0", + "netdev", "netwatch", "pin-project", "pkarr", @@ -1779,16 +1642,14 @@ dependencies = [ "portmapper", "rand 0.9.2", "reqwest", - "ring", "rustls", "rustls-pki-types", + "rustls-platform-verifier", "rustls-webpki", "serde", "smallvec", "snafu", "strum", - "stun-rs", - "surge-ping", "swarm-discovery", "time", "tokio", @@ -1797,15 +1658,15 @@ dependencies = [ "tracing", "url", "wasm-bindgen-futures", - "webpki-roots 0.26.11", + "webpki-roots", "z32", ] [[package]] name = "iroh-base" -version = "0.93.0" +version = "0.94.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "929fbe14046dfb01b41ccccaa5b476549924daa54438518bda11a9ab1598b2a9" +checksum = "db942f6f3d6fa9b475690c6e8e6684d60591dd886bf1bdfef4c60d89d502215c" dependencies = [ "curve25519-dalek", "data-encoding", @@ -1813,11 +1674,12 @@ dependencies = [ "ed25519-dalek", "n0-snafu", "nested_enum_utils", - "postcard", "rand_core 0.9.3", "serde", "snafu", "url", + "zeroize", + "zeroize_derive", ] [[package]] @@ -1844,8 +1706,9 @@ dependencies = [ "iroh-metrics", "iroh-quinn", "iroh-test", + "iroh-tickets", "irpc", - "n0-future 0.2.0", + "n0-future", "n0-snafu", "nested_enum_utils", "postcard", @@ -1969,9 +1832,9 @@ dependencies = [ [[package]] name = "iroh-relay" -version = "0.93.0" +version = "0.94.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbc49e535c2cf410d19f82d46dac2b3d0bff1763759a28cd1c67870085f2fc4" +checksum = "360e201ab1803201de9a125dd838f7a4d13e6ba3a79aeb46c7fbf023266c062e" dependencies = [ "blake3", "bytes", @@ -1989,7 +1852,7 @@ dependencies = [ "iroh-quinn", "iroh-quinn-proto", "lru 0.16.1", - "n0-future 0.1.3", + "n0-future", "n0-snafu", "nested_enum_utils", "num_enum", @@ -2000,7 +1863,6 @@ dependencies = [ "reqwest", "rustls", "rustls-pki-types", - "rustls-webpki", "serde", "serde_bytes", "sha1", @@ -2012,7 +1874,7 @@ dependencies = [ "tokio-websockets", "tracing", "url", - "webpki-roots 0.26.11", + "webpki-roots", "ws_stream_wasm", "z32", ] @@ -2029,18 +1891,34 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "iroh-tickets" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7683c7819693eb8b3d61d1d45ffa92e2faeb07762eb0c3debb50ad795538d221" +dependencies = [ + "data-encoding", + "derive_more 2.0.1", + "iroh-base", + "n0-snafu", + "nested_enum_utils", + "postcard", + "serde", + "snafu", +] + [[package]] name = "irpc" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e3fc4aa2bc2c1002655fab4254390f016f8b9bb65390600f9d8b11f9bdac76d" +checksum = "52cf44fdb253f2a3e22e5ecfa8efa466929f8b7cdd4fc0f958f655406e8cdab6" dependencies = [ "anyhow", "futures-buffered", "futures-util", "iroh-quinn", "irpc-derive", - "n0-future 0.1.3", + "n0-future", "postcard", "rcgen", "rustls", @@ -2054,13 +1932,13 @@ dependencies = [ [[package]] name = "irpc-derive" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f5706d47257e3f40b9e7dbc1934942b5792cc6a8670b7dda8856c2f5709cf98" +checksum = "969df6effc474e714fb7e738eb9859aa22f40dc2280cadeab245817075c7f273" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.104", ] [[package]] @@ -2215,12 +2093,6 @@ dependencies = [ "regex-automata", ] -[[package]] -name = "md5" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771" - [[package]] name = "memchr" version = "2.7.5" @@ -2268,30 +2140,9 @@ dependencies = [ [[package]] name = "n0-future" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bb0e5d99e681ab3c938842b96fcb41bf8a7bb4bfdb11ccbd653a7e83e06c794" -dependencies = [ - "cfg_aliases", - "derive_more 1.0.0", - "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-future" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d7dd42bd0114c9daa9c4f2255d692a73bba45767ec32cf62892af6fe5d31f6" +checksum = "439e746b307c1fd0c08771c3cafcd1746c3ccdb0d9c7b859d3caded366b6da76" dependencies = [ "cfg_aliases", "derive_more 1.0.0", @@ -2323,12 +2174,12 @@ dependencies = [ [[package]] name = "n0-watcher" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31462392a10d5ada4b945e840cbec2d5f3fee752b96c4b33eb41414d8f45c2a" +checksum = "34c65e127e06e5a2781b28df6a33ea474a7bddc0ac0cfea888bd20c79a1b6516" dependencies = [ - "derive_more 1.0.0", - "n0-future 0.1.3", + "derive_more 2.0.1", + "n0-future", "snafu", ] @@ -2346,32 +2197,15 @@ dependencies = [ [[package]] name = "netdev" -version = "0.36.0" +version = "0.38.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "862209dce034f82a44c95ce2b5183730d616f2a68746b9c1959aa2572e77c0a1" +checksum = "67ab878b4c90faf36dab10ea51d48c69ae9019bcca47c048a7c9b273d5d7a823" dependencies = [ "dlopen2", "ipnet", "libc", "netlink-packet-core", - "netlink-packet-route 0.22.0", - "netlink-sys", - "once_cell", - "system-configuration", - "windows-sys 0.59.0", -] - -[[package]] -name = "netdev" -version = "0.37.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa1e3eaf125c54c21e6221df12dd2a0a682784a068782dd564c836c0f281b6d" -dependencies = [ - "dlopen2", - "ipnet", - "libc", - "netlink-packet-core", - "netlink-packet-route 0.22.0", + "netlink-packet-route", "netlink-sys", "once_cell", "system-configuration", @@ -2380,62 +2214,30 @@ dependencies = [ [[package]] name = "netlink-packet-core" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4" -dependencies = [ - "anyhow", - "byteorder", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-route" -version = "0.22.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0e7987b28514adf555dc1f9a5c30dfc3e50750bbaffb1aec41ca7b23dcd8e4" +checksum = "3463cbb78394cb0141e2c926b93fc2197e473394b761986eca3b9da2c63ae0f4" dependencies = [ - "anyhow", - "bitflags", - "byteorder", - "libc", - "log", - "netlink-packet-core", - "netlink-packet-utils", + "paste", ] [[package]] name = "netlink-packet-route" -version = "0.24.0" +version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d83370a96813d7c977f8b63054f1162df6e5784f1c598d689236564fb5a6f2" +checksum = "3ec2f5b6839be2a19d7fa5aab5bc444380f6311c2b693551cb80f45caaa7b5ef" dependencies = [ - "anyhow", "bitflags", - "byteorder", "libc", "log", "netlink-packet-core", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-utils" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" -dependencies = [ - "anyhow", - "byteorder", - "paste", - "thiserror 1.0.69", ] [[package]] name = "netlink-proto" -version = "0.11.5" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72452e012c2f8d612410d89eea01e2d9b56205274abb35d53f60200b2ec41d60" +checksum = "b65d130ee111430e47eed7896ea43ca693c387f097dd97376bffafbf25812128" dependencies = [ "bytes", "futures", @@ -2460,9 +2262,9 @@ dependencies = [ [[package]] name = "netwatch" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a63d76f52f3f15ebde3ca751a2ab73a33ae156662bc04383bac8e824f84e9bb" +checksum = "98d7ec7abdbfe67ee70af3f2002326491178419caea22254b9070e6ff0c83491" dependencies = [ "atomic-waker", "bytes", @@ -2471,12 +2273,12 @@ dependencies = [ "iroh-quinn-udp", "js-sys", "libc", - "n0-future 0.1.3", + "n0-future", "n0-watcher", "nested_enum_utils", - "netdev 0.37.3", + "netdev", "netlink-packet-core", - "netlink-packet-route 0.24.0", + "netlink-packet-route", "netlink-proto", "netlink-sys", "pin-project-lite", @@ -2488,17 +2290,11 @@ dependencies = [ "tokio-util", "tracing", "web-sys", - "windows", - "windows-result", + "windows 0.62.2", + "windows-result 0.4.1", "wmi", ] -[[package]] -name = "no-std-net" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43794a0ace135be66a25d3ae77d41b91615fb68ae937f904090203e81f755b65" - [[package]] name = "ntimestamp" version = "1.0.0" @@ -2651,50 +2447,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" -[[package]] -name = "pest" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323" -dependencies = [ - "memchr", - "thiserror 2.0.12", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.104", -] - -[[package]] -name = "pest_meta" -version = "2.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5" -dependencies = [ - "pest", - "sha2 0.10.9", -] - [[package]] name = "pharos" version = "0.5.3" @@ -2778,48 +2530,6 @@ dependencies = [ "spki", ] -[[package]] -name = "pnet_base" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe4cf6fb3ab38b68d01ab2aea03ed3d1132b4868fa4e06285f29f16da01c5f4c" -dependencies = [ - "no-std-net", -] - -[[package]] -name = "pnet_macros" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "688b17499eee04a0408aca0aa5cba5fc86401d7216de8a63fdf7a4c227871804" -dependencies = [ - "proc-macro2", - "quote", - "regex", - "syn 2.0.104", -] - -[[package]] -name = "pnet_macros_support" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eea925b72f4bd37f8eab0f221bbe4c78b63498350c983ffa9dd4bcde7e030f56" -dependencies = [ - "pnet_base", -] - -[[package]] -name = "pnet_packet" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9a005825396b7fe7a38a8e288dbc342d5034dac80c15212436424fef8ea90ba" -dependencies = [ - "glob", - "pnet_base", - "pnet_macros", - "pnet_macros_support", -] - [[package]] name = "poly1305" version = "0.9.0-rc.2" @@ -2838,9 +2548,9 @@ checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" [[package]] name = "portmapper" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90f7313cafd74e95e6a358c1d0a495112f175502cc2e69870d0a5b12b6553059" +checksum = "d73aa9bd141e0ff6060fea89a5437883f3b9ceea1cda71c790b90e17d072a3b3" dependencies = [ "base64", "bytes", @@ -2926,40 +2636,6 @@ dependencies = [ "zerocopy", ] -[[package]] -name = "precis-core" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c2e7b31f132e0c6f8682cfb7bf4a5340dbe925b7986618d0826a56dfe0c8e56" -dependencies = [ - "precis-tools", - "ucd-parse", - "unicode-normalization", -] - -[[package]] -name = "precis-profiles" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4f67f78f50388f03494794766ba824a704db16fb5d400fe8d545fa7bc0d3f1" -dependencies = [ - "lazy_static", - "precis-core", - "precis-tools", - "unicode-normalization", -] - -[[package]] -name = "precis-tools" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6cc1eb2d5887ac7bfd2c0b745764db89edb84b856e4214e204ef48ef96d10c4a" -dependencies = [ - "lazy_static", - "regex", - "ucd-parse", -] - [[package]] name = "proc-macro-crate" version = "3.3.0" @@ -3100,16 +2776,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "quoted-string-parser" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dc75379cdb451d001f1cb667a9f74e8b355e9df84cc5193513cbe62b96fc5e9" -dependencies = [ - "pest", - "pest_derive", -] - [[package]] name = "r-efi" version = "5.3.0" @@ -3199,9 +2865,9 @@ dependencies = [ [[package]] name = "rcgen" -version = "0.13.2" +version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75e669e5202259b5314d1ea5397316ad400819437857b90861765f24c4cf80a2" +checksum = "5fae430c6b28f1ad601274e78b7dffa0546de0b73b4cd32f46723c0c2a16f7a5" dependencies = [ "pem", "ring", @@ -3257,19 +2923,7 @@ dependencies = [ "cfg-if", "libc", "rustix", - "windows", -] - -[[package]] -name = "regex" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", + "windows 0.61.3", ] [[package]] @@ -3283,12 +2937,6 @@ dependencies = [ "regex-syntax", ] -[[package]] -name = "regex-lite" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" - [[package]] name = "regex-syntax" version = "0.8.5" @@ -3333,7 +2981,7 @@ dependencies = [ "wasm-bindgen-futures", "wasm-streams", "web-sys", - "webpki-roots 1.0.2", + "webpki-roots", ] [[package]] @@ -3392,9 +3040,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.29" +version = "0.23.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1" +checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c" dependencies = [ "log", "once_cell", @@ -3456,9 +3104,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.103.4" +version = "0.103.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +checksum = "e10b3f4191e8a80e6b43eebabfac91e5dcecebb27a71f04e820c47ec41d314bf" dependencies = [ "ring", "rustls-pki-types", @@ -3572,10 +3220,11 @@ checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" [[package]] name = "serde" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" dependencies = [ + "serde_core", "serde_derive", ] @@ -3588,11 +3237,20 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + [[package]] name = "serde_derive" -version = "1.0.219" +version = "1.0.228" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", @@ -3644,13 +3302,13 @@ dependencies = [ [[package]] name = "sha1" -version = "0.10.6" +version = "0.11.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +checksum = "c5e046edf639aa2e7afb285589e5405de2ef7e61d4b0ac1e30256e3eab911af9" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.10.7", + "digest", ] [[package]] @@ -3659,17 +3317,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" -[[package]] -name = "sha2" -version = "0.10.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - [[package]] name = "sha2" version = "0.11.0-rc.2" @@ -3678,7 +3325,7 @@ checksum = "d1e3878ab0f98e35b2df35fe53201d088299b41a6bb63e3e34dada2ac4abd924" dependencies = [ "cfg-if", "cpufeatures", - "digest 0.11.0-rc.3", + "digest", ] [[package]] @@ -3749,9 +3396,9 @@ checksum = "fad6c857cbab2627dcf01ec85a623ca4e7dcb5691cbaa3d7fb7653671f0d09c9" [[package]] name = "snafu" -version = "0.8.6" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "320b01e011bf8d5d7a4a4a4be966d9160968935849c83b918827f6a435e7f627" +checksum = "6e84b3f4eacbf3a1ce05eac6763b4d629d60cbc94d632e4092c54ade71f1e1a2" dependencies = [ "backtrace", "snafu-derive", @@ -3759,9 +3406,9 @@ dependencies = [ [[package]] name = "snafu-derive" -version = "0.8.6" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1961e2ef424c1424204d3a5d6975f934f56b6d50ff5732382d84ebf460e147f7" +checksum = "c1c97747dbf44bb1ca44a561ece23508e99cb592e862f22222dcf42f51d1e451" dependencies = [ "heck", "proc-macro2", @@ -3870,52 +3517,12 @@ dependencies = [ "syn 2.0.104", ] -[[package]] -name = "stun-rs" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb921f10397d5669e1af6455e9e2d367bf1f9cebcd6b1dd1dc50e19f6a9ac2ac" -dependencies = [ - "base64", - "bounded-integer", - "byteorder", - "crc", - "enumflags2", - "fallible-iterator", - "hmac-sha1", - "hmac-sha256", - "hostname-validator", - "lazy_static", - "md5", - "paste", - "precis-core", - "precis-profiles", - "quoted-string-parser", - "rand 0.9.2", -] - [[package]] name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "surge-ping" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fda78103d8016bb25c331ddc54af634e801806463682cc3e549d335df644d95" -dependencies = [ - "hex", - "parking_lot", - "pnet_packet", - "rand 0.9.2", - "socket2 0.5.10", - "thiserror 1.0.69", - "tokio", - "tracing", -] - [[package]] name = "swarm-discovery" version = "0.4.0" @@ -4405,21 +4012,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" -[[package]] -name = "ucd-parse" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06ff81122fcbf4df4c1660b15f7e3336058e7aec14437c9f85c6b31a0f279b9" -dependencies = [ - "regex-lite", -] - -[[package]] -name = "ucd-trie" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" - [[package]] name = "unarray" version = "0.1.4" @@ -4432,15 +4024,6 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" -[[package]] -name = "unicode-normalization" -version = "0.1.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-xid" version = "0.2.6" @@ -4453,7 +4036,7 @@ version = "0.6.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a55be643b40a21558f44806b53ee9319595bc7ca6896372e4e08e5d7d83c9cd6" dependencies = [ - "crypto-common 0.2.0-rc.4", + "crypto-common", "subtle", ] @@ -4677,18 +4260,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" -dependencies = [ - "webpki-roots 1.0.2", -] - -[[package]] -name = "webpki-roots" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +checksum = "32b130c0d2d49f8b6889abc456e795e82525204f27c42cf767cf0d7734e089b8" dependencies = [ "rustls-pki-types", ] @@ -4736,11 +4310,23 @@ version = "0.61.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" dependencies = [ - "windows-collections", - "windows-core", - "windows-future", - "windows-link", - "windows-numerics", + "windows-collections 0.2.0", + "windows-core 0.61.2", + "windows-future 0.2.1", + "windows-link 0.1.3", + "windows-numerics 0.2.0", +] + +[[package]] +name = "windows" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580" +dependencies = [ + "windows-collections 0.3.2", + "windows-core 0.62.2", + "windows-future 0.3.2", + "windows-numerics 0.3.1", ] [[package]] @@ -4749,7 +4335,16 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-core", + "windows-core 0.61.2", +] + +[[package]] +name = "windows-collections" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610" +dependencies = [ + "windows-core 0.62.2", ] [[package]] @@ -4760,9 +4355,22 @@ checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" dependencies = [ "windows-implement", "windows-interface", - "windows-link", - "windows-result", - "windows-strings", + "windows-link 0.1.3", + "windows-result 0.3.4", + "windows-strings 0.4.2", +] + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link 0.2.1", + "windows-result 0.4.1", + "windows-strings 0.5.1", ] [[package]] @@ -4771,16 +4379,27 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" dependencies = [ - "windows-core", - "windows-link", - "windows-threading", + "windows-core 0.61.2", + "windows-link 0.1.3", + "windows-threading 0.1.0", +] + +[[package]] +name = "windows-future" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", + "windows-threading 0.2.1", ] [[package]] name = "windows-implement" -version = "0.60.0" +version = "0.60.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", @@ -4789,9 +4408,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.59.1" +version = "0.59.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", @@ -4804,14 +4423,30 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + [[package]] name = "windows-numerics" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-core", - "windows-link", + "windows-core 0.61.2", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-numerics" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26" +dependencies = [ + "windows-core 0.62.2", + "windows-link 0.2.1", ] [[package]] @@ -4820,7 +4455,16 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" dependencies = [ - "windows-link", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -4829,7 +4473,16 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" dependencies = [ - "windows-link", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -4929,7 +4582,7 @@ version = "0.53.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" dependencies = [ - "windows-link", + "windows-link 0.1.3", "windows_aarch64_gnullvm 0.53.0", "windows_aarch64_msvc 0.53.0", "windows_i686_gnu 0.53.0", @@ -4946,7 +4599,16 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" dependencies = [ - "windows-link", + "windows-link 0.1.3", +] + +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link 0.2.1", ] [[package]] @@ -5168,8 +4830,8 @@ dependencies = [ "log", "serde", "thiserror 2.0.12", - "windows", - "windows-core", + "windows 0.61.3", + "windows-core 0.61.2", ] [[package]] @@ -5294,9 +4956,23 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.8.1" +version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] [[package]] name = "zerotrie" diff --git a/Cargo.toml b/Cargo.toml index 3b3fae05..e8a22c80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ bytes = { version = "1", features = ["serde"] } derive_more = { version = "2.0.1", features = ["from", "try_from", "into", "debug", "display", "deref", "deref_mut"] } futures-lite = "2.6.0" quinn = { package = "iroh-quinn", version = "0.14.0" } -n0-future = "0.2.0" +n0-future = "0.3.0" n0-snafu = "0.2.2" range-collections = { version = "0.4.6", features = ["serde"] } smallvec = { version = "1", features = ["serde", "const_new"] } @@ -36,11 +36,12 @@ chrono = "0.4.39" nested_enum_utils = "0.2.1" ref-cast = "1.0.24" arrayvec = "0.7.6" -iroh = "0.93" +iroh = "0.94" self_cell = "1.1.0" genawaiter = { version = "0.99.1", features = ["futures03"] } -iroh-base = "0.93" -irpc = { version = "0.9.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false } +iroh-base = "0.94" +iroh-tickets = "0.1" +irpc = { version = "0.10.0", features = ["rpc", "quinn_endpoint_setup", "spans", "stream", "derive"], default-features = false } iroh-metrics = { version = "0.36" } redb = { version = "2.6.3", optional = true } reflink-copy = { version = "0.1.24", optional = true } @@ -59,7 +60,7 @@ tracing-subscriber = { version = "0.3.20", features = ["fmt"] } tracing-test = "0.2.5" walkdir = "2.5.0" atomic_refcell = "0.1.13" -iroh = { version = "0.93", features = ["discovery-local-network"]} +iroh = { version = "0.94", features = ["discovery-local-network"]} async-compression = { version = "0.4.30", features = ["lz4", "tokio"] } concat_const = "0.2.0" diff --git a/README.md b/README.md index a3a26f23..0153f326 100644 --- a/README.md +++ b/README.md @@ -40,14 +40,14 @@ use iroh_blobs::{store::mem::MemStore, BlobsProtocol, ticket::BlobTicket}; async fn main() -> anyhow::Result<()> { // create an iroh endpoint that includes the standard discovery mechanisms // we've built at number0 - let endpoint = Endpoint::builder().discovery_n0().bind().await?; + let endpoint = Endpoint::bind().await?; // create a protocol handler using an in-memory blob store. let store = MemStore::new(); let tag = store.add_slice(b"Hello world").await?; let _ = endpoint.online().await; - let addr = endpoint.node_addr(); + let addr = endpoint.addr(); let ticket = BlobTicket::new(addr, tag.hash, tag.format); // build the router diff --git a/examples/compression.rs b/examples/compression.rs index 343209cd..eb83f91d 100644 --- a/examples/compression.rs +++ b/examples/compression.rs @@ -27,7 +27,7 @@ use crate::common::get_or_generate_secret_key; #[derive(Debug, Parser)] #[command(version, about)] pub enum Args { - /// Limit requests by node id + /// Limit requests by endpoint id Provide { /// Path for files to add. path: PathBuf, @@ -160,7 +160,7 @@ impl ProtocolHandler for CompressedBlobsProtocol { .events .client_connected(|| ClientConnected { connection_id, - node_id: connection.remote_node_id().ok(), + endpoint_id: connection.remote_id().ok(), }) .await { @@ -184,11 +184,7 @@ async fn main() -> Result<()> { setup_logging(); let args = Args::parse(); let secret = get_or_generate_secret_key()?; - let endpoint = iroh::Endpoint::builder() - .secret_key(secret) - .discovery_n0() - .bind() - .await?; + let endpoint = iroh::Endpoint::builder().secret_key(secret).bind().await?; let compression = lz4::Compression; match args { Args::Provide { path } => { @@ -198,7 +194,7 @@ async fn main() -> Result<()> { let router = iroh::protocol::Router::builder(endpoint.clone()) .accept(lz4::Compression::ALPN, blobs) .spawn(); - let ticket = BlobTicket::new(endpoint.node_id().into(), tag.hash, tag.format); + let ticket = BlobTicket::new(endpoint.id().into(), tag.hash, tag.format); println!("Serving blob with hash {}", tag.hash); println!("Ticket: {ticket}"); println!("Node is running. Press Ctrl-C to exit."); @@ -209,7 +205,7 @@ async fn main() -> Result<()> { Args::Get { ticket, target } => { let store = MemStore::new(); let conn = endpoint - .connect(ticket.node_addr().clone(), lz4::Compression::ALPN) + .connect(ticket.addr().clone(), lz4::Compression::ALPN) .await?; let connection_id = conn.stable_id() as u64; let (send, recv) = conn.open_bi().await?; diff --git a/examples/custom-protocol.rs b/examples/custom-protocol.rs index 2ba2899b..6d782f19 100644 --- a/examples/custom-protocol.rs +++ b/examples/custom-protocol.rs @@ -17,13 +17,13 @@ //! //! cargo run --example custom-protocol -- listen "hello-world" "foo-bar" "hello-moon" //! -//! This spawns an iroh nodes with three blobs. It will print the node's node id. +//! This spawns an iroh node with three blobs. It will print the node's endpoint id. //! //! In another terminal, run //! -//! cargo run --example custom-protocol -- query hello +//! cargo run --example custom-protocol -- query hello //! -//! Replace with the node id from above. This will connect to the listening node with our +//! Replace with the endpoint id from above. This will connect to the listening node with our //! custom protocol and query for the string `hello`. The listening node will return a list of //! blob hashes that contain `hello`. We will then download all these blobs with iroh-blobs, //! and then print a list of the hashes with their content. @@ -46,7 +46,7 @@ use iroh::{ discovery::pkarr::PkarrResolver, endpoint::Connection, protocol::{AcceptError, ProtocolHandler, Router}, - Endpoint, NodeId, + Endpoint, EndpointId, }; use iroh_blobs::{api::Store, store::mem::MemStore, BlobsProtocol, Hash}; mod common; @@ -67,8 +67,8 @@ pub enum Command { }, /// Query a remote node for data and print the results. Query { - /// The node id of the node we want to query. - node_id: NodeId, + /// The endpoint id of the node we want to query. + endpoint_id: EndpointId, /// The text we want to match. query: String, }, @@ -81,17 +81,13 @@ pub enum Command { const ALPN: &[u8] = b"iroh-example/text-search/0"; async fn listen(text: Vec) -> Result<()> { - // allow the user to provide a secret so we can have a stable node id. + // allow the user to provide a secret so we can have a stable endpoint id. // This is only needed for the listen side. let secret_key = get_or_generate_secret_key()?; // Use an in-memory store for this example. You would use a persistent store in production code. let store = MemStore::new(); // Create an endpoint with the secret key and discovery publishing to the n0 dns server enabled. - let endpoint = Endpoint::builder() - .secret_key(secret_key) - .discovery_n0() - .bind() - .await?; + let endpoint = Endpoint::builder().secret_key(secret_key).bind().await?; // Build our custom protocol handler. The `builder` exposes access to various subsystems in the // iroh node. In our case, we need a blobs client and the endpoint. let proto = BlobSearch::new(&store); @@ -108,9 +104,9 @@ async fn listen(text: Vec) -> Result<()> { .accept(iroh_blobs::ALPN, blobs.clone()) .spawn(); - // Print our node id, so clients know how to connect to us. - let node_id = node.endpoint().node_id(); - println!("our node id: {node_id}"); + // Print our endpoint id, so clients know how to connect to us. + let node_id = node.endpoint().id(); + println!("our endpoint id: {node_id}"); // Wait for Ctrl-C to be pressed. tokio::signal::ctrl_c().await?; @@ -118,20 +114,20 @@ async fn listen(text: Vec) -> Result<()> { Ok(()) } -async fn query(node_id: NodeId, query: String) -> Result<()> { +async fn query(endpoint_id: EndpointId, query: String) -> Result<()> { // Build a in-memory node. For production code, you'd want a persistent node instead usually. let store = MemStore::new(); // Create an endpoint with a random secret key and no discovery publishing. // For a client we just need discovery resolution via the n0 dns server, which // the PkarrResolver provides. - let endpoint = Endpoint::builder() - .add_discovery(PkarrResolver::n0_dns()) + let endpoint = Endpoint::empty_builder(iroh::RelayMode::Default) + .discovery(PkarrResolver::n0_dns()) .bind() .await?; // Query the remote node. // This will send the query over our custom protocol, read hashes on the reply stream, // and download each hash over iroh-blobs. - let hashes = query_remote(&endpoint, &store, node_id, &query).await?; + let hashes = query_remote(&endpoint, &store, endpoint_id, &query).await?; // Print out our query results. for hash in hashes { @@ -157,10 +153,10 @@ async fn main() -> Result<()> { listen(text).await?; } Command::Query { - node_id, + endpoint_id, query: query_text, } => { - query(node_id, query_text).await?; + query(endpoint_id, query_text).await?; } } @@ -180,8 +176,8 @@ impl ProtocolHandler for BlobSearch { /// the connection lasts. async fn accept(&self, connection: Connection) -> std::result::Result<(), AcceptError> { let this = self.clone(); - // We can get the remote's node id from the connection. - let node_id = connection.remote_node_id()?; + // We can get the remote's endpoint id from the connection. + let node_id = connection.remote_id()?; println!("accepted connection from {node_id}"); // Our protocol is a simple request-response protocol, so we expect the @@ -269,14 +265,14 @@ impl BlobSearch { pub async fn query_remote( endpoint: &Endpoint, store: &Store, - node_id: NodeId, + endpoint_id: EndpointId, query: &str, ) -> Result> { // Establish a connection to our node. - // We use the default node discovery in iroh, so we can connect by node id without + // We use the default node discovery in iroh, so we can connect by endpoint id without // providing further information. - let conn = endpoint.connect(node_id, ALPN).await?; - let blobs_conn = endpoint.connect(node_id, iroh_blobs::ALPN).await?; + let conn = endpoint.connect(endpoint_id, ALPN).await?; + let blobs_conn = endpoint.connect(endpoint_id, iroh_blobs::ALPN).await?; // Open a bi-directional in our connection. let (mut send, mut recv) = conn.open_bi().await?; diff --git a/examples/get-blob.rs b/examples/get-blob.rs index 0c6ea135..bfaa409a 100644 --- a/examples/get-blob.rs +++ b/examples/get-blob.rs @@ -29,7 +29,7 @@ async fn main() -> anyhow::Result<()> { setup_logging(); let cli = Cli::parse(); let ticket = cli.ticket; - let endpoint = iroh::Endpoint::builder() + let endpoint = iroh::Endpoint::empty_builder(iroh::RelayMode::Default) .discovery(PkarrResolver::n0_dns()) .bind() .await?; @@ -37,9 +37,7 @@ async fn main() -> anyhow::Result<()> { ticket.format() == BlobFormat::Raw, "This example only supports raw blobs." ); - let connection = endpoint - .connect(ticket.node_addr().node_id, iroh_blobs::ALPN) - .await?; + let connection = endpoint.connect(ticket.addr().id, iroh_blobs::ALPN).await?; let mut progress = iroh_blobs::get::request::get_blob(connection, ticket.hash()); let stats = if cli.progress { loop { diff --git a/examples/limit.rs b/examples/limit.rs index e44aeeb7..4a9a379e 100644 --- a/examples/limit.rs +++ b/examples/limit.rs @@ -1,4 +1,4 @@ -/// Example how to limit blob requests by hash and node id, and to add +/// Example how to limit blob requests by hash and endpoint id, and to add /// throttling or limiting the maximum number of connections. /// /// Limiting is done via a fn that returns an EventSender and internally @@ -21,7 +21,7 @@ use std::{ use anyhow::Result; use clap::Parser; use common::setup_logging; -use iroh::{protocol::Router, NodeAddr, NodeId, SecretKey}; +use iroh::{protocol::Router, EndpointAddr, EndpointId, SecretKey}; use iroh_blobs::{ provider::events::{ AbortReason, ConnectMode, EventMask, EventSender, ProviderMessage, RequestMode, @@ -38,14 +38,14 @@ use crate::common::get_or_generate_secret_key; #[derive(Debug, Parser)] #[command(version, about)] pub enum Args { - /// Limit requests by node id - ByNodeId { + /// Limit requests by endpoint id + ByEndpointId { /// Path for files to add. paths: Vec, #[clap(long("allow"))] - /// Nodes that are allowed to download content. - allowed_nodes: Vec, - /// Number of secrets to generate for allowed node ids. + /// Endpoints that are allowed to download content. + allowed_endpoints: Vec, + /// Number of secrets to generate for allowed endpoint ids. #[clap(long, default_value_t = 1)] secrets: usize, }, @@ -77,7 +77,7 @@ pub enum Args { }, } -fn limit_by_node_id(allowed_nodes: HashSet) -> EventSender { +fn limit_by_node_id(allowed_nodes: HashSet) -> EventSender { let mask = EventMask { // We want a request for each incoming connection so we can accept // or reject them. We don't need any other events. @@ -88,17 +88,17 @@ fn limit_by_node_id(allowed_nodes: HashSet) -> EventSender { n0_future::task::spawn(async move { while let Some(msg) = rx.recv().await { if let ProviderMessage::ClientConnected(msg) = msg { - let res = match msg.node_id { - Some(node_id) if allowed_nodes.contains(&node_id) => { - println!("Client connected: {node_id}"); + let res: std::result::Result<(), AbortReason> = match msg.endpoint_id { + Some(endpoint_id) if allowed_nodes.contains(&endpoint_id) => { + println!("Client connected: {endpoint_id}"); Ok(()) } - Some(node_id) => { - println!("Client rejected: {node_id}"); + Some(endpoint_id) => { + println!("Client rejected: {endpoint_id}"); Err(AbortReason::Permission) } None => { - println!("Client rejected: no node id"); + println!("Client rejected: no endpoint id"); Err(AbortReason::Permission) } }; @@ -206,7 +206,7 @@ fn limit_max_connections(max_connections: usize) -> EventSender { match msg { ProviderMessage::ClientConnected(msg) => { let connection_id = msg.connection_id; - let node_id = msg.node_id; + let node_id = msg.endpoint_id; let res = if let Ok(n) = requests.inc() { println!("Accepting connection {n}, node_id {node_id:?}, connection_id {connection_id}"); Ok(()) @@ -231,15 +231,11 @@ async fn main() -> Result<()> { setup_logging(); let args = Args::parse(); let secret = get_or_generate_secret_key()?; - let endpoint = iroh::Endpoint::builder() - .secret_key(secret) - .discovery_n0() - .bind() - .await?; + let endpoint = iroh::Endpoint::builder().secret_key(secret).bind().await?; match args { Args::Get { ticket } => { let connection = endpoint - .connect(ticket.node_addr().clone(), iroh_blobs::ALPN) + .connect(ticket.addr().clone(), iroh_blobs::ALPN) .await?; let (data, stats) = iroh_blobs::get::request::get_blob(connection, ticket.hash()) .bytes_and_stats() @@ -247,26 +243,26 @@ async fn main() -> Result<()> { println!("Downloaded {} bytes", data.len()); println!("Stats: {stats:?}"); } - Args::ByNodeId { + Args::ByEndpointId { paths, - allowed_nodes, + allowed_endpoints, secrets, } => { - let mut allowed_nodes = allowed_nodes.into_iter().collect::>(); + let mut allowed_endpoints = allowed_endpoints.into_iter().collect::>(); if secrets > 0 { - println!("Generating {secrets} new secret keys for allowed nodes:"); + println!("Generating {secrets} new secret keys for allowed endpoints:"); let mut rand = rng(); for _ in 0..secrets { let secret = SecretKey::generate(&mut rand); let public = secret.public(); - allowed_nodes.insert(public); + allowed_endpoints.insert(public); println!("IROH_SECRET={}", hex::encode(secret.to_bytes())); } } let store = MemStore::new(); let hashes = add_paths(&store, paths).await?; - let events = limit_by_node_id(allowed_nodes.clone()); + let events = limit_by_node_id(allowed_endpoints.clone()); let (router, addr) = setup(store, events).await?; for (path, hash) in hashes { @@ -274,9 +270,9 @@ async fn main() -> Result<()> { println!("{}: {ticket}", path.display()); } println!(); - println!("Node id: {}\n", router.endpoint().node_id()); - for id in &allowed_nodes { - println!("Allowed node: {id}"); + println!("Endpoint id: {}\n", router.endpoint().id()); + for id in &allowed_endpoints { + println!("Allowed endpoint: {id}"); } tokio::signal::ctrl_c().await?; @@ -350,15 +346,11 @@ async fn add_paths(store: &MemStore, paths: Vec) -> Result Result<(Router, NodeAddr)> { +async fn setup(store: MemStore, events: EventSender) -> Result<(Router, EndpointAddr)> { let secret = get_or_generate_secret_key()?; - let endpoint = iroh::Endpoint::builder() - .discovery_n0() - .secret_key(secret) - .bind() - .await?; + let endpoint = iroh::Endpoint::builder().secret_key(secret).bind().await?; endpoint.online().await; - let addr = endpoint.node_addr(); + let addr = endpoint.addr(); let blobs = BlobsProtocol::new(&store, Some(events)); let router = Router::builder(endpoint) .accept(iroh_blobs::ALPN, blobs) diff --git a/examples/mdns-discovery.rs b/examples/mdns-discovery.rs index 4266b75a..638042ea 100644 --- a/examples/mdns-discovery.rs +++ b/examples/mdns-discovery.rs @@ -40,8 +40,8 @@ pub enum Commands { /// Get the node_id and hash string from a node running accept in the local network /// Download the content from that node. Connect { - /// Node ID of a node on the local network - node_id: PublicKey, + /// Endpoint ID of a node on the local network + endpoint_id: PublicKey, /// Hash of content you want to download from the node hash: Hash, /// save the content to a file @@ -60,9 +60,9 @@ async fn accept(path: &Path) -> Result<()> { println!("Starting iroh node with mdns discovery..."); // create a new node - let endpoint = Endpoint::builder() + let endpoint = Endpoint::empty_builder(RelayMode::Default) .secret_key(key) - .add_discovery(MdnsDiscovery::builder()) + .discovery(MdnsDiscovery::builder()) .relay_mode(RelayMode::Disabled) .bind() .await?; @@ -80,7 +80,7 @@ async fn accept(path: &Path) -> Result<()> { let absolute = path.canonicalize()?; println!("Adding {} as {}...", path.display(), absolute.display()); let tag = store.add_path(absolute).await?; - println!("To fetch the blob:\n\tcargo run --example mdns-discovery --features examples -- connect {} {} -o [FILE_PATH]", node.endpoint().node_id(), tag.hash); + println!("To fetch the blob:\n\tcargo run --example mdns-discovery --features examples -- connect {} {} -o [FILE_PATH]", node.endpoint().id(), tag.hash); tokio::signal::ctrl_c().await?; node.shutdown().await?; Ok(()) @@ -93,15 +93,14 @@ async fn connect(node_id: PublicKey, hash: Hash, out: Option) -> Result println!("Starting iroh node with mdns discovery..."); // create a new node - let endpoint = Endpoint::builder() + let endpoint = Endpoint::empty_builder(RelayMode::Disabled) .secret_key(key) - .add_discovery(discovery) - .relay_mode(RelayMode::Disabled) + .discovery(discovery) .bind() .await?; let store = MemStore::new(); - println!("NodeID: {}", endpoint.node_id()); + println!("NodeID: {}", endpoint.id()); let conn = endpoint.connect(node_id, iroh_blobs::ALPN).await?; let stats = store.remote().fetch(conn, hash).await?; println!( @@ -136,8 +135,12 @@ async fn main() -> anyhow::Result<()> { Commands::Accept { path } => { accept(path).await?; } - Commands::Connect { node_id, hash, out } => { - connect(*node_id, *hash, out.clone()).await?; + Commands::Connect { + endpoint_id, + hash, + out, + } => { + connect(*endpoint_id, *hash, out.clone()).await?; } } Ok(()) diff --git a/examples/random_store.rs b/examples/random_store.rs index 7d9233f3..dd1dc6f0 100644 --- a/examples/random_store.rs +++ b/examples/random_store.rs @@ -3,7 +3,6 @@ use std::{env, path::PathBuf, str::FromStr}; use anyhow::{Context, Result}; use clap::{Parser, Subcommand}; use iroh::{discovery::static_provider::StaticProvider, SecretKey}; -use iroh_base::ticket::NodeTicket; use iroh_blobs::{ api::downloader::Shuffled, provider::events::{AbortReason, EventMask, EventSender, ProviderMessage}, @@ -11,6 +10,7 @@ use iroh_blobs::{ test::{add_hash_sequences, create_random_blobs}, HashAndFormat, }; +use iroh_tickets::endpoint::EndpointTicket; use irpc::RpcMessage; use n0_future::StreamExt; use rand::{rngs::StdRng, Rng, SeedableRng}; @@ -80,7 +80,7 @@ pub struct RequestArgs { pub content: Vec, /// Nodes to request from - pub nodes: Vec, + pub nodes: Vec, /// Split large requests #[arg(long, default_value_t = false)] @@ -242,8 +242,8 @@ async fn provide(args: ProvideArgs) -> anyhow::Result<()> { let router = iroh::protocol::Router::builder(endpoint.clone()) .accept(iroh_blobs::ALPN, blobs) .spawn(); - let addr = router.endpoint().node_addr(); - let ticket = NodeTicket::from(addr.clone()); + let addr = router.endpoint().addr(); + let ticket = EndpointTicket::from(addr.clone()); println!("Node address: {addr:?}"); println!("ticket:\n{ticket}"); ctrl_c().await?; @@ -272,12 +272,12 @@ async fn request(args: RequestArgs) -> anyhow::Result<()> { .await?; let downloader = store.downloader(&endpoint); for ticket in &args.nodes { - sp.add_node_info(ticket.node_addr().clone()); + sp.add_endpoint_info(ticket.endpoint_addr().clone()); } let nodes = args .nodes .iter() - .map(|ticket| ticket.node_addr().node_id) + .map(|ticket| ticket.endpoint_addr().id) .collect::>(); for content in args.content { let mut progress = downloader diff --git a/examples/transfer-collection.rs b/examples/transfer-collection.rs index 506a95ea..73fea9cd 100644 --- a/examples/transfer-collection.rs +++ b/examples/transfer-collection.rs @@ -8,7 +8,9 @@ use std::collections::HashMap; use anyhow::{Context, Result}; -use iroh::{discovery::static_provider::StaticProvider, protocol::Router, Endpoint, NodeAddr}; +use iroh::{ + discovery::static_provider::StaticProvider, protocol::Router, Endpoint, EndpointAddr, RelayMode, +}; use iroh_blobs::{ api::{downloader::Shuffled, Store, TempTag}, format::collection::Collection, @@ -27,8 +29,8 @@ struct Node { impl Node { async fn new(disc: &StaticProvider) -> Result { - let endpoint = Endpoint::builder() - .add_discovery(disc.clone()) + let endpoint = Endpoint::empty_builder(RelayMode::Default) + .discovery(disc.clone()) .bind() .await?; @@ -51,9 +53,9 @@ impl Node { // get address of this node. Has the side effect of waiting for the node // to be online & ready to accept connections - async fn node_addr(&self) -> Result { + async fn node_addr(&self) -> Result { self.router.endpoint().online().await; - let addr = self.router.endpoint().node_addr(); + let addr = self.router.endpoint().addr(); Ok(addr) } @@ -90,9 +92,9 @@ impl Node { } /// retrieve an entire collection from a given hash and provider - async fn get_collection(&self, hash: Hash, provider: NodeAddr) -> Result<()> { + async fn get_collection(&self, hash: Hash, provider: EndpointAddr) -> Result<()> { let req = HashAndFormat::hash_seq(hash); - let addrs = Shuffled::new(vec![provider.node_id]); + let addrs = Shuffled::new(vec![provider.id]); self.store .downloader(self.router.endpoint()) .download(req, addrs) @@ -105,7 +107,7 @@ impl Node { async fn main() -> anyhow::Result<()> { // create a local provider for nodes to discover each other. // outside of a development environment, production apps would - // use `Endpoint::builder().discovery_n0()` or a similar method + // use `Endpoint::bind()` or a similar method let disc = StaticProvider::new(); // create a sending node @@ -124,7 +126,7 @@ async fn main() -> anyhow::Result<()> { let recv_node = Node::new(&disc).await?; // add the send node to the discovery provider so the recv node can find it - disc.add_node_info(send_node_addr.clone()); + disc.add_endpoint_info(send_node_addr.clone()); // fetch the collection and all contents recv_node.get_collection(hash, send_node_addr).await?; diff --git a/examples/transfer.rs b/examples/transfer.rs index 76e768d2..65bc7db3 100644 --- a/examples/transfer.rs +++ b/examples/transfer.rs @@ -7,7 +7,7 @@ use iroh_blobs::{store::mem::MemStore, ticket::BlobTicket, BlobsProtocol}; async fn main() -> anyhow::Result<()> { // Create an endpoint, it allows creating and accepting // connections in the iroh p2p world - let endpoint = Endpoint::builder().discovery_n0().bind().await?; + let endpoint = Endpoint::bind().await?; // We initialize an in-memory backing store for iroh-blobs let store = MemStore::new(); @@ -30,7 +30,7 @@ async fn main() -> anyhow::Result<()> { // and allows us to control when/if it gets garbage-collected let tag = store.blobs().add_path(abs_path).await?; - let node_id = endpoint.node_id(); + let node_id = endpoint.id(); let ticket = BlobTicket::new(node_id.into(), tag.hash, tag.format); println!("File hashed. Fetch this file by running:"); @@ -63,7 +63,7 @@ async fn main() -> anyhow::Result<()> { println!("Starting download."); downloader - .download(ticket.hash(), Some(ticket.node_addr().node_id)) + .download(ticket.hash(), Some(ticket.addr().id)) .await?; println!("Finished download."); diff --git a/proptest-regressions/store/fs/util/entity_manager.txt b/proptest-regressions/store/fs/util/entity_manager.txt index 7d4e8e8f..d0398f75 100644 --- a/proptest-regressions/store/fs/util/entity_manager.txt +++ b/proptest-regressions/store/fs/util/entity_manager.txt @@ -6,3 +6,4 @@ # everyone who runs the test benefits from these saved cases. cc 0f2ebc49ab2f84e112f08407bb94654fbcb1f19050a4a8a6196383557696438a # shrinks to input = _TestCountersManagerProptestFsArgs { entries: [(15313427648878534792, 264348813928009031854006459208395772047), (1642534478798447378, 15989109311941500072752977306696275871), (8755041673862065815, 172763711808688570294350362332402629716), (4993597758667891804, 114145440157220458287429360639759690928), (15031383154962489250, 63217081714858286463391060323168548783), (17668469631267503333, 11878544422669770587175118199598836678), (10507570291819955314, 126584081645379643144412921692654648228), (3979008599365278329, 283717221942996985486273080647433218905), (8316838360288996639, 334043288511621783152802090833905919408), (15673798930962474157, 77551315511802713260542200115027244708), (12058791254144360414, 56638044274259821850511200885092637649), (8191628769638031337, 314181956273420400069887649110740549194), (6290369460137232066, 255779791286732775990301011955519176773), (11919824746661852269, 319400891587146831511371932480749645441), (12491631698789073154, 271279849791970841069522263758329847554), (53891048909263304, 12061234604041487609497959407391945555), (9486366498650667097, 311383186592430597410801882015456718030), (15696332331789302593, 306911490707714340526403119780178604150), (8699088947997536151, 312272624973367009520183311568498652066), (1144772544750976199, 200591877747619565555594857038887015), (5907208586200645081, 299942008952473970881666769409865744975), (3384528743842518913, 26230956866762934113564101494944411446), (13877357832690956494, 229457597607752760006918374695475345151), (2965687966026226090, 306489188264741716662410004273408761623), (13624286905717143613, 232801392956394366686194314010536008033), (3622356130274722018, 162030840677521022192355139208505458492), (17807768575470996347, 264107246314713159406963697924105744409), (5103434150074147746, 331686166459964582006209321975587627262), (5962771466034321974, 300961804728115777587520888809168362574), (2930645694242691907, 127752709774252686733969795258447263979), (16197574560597474644, 245410120683069493317132088266217906749), (12478835478062365617, 103838791113879912161511798836229961653), (5503595333662805357, 92368472243854403026472376408708548349), (18122734335129614364, 288955542597300001147753560885976966029), (12688080215989274550, 85237436689682348751672119832134138932), (4148468277722853958, 297778117327421209654837771300216669574), (8749445804640085302, 79595866493078234154562014325793780126), (12442730869682574563, 196176786402808588883611974143577417817), (6110644747049355904, 26592587989877021920275416199052685135), (5851164380497779369, 158876888501825038083692899057819261957), (9497384378514985275, 15279835675313542048650599472403150097), (10661092311826161857, 250089949043892591422587928179995867509), (10046856000675345423, 231369150063141386398059701278066296663)] } cc 76888f93675aca856046821142e0f8dd6171ecbca2b2fb2612e2ccf8fb642b67 # shrinks to input = _TestCountersManagerProptestFsArgs { entries: [(4306300120905349883, 44028232064888275756989554345798606606), (13419562989696853297, 297225061196384743010175600480992461777), (4600545388725048575, 319024777944692442173521074338932622027), (11924469201417769946, 290126334103578499810346516670302802842), (2150076364877215359, 213957508179788124392023233632127334025), (2513497990495955776, 7425952384271563468605443743299630055), (14784519504379667574, 209102176380410663068514976101053847121), (3589018664409806533, 143539073128281654988615675279132949539), (12163255676316221910, 68261431317828245529088264283730310447), (15953238975034584216, 120566915371382433441278003421157478859), (6293912069208757821, 54376221216199661139416453798278484358), (18408187014091379100, 160227239986709222921681152272167766516), (18224691851384849998, 230951397761410506492316028434133464542), (17218108759165771012, 230831401271946284847544140042531898300), (15156861699203125197, 274419864858876512298091294679889505416), (13197866550741263112, 317569618673855709115791823801131083319), (5457536710317675425, 264100465594513117047187960359952352601), (6419381816113193473, 97830434597410923324208428511886405696), (5509774606527762921, 51377792339839665748346223023626770993), (3302884055341784375, 260024947302198645578544387819129813215), (7918740211035003255, 281378863798916751001154282897883115117), (2107923747770684554, 4222310695795814822585776810386837522), (1988849030739458584, 97044202427348897203209230721452399078), (17000851872752693509, 154967569583821344066124364203881263442), (7204118357407989275, 293489743217018103289756063378018736213), (8379490247240411923, 91291993991616380545421710143276496062), (6067846780114877285, 117378294706679402333724324394932467070), (6559069473214523762, 330533491611532325905048043451453362184), (1066716766275783661, 14900329515024496203681878322771717089), (3969544049792556621, 299925942970250984690757497097936404520), (1871651009149288279, 269532663769476813929854896620535419927), (9885923542173402939, 332347180744841318697161540487151553089), (8743551960605987234, 82895354018256482956918848969653357161), (18444906840677790884, 140951189435890586485485914583535891710), (13186290687428042898, 156781959554744750775008814037900689629), (11253344694094324994, 173003087909699540403477415680185472166), (15359595929118467798, 334133929399407497923349560480857143925), (450753775453578376, 185062409187456936422223327885008555109), (5812669297982828223, 304450764862712727874277633964000192257), (5446431204912329700, 63591795618582560687940570634859474113), (12639950240321649272, 229465965587199764990249271930115998317), (8666241046976392242, 127169189810538544860066577390902103071), (15875344269296451901, 59314152116324788008302123296358029667), (17554612189790211905, 271354287586940637417955997246049015908), (2654666284440384247, 236192749343056755001648024964710799784), (3653085434641832523, 222611620216912476618464093834705618103), (2117280733558696133, 160273208193736809842040581629127362879), (15052687776534295171, 145937384428000340885721647247111254565), (14037243134892329831, 48648195516567212103580801887048711483), (9467080097152043608, 266945396762492281384357764614500138375), (2706297963598729254, 301505662334146630272416432816290497813), (7293916663622670946, 238683745638275436602208159421396156156), (9244966065396610028, 33307016963739390689548576588029894837), (1752320522681001931, 67331614351445449534791948958610485134), (13095820849418318043, 167220720368084276476264354546008346754), (2689852485877961108, 295988764749889891843145129746265206397), (16677044930197861079, 238123490797857333537723337779861037465), (1921976638111110551, 198905043115016585827638257647548833710), (78362912300221566, 97081461393166374265589962390002181072), (3959569947932321574, 224306094090967444142819090846108416832), (11193248764198058671, 209017727259932159026175830711818202266), (6959892815010617835, 209133472960436703368896187256879102139), (10121904169365490638, 120711360828413383714152810706442997143), (15460955954420808897, 303801388017089859688481259123309944609)] } +cc 12ef8cd43b8afd13f5a340612467c3997d5ba5efb72608fd8476df6241cd5aa1 # shrinks to input = _TestCountersManagerProptestFsArgs { entries: [(2380592976622330085, 28516108757883961008176578318775021719), (8094894356939531654, 10718326961815311951184411412724517285), (11921203167710682804, 310288141616457254365559878316491544849), (13755617706517689978, 126028148224965541431804524598571779560), (6681614816800093434, 188575223354091786892657643171613711890), (9571670957336898177, 162083372527284177662836758107322549696), (2471999314763911845, 274506062817616062670674409225732303245), (2836625124847079742, 75787776531374675700471634021065530467), (9934830121676810192, 333354798300858092905435764243659450444), (1381333832840346344, 311324743659801803453113425049900538575), (2302196496218675635, 212395921569910513862597773808400465806), (7146669409711908638, 161533726219296727821573878538273791643), (9801346383070508849, 285977560966921823091612392629841447928), (2395572114571121128, 300614943467177946509122704605046879066), (1101095318254669049, 139928502252989726945144303961224264478), (5986229782663173435, 51283959460964936192936235482113538648), (13854002339590051175, 125654892410344413752629163920107545730), (13781018864334141847, 339287264555190604626070138477739299040), (8546835162200571161, 242910440411389951824048922104772319511), (8066879592155044556, 55832109607420666571038493505740840185), (14787955442052669563, 246675464222165977161309275899452278610), (5558308994887530238, 319508707095130301388093140508558819418), (17473663508960542307, 112920447985509513405631401418029732186), (7425779317831660569, 132448537900465951563891971286136125763), (15265160054173207437, 140190286198724402505961550430181003655), (8044231424887912441, 317701385434560239701035440023001111619), (18207647684999546383, 156462950301818782445532607898817811099), (8456937428392640571, 129187044946008952138680436136748694164), (9660941432317156944, 51479307487693462367343530067170855074), (11974801735864477299, 71978532481986688402941554512997729133), (10626657922903390031, 285950609178099918824151788088218613887), (2974958498712082592, 175654253987907967247168257314734451820), (12578937525703736023, 247767660502531391132888993156509975109), (6474485429084047310, 185699318630058530773063031667743205026), (9596435365191952368, 247282028355602232640954773341038022511), (16675753750985703664, 286981992456627169557114395380354199353), (5138746712869968684, 39169132249829779216912902933505417364), (5019751313689498512, 288894759535386990584801246723637837482), (17091672548346263602, 282839768601869514496167753085903788351), (4895177945922371064, 167828453438287303763038936162552479750), (2258097882389241656, 170851112204495629460395415712928869647), (9050221542730812158, 25405115484423843502337976841510097953), (7064897051505340986, 316792416532750676517556783749946421277), (717306906634626341, 11477313054467332810070253416539691287), (15152720356165740302, 226188535012436112058185147883078892901), (16262065584679956398, 200597764486196728395762424740284874739), (12141546842055714234, 6421701224446554517809057969648748019), (10245649263580140634, 195892352469673304447008633237343975635), (13790768687577295788, 202614205603220920131098763636823488868), (11831959142111758471, 176543487457291161573982093949022763125), (17777605318963627052, 319212788065850949515084373029102475409), (564823812078008836, 145963479570581268538880853053610131139), (13457405482865604377, 148949589505534127482576600176076395767), (9055054759637260914, 337059293313500945330898738738354952025), (895596410378228543, 74004207652448032350331180680239961718), (4726795347504570828, 51571582687704702848638972771018932833), (16833682733301673728, 34377835113215379262864813936882362439), (15034855392108016430, 203627474995536168557780237872359326487), (11405774954355622168, 322678365343543193887914339203997893240), (1457678872205580285, 99318560493394084478210028931820817917), (1321755794936092808, 261494917638705227451935424828339016073), (11898454905244575171, 203086212025490211591258974121885166350), (478255349182567124, 306605025185865800140176585951924482496), (7986940786120947832, 298777454068286672273086573102781823453), (15696893798940752922, 127230076438002883309661015950009791604), (17310811611359025996, 284507994087592321247856810143192637533), (6019323075533001187, 249604570518388686353612686763609744902), (6835459638208946175, 183267248548541678775421865746870938606), (7003248991841775631, 221568917599294958602977617633161129342), (15665994793425721324, 297884599502068866963806845302593747125), (17518176331196234001, 323328424090327758541459557627854544629), (7421245675015116149, 46410559889062524219094102930635938522), (17093820111011874288, 305200722531614663405336520596512516063), (7575694490593166082, 192069555144365913694281795349960087024), (5101843262278972871, 31632907314836790421567225483192160258)] } diff --git a/src/api/downloader.rs b/src/api/downloader.rs index 4a5a25dd..fffacc14 100644 --- a/src/api/downloader.rs +++ b/src/api/downloader.rs @@ -8,7 +8,7 @@ use std::{ use anyhow::bail; use genawaiter::sync::Gen; -use iroh::{Endpoint, NodeId}; +use iroh::{Endpoint, EndpointId}; use irpc::{channel::mpsc, rpc_requests}; use n0_future::{future, stream, BufferedStreamExt, Stream, StreamExt}; use rand::seq::SliceRandom; @@ -50,11 +50,11 @@ pub enum DownloadProgressItem { #[serde(skip)] Error(anyhow::Error), TryProvider { - id: NodeId, + id: EndpointId, request: Arc, }, ProviderFailed { - id: NodeId, + id: EndpointId, request: Arc, }, PartComplete { @@ -244,7 +244,7 @@ impl SupportedRequest for HashAndFormat { #[derive(Debug, Serialize, Deserialize)] pub struct AddProviderRequest { pub hash: Hash, - pub providers: Vec, + pub providers: Vec, } #[derive(Debug)] @@ -486,16 +486,16 @@ async fn execute_get( /// Trait for pluggable content discovery strategies. pub trait ContentDiscovery: Debug + Send + Sync + 'static { - fn find_providers(&self, hash: HashAndFormat) -> n0_future::stream::Boxed; + fn find_providers(&self, hash: HashAndFormat) -> n0_future::stream::Boxed; } impl ContentDiscovery for C where C: Debug + Clone + IntoIterator + Send + Sync + 'static, C::IntoIter: Send + Sync + 'static, - I: Into + Send + Sync + 'static, + I: Into + Send + Sync + 'static, { - fn find_providers(&self, _: HashAndFormat) -> n0_future::stream::Boxed { + fn find_providers(&self, _: HashAndFormat) -> n0_future::stream::Boxed { let providers = self.clone(); n0_future::stream::iter(providers.into_iter().map(Into::into)).boxed() } @@ -503,17 +503,17 @@ where #[derive(derive_more::Debug)] pub struct Shuffled { - nodes: Vec, + nodes: Vec, } impl Shuffled { - pub fn new(nodes: Vec) -> Self { + pub fn new(nodes: Vec) -> Self { Self { nodes } } } impl ContentDiscovery for Shuffled { - fn find_providers(&self, _: HashAndFormat) -> n0_future::stream::Boxed { + fn find_providers(&self, _: HashAndFormat) -> n0_future::stream::Boxed { let mut nodes = self.nodes.clone(); nodes.shuffle(&mut rand::rng()); n0_future::stream::iter(nodes).boxed() @@ -548,13 +548,13 @@ mod tests { let (r3, store3, _, sp3) = node_test_setup_fs(testdir.path().join("c")).await?; let tt1 = store1.add_slice("hello world").await?; let tt2 = store2.add_slice("hello world 2").await?; - let node1_addr = r1.endpoint().node_addr(); - let node1_id = node1_addr.node_id; - let node2_addr = r2.endpoint().node_addr(); - let node2_id = node2_addr.node_id; + let node1_addr = r1.endpoint().addr(); + let node1_id = node1_addr.id; + let node2_addr = r2.endpoint().addr(); + let node2_id = node2_addr.id; let swarm = Downloader::new(&store3, r3.endpoint()); - sp3.add_node_info(node1_addr.clone()); - sp3.add_node_info(node2_addr.clone()); + sp3.add_endpoint_info(node1_addr.clone()); + sp3.add_endpoint_info(node2_addr.clone()); let request = GetManyRequest::builder() .hash(tt1.hash, ChunkRanges::all()) .hash(tt2.hash, ChunkRanges::all()) @@ -585,13 +585,13 @@ mod tests { format: crate::BlobFormat::HashSeq, }) .await?; - let node1_addr = r1.endpoint().node_addr(); - let node1_id = node1_addr.node_id; - let node2_addr = r2.endpoint().node_addr(); - let node2_id = node2_addr.node_id; + let node1_addr = r1.endpoint().addr(); + let node1_id = node1_addr.id; + let node2_addr = r2.endpoint().addr(); + let node2_id = node2_addr.id; let swarm = Downloader::new(&store3, r3.endpoint()); - sp3.add_node_info(node1_addr.clone()); - sp3.add_node_info(node2_addr.clone()); + sp3.add_endpoint_info(node1_addr.clone()); + sp3.add_endpoint_info(node2_addr.clone()); let request = GetRequest::builder() .root(ChunkRanges::all()) .next(ChunkRanges::all()) @@ -652,13 +652,13 @@ mod tests { format: crate::BlobFormat::HashSeq, }) .await?; - let node1_addr = r1.endpoint().node_addr(); - let node1_id = node1_addr.node_id; - let node2_addr = r2.endpoint().node_addr(); - let node2_id = node2_addr.node_id; + let node1_addr = r1.endpoint().addr(); + let node1_id = node1_addr.id; + let node2_addr = r2.endpoint().addr(); + let node2_id = node2_addr.id; let swarm = Downloader::new(&store3, r3.endpoint()); - sp3.add_node_info(node1_addr.clone()); - sp3.add_node_info(node2_addr.clone()); + sp3.add_endpoint_info(node1_addr.clone()); + sp3.add_endpoint_info(node2_addr.clone()); let request = GetRequest::all(root.hash); let mut progress = swarm .download_with_opts(DownloadOptions::new( diff --git a/src/net_protocol.rs b/src/net_protocol.rs index c6abc1f0..4eb11265 100644 --- a/src/net_protocol.rs +++ b/src/net_protocol.rs @@ -16,9 +16,9 @@ //! let t = store.add_slice(b"hello world").await?; //! //! // create an iroh endpoint -//! let endpoint = Endpoint::builder().discovery_n0().bind().await?; +//! let endpoint = Endpoint::bind().await?; //! endpoint.online().await; -//! let addr = endpoint.node_addr(); +//! let addr = endpoint.addr(); //! //! // create a blobs protocol handler //! let blobs = BlobsProtocol::new(&store, None); diff --git a/src/provider.rs b/src/provider.rs index 904a272f..39025401 100644 --- a/src/provider.rs +++ b/src/provider.rs @@ -298,7 +298,7 @@ pub async fn handle_connection( if let Err(cause) = progress .client_connected(|| ClientConnected { connection_id, - node_id: connection.remote_node_id().ok(), + endpoint_id: connection.remote_id().ok(), }) .await { diff --git a/src/provider/events.rs b/src/provider/events.rs index 7287fd1a..932570e9 100644 --- a/src/provider/events.rs +++ b/src/provider/events.rs @@ -584,7 +584,7 @@ pub enum ProviderProto { } mod proto { - use iroh::NodeId; + use iroh::EndpointId; use serde::{Deserialize, Serialize}; use crate::{provider::TransferStats, Hash}; @@ -592,7 +592,7 @@ mod proto { #[derive(Debug, Serialize, Deserialize)] pub struct ClientConnected { pub connection_id: u64, - pub node_id: Option, + pub endpoint_id: Option, } #[derive(Debug, Serialize, Deserialize)] diff --git a/src/tests.rs b/src/tests.rs index d5ec46f8..76af8f0a 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -2,7 +2,9 @@ use std::{collections::HashSet, io, ops::Range, path::PathBuf}; use bao_tree::ChunkRanges; use bytes::Bytes; -use iroh::{discovery::static_provider::StaticProvider, protocol::Router, Endpoint, NodeId}; +use iroh::{ + discovery::static_provider::StaticProvider, protocol::Router, Endpoint, EndpointId, RelayMode, +}; use irpc::RpcMessage; use n0_future::{task::AbortOnDropHandle, StreamExt}; use tempfile::TempDir; @@ -226,7 +228,7 @@ async fn two_nodes_get_blobs( for size in sizes { tts.push(store1.add_bytes(test_data(size)).await?); } - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); let conn = r2.endpoint().connect(addr1, crate::ALPN).await?; for size in sizes { let hash = Hash::new(test_data(size)); @@ -259,7 +261,7 @@ async fn two_nodes_observe( let size = 1024 * 1024 * 8 + 1; let data = test_data(size); let (hash, bao) = create_n0_bao(&data, &ChunkRanges::all())?; - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); let conn = r2.endpoint().connect(addr1, crate::ALPN).await?; let mut stream = store2 .remote() @@ -308,7 +310,7 @@ async fn two_nodes_get_many( tts.push(store1.add_bytes(test_data(size)).await?); } let hashes = tts.iter().map(|tt| tt.hash).collect::>(); - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); let conn = r2.endpoint().connect(addr1, crate::ALPN).await?; store2 .remote() @@ -339,7 +341,7 @@ async fn two_nodes_get_many_mem() -> TestResult<()> { } fn event_handler( - allowed_nodes: impl IntoIterator, + allowed_nodes: impl IntoIterator, ) -> (EventSender, watch::Receiver, AbortOnDropHandle<()>) { let (count_tx, count_rx) = tokio::sync::watch::channel(0usize); let (events_tx, mut events_rx) = EventSender::channel(16, EventMask::ALL_READONLY); @@ -348,8 +350,8 @@ fn event_handler( while let Some(event) = events_rx.recv().await { match event { ProviderMessage::ClientConnected(msg) => { - let res = match msg.node_id { - Some(node_id) if allowed_nodes.contains(&node_id) => Ok(()), + let res = match msg.endpoint_id { + Some(endpoint_id) if allowed_nodes.contains(&endpoint_id) => Ok(()), Some(_) => Err(AbortReason::Permission), None => Err(AbortReason::Permission), }; @@ -385,7 +387,7 @@ async fn two_nodes_push_blobs( for size in sizes { tts.push(store1.add_bytes(test_data(size)).await?); } - let addr2 = r2.endpoint().node_addr(); + let addr2 = r2.endpoint().addr(); let conn = r1.endpoint().connect(addr2, crate::ALPN).await?; for size in sizes { let hash = Hash::new(test_data(size)); @@ -411,11 +413,11 @@ async fn two_nodes_push_blobs_fs() -> TestResult<()> { tracing_subscriber::fmt::try_init().ok(); let testdir = tempfile::tempdir()?; let (r1, store1, _, sp1) = node_test_setup_fs(testdir.path().join("a")).await?; - let (events_tx, count_rx, _task) = event_handler([r1.endpoint().node_id()]); + let (events_tx, count_rx, _task) = event_handler([r1.endpoint().id()]); let (r2, store2, _, sp2) = node_test_setup_with_events_fs(testdir.path().join("b"), events_tx).await?; - sp1.add_node_info(r2.endpoint().node_addr()); - sp2.add_node_info(r1.endpoint().node_addr()); + sp1.add_endpoint_info(r2.endpoint().addr()); + sp2.add_endpoint_info(r1.endpoint().addr()); two_nodes_push_blobs(r1, &store1, r2, &store2, count_rx).await } @@ -423,10 +425,10 @@ async fn two_nodes_push_blobs_fs() -> TestResult<()> { async fn two_nodes_push_blobs_mem() -> TestResult<()> { tracing_subscriber::fmt::try_init().ok(); let (r1, store1, sp1) = node_test_setup_mem().await?; - let (events_tx, count_rx, _task) = event_handler([r1.endpoint().node_id()]); + let (events_tx, count_rx, _task) = event_handler([r1.endpoint().id()]); let (r2, store2, sp2) = node_test_setup_with_events_mem(events_tx).await?; - sp1.add_node_info(r2.endpoint().node_addr()); - sp2.add_node_info(r1.endpoint().node_addr()); + sp1.add_endpoint_info(r2.endpoint().addr()); + sp2.add_endpoint_info(r1.endpoint().addr()); two_nodes_push_blobs(r1, &store1, r2, &store2, count_rx).await } @@ -500,7 +502,10 @@ pub async fn node_test_setup_with_events_fs( ) -> TestResult<(Router, FsStore, PathBuf, StaticProvider)> { let store = crate::store::fs::FsStore::load(&db_path).await?; let sp = StaticProvider::new(); - let ep = Endpoint::builder().discovery(sp.clone()).bind().await?; + let ep = Endpoint::empty_builder(RelayMode::Default) + .discovery(sp.clone()) + .bind() + .await?; let blobs = BlobsProtocol::new(&store, Some(events)); let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn(); Ok((router, store, db_path, sp)) @@ -515,7 +520,10 @@ pub async fn node_test_setup_with_events_mem( ) -> TestResult<(Router, MemStore, StaticProvider)> { let store = MemStore::new(); let sp = StaticProvider::new(); - let ep = Endpoint::builder().discovery(sp.clone()).bind().await?; + let ep = Endpoint::empty_builder(RelayMode::Default) + .discovery(sp.clone()) + .bind() + .await?; let blobs = BlobsProtocol::new(&store, Some(events)); let router = Router::builder(ep).accept(crate::ALPN, blobs).spawn(); Ok((router, store, sp)) @@ -532,20 +540,20 @@ async fn two_node_test_setup_fs() -> TestResult<( let db2_path = testdir.path().join("db2"); let (r1, store1, p1, sp1) = node_test_setup_fs(db1_path).await?; let (r2, store2, p2, sp2) = node_test_setup_fs(db2_path).await?; - sp1.add_node_info(r2.endpoint().node_addr()); - sp2.add_node_info(r1.endpoint().node_addr()); + sp1.add_endpoint_info(r2.endpoint().addr()); + sp2.add_endpoint_info(r1.endpoint().addr()); Ok((testdir, (r1, store1, p1), (r2, store2, p2))) } /// Sets up two nodes with a router and a blob store each. /// /// Note that this does not configure discovery, so nodes will only find each other -/// with full node addresses, not just node ids! +/// with full node addresses, not just endpoint ids! async fn two_node_test_setup_mem() -> TestResult<((Router, MemStore), (Router, MemStore))> { let (r1, store1, sp1) = node_test_setup_mem().await?; let (r2, store2, sp2) = node_test_setup_mem().await?; - sp1.add_node_info(r2.endpoint().node_addr()); - sp2.add_node_info(r1.endpoint().node_addr()); + sp1.add_endpoint_info(r2.endpoint().addr()); + sp2.add_endpoint_info(r1.endpoint().addr()); Ok(((r1, store1), (r2, store2))) } @@ -555,7 +563,7 @@ async fn two_nodes_hash_seq( r2: Router, store2: &Store, ) -> TestResult<()> { - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); let sizes = INTERESTING_SIZES; let root = add_test_hash_seq(store1, sizes).await?; let conn = r2.endpoint().connect(addr1, crate::ALPN).await?; @@ -583,7 +591,7 @@ async fn two_nodes_hash_seq_mem() -> TestResult<()> { async fn two_nodes_hash_seq_progress() -> TestResult<()> { tracing_subscriber::fmt::try_init().ok(); let (_testdir, (r1, store1, _), (r2, store2, _)) = two_node_test_setup_fs().await?; - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); let sizes = INTERESTING_SIZES; let root = add_test_hash_seq(&store1, sizes).await?; let conn = r2.endpoint().connect(addr1, crate::ALPN).await?; @@ -612,14 +620,14 @@ async fn node_serve_hash_seq() -> TestResult<()> { let hash_seq = tts.iter().map(|x| x.hash).collect::(); let root_tt = store.add_bytes(hash_seq).await?; let root = root_tt.hash; - let endpoint = Endpoint::builder().discovery_n0().bind().await?; + let endpoint = Endpoint::bind().await?; let blobs = crate::net_protocol::BlobsProtocol::new(&store, None); let r1 = Router::builder(endpoint) .accept(crate::protocol::ALPN, blobs) .spawn(); - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); info!("node addr: {addr1:?}"); - let endpoint2 = Endpoint::builder().discovery_n0().bind().await?; + let endpoint2 = Endpoint::bind().await?; let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?; let (hs, sizes) = get::request::get_hash_seq_and_sizes(&conn, &root, 1024, None).await?; println!("hash seq: {hs:?}"); @@ -643,14 +651,14 @@ async fn node_serve_blobs() -> TestResult<()> { for size in sizes { tts.push(store.add_bytes(test_data(size)).await?); } - let endpoint = Endpoint::builder().discovery_n0().bind().await?; + let endpoint = Endpoint::bind().await?; let blobs = crate::net_protocol::BlobsProtocol::new(&store, None); let r1 = Router::builder(endpoint) .accept(crate::protocol::ALPN, blobs) .spawn(); - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); info!("node addr: {addr1:?}"); - let endpoint2 = Endpoint::builder().discovery_n0().bind().await?; + let endpoint2 = Endpoint::bind().await?; let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?; for size in sizes { let expected = test_data(size); @@ -683,14 +691,14 @@ async fn node_smoke_mem() -> TestResult<()> { async fn node_smoke(store: &Store) -> TestResult<()> { let tt = store.add_bytes(b"hello world".to_vec()).temp_tag().await?; let hash = tt.hash(); - let endpoint = Endpoint::builder().discovery_n0().bind().await?; + let endpoint = Endpoint::bind().await?; let blobs = crate::net_protocol::BlobsProtocol::new(store, None); let r1 = Router::builder(endpoint) .accept(crate::protocol::ALPN, blobs) .spawn(); - let addr1 = r1.endpoint().node_addr(); + let addr1 = r1.endpoint().addr(); info!("node addr: {addr1:?}"); - let endpoint2 = Endpoint::builder().discovery_n0().bind().await?; + let endpoint2 = Endpoint::bind().await?; let conn = endpoint2.connect(addr1, crate::protocol::ALPN).await?; let (size, stats) = get::request::get_unverified_size(&conn, &hash).await?; info!("size: {} stats: {:?}", size, stats); diff --git a/src/ticket.rs b/src/ticket.rs index 9517c5c9..55ef00ae 100644 --- a/src/ticket.rs +++ b/src/ticket.rs @@ -2,8 +2,8 @@ use std::{collections::BTreeSet, net::SocketAddr, str::FromStr}; use anyhow::Result; -use iroh::{NodeAddr, NodeId, RelayUrl}; -use iroh_base::ticket::{self, Ticket}; +use iroh::{EndpointAddr, EndpointId, RelayUrl}; +use iroh_tickets::{ParseError, Ticket}; use serde::{Deserialize, Serialize}; use crate::{BlobFormat, Hash, HashAndFormat}; @@ -15,7 +15,7 @@ use crate::{BlobFormat, Hash, HashAndFormat}; #[display("{}", Ticket::serialize(self))] pub struct BlobTicket { /// The provider to get a file from. - node: NodeAddr, + addr: EndpointAddr, /// The format of the blob. format: BlobFormat, /// The hash to retrieve. @@ -51,7 +51,7 @@ struct Variant0BlobTicket { #[derive(Serialize, Deserialize)] struct Variant0NodeAddr { - node_id: NodeId, + endpoint_id: EndpointId, info: Variant0AddrInfo, } @@ -67,10 +67,10 @@ impl Ticket for BlobTicket { fn to_bytes(&self) -> Vec { let data = TicketWireFormat::Variant0(Variant0BlobTicket { node: Variant0NodeAddr { - node_id: self.node.node_id, + endpoint_id: self.addr.id, info: Variant0AddrInfo { - relay_url: self.node.relay_url.clone(), - direct_addresses: self.node.direct_addresses.clone(), + relay_url: self.addr.relay_urls().next().cloned(), + direct_addresses: self.addr.ip_addrs().cloned().collect(), }, }, format: self.format, @@ -79,23 +79,22 @@ impl Ticket for BlobTicket { postcard::to_stdvec(&data).expect("postcard serialization failed") } - fn from_bytes(bytes: &[u8]) -> std::result::Result { + fn from_bytes(bytes: &[u8]) -> std::result::Result { let res: TicketWireFormat = postcard::from_bytes(bytes)?; let TicketWireFormat::Variant0(Variant0BlobTicket { node, format, hash }) = res; - Ok(Self { - node: NodeAddr { - node_id: node.node_id, - relay_url: node.info.relay_url, - direct_addresses: node.info.direct_addresses, - }, - format, - hash, - }) + let mut addr = EndpointAddr::new(node.endpoint_id); + if let Some(relay_url) = node.info.relay_url { + addr = addr.with_relay_url(relay_url); + } + for ip_addr in node.info.direct_addresses { + addr = addr.with_ip_addr(ip_addr); + } + Ok(Self { addr, format, hash }) } } impl FromStr for BlobTicket { - type Err = ticket::ParseError; + type Err = ParseError; fn from_str(s: &str) -> Result { Ticket::deserialize(s) @@ -104,8 +103,8 @@ impl FromStr for BlobTicket { impl BlobTicket { /// Creates a new ticket. - pub fn new(node: NodeAddr, hash: Hash, format: BlobFormat) -> Self { - Self { hash, format, node } + pub fn new(addr: EndpointAddr, hash: Hash, format: BlobFormat) -> Self { + Self { hash, format, addr } } /// The hash of the item this ticket can retrieve. @@ -113,9 +112,9 @@ impl BlobTicket { self.hash } - /// The [`NodeAddr`] of the provider for this ticket. - pub fn node_addr(&self) -> &NodeAddr { - &self.node + /// The [`EndpointAddr`] of the provider for this ticket. + pub fn addr(&self) -> &EndpointAddr { + &self.addr } /// The [`BlobFormat`] for this ticket. @@ -136,9 +135,9 @@ impl BlobTicket { } /// Get the contents of the ticket, consuming it. - pub fn into_parts(self) -> (NodeAddr, Hash, BlobFormat) { - let BlobTicket { node, hash, format } = self; - (node, hash, format) + pub fn into_parts(self) -> (EndpointAddr, Hash, BlobFormat) { + let BlobTicket { addr, hash, format } = self; + (addr, hash, format) } } @@ -147,7 +146,11 @@ impl Serialize for BlobTicket { if serializer.is_human_readable() { serializer.serialize_str(&self.to_string()) } else { - let BlobTicket { node, format, hash } = self; + let BlobTicket { + addr: node, + format, + hash, + } = self; (node, format, hash).serialize(serializer) } } @@ -169,7 +172,7 @@ impl<'de> Deserialize<'de> for BlobTicket { mod tests { use std::net::SocketAddr; - use iroh::{PublicKey, SecretKey}; + use iroh::{PublicKey, SecretKey, TransportAddr}; use iroh_test::{assert_eq_hex, hexdump::parse_hexdump}; use super::*; @@ -178,10 +181,9 @@ mod tests { let hash = Hash::new(b"hi there"); let peer = SecretKey::generate(&mut rand::rng()).public(); let addr = SocketAddr::from_str("127.0.0.1:1234").unwrap(); - let relay_url = None; BlobTicket { hash, - node: NodeAddr::from_parts(peer, relay_url, [addr]), + addr: EndpointAddr::from_parts(peer, [TransportAddr::Ip(addr)]), format: BlobFormat::HashSeq, } } @@ -207,12 +209,12 @@ mod tests { let hash = Hash::from_str("0b84d358e4c8be6c38626b2182ff575818ba6bd3f4b90464994be14cb354a072") .unwrap(); - let node_id = + let endpoint_id = PublicKey::from_str("ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6") .unwrap(); let ticket = BlobTicket { - node: NodeAddr::from_parts(node_id, None, []), + addr: EndpointAddr::new(endpoint_id), format: BlobFormat::Raw, hash, }; @@ -223,7 +225,7 @@ mod tests { .unwrap(); let expected = parse_hexdump(" 00 # discriminator for variant 0 - ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6 # node id, 32 bytes, see above + ae58ff8833241ac82d6ff7611046ed67b5072d142c588d0063e942d9a75502b6 # endpoint id, 32 bytes, see above 00 # relay url 00 # number of addresses (0) 00 # format (raw) diff --git a/src/util/connection_pool.rs b/src/util/connection_pool.rs index 33632b81..e3c2d3a1 100644 --- a/src/util/connection_pool.rs +++ b/src/util/connection_pool.rs @@ -21,7 +21,7 @@ use std::{ use iroh::{ endpoint::{ConnectError, Connection}, - Endpoint, NodeId, + Endpoint, EndpointId, }; use n0_future::{ future::{self}, @@ -152,12 +152,12 @@ pub enum ConnectionPoolError { enum ActorMessage { RequestRef(RequestRef), - ConnectionIdle { id: NodeId }, - ConnectionShutdown { id: NodeId }, + ConnectionIdle { id: EndpointId }, + ConnectionShutdown { id: EndpointId }, } struct RequestRef { - id: NodeId, + id: EndpointId, tx: oneshot::Sender>, } @@ -171,7 +171,7 @@ struct Context { impl Context { async fn run_connection_actor( self: Arc, - node_id: NodeId, + node_id: EndpointId, mut rx: mpsc::Receiver, ) { let context = self; @@ -288,11 +288,11 @@ impl Context { struct Actor { rx: mpsc::Receiver, - connections: HashMap>, + connections: HashMap>, context: Arc, // idle set (most recent last) // todo: use a better data structure if this becomes a performance issue - idle: VecDeque, + idle: VecDeque, // per connection tasks tasks: FuturesUnordered>, } @@ -321,20 +321,20 @@ impl Actor { ) } - fn add_idle(&mut self, id: NodeId) { + fn add_idle(&mut self, id: EndpointId) { self.remove_idle(id); self.idle.push_back(id); } - fn remove_idle(&mut self, id: NodeId) { + fn remove_idle(&mut self, id: EndpointId) { self.idle.retain(|&x| x != id); } - fn pop_oldest_idle(&mut self) -> Option { + fn pop_oldest_idle(&mut self) -> Option { self.idle.pop_front() } - fn remove_connection(&mut self, id: NodeId) { + fn remove_connection(&mut self, id: EndpointId) { self.connections.remove(&id); self.remove_idle(id); } @@ -433,7 +433,7 @@ impl ConnectionPool { /// with either an error or a connection. pub async fn get_or_connect( &self, - id: NodeId, + id: EndpointId, ) -> std::result::Result { let (tx, rx) = oneshot::channel(); self.tx @@ -447,7 +447,7 @@ impl ConnectionPool { /// /// This will finish pending tasks and close the connection. New tasks will /// get a new connection if they are submitted after this call - pub async fn close(&self, id: NodeId) -> std::result::Result<(), ConnectionPoolError> { + pub async fn close(&self, id: EndpointId) -> std::result::Result<(), ConnectionPoolError> { self.tx .send(ActorMessage::ConnectionShutdown { id }) .await @@ -458,7 +458,10 @@ impl ConnectionPool { /// Notify the connection pool that a connection is idle. /// /// Should only be called from connection handlers. - pub(crate) async fn idle(&self, id: NodeId) -> std::result::Result<(), ConnectionPoolError> { + pub(crate) async fn idle( + &self, + id: EndpointId, + ) -> std::result::Result<(), ConnectionPoolError> { self.tx .send(ActorMessage::ConnectionIdle { id }) .await @@ -542,7 +545,7 @@ mod tests { discovery::static_provider::StaticProvider, endpoint::{Connection, ConnectionType}, protocol::{AcceptError, ProtocolHandler, Router}, - Endpoint, NodeAddr, NodeId, SecretKey, Watcher, + Endpoint, EndpointAddr, EndpointId, RelayMode, SecretKey, TransportAddr, Watcher, }; use n0_future::{io, stream, BufferedStreamExt, StreamExt}; use n0_snafu::ResultExt; @@ -560,7 +563,7 @@ mod tests { impl ProtocolHandler for Echo { async fn accept(&self, connection: Connection) -> Result<(), AcceptError> { let conn_id = connection.stable_id(); - let id = connection.remote_node_id().map_err(AcceptError::from_err)?; + let id = connection.remote_id().map_err(AcceptError::from_err)?; trace!(%id, %conn_id, "Accepting echo connection"); loop { match connection.accept_bi().await { @@ -581,7 +584,7 @@ mod tests { async fn echo_client(conn: &Connection, text: &[u8]) -> n0_snafu::Result> { let conn_id = conn.stable_id(); - let id = conn.remote_node_id().e()?; + let id = conn.remote_id().e()?; trace!(%id, %conn_id, "Sending echo request"); let (mut send, mut recv) = conn.open_bi().await.e()?; send.write_all(text).await.e()?; @@ -591,13 +594,13 @@ mod tests { Ok(response) } - async fn echo_server() -> TestResult<(NodeAddr, Router)> { + async fn echo_server() -> TestResult<(EndpointAddr, Router)> { let endpoint = iroh::Endpoint::builder() .alpns(vec![ECHO_ALPN.to_vec()]) .bind() .await?; endpoint.online().await; - let addr = endpoint.node_addr(); + let addr = endpoint.addr(); let router = iroh::protocol::Router::builder(endpoint) .accept(ECHO_ALPN, Echo) .spawn(); @@ -605,16 +608,16 @@ mod tests { Ok((addr, router)) } - async fn echo_servers(n: usize) -> TestResult<(Vec, Vec, StaticProvider)> { + async fn echo_servers(n: usize) -> TestResult<(Vec, Vec, StaticProvider)> { let res = stream::iter(0..n) .map(|_| echo_server()) .buffered_unordered(16) .collect::>() .await; - let res: Vec<(NodeAddr, Router)> = res.into_iter().collect::>>()?; + let res: Vec<(EndpointAddr, Router)> = res.into_iter().collect::>>()?; let (addrs, routers): (Vec<_>, Vec<_>) = res.into_iter().unzip(); - let ids = addrs.iter().map(|a| a.node_id).collect::>(); - let discovery = StaticProvider::from_node_info(addrs); + let ids = addrs.iter().map(|a| a.id).collect::>(); + let discovery = StaticProvider::from_endpoint_info(addrs); Ok((ids, routers, discovery)) } @@ -642,7 +645,7 @@ mod tests { impl EchoClient { async fn echo( &self, - id: NodeId, + id: EndpointId, text: Vec, ) -> Result), n0_snafu::Error>, PoolConnectError> { let conn = self.pool.get_or_connect(id).await?; @@ -659,7 +662,7 @@ mod tests { async fn connection_pool_errors() -> TestResult<()> { // set up static discovery for all addrs let discovery = StaticProvider::new(); - let endpoint = iroh::Endpoint::builder() + let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default) .discovery(discovery.clone()) .bind() .await?; @@ -669,16 +672,15 @@ mod tests { let non_existing = SecretKey::from_bytes(&[0; 32]).public(); let res = client.echo(non_existing, b"Hello, world!".to_vec()).await; // trying to connect to a non-existing id will fail with ConnectError - // because we don't have any information about the node + // because we don't have any information about the endpoint. assert!(matches!(res, Err(PoolConnectError::ConnectError { .. }))); } { let non_listening = SecretKey::from_bytes(&[0; 32]).public(); // make up fake node info - discovery.add_node_info(NodeAddr { - node_id: non_listening, - relay_url: None, - direct_addresses: vec!["127.0.0.1:12121".parse().unwrap()] + discovery.add_endpoint_info(EndpointAddr { + id: non_listening, + addrs: vec![TransportAddr::Ip("127.0.0.1:12121".parse().unwrap())] .into_iter() .collect(), }); @@ -695,8 +697,8 @@ mod tests { async fn connection_pool_smoke() -> TestResult<()> { let n = 32; let (ids, routers, discovery) = echo_servers(n).await?; - // build a client endpoint that can resolve all the node ids - let endpoint = iroh::Endpoint::builder() + // build a client endpoint that can resolve all the endpoint ids + let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default) .discovery(discovery.clone()) .bind() .await?; @@ -730,8 +732,8 @@ mod tests { async fn connection_pool_idle() -> TestResult<()> { let n = 32; let (ids, routers, discovery) = echo_servers(n).await?; - // build a client endpoint that can resolve all the node ids - let endpoint = iroh::Endpoint::builder() + // build a client endpoint that can resolve all the endpoint ids + let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default) .discovery(discovery.clone()) .bind() .await?; @@ -762,7 +764,7 @@ mod tests { async fn on_connected_error() -> TestResult<()> { let n = 1; let (ids, routers, discovery) = echo_servers(n).await?; - let endpoint = iroh::Endpoint::builder() + let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default) .discovery(discovery) .bind() .await?; @@ -792,13 +794,13 @@ mod tests { async fn on_connected_direct() -> TestResult<()> { let n = 1; let (ids, routers, discovery) = echo_servers(n).await?; - let endpoint = iroh::Endpoint::builder() + let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default) .discovery(discovery) .bind() .await?; let on_connected = |ep: Endpoint, conn: Connection| async move { - let Ok(id) = conn.remote_node_id() else { - return Err(io::Error::other("unable to get node id")); + let Ok(id) = conn.remote_id() else { + return Err(io::Error::other("unable to get endpoint id")); }; let Some(watcher) = ep.conn_type(id) else { return Err(io::Error::other("unable to get conn_type watcher")); @@ -835,7 +837,7 @@ mod tests { async fn watch_close() -> TestResult<()> { let n = 1; let (ids, routers, discovery) = echo_servers(n).await?; - let endpoint = iroh::Endpoint::builder() + let endpoint = iroh::Endpoint::empty_builder(RelayMode::Default) .discovery(discovery) .bind() .await?;