From ca92de26673c3280ab062f91ed5c90850ea074ba Mon Sep 17 00:00:00 2001 From: Ericson Soares Date: Fri, 20 Dec 2024 03:06:55 -0300 Subject: [PATCH] First draft on new p2p design --- Cargo.lock | 544 +++++++++--------- Cargo.toml | 47 +- core/Cargo.toml | 8 +- core/crates/cloud-services/Cargo.toml | 12 +- core/crates/cloud-services/src/client.rs | 20 +- .../tasks/media_data_extractor.rs | 2 +- .../src/media_processor/tasks/thumbnailer.rs | 10 +- core/crates/p2p/Cargo.toml | 70 +++ core/crates/p2p/src/error.rs | 24 + core/crates/p2p/src/lib.rs | 162 ++++++ .../authorize_new_device_in_sync_group.rs | 22 + .../p2p/src/schema/cloud_services/mod.rs | 25 + .../notify_new_sync_messages.rs | 12 + core/crates/p2p/src/schema/mod.rs | 36 ++ core/crates/p2p/src/server/mod.rs | 191 ++++++ .../p2p/src/server/router/cloud_services.rs | 47 ++ core/crates/p2p/src/server/router/mod.rs | 19 + core/src/api/libraries.rs | 2 +- core/src/api/locations.rs | 2 +- core/src/api/mod.rs | 2 +- core/src/api/p2p.rs | 4 +- core/src/custom_uri/mod.rs | 6 +- core/src/lib.rs | 6 +- core/src/library/config.rs | 2 +- core/src/library/library.rs | 2 +- core/src/library/manager/error.rs | 2 +- core/src/library/manager/mod.rs | 6 +- core/src/node/config.rs | 4 +- core/src/{p2p => old_p2p}/events.rs | 2 +- core/src/{p2p => old_p2p}/libraries.rs | 2 +- core/src/{p2p => old_p2p}/manager.rs | 6 +- core/src/{p2p => old_p2p}/metadata.rs | 0 core/src/{p2p => old_p2p}/mod.rs | 0 .../{p2p => old_p2p}/operations/library.rs | 10 +- core/src/{p2p => old_p2p}/operations/mod.rs | 0 core/src/{p2p => old_p2p}/operations/ping.rs | 4 +- core/src/{p2p => old_p2p}/operations/rspc.rs | 4 +- .../{p2p => old_p2p}/operations/spacedrop.rs | 8 +- core/src/{p2p => old_p2p}/protocol.rs | 4 +- core/src/{p2p => old_p2p}/sync/mod.rs | 0 core/src/{p2p => old_p2p}/sync/proto.rs | 2 +- crates/ai/src/old_image_labeler/mod.rs | 2 +- crates/images/src/error.rs | 2 +- crates/{p2p => old-p2p}/Cargo.toml | 2 +- crates/{p2p => old-p2p}/README.md | 0 .../{p2p => old-p2p}/crates/block/Cargo.toml | 4 +- .../crates/block/src/block.rs | 0 .../crates/block/src/block_size.rs | 0 .../{p2p => old-p2p}/crates/block/src/lib.rs | 0 .../crates/block/src/sb_request.rs | 2 +- .../{p2p => old-p2p}/crates/proto/Cargo.toml | 2 +- .../{p2p => old-p2p}/crates/proto/src/lib.rs | 0 .../{p2p => old-p2p}/crates/tunnel/Cargo.toml | 6 +- .../{p2p => old-p2p}/crates/tunnel/src/lib.rs | 4 +- crates/{p2p => old-p2p}/src/hook.rs | 0 crates/{p2p => old-p2p}/src/hooks.rs | 0 crates/{p2p => old-p2p}/src/hooks/mdns.rs | 0 crates/{p2p => old-p2p}/src/hooks/quic.rs | 0 .../{p2p => old-p2p}/src/hooks/quic/handle.rs | 0 .../src/hooks/quic/transport.rs | 0 .../{p2p => old-p2p}/src/hooks/quic/utils.rs | 0 crates/{p2p => old-p2p}/src/identity.rs | 0 crates/{p2p => old-p2p}/src/lib.rs | 0 crates/{p2p => old-p2p}/src/p2p.rs | 0 crates/{p2p => old-p2p}/src/peer.rs | 0 crates/{p2p => old-p2p}/src/smart_guards.rs | 0 crates/{p2p => old-p2p}/src/stream.rs | 0 67 files changed, 995 insertions(+), 360 deletions(-) create mode 100644 core/crates/p2p/Cargo.toml create mode 100644 core/crates/p2p/src/error.rs create mode 100644 core/crates/p2p/src/lib.rs create mode 100644 core/crates/p2p/src/schema/cloud_services/authorize_new_device_in_sync_group.rs create mode 100644 core/crates/p2p/src/schema/cloud_services/mod.rs create mode 100644 core/crates/p2p/src/schema/cloud_services/notify_new_sync_messages.rs create mode 100644 core/crates/p2p/src/schema/mod.rs create mode 100644 core/crates/p2p/src/server/mod.rs create mode 100644 core/crates/p2p/src/server/router/cloud_services.rs create mode 100644 core/crates/p2p/src/server/router/mod.rs rename core/src/{p2p => old_p2p}/events.rs (99%) rename core/src/{p2p => old_p2p}/libraries.rs (98%) rename core/src/{p2p => old_p2p}/manager.rs (99%) rename core/src/{p2p => old_p2p}/metadata.rs (100%) rename core/src/{p2p => old_p2p}/mod.rs (100%) rename core/src/{p2p => old_p2p}/operations/library.rs (90%) rename core/src/{p2p => old_p2p}/operations/mod.rs (100%) rename core/src/{p2p => old_p2p}/operations/ping.rs (91%) rename core/src/{p2p => old_p2p}/operations/rspc.rs (94%) rename core/src/{p2p => old_p2p}/operations/spacedrop.rs (97%) rename core/src/{p2p => old_p2p}/protocol.rs (96%) rename core/src/{p2p => old_p2p}/sync/mod.rs (100%) rename core/src/{p2p => old_p2p}/sync/proto.rs (97%) rename crates/{p2p => old-p2p}/Cargo.toml (98%) rename crates/{p2p => old-p2p}/README.md (100%) rename crates/{p2p => old-p2p}/crates/block/Cargo.toml (84%) rename crates/{p2p => old-p2p}/crates/block/src/block.rs (100%) rename crates/{p2p => old-p2p}/crates/block/src/block_size.rs (100%) rename crates/{p2p => old-p2p}/crates/block/src/lib.rs (100%) rename crates/{p2p => old-p2p}/crates/block/src/sb_request.rs (99%) rename crates/{p2p => old-p2p}/crates/proto/Cargo.toml (92%) rename crates/{p2p => old-p2p}/crates/proto/src/lib.rs (100%) rename crates/{p2p => old-p2p}/crates/tunnel/Cargo.toml (75%) rename crates/{p2p => old-p2p}/crates/tunnel/src/lib.rs (97%) rename crates/{p2p => old-p2p}/src/hook.rs (100%) rename crates/{p2p => old-p2p}/src/hooks.rs (100%) rename crates/{p2p => old-p2p}/src/hooks/mdns.rs (100%) rename crates/{p2p => old-p2p}/src/hooks/quic.rs (100%) rename crates/{p2p => old-p2p}/src/hooks/quic/handle.rs (100%) rename crates/{p2p => old-p2p}/src/hooks/quic/transport.rs (100%) rename crates/{p2p => old-p2p}/src/hooks/quic/utils.rs (100%) rename crates/{p2p => old-p2p}/src/identity.rs (100%) rename crates/{p2p => old-p2p}/src/lib.rs (100%) rename crates/{p2p => old-p2p}/src/p2p.rs (100%) rename crates/{p2p => old-p2p}/src/peer.rs (100%) rename crates/{p2p => old-p2p}/src/smart_guards.rs (100%) rename crates/{p2p => old-p2p}/src/stream.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 1a71c55c898b..a40139c49062 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.90" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95" +checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" [[package]] name = "arbitrary" @@ -599,9 +599,9 @@ dependencies = [ [[package]] name = "axum" -version = "0.7.7" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", @@ -609,10 +609,10 @@ dependencies = [ "base64 0.22.1", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-util", "itoa 1.0.11", "matchit", @@ -644,7 +644,7 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "mime", @@ -658,25 +658,26 @@ dependencies = [ [[package]] name = "axum-extra" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73c3220b188aea709cf1b6c5f9b01c3bd936bb08bd2b5184a12b35ac8131b1f9" +checksum = "c794b30c904f0a1c2fb7740f7df7f7972dfaa14ef6f57cb6178dc63e5dca2f04" dependencies = [ "axum", "axum-core", "bytes", + "fastrand 2.1.1", "futures-util", "headers", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", "mime", + "multer", "pin-project-lite", "serde", "tower", "tower-layer", "tower-service", - "tracing", ] [[package]] @@ -776,15 +777,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bincode" version = "2.0.0-rc.3" @@ -864,18 +856,6 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b81e1519b0d82120d2fd469d5bfb2919a9361c48b02d82d04befc1cdd2002452" -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - [[package]] name = "blake2" version = "0.10.6" @@ -887,9 +867,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d82033247fd8e890df8f740e407ad4d038debb9eb1f40533fffb32e7d17dc6f7" +checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" dependencies = [ "arrayref", "arrayvec", @@ -1060,9 +1040,9 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "bytes" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" +checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" dependencies = [ "serde", ] @@ -1272,9 +1252,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" dependencies = [ "android-tzdata", "iana-time-zone", @@ -2452,18 +2432,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "educe" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8" -dependencies = [ - "enum-ordinalize", - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "either" version = "1.13.0" @@ -2548,26 +2516,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "enum-ordinalize" -version = "4.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5" -dependencies = [ - "enum-ordinalize-derive", -] - -[[package]] -name = "enum-ordinalize-derive" -version = "4.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.87", -] - [[package]] name = "enumflags2" version = "0.7.10" @@ -2633,12 +2581,12 @@ checksum = "a02a5d186d7bf1cb21f1f95e1a9cfa5c1f2dcd803a47aad454423ceec13525c5" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -2836,6 +2784,12 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + [[package]] name = "flate2" version = "1.0.34" @@ -2984,12 +2938,6 @@ dependencies = [ "libc", ] -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "futf" version = "0.1.5" @@ -3049,11 +2997,11 @@ dependencies = [ [[package]] name = "futures-concurrency" -version = "7.6.1" +version = "7.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b14ac911e85d57c5ea6eef76d7b4d4a3177ecd15f4bea2e61927e9e3823e19f" +checksum = "d9b724496da7c26fcce66458526ce68fc2ecf4aaaa994281cf322ded5755520c" dependencies = [ - "bitvec", + "fixedbitset 0.5.7", "futures-buffered", "futures-core", "futures-lite 1.13.0", @@ -3568,7 +3516,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0bb0228f477c0900c880fd78c8759b95c7636dbd7842707f49e132378aa2acdc" dependencies = [ "heck 0.4.1", - "proc-macro-crate 2.0.2", + "proc-macro-crate 2.0.0", "proc-macro-error 1.0.4", "proc-macro2", "quote", @@ -3687,7 +3635,7 @@ dependencies = [ "presser", "thiserror 1.0.64", "winapi", - "windows 0.51.1", + "windows 0.52.0", ] [[package]] @@ -3813,7 +3761,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.1.0", + "http 1.2.0", "indexmap 2.6.0", "slab", "tokio", @@ -3907,7 +3855,7 @@ dependencies = [ "base64 0.21.7", "bytes", "headers-core", - "http 1.1.0", + "http 1.2.0", "httpdate", "mime", "sha1", @@ -3919,7 +3867,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -4163,9 +4111,9 @@ dependencies = [ [[package]] name = "http" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea" dependencies = [ "bytes", "fnv", @@ -4190,7 +4138,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.1.0", + "http 1.2.0", ] [[package]] @@ -4201,7 +4149,7 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "pin-project-lite", ] @@ -4234,8 +4182,8 @@ dependencies = [ "base64 0.22.1", "form_urlencoded", "futures", - "http 1.1.0", - "hyper 1.5.0", + "http 1.2.0", + "hyper 1.5.2", "hyper-util", "percent-encoding", "sha1", @@ -4285,15 +4233,15 @@ dependencies = [ [[package]] name = "hyper" -version = "1.5.0" +version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0" dependencies = [ "bytes", "futures-channel", "futures-util", "h2 0.4.6", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "httparse", "httpdate", @@ -4311,8 +4259,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", - "http 1.1.0", - "hyper 1.5.0", + "http 1.2.0", + "hyper 1.5.2", "hyper-util", "rustls", "rustls-pki-types", @@ -4343,7 +4291,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-util", "native-tls", "tokio", @@ -4360,9 +4308,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", - "hyper 1.5.0", + "hyper 1.5.2", "pin-project-lite", "socket2", "tokio", @@ -4381,7 +4329,7 @@ dependencies = [ "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core 0.51.1", + "windows-core 0.52.0", ] [[package]] @@ -4497,9 +4445,9 @@ dependencies = [ "attohttpc", "bytes", "futures", - "http 1.1.0", + "http 1.2.0", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-util", "log", "rand 0.8.5", @@ -4510,9 +4458,9 @@ dependencies = [ [[package]] name = "image" -version = "0.25.4" +version = "0.25.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc144d44a31d753b02ce64093d532f55ff8dc4ebf2ffb8a63c0dda691385acae" +checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" dependencies = [ "bytemuck", "byteorder-lite", @@ -4748,9 +4696,9 @@ dependencies = [ "hickory-proto 0.25.0-alpha.2", "hickory-resolver 0.25.0-alpha.2", "hostname 0.4.0", - "http 1.1.0", + "http 1.2.0", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-util", "igd-next", "iroh-base", @@ -4776,7 +4724,7 @@ dependencies = [ "postcard", "rand 0.8.5", "rcgen 0.13.1", - "reqwest 0.12.8", + "reqwest 0.12.9", "ring 0.17.8", "rtnetlink 0.13.1", "rtnetlink 0.14.1", @@ -4789,7 +4737,7 @@ dependencies = [ "stun-rs", "surge-ping", "swarm-discovery", - "thiserror 2.0.3", + "thiserror 2.0.8", "time", "tokio", "tokio-rustls", @@ -4828,7 +4776,7 @@ dependencies = [ "rand_core 0.6.4", "serde", "ssh-key", - "thiserror 2.0.3", + "thiserror 2.0.8", "ttl_cache", "url", "zeroize", @@ -4856,11 +4804,11 @@ dependencies = [ "anyhow", "erased_set", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-util", "once_cell", "prometheus-client", - "reqwest 0.12.8", + "reqwest 0.12.9", "serde", "struct_iterable", "time", @@ -4886,7 +4834,7 @@ dependencies = [ "netwatch", "portmapper", "rand 0.8.5", - "reqwest 0.12.8", + "reqwest 0.12.9", "rustls", "surge-ping", "thiserror 1.0.64", @@ -4965,9 +4913,9 @@ dependencies = [ "hickory-proto 0.25.0-alpha.2", "hickory-resolver 0.25.0-alpha.2", "hostname 0.4.0", - "http 1.1.0", + "http 1.2.0", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-util", "iroh-base", "iroh-metrics", @@ -4982,7 +4930,7 @@ dependencies = [ "rand 0.8.5", "rcgen 0.13.1", "regex", - "reqwest 0.12.8", + "reqwest 0.12.9", "ring 0.17.8", "rustls", "rustls-pemfile 2.2.0", @@ -4991,7 +4939,7 @@ dependencies = [ "smallvec", "socket2", "stun-rs", - "thiserror 2.0.3", + "thiserror 2.0.8", "time", "tokio", "tokio-rustls", @@ -5355,9 +5303,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.161" +version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libdbus-sys" @@ -6155,6 +6103,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" dependencies = [ "cfg-if", + "rayon", ] [[package]] @@ -6360,6 +6309,23 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http 1.2.0", + "httparse", + "memchr", + "mime", + "spin 0.9.8", + "version_check", +] + [[package]] name = "multiaddr" version = "0.18.2" @@ -6526,6 +6492,18 @@ dependencies = [ "jni-sys", ] +[[package]] +name = "nested_enum_utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f256ef99e7ac37428ef98c89bef9d84b590172de4bbfbe81b68a4cd3abadb32" +dependencies = [ + "proc-macro-crate 3.2.0", + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "netdev" version = "0.31.0" @@ -6702,7 +6680,7 @@ dependencies = [ "rtnetlink 0.14.1", "serde", "socket2", - "thiserror 2.0.3", + "thiserror 2.0.8", "time", "tokio", "tokio-util", @@ -7002,7 +6980,7 @@ version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56" dependencies = [ - "proc-macro-crate 2.0.2", + "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 2.0.87", @@ -7709,7 +7687,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ - "fixedbitset", + "fixedbitset 0.4.2", "indexmap 2.6.0", ] @@ -7891,9 +7869,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -8131,7 +8109,7 @@ dependencies = [ "serde", "smallvec", "socket2", - "thiserror 2.0.3", + "thiserror 2.0.8", "time", "tokio", "tokio-util", @@ -8141,9 +8119,9 @@ dependencies = [ [[package]] name = "postcard" -version = "1.0.10" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" +checksum = "170a2601f67cc9dba8edd8c4870b15f71a6a2dc196daec8c83f72b59dff628a8" dependencies = [ "cobs", "embedded-io 0.4.0", @@ -8376,14 +8354,22 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.2" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" dependencies = [ - "toml_datetime", "toml_edit 0.20.2", ] +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit 0.22.22", +] + [[package]] name = "proc-macro-error" version = "0.4.12" @@ -8654,13 +8640,13 @@ dependencies = [ [[package]] name = "quic-rpc" -version = "0.17.1" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7a980daf521a275ae2a04fefc311c96fd0cf11ae430324d1b914d072bcc408b" +checksum = "8649f6353ef952672f35ddaf586c1a57152373f3d5b0767c5140b08f2d7ec6f8" dependencies = [ "anyhow", "bytes", - "derive_more 1.0.0", + "document-features", "flume", "futures-lite 2.5.0", "futures-sink", @@ -8679,6 +8665,18 @@ dependencies = [ "tracing", ] +[[package]] +name = "quic-rpc-derive" +version = "0.17.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a32e88a525c7616b2bfce4be94a875eeac46bf20faea5e580cb54dc739e64e5" +dependencies = [ + "proc-macro2", + "quic-rpc", + "quote", + "syn 1.0.109", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -8798,12 +8796,6 @@ dependencies = [ "pest_derive", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" version = "0.7.3" @@ -8962,6 +8954,7 @@ dependencies = [ "loop9", "quick-error 2.0.1", "rav1e", + "rayon", "rgb", ] @@ -9062,9 +9055,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -9183,9 +9176,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", @@ -9195,10 +9188,10 @@ dependencies = [ "futures-core", "futures-util", "h2 0.4.6", - "http 1.1.0", + "http 1.2.0", "http-body 1.0.1", "http-body-util", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-rustls", "hyper-tls 0.6.0", "hyper-util", @@ -9241,8 +9234,8 @@ checksum = "d1ccd3b55e711f91a9885a2fa6fbbb2e39db1776420b062efc058c6410f7e5e3" dependencies = [ "anyhow", "async-trait", - "http 1.1.0", - "reqwest 0.12.8", + "http 1.2.0", + "reqwest 0.12.9", "serde", "thiserror 1.0.64", "tower-service", @@ -9258,10 +9251,10 @@ dependencies = [ "async-trait", "futures", "getrandom 0.2.15", - "http 1.1.0", - "hyper 1.5.0", + "http 1.2.0", + "hyper 1.5.2", "parking_lot 0.11.2", - "reqwest 0.12.8", + "reqwest 0.12.9", "reqwest-middleware", "retry-policies", "thiserror 1.0.64", @@ -9577,15 +9570,15 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.38" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -9904,7 +9897,7 @@ dependencies = [ "ort", "ort-sys", "prisma-client-rust", - "reqwest 0.12.8", + "reqwest 0.12.9", "rmp-serde", "rmpv", "sd-core-file-path-helper", @@ -9914,7 +9907,7 @@ dependencies = [ "sd-sync", "sd-utils", "serde", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tracing", "url", @@ -9939,7 +9932,7 @@ dependencies = [ "rspc", "serde", "specta", - "thiserror 2.0.3", + "thiserror 2.0.8", "tracing", "url", "uuid", @@ -9970,7 +9963,7 @@ dependencies = [ "hostname 0.4.0", "http-body 1.0.1", "http-range", - "hyper 1.5.0", + "hyper 1.5.2", "hyper-util", "icrate", "image", @@ -9986,7 +9979,7 @@ dependencies = [ "plist", "prisma-client-rust", "regex", - "reqwest 0.12.8", + "reqwest 0.12.9", "rmp-serde", "rmpv", "rspc", @@ -10004,10 +9997,10 @@ dependencies = [ "sd-file-ext", "sd-images", "sd-media-metadata", - "sd-p2p", - "sd-p2p-block", - "sd-p2p-proto", - "sd-p2p-tunnel", + "sd-old-p2p", + "sd-old-p2p-block", + "sd-old-p2p-proto", + "sd-old-p2p-tunnel", "sd-prisma", "sd-sync", "sd-task-system", @@ -10024,7 +10017,7 @@ dependencies = [ "sysinfo", "tar", "tempfile", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tokio-stream", "tokio-util", @@ -10057,7 +10050,7 @@ dependencies = [ "iroh-quinn", "paste", "quic-rpc", - "reqwest 0.12.8", + "reqwest 0.12.9", "reqwest-middleware", "reqwest-retry", "rmp-serde", @@ -10073,7 +10066,7 @@ dependencies = [ "serde", "serde_json", "specta", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tokio-stream", "tokio-util", @@ -10094,7 +10087,7 @@ dependencies = [ "sd-prisma", "sd-utils", "serde", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tracing", "windows 0.58.0", @@ -10136,7 +10129,7 @@ dependencies = [ "static_assertions", "strum", "tempfile", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tokio-stream", "tracing", @@ -10161,12 +10154,39 @@ dependencies = [ "serde", "specta", "tempfile", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tracing", "uuid", ] +[[package]] +name = "sd-core-p2p" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-stream", + "derive_more 1.0.0", + "flume", + "futures", + "futures-concurrency", + "iroh", + "nested_enum_utils", + "postcard", + "quic-rpc", + "quic-rpc-derive", + "sd-cloud-schema", + "sd-core-cloud-services", + "sd-crypto", + "serde", + "specta", + "thiserror 2.0.8", + "tokio", + "tokio-util", + "tracing", + "url", +] + [[package]] name = "sd-core-prisma-helpers" version = "0.1.0" @@ -10200,7 +10220,7 @@ dependencies = [ "sd-sync", "sd-utils", "serde", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tracing", "tracing-subscriber", @@ -10229,7 +10249,7 @@ dependencies = [ "serde", "serdect 0.3.0-rc.0", "tempfile", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "typenum", "zeroize", @@ -10243,8 +10263,8 @@ dependencies = [ "axum-extra", "dbus", "futures", - "http 1.1.0", - "hyper 1.5.0", + "http 1.2.0", + "hyper 1.5.2", "mimalloc", "opener", "prisma-client-rust", @@ -10272,7 +10292,7 @@ dependencies = [ "tauri-plugin-shell", "tauri-plugin-updater", "tauri-specta", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tracing", "uuid", @@ -10309,7 +10329,7 @@ dependencies = [ name = "sd-fda" version = "0.1.0" dependencies = [ - "thiserror 1.0.64", + "thiserror 2.0.8", ] [[package]] @@ -10322,7 +10342,7 @@ dependencies = [ "libc", "sd-utils", "tempfile", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tracing", "webp", @@ -10344,7 +10364,7 @@ dependencies = [ name = "sd-images" version = "0.1.0" dependencies = [ - "bincode 2.0.0-rc.3", + "bincode", "image", "libheif-rs", "libheif-sys", @@ -10353,7 +10373,7 @@ dependencies = [ "rspc", "serde", "specta", - "thiserror 1.0.64", + "thiserror 2.0.8", "tracing", ] @@ -10369,7 +10389,7 @@ dependencies = [ "serde", "serde_json", "specta", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", ] @@ -10404,7 +10424,7 @@ dependencies = [ ] [[package]] -name = "sd-p2p" +name = "sd-old-p2p" version = "0.2.0" dependencies = [ "base64 0.22.1", @@ -10423,7 +10443,7 @@ dependencies = [ "specta", "stable-vec", "sync_wrapper 1.0.1", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tokio-util", "tracing", @@ -10433,33 +10453,33 @@ dependencies = [ ] [[package]] -name = "sd-p2p-block" +name = "sd-old-p2p-block" version = "0.1.0" dependencies = [ - "sd-p2p-proto", - "thiserror 1.0.64", + "sd-old-p2p-proto", + "thiserror 2.0.8", "tokio", "tracing", "uuid", ] [[package]] -name = "sd-p2p-proto" +name = "sd-old-p2p-proto" version = "0.1.0" dependencies = [ "ed25519-dalek", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "uuid", ] [[package]] -name = "sd-p2p-tunnel" +name = "sd-old-p2p-tunnel" version = "0.1.0" dependencies = [ - "sd-p2p", - "sd-p2p-proto", - "thiserror 1.0.64", + "sd-old-p2p", + "sd-old-p2p-proto", + "thiserror 2.0.8", "tokio", ] @@ -10481,7 +10501,7 @@ version = "0.1.0" dependencies = [ "axum", "axum-extra", - "http 1.1.0", + "http 1.2.0", "include_dir", "mime_guess", "rspc", @@ -10512,7 +10532,7 @@ dependencies = [ "nom", "prisma-client-rust-sdk", "serde", - "thiserror 1.0.64", + "thiserror 2.0.8", ] [[package]] @@ -10530,7 +10550,7 @@ dependencies = [ "rmp-serde", "serde", "tempfile", - "thiserror 1.0.64", + "thiserror 2.0.8", "tokio", "tokio-stream", "tracing", @@ -10549,7 +10569,7 @@ dependencies = [ "rmpv", "rspc", "sd-prisma", - "thiserror 1.0.64", + "thiserror 2.0.8", "tracing", "uhlc", "uuid", @@ -10639,9 +10659,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] @@ -10697,9 +10717,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -10719,9 +10739,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "indexmap 2.6.0", "itoa 1.0.11", @@ -11755,12 +11775,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - [[package]] name = "tar" version = "0.4.42" @@ -11794,7 +11808,7 @@ dependencies = [ "glob", "gtk", "heck 0.5.0", - "http 1.1.0", + "http 1.2.0", "jni 0.21.1", "libc", "log", @@ -11806,7 +11820,7 @@ dependencies = [ "percent-encoding", "plist", "raw-window-handle", - "reqwest 0.12.8", + "reqwest 0.12.9", "serde", "serde_json", "serde_repr", @@ -12009,9 +12023,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c752aee1b00ec3c4d4f440095995d9bd2c640b478f2067d1fba388900b82eb96" dependencies = [ "data-url", - "http 1.1.0", + "http 1.2.0", "regex", - "reqwest 0.12.8", + "reqwest 0.12.9", "schemars", "serde", "serde_json", @@ -12073,11 +12087,11 @@ dependencies = [ "dirs", "flate2", "futures-util", - "http 1.1.0", + "http 1.2.0", "infer", "minisign-verify", "percent-encoding", - "reqwest 0.12.8", + "reqwest 0.12.9", "semver", "serde", "serde_json", @@ -12101,7 +12115,7 @@ checksum = "a1ef7363e7229ac8d04e8a5d405670dbd43dde8fc4bc3bc56105c35452d03784" dependencies = [ "dpi", "gtk", - "http 1.1.0", + "http 1.2.0", "jni 0.21.1", "raw-window-handle", "serde", @@ -12119,7 +12133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62fa2068e8498ad007b54d5773d03d57c3ff6dd96f8c8ce58beff44d0d5e0d30" dependencies = [ "gtk", - "http 1.1.0", + "http 1.2.0", "jni 0.21.1", "log", "objc2", @@ -12212,9 +12226,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand 2.1.1", @@ -12260,11 +12274,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.3" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" +checksum = "08f5383f3e0071702bf93ab5ee99b52d26936be9dedd9413067cbdcddcb6141a" dependencies = [ - "thiserror-impl 2.0.3", + "thiserror-impl 2.0.8", ] [[package]] @@ -12280,9 +12294,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.3" +version = "2.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +checksum = "f2f357fcec90b3caef6623a099691be676d033b40a058ac95d2a6ade6fa0c943" dependencies = [ "proc-macro2", "quote", @@ -12393,9 +12407,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -12457,12 +12471,12 @@ dependencies = [ "pem", "proc-macro2", "rcgen 0.13.1", - "reqwest 0.12.8", + "reqwest 0.12.9", "ring 0.17.8", "rustls", "serde", "serde_json", - "thiserror 2.0.3", + "thiserror 2.0.8", "time", "tokio", "tokio-rustls", @@ -12476,20 +12490,17 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "caf600e7036b17782571dd44fa0a5cea3c82f60db5137f774a325a76a0d6852b" dependencies = [ - "bincode 1.3.3", "bytes", - "educe", "futures-core", "futures-sink", "pin-project", - "serde", ] [[package]] name = "tokio-stream" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", @@ -12528,7 +12539,7 @@ checksum = "8e57a65894797a018b28345fa298a00c450a574aa9671e50b18218a6292a55ac" dependencies = [ "futures-channel", "futures-util", - "http 1.1.0", + "http 1.2.0", "httparse", "js-sys", "thiserror 1.0.64", @@ -12540,9 +12551,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" +checksum = "d7fcaa8d55a2bdd6b83ace262b016eca0d79ee02818c5c1bcdf0305114081078" dependencies = [ "bytes", "futures-core", @@ -12580,9 +12591,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] @@ -12597,7 +12608,7 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", ] [[package]] @@ -12610,7 +12621,18 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.5.40", +] + +[[package]] +name = "toml_edit" +version = "0.22.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" +dependencies = [ + "indexmap 2.6.0", + "toml_datetime", + "winnow 0.6.20", ] [[package]] @@ -12643,9 +12665,9 @@ checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "log", "pin-project-lite", @@ -12678,9 +12700,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", @@ -12689,9 +12711,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -12730,9 +12752,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", "nu-ansi-term", @@ -12850,7 +12872,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http 1.2.0", "httparse", "log", "rand 0.8.5", @@ -12869,7 +12891,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.1.0", + "http 1.2.0", "httparse", "log", "native-tls", @@ -13702,7 +13724,7 @@ dependencies = [ "document-features", "js-sys", "log", - "parking_lot 0.11.2", + "parking_lot 0.12.3", "profiling", "raw-window-handle", "smallvec", @@ -13730,7 +13752,7 @@ dependencies = [ "log", "naga", "once_cell", - "parking_lot 0.11.2", + "parking_lot 0.12.3", "profiling", "raw-window-handle", "rustc-hash 1.1.0", @@ -13768,7 +13790,7 @@ dependencies = [ "ndk-sys 0.5.0+25.2.9519653", "objc", "once_cell", - "parking_lot 0.11.2", + "parking_lot 0.12.3", "profiling", "raw-window-handle", "renderdoc-sys", @@ -14281,6 +14303,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" +dependencies = [ + "memchr", +] + [[package]] name = "winreg" version = "0.50.0" @@ -14311,7 +14342,7 @@ dependencies = [ "futures", "log", "serde", - "thiserror 2.0.3", + "thiserror 2.0.8", "windows 0.58.0", "windows-core 0.58.0", ] @@ -14330,7 +14361,7 @@ dependencies = [ "gdkx11", "gtk", "html5ever", - "http 1.1.0", + "http 1.2.0", "javascriptcore-rs", "jni 0.21.1", "kuchikiki", @@ -14357,15 +14388,6 @@ dependencies = [ "x11-dl", ] -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - [[package]] name = "x11" version = "2.21.0" diff --git a/Cargo.toml b/Cargo.toml index 3d48b2a01120..164575fa8891 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,47 +23,50 @@ rust-version = "1.81" sd-cloud-schema = { git = "https://github.com/spacedriveapp/cloud-services-schema", rev = "4e4565bee4" } # Third party dependencies used by one or more of our crates +anyhow = "1.0.94" async-channel = "2.3" async-stream = "0.3.6" async-trait = "0.1.83" -axum = "0.7.7" -axum-extra = "0.9.4" +axum = "0.7.9" +axum-extra = "0.9.6" base64 = "0.22.1" -blake3 = "1.5.4" -bytes = "1.7.1" # Update blocked by hyper -chrono = "0.4.38" +blake3 = "1.5.5" +bytes = "1.9.0" +chrono = "0.4.39" ed25519-dalek = "2.1" flume = "0.11.0" futures = "0.3.31" -futures-concurrency = "7.6" +futures-concurrency = "7.6.2" globset = "0.4.15" -http = "1.1" -hyper = "1.5" -image = "0.25.4" +http = "1.2.0" +hyper = "1.5.2" +image = "0.25.5" +iroh = "0.29.0" itertools = "0.13.0" lending-stream = "1.0" -libc = "0.2.159" +libc = "0.2.169" mimalloc = "0.1.43" normpath = "1.3" -pin-project-lite = "0.2.14" +pin-project-lite = "0.2.15" +quic-rpc = "0.17.3" rand = "0.9.0-alpha.2" -regex = "1.11" -reqwest = { version = "0.12.8", default-features = false } +regex = "1.11.1" +reqwest = { version = "0.12.9", default-features = false } rmp = "0.8.14" rmp-serde = "1.3" rmpv = { version = "1.3", features = ["with-serde"] } -serde = "1.0" -serde_json = "1.0" +serde = "1.0.216" +serde_json = "1.0.133" specta = "=2.0.0-rc.20" strum = "0.26" strum_macros = "0.26" -tempfile = "3.13" -thiserror = "1.0" -tokio = "1.40" -tokio-stream = "0.1.16" -tokio-util = "0.7.12" -tracing = "0.1.40" -tracing-subscriber = "0.3.18" +tempfile = "3.14.0" +thiserror = "2.0.8" +tokio = "1.42.0" +tokio-stream = "0.1.17" +tokio-util = "0.7.13" +tracing = "0.1.41" +tracing-subscriber = "0.3.19" tracing-test = "0.2.5" uhlc = "0.8.0" # Must follow version used by specta uuid = "1.10" # Must follow version used by specta diff --git a/core/Cargo.toml b/core/Cargo.toml index 967553ab50e8..83d565235983 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -35,10 +35,10 @@ sd-ffmpeg = { path = "../crates/ffmpeg", optional = true } sd-file-ext = { path = "../crates/file-ext" } sd-images = { path = "../crates/images", features = ["rspc", "serde", "specta"] } sd-media-metadata = { path = "../crates/media-metadata" } -sd-p2p = { path = "../crates/p2p", features = ["specta"] } -sd-p2p-block = { path = "../crates/p2p/crates/block" } -sd-p2p-proto = { path = "../crates/p2p/crates/proto" } -sd-p2p-tunnel = { path = "../crates/p2p/crates/tunnel" } +sd-old-p2p = { path = "../crates/old-p2p", features = ["specta"] } +sd-old-p2p-block = { path = "../crates/old-p2p/crates/block" } +sd-old-p2p-proto = { path = "../crates/old-p2p/crates/proto" } +sd-old-p2p-tunnel = { path = "../crates/old-p2p/crates/tunnel" } sd-prisma = { path = "../crates/prisma" } sd-sync = { path = "../crates/sync" } sd-task-system = { path = "../crates/task-system" } diff --git a/core/crates/cloud-services/Cargo.toml b/core/crates/cloud-services/Cargo.toml index 8923e00ddc81..e5a385496916 100644 --- a/core/crates/cloud-services/Cargo.toml +++ b/core/crates/cloud-services/Cargo.toml @@ -16,6 +16,7 @@ sd-prisma = { path = "../../../crates/prisma" } sd-utils = { path = "../../../crates/utils" } # Workspace dependencies +anyhow = { workspace = true } async-stream = { workspace = true } base64 = { workspace = true } blake3 = { workspace = true } @@ -23,6 +24,8 @@ chrono = { workspace = true, features = ["serde"] } flume = { workspace = true } futures = { workspace = true } futures-concurrency = { workspace = true } +iroh = { workspace = true, features = ["discovery-local-network"] } +quic-rpc = { workspace = true, features = ["iroh-transport", "quinn-transport"] } rmp-serde = { workspace = true } rspc = { workspace = true } serde = { workspace = true, features = ["derive"] } @@ -37,12 +40,9 @@ uuid = { workspace = true, features = ["serde"] } zeroize = { workspace = true } # External dependencies -anyhow = "1.0.86" -dashmap = "6.1.0" -iroh = { version = "0.29.0", features = ["discovery-local-network"] } -paste = "=1.0.15" -quic-rpc = { version = "0.17.1", features = ["iroh-transport", "quinn-transport"] } -quinn = { package = "iroh-quinn", version = "0.12" } +dashmap = "6.1.0" +paste = "=1.0.15" +quinn = { package = "iroh-quinn", version = "0.12" } # Using whatever version of reqwest that reqwest-middleware uses, just putting here to enable some features reqwest = { version = "0.12", features = ["json", "native-tls-vendored", "stream"] } reqwest-middleware = { version = "0.4", features = ["json"] } diff --git a/core/crates/cloud-services/src/client.rs b/core/crates/cloud-services/src/client.rs index 13aee00dfa9c..d82319941225 100644 --- a/core/crates/cloud-services/src/client.rs +++ b/core/crates/cloud-services/src/client.rs @@ -1,16 +1,16 @@ use crate::p2p::{NotifyUser, UserResponse}; -use sd_cloud_schema::{Client, Request, Response, ServicesALPN}; +use sd_cloud_schema::{Client, Service, ServicesALPN}; use std::{net::SocketAddr, sync::Arc, time::Duration}; use futures::Stream; use iroh::relay::RelayUrl; -use quic_rpc::{transport::quinn::QuinnConnector, RpcClient, RpcMessage}; +use quic_rpc::{client::QuinnConnector, RpcClient}; use quinn::{crypto::rustls::QuicClientConfig, ClientConfig, Endpoint}; use reqwest::{IntoUrl, Url}; use reqwest_middleware::{reqwest, ClientBuilder, ClientWithMiddleware}; -use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware}; +// use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware}; use tokio::sync::{Mutex, RwLock}; use tracing::warn; @@ -18,11 +18,13 @@ use super::{ error::Error, key_manager::KeyManager, p2p::CloudP2P, token_refresher::TokenRefresher, }; +pub type CloudServicesClient = Client>; + #[derive(Debug, Default, Clone)] -enum ClientState { +enum ClientState { #[default] NotConnected, - Connected(Client>), + Connected(CloudServicesClient), } /// Cloud services are a optional feature that allows you to interact with the cloud services @@ -35,7 +37,7 @@ enum ClientState { /// that core can always operate without the cloud services. #[derive(Debug)] pub struct CloudServices { - client_state: Arc>>, + client_state: Arc>, get_cloud_api_address: Url, http_client: ClientWithMiddleware, domain_name: String, @@ -158,7 +160,7 @@ impl CloudServices { http_client: &ClientWithMiddleware, get_cloud_api_address: Url, domain_name: String, - ) -> Result>, Error> { + ) -> Result { let cloud_api_address = http_client .get(get_cloud_api_address) .send() @@ -257,7 +259,7 @@ impl CloudServices { .map_err(Error::FailedToCreateEndpoint)?; endpoint.set_default_client_config(client_config); - Ok(Client::new(RpcClient::new(QuinnConnector::new( + Ok(Client::new(RpcClient::new(QuinnConnector::::new( endpoint, cloud_api_address, domain_name, @@ -269,7 +271,7 @@ impl CloudServices { /// If the client is not connected, it will try to connect to the cloud services. /// Available routes documented in /// [`sd_cloud_schema::Service`](https://github.com/spacedriveapp/cloud-services-schema). - pub async fn client(&self) -> Result>, Error> { + pub async fn client(&self) -> Result { if let ClientState::Connected(client) = { &*self.client_state.read().await } { return Ok(client.clone()); } diff --git a/core/crates/heavy-lifting/src/media_processor/tasks/media_data_extractor.rs b/core/crates/heavy-lifting/src/media_processor/tasks/media_data_extractor.rs index cd1c962da301..3d72845e1771 100644 --- a/core/crates/heavy-lifting/src/media_processor/tasks/media_data_extractor.rs +++ b/core/crates/heavy-lifting/src/media_processor/tasks/media_data_extractor.rs @@ -36,7 +36,7 @@ use tracing::{debug, instrument, trace, Level}; #[derive(thiserror::Error, Debug, Serialize, Deserialize, Type, Clone)] pub enum NonCriticalMediaDataExtractorError { - #[error("failed to extract media data from : {1}", .0.display())] + #[error("failed to extract media data from : {1}", path = .0.display())] FailedToExtractImageMediaData(PathBuf, String), #[error("file path missing object id: ")] FilePathMissingObjectId(file_path::id::Type), diff --git a/core/crates/heavy-lifting/src/media_processor/tasks/thumbnailer.rs b/core/crates/heavy-lifting/src/media_processor/tasks/thumbnailer.rs index 1497e3cc4672..79687f8f6ea9 100644 --- a/core/crates/heavy-lifting/src/media_processor/tasks/thumbnailer.rs +++ b/core/crates/heavy-lifting/src/media_processor/tasks/thumbnailer.rs @@ -211,17 +211,17 @@ pub enum NonCriticalThumbnailerError { MissingCasId(file_path::id::Type), #[error("failed to extract isolated file path data from file path : {1}")] FailedToExtractIsolatedFilePathData(file_path::id::Type, String), - #[error("failed to generate video file thumbnail : {1}", .0.display())] + #[error("failed to generate video file thumbnail : {1}", path = .0.display())] VideoThumbnailGenerationFailed(PathBuf, String), - #[error("failed to format image : {1}", .0.display())] + #[error("failed to format image : {1}", path = .0.display())] FormatImage(PathBuf, String), - #[error("failed to encode webp image : {1}", .0.display())] + #[error("failed to encode webp image : {1}", path = .0.display())] WebPEncoding(PathBuf, String), - #[error("processing thread panicked while generating thumbnail from : {1}", .0.display())] + #[error("processing thread panicked while generating thumbnail from : {1}", path = .0.display())] PanicWhileGeneratingThumbnail(PathBuf, String), #[error("failed to create shard directory for thumbnail: {0}")] CreateShardDirectory(String), - #[error("failed to save thumbnail : {1}", .0.display())] + #[error("failed to save thumbnail : {1}", path = .0.display())] SaveThumbnail(PathBuf, String), #[error("task timed out: {0}")] TaskTimeout(TaskId), diff --git a/core/crates/p2p/Cargo.toml b/core/crates/p2p/Cargo.toml new file mode 100644 index 000000000000..9427dd58188f --- /dev/null +++ b/core/crates/p2p/Cargo.toml @@ -0,0 +1,70 @@ +[package] +edition = "2021" +name = "sd-core-p2p" +version = "0.1.0" + +[lints.rust] +# Warns +deprecated = "warn" +rust_2018_idioms = { level = "warn", priority = -1 } +trivial_casts = "warn" +trivial_numeric_casts = "warn" +unused_allocation = "warn" +unused_qualifications = "warn" +# Forbids +deprecated_in_future = "forbid" + +[lints.clippy] +# Warns +all = { level = "warn", priority = -1 } +cast_lossless = "warn" +cast_possible_truncation = "warn" +cast_possible_wrap = "warn" +cast_precision_loss = "warn" +cast_sign_loss = "warn" +complexity = { level = "warn", priority = -1 } +correctness = { level = "warn", priority = -1 } +dbg_macro = "warn" +deprecated_cfg_attr = "warn" +nursery = { level = "warn", priority = -1 } +pedantic = { level = "warn", priority = -1 } +perf = { level = "warn", priority = -1 } +separated_literal_suffix = "warn" +style = { level = "warn", priority = -1 } +suspicious = { level = "warn", priority = -1 } +unnecessary_cast = "warn" +unwrap_used = "warn" +# Allows +missing_errors_doc = "allow" +module_name_repetitions = "allow" + +[dependencies] +# Core Spacedrive Sub-crates +sd-core-cloud-services = { path = "../cloud-services" } + +# Spacedrive Sub-crates +sd-cloud-schema = { workspace = true } +sd-crypto = { path = "../../../crates/crypto" } + + +# Workspace dependencies +anyhow = { workspace = true } +async-stream = { workspace = true } +flume = { workspace = true } +futures = { workspace = true } +futures-concurrency = { workspace = true } +iroh = { workspace = true, features = ["discovery-local-network"] } +quic-rpc = { workspace = true, features = ["iroh-transport"] } +serde = { workspace = true, features = ["derive"] } +specta = { workspace = true, features = ["chrono", "uuid"] } +thiserror = { workspace = true } +tokio = { workspace = true, features = ["sync"] } +tokio-util = { workspace = true } +tracing = { workspace = true } + +# External dependencies +derive_more = { version = "1.0", features = ["display", "from", "try_into"] } +nested_enum_utils = "0.1" +postcard = { version = "1.1", features = ["use-std"] } +quic-rpc-derive = "0.17" +url = "2.5" diff --git a/core/crates/p2p/src/error.rs b/core/crates/p2p/src/error.rs new file mode 100644 index 000000000000..d004227f5249 --- /dev/null +++ b/core/crates/p2p/src/error.rs @@ -0,0 +1,24 @@ +use std::io; + +#[derive(Debug, thiserror::Error)] +pub enum Error { + // Network setup errors + #[error("Setup iroh endpoint: {0}")] + SetupEndpoint(anyhow::Error), + #[error("Setup iroh listener: {0}")] + SetupListener(io::Error), + #[error("Initialize LocalSwarmDiscovery: {0}")] + LocalSwarmDiscoveryInit(anyhow::Error), + #[error("Initialize DhtDiscovery: {0}")] + DhtDiscoveryInit(anyhow::Error), + + // Known hosts loading errors + #[error("Serialize known devices: {0}")] + SerializeKnownDevices(postcard::Error), + #[error("Deserialize known devices: {0}")] + DeserializeKnownDevices(postcard::Error), + #[error("Load known devices from file: {0}")] + LoadKnownDevices(io::Error), + #[error("Save known devices to file: {0}")] + SaveKnownDevices(io::Error), +} diff --git a/core/crates/p2p/src/lib.rs b/core/crates/p2p/src/lib.rs new file mode 100644 index 000000000000..d1f8646392c0 --- /dev/null +++ b/core/crates/p2p/src/lib.rs @@ -0,0 +1,162 @@ +use sd_core_cloud_services::CloudServices; + +use sd_cloud_schema::devices; +use sd_crypto::CryptoRng; + +use std::{path::Path, sync::Arc}; + +use iroh::{ + discovery::{ + dns::DnsDiscovery, local_swarm_discovery::LocalSwarmDiscovery, pkarr::dht::DhtDiscovery, + ConcurrentDiscovery, + }, + key::SecretKey, + Endpoint, NodeId, RelayMap, RelayMode, RelayUrl, +}; +use quic_rpc::{server::IrohListener, RpcServer}; +use tokio::{ + fs, io, + sync::{oneshot, RwLock}, +}; +use url::Url; + +mod error; +mod schema; +mod server; + +use server::Server; + +pub use error::Error; + +const KNOWN_DEVICES_FILE_NAME: &str = "known_devices.bin"; + +#[derive(Debug, Clone)] +pub struct P2P { + current_device_pub_id: devices::PubId, + known_devices_file_path: Arc>, + endpoint: Endpoint, + cloud_services: Arc>>, + known_devices: Arc>>, + cancel_tx: flume::Sender>, +} + +impl P2P { + pub async fn new( + data_directory: impl AsRef + Send, + current_device_pub_id: devices::PubId, + rng: CryptoRng, + iroh_secret_key: SecretKey, + dns_origin_domain: String, + dns_pkarr_url: Url, + relay_url: RelayUrl, + ) -> Result { + async fn inner( + data_directory: &Path, + current_device_pub_id: devices::PubId, + rng: CryptoRng, + iroh_secret_key: SecretKey, + dns_origin_domain: String, + dns_pkarr_url: Url, + relay_url: RelayUrl, + ) -> Result { + let endpoint = Endpoint::builder() + .alpns(vec![schema::ALPN::LATEST.to_vec()]) + .discovery(Box::new(ConcurrentDiscovery::from_services(vec![ + Box::new(DnsDiscovery::new(dns_origin_domain)), + Box::new( + LocalSwarmDiscovery::new(iroh_secret_key.public()) + .map_err(Error::LocalSwarmDiscoveryInit)?, + ), + Box::new( + DhtDiscovery::builder() + .secret_key(iroh_secret_key.clone()) + .pkarr_relay(dns_pkarr_url) + .build() + .map_err(Error::DhtDiscoveryInit)?, + ), + ]))) + .secret_key(iroh_secret_key) + .relay_mode(RelayMode::Custom(RelayMap::from_url(relay_url))) + .bind() + .await + .map_err(Error::SetupEndpoint)?; + + let (cancel_tx, cancel_rx) = flume::bounded(1); + + let known_devices_file_path = data_directory + .join(KNOWN_DEVICES_FILE_NAME) + .into_boxed_path(); + + let known_devices = Arc::new(RwLock::new( + P2P::load_known_devices(&known_devices_file_path).await?, + )); + + let cloud_services = Arc::default(); + + Server::new( + current_device_pub_id, + Arc::clone(&cloud_services), + Arc::clone(&known_devices), + ) + .dispatch( + RpcServer::new( + IrohListener::::new(endpoint.clone()) + .map_err(Error::SetupListener)?, + ), + cancel_rx, + ); + + Ok(P2P { + current_device_pub_id, + endpoint, + cloud_services, + known_devices, + known_devices_file_path: Arc::new(known_devices_file_path), + cancel_tx, + }) + } + + inner( + data_directory.as_ref(), + current_device_pub_id, + rng, + iroh_secret_key, + dns_origin_domain, + dns_pkarr_url, + relay_url, + ) + .await + } + + async fn load_known_devices( + known_devices_file_path: impl AsRef + Send, + ) -> Result, Error> { + async fn inner(known_devices_file_path: &Path) -> Result, Error> { + match fs::read(known_devices_file_path).await { + Ok(data) => postcard::from_bytes(&data).map_err(Error::DeserializeKnownDevices), + Err(e) if e.kind() == io::ErrorKind::NotFound => Ok(Vec::new()), + Err(e) => Err(Error::LoadKnownDevices(e)), + } + } + + inner(known_devices_file_path.as_ref()).await + } + + pub async fn set_cloud_services(&self, cloud_services: CloudServices) { + self.cloud_services.write().await.replace(cloud_services); + } + + pub async fn shutdown(&self) -> Result<(), Error> { + let (tx, rx) = oneshot::channel(); + self.cancel_tx.send_async(tx).await.unwrap(); + rx.await.unwrap(); + + fs::write( + self.known_devices_file_path.as_ref(), + &postcard::to_stdvec(&*self.known_devices.read().await) + .map_err(Error::SerializeKnownDevices)?, + ) + .await + .map_err(Error::SaveKnownDevices) + } +} diff --git a/core/crates/p2p/src/schema/cloud_services/authorize_new_device_in_sync_group.rs b/core/crates/p2p/src/schema/cloud_services/authorize_new_device_in_sync_group.rs new file mode 100644 index 000000000000..fbea51866c79 --- /dev/null +++ b/core/crates/p2p/src/schema/cloud_services/authorize_new_device_in_sync_group.rs @@ -0,0 +1,22 @@ +use sd_cloud_schema::{devices, libraries, sync::groups}; + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Request { + pub sync_group: groups::GroupWithDevices, + pub asking_device: devices::Device, +} + +#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] +pub enum Response { + Accepted { + authorizor_device: devices::Device, + keys: Vec>, + library_pub_id: libraries::PubId, + library_name: String, + library_description: Option, + }, + Rejected, + TimedOut, +} diff --git a/core/crates/p2p/src/schema/cloud_services/mod.rs b/core/crates/p2p/src/schema/cloud_services/mod.rs new file mode 100644 index 000000000000..39d1ff7ec009 --- /dev/null +++ b/core/crates/p2p/src/schema/cloud_services/mod.rs @@ -0,0 +1,25 @@ +use crate::schema::Service; + +use nested_enum_utils::enum_conversions; +use serde::{Deserialize, Serialize}; + +pub mod authorize_new_device_in_sync_group; +pub mod notify_new_sync_messages; + +#[allow(clippy::large_enum_variant)] +#[nested_enum_utils::enum_conversions(super::Request)] +#[derive(Debug, Serialize, Deserialize)] +#[quic_rpc_derive::rpc_requests(Service)] +pub enum Request { + #[rpc(response = authorize_new_device_in_sync_group::Response)] + AuthorizeNewDeviceInSyncGroup(authorize_new_device_in_sync_group::Request), + #[rpc(response = notify_new_sync_messages::Response)] + NotifyNewSyncMessages(notify_new_sync_messages::Request), +} + +#[derive(Debug, Serialize, Deserialize)] +#[enum_conversions(super::Response)] +pub enum Response { + AuthorizeNewDeviceInSyncGroup(authorize_new_device_in_sync_group::Response), + NotifyNewSyncMessages(notify_new_sync_messages::Response), +} diff --git a/core/crates/p2p/src/schema/cloud_services/notify_new_sync_messages.rs b/core/crates/p2p/src/schema/cloud_services/notify_new_sync_messages.rs new file mode 100644 index 000000000000..415e0dd6b224 --- /dev/null +++ b/core/crates/p2p/src/schema/cloud_services/notify_new_sync_messages.rs @@ -0,0 +1,12 @@ +use sd_cloud_schema::{devices, sync::groups}; + +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct Request { + pub sync_group_pub_id: groups::PubId, + pub device_pub_id: devices::PubId, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Response; diff --git a/core/crates/p2p/src/schema/mod.rs b/core/crates/p2p/src/schema/mod.rs new file mode 100644 index 000000000000..8e40a360af0a --- /dev/null +++ b/core/crates/p2p/src/schema/mod.rs @@ -0,0 +1,36 @@ +use serde::{Deserialize, Serialize}; + +pub mod cloud_services; + +/// ALPN for the Spacedrive P2P protocol +/// +/// P2P with associated constants for each existing version and an alias for the latest version. +/// This application layer protocol is used when a cloud service needs to devices communicating +/// with each other, like for sending sync keys, or other strictly P2P features, like Spacedrop. +pub struct ALPN; + +impl ALPN { + pub const LATEST: &'static [u8] = Self::V1; + pub const V1: &'static [u8] = b"sd-p2p/v1"; +} + +#[derive(Debug, Clone)] +pub struct Service; + +impl quic_rpc::Service for Service { + type Req = Request; + + type Res = Response; +} + +#[nested_enum_utils::enum_conversions] +#[derive(Debug, Serialize, Deserialize)] +pub enum Request { + CloudServices(cloud_services::Request), +} + +#[nested_enum_utils::enum_conversions] +#[derive(Debug, Serialize, Deserialize)] +pub enum Response { + CloudServices(cloud_services::Response), +} diff --git a/core/crates/p2p/src/server/mod.rs b/core/crates/p2p/src/server/mod.rs new file mode 100644 index 000000000000..14d874092694 --- /dev/null +++ b/core/crates/p2p/src/server/mod.rs @@ -0,0 +1,191 @@ +use sd_core_cloud_services::CloudServices; + +use sd_cloud_schema::devices; + +use std::{pin::pin, sync::Arc, time::Duration}; + +use anyhow::Context as _; +use futures::StreamExt as _; +use futures_concurrency::stream::Merge as _; +use iroh::NodeId; +use quic_rpc::{ + server::{Accepting, RpcServerError}, + Listener, RpcServer, +}; +use tokio::{ + spawn, + sync::{oneshot, RwLock}, + task::JoinError, + time::timeout, +}; +use tracing::{error, info, warn}; + +use super::schema; + +mod router; + +const SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(20); + +#[derive(Debug, Clone)] +pub struct Server { + current_device_pub_id: devices::PubId, + cloud_services: Arc>>, + known_devices: Arc>>, +} + +impl Server { + pub fn new( + current_device_pub_id: devices::PubId, + cloud_services: Arc>>, + known_devices: Arc>>, + ) -> Self { + Self { + current_device_pub_id, + cloud_services, + known_devices, + } + } + + async fn handle_single_request( + self, + accepting: Accepting>, + out_tx: flume::Sender, JoinError>>, + ) { + async fn inner( + server: Server, + accepting: Accepting>, + ) -> anyhow::Result<()> { + let (req, chan) = accepting + .read_first() + .await + .context("Failed to receive request")?; + + router::handle(server, req, chan).await + } + + // Running on a detached task to avoid panicking the main task + let res = spawn(inner(self, accepting)).await; + out_tx.send_async(res).await.expect("channel never closes"); + } + + pub fn dispatch( + self, + rpc_server: RpcServer>, + cancel_rx: flume::Receiver>, + ) { + spawn({ + async move { + loop { + info!("Starting P2P Server"); + if let Err(e) = + spawn(self.clone().run_loop(rpc_server.clone(), cancel_rx.clone())).await + { + if e.is_panic() { + error!(?e, "P2P Server crashed, restarting..."); + } else { + break; + } + } + } + } + }); + } + + async fn run_loop( + self, + rpc_server: RpcServer>, + cancel_rx: flume::Receiver>, + ) { + enum StreamMessage> { + AcceptResult(Result, RpcServerError>), + RequestOutcome(Result, JoinError>), + Shutdown(oneshot::Sender<()>), + } + + let (out_tx, out_rx) = flume::bounded(32); + + let mut msg_stream = pin!(( + async_stream::stream! { + loop { + yield StreamMessage::AcceptResult(rpc_server.accept().await); + } + }, + cancel_rx.stream().map(StreamMessage::Shutdown), + out_rx.stream().map(StreamMessage::RequestOutcome) + ) + .merge()); + + let mut inflight_count = 0u32; + + info!("P2P listening for connections..."); + + while let Some(msg) = msg_stream.next().await { + match msg { + StreamMessage::AcceptResult(Ok(accepting)) => { + spawn( + self.clone() + .handle_single_request(accepting, out_tx.clone()), + ); + inflight_count += 1; + } + StreamMessage::AcceptResult(Err(e)) => { + error!(?e, "Failed to accept request;"); + } + + StreamMessage::RequestOutcome(out) => { + process_request_outcome(out); + inflight_count -= 1; + } + + StreamMessage::Shutdown(tx) => { + // Received an Interrupt signal, which means the user wants to stop the server, + // so we wait for all inflight requests to finish before exiting + // this way we're doing a graceful shutdown + + let wait_all_to_finish = async { + while inflight_count > 0 { + process_request_outcome( + // SAFETY: channel never closes + out_rx.recv_async().await.expect("channel never closes"), + ); + inflight_count -= 1; + } + }; + + if let Err(elapsed) = timeout(SHUTDOWN_TIMEOUT, wait_all_to_finish).await { + warn!(?elapsed, %inflight_count, "Server graceful shutdown timed out"); + } else { + info!("Server graceful shutdown complete!"); + } + + if tx.send(()).is_err() { + warn!("Failed to send P2P shutdown completion response;"); + } + + break; + } + } + } + } +} + +fn process_request_outcome(out: Result, JoinError>) { + match out { + Ok(Err(e)) => { + error!(?e, "Failed to handle request;"); + } + Err(e) if e.is_panic() => { + if let Some(msg) = e.into_panic().downcast_ref::<&str>() { + error!(?msg, "Panic in request handler!"); + } else { + error!("Some unknown panic in request handler!"); + } + } + Ok(Ok(())) | Err(_) => { + // The request was handled successfully, or the JoinHandle was aborted, + // which can't happen because we don't even have the handle, so... + // ... + // Everything is Awesome! + } + } +} diff --git a/core/crates/p2p/src/server/router/cloud_services.rs b/core/crates/p2p/src/server/router/cloud_services.rs new file mode 100644 index 000000000000..0378c4c7a8e0 --- /dev/null +++ b/core/crates/p2p/src/server/router/cloud_services.rs @@ -0,0 +1,47 @@ +use crate::{ + schema::{ + self, + cloud_services::{self, authorize_new_device_in_sync_group, notify_new_sync_messages}, + }, + server::Server, +}; + +use anyhow::Context as _; +use quic_rpc::{server::RpcChannel, Listener}; + +pub async fn router( + server: Server, + request: cloud_services::Request, + chan: RpcChannel>, +) -> anyhow::Result<()> { + match request { + cloud_services::Request::AuthorizeNewDeviceInSyncGroup(req) => { + chan.rpc(req, server, authorize_new_device_in_sync_group) + .await + } + cloud_services::Request::NotifyNewSyncMessages(req) => { + chan.rpc(req, server, notify_new_sync_messages).await + } + } + .context("Failed to handle cloud services request") +} + +async fn authorize_new_device_in_sync_group( + server: Server, + authorize_new_device_in_sync_group::Request { + sync_group, + asking_device, + }: authorize_new_device_in_sync_group::Request, +) -> authorize_new_device_in_sync_group::Response { + todo!() +} + +async fn notify_new_sync_messages( + server: Server, + notify_new_sync_messages::Request { + sync_group_pub_id, + device_pub_id, + }: notify_new_sync_messages::Request, +) -> notify_new_sync_messages::Response { + todo!() +} diff --git a/core/crates/p2p/src/server/router/mod.rs b/core/crates/p2p/src/server/router/mod.rs new file mode 100644 index 000000000000..8710b9017b9a --- /dev/null +++ b/core/crates/p2p/src/server/router/mod.rs @@ -0,0 +1,19 @@ +use anyhow::Context; +use quic_rpc::{server::RpcChannel, Listener}; + +use crate::schema; + +use super::Server; + +mod cloud_services; + +pub async fn handle( + server: Server, + request: schema::Request, + chan: RpcChannel>, +) -> anyhow::Result<()> { + match request { + schema::Request::CloudServices(req) => cloud_services::router(server, req, chan).await, + } + .context("Failed to handle p2p request") +} diff --git a/core/src/api/libraries.rs b/core/src/api/libraries.rs index 76c4a4301827..47532e52b736 100644 --- a/core/src/api/libraries.rs +++ b/core/src/api/libraries.rs @@ -10,7 +10,7 @@ use crate::{ use sd_core_heavy_lifting::JobId; use sd_file_ext::kind::ObjectKind; -use sd_p2p::RemoteIdentity; +use sd_old_p2p::RemoteIdentity; use sd_prisma::prisma::{file_path, indexer_rule, object, object_kind_statistics, statistics}; use sd_utils::{db::size_in_bytes_from_db, u64_to_frontend}; diff --git a/core/src/api/locations.rs b/core/src/api/locations.rs index a5d11fa3adf5..a3f4a55f5570 100644 --- a/core/src/api/locations.rs +++ b/core/src/api/locations.rs @@ -5,7 +5,7 @@ use crate::{ relink_location, scan_location, scan_location_sub_path, LocationCreateArgs, LocationError, LocationUpdateArgs, ScanState, }, - p2p::PeerMetadata, + old_p2p::PeerMetadata, util::AbortOnDrop, }; diff --git a/core/src/api/mod.rs b/core/src/api/mod.rs index 7a1dd1597d58..15e664cce9b7 100644 --- a/core/src/api/mod.rs +++ b/core/src/api/mod.rs @@ -13,7 +13,7 @@ use sd_core_heavy_lifting::media_processor::ThumbKey; use sd_core_sync::DevicePubId; use sd_cloud_schema::devices::DeviceOS; -use sd_p2p::RemoteIdentity; +use sd_old_p2p::RemoteIdentity; use sd_prisma::prisma::file_path; use std::sync::Arc; diff --git a/core/src/api/p2p.rs b/core/src/api/p2p.rs index 472e0e46436f..00e45fb66a43 100644 --- a/core/src/api/p2p.rs +++ b/core/src/api/p2p.rs @@ -1,6 +1,6 @@ -use crate::p2p::{operations, ConnectionMethod, DiscoveryMethod, Header, P2PEvent, PeerMetadata}; +use crate::old_p2p::{operations, ConnectionMethod, DiscoveryMethod, Header, P2PEvent, PeerMetadata}; -use sd_p2p::{PeerConnectionCandidate, RemoteIdentity}; +use sd_old_p2p::{PeerConnectionCandidate, RemoteIdentity}; use rspc::{alpha::AlphaRouter, ErrorCode}; use serde::Deserialize; diff --git a/core/src/custom_uri/mod.rs b/core/src/custom_uri/mod.rs index 89bd85122b20..531e4345e926 100644 --- a/core/src/custom_uri/mod.rs +++ b/core/src/custom_uri/mod.rs @@ -1,7 +1,7 @@ use crate::{ api::{utils::InvalidateOperationEvent, CoreEvent}, library::Library, - p2p::operations::{self, request_file}, + old_p2p::operations::{self, request_file}, util::InfallibleResponse, Node, }; @@ -11,8 +11,8 @@ use sd_core_heavy_lifting::media_processor::WEBP_EXTENSION; use sd_core_prisma_helpers::file_path_to_handle_custom_uri; use sd_file_ext::text::is_text; -use sd_p2p::{RemoteIdentity, P2P}; -use sd_p2p_block::Range; +use sd_old_p2p::{RemoteIdentity, P2P}; +use sd_old_p2p_block::Range; use sd_prisma::prisma::{file_path, location}; use sd_utils::db::maybe_missing; use tokio_util::sync::PollSender; diff --git a/core/src/lib.rs b/core/src/lib.rs index 419b395f631b..7030519f40fb 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -46,7 +46,7 @@ pub(crate) mod node; pub(crate) mod notifications; pub(crate) mod object; pub(crate) mod old_job; -pub(crate) mod p2p; +pub(crate) mod old_p2p; pub(crate) mod preferences; #[doc(hidden)] // TODO(@Oscar): Make this private when breaking out `utils` into `sd-utils` pub mod util; @@ -66,7 +66,7 @@ pub struct Node { pub libraries: Arc, pub volumes: Arc, pub locations: location::Locations, - pub p2p: Arc, + pub p2p: Arc, pub event_bus: (broadcast::Sender, broadcast::Receiver), pub notifications: Notifications, pub task_system: TaskSystem, @@ -151,7 +151,7 @@ impl Node { let task_system = TaskSystem::new(); - let (p2p, start_p2p) = p2p::P2PManager::new(config.clone(), libraries.clone()) + let (p2p, start_p2p) = old_p2p::P2PManager::new(config.clone(), libraries.clone()) .await .map_err(NodeError::P2PManager)?; diff --git a/core/src/library/config.rs b/core/src/library/config.rs index 20c245d10edd..acd7d90a536d 100644 --- a/core/src/library/config.rs +++ b/core/src/library/config.rs @@ -3,7 +3,7 @@ use crate::{ util::version_manager::{Kind, ManagedVersion, VersionManager, VersionManagerError}, }; -use sd_p2p::{Identity, RemoteIdentity}; +use sd_old_p2p::{Identity, RemoteIdentity}; use sd_prisma::prisma::{file_path, indexer_rule, instance, location, PrismaClient}; use sd_utils::{db::maybe_missing, error::FileIOError}; diff --git a/core/src/library/library.rs b/core/src/library/library.rs index f4e284f8a073..62d132b2066e 100644 --- a/core/src/library/library.rs +++ b/core/src/library/library.rs @@ -9,7 +9,7 @@ use sd_core_sync::{backfill::backfill_operations, SyncManager}; use sd_actors::ActorsCollection; use sd_cloud_schema::sync::groups; use sd_crypto::{CryptoRng, SeedableRng}; -use sd_p2p::Identity; +use sd_old_p2p::Identity; use sd_prisma::prisma::{file_path, location, PrismaClient}; use sd_utils::{db::maybe_missing, error::FileIOError}; diff --git a/core/src/library/manager/error.rs b/core/src/library/manager/error.rs index 4fc01dd4e7fa..9aa42ebd88c4 100644 --- a/core/src/library/manager/error.rs +++ b/core/src/library/manager/error.rs @@ -3,7 +3,7 @@ use crate::{library::LibraryConfigError, location::LocationManagerError}; use sd_core_indexer_rules::seed::SeederError; use sd_core_sync::DevicePubId; -use sd_p2p::IdentityErr; +use sd_old_p2p::IdentityErr; use sd_utils::{ db::{self, MissingFieldError}, error::{FileIOError, NonUtf8PathError}, diff --git a/core/src/library/manager/mod.rs b/core/src/library/manager/mod.rs index 08283a68f7e8..58ada1ecf0a8 100644 --- a/core/src/library/manager/mod.rs +++ b/core/src/library/manager/mod.rs @@ -3,14 +3,14 @@ use crate::{ invalidate_query, location::metadata::{LocationMetadataError, SpacedriveLocationMetadataFile}, object::tag, - p2p, + old_p2p, util::{mpscrr, MaybeUndefined}, Node, }; use sd_core_sync::{SyncEvent, SyncManager}; -use sd_p2p::{Identity, RemoteIdentity}; +use sd_old_p2p::{Identity, RemoteIdentity}; use sd_prisma::{ prisma::{self, device, instance, location, PrismaClient}, prisma_sync, @@ -629,7 +629,7 @@ async fn sync_rx_actor( InvalidateOperationEvent::all(), )), SyncEvent::Created => { - p2p::sync::originator(library.clone(), &library.sync, &node.p2p).await + old_p2p::sync::originator(library.clone(), &library.sync, &node.p2p).await } } } diff --git a/core/src/node/config.rs b/core/src/node/config.rs index 28ddb7a4ab87..aa9bf8d3bc79 100644 --- a/core/src/node/config.rs +++ b/core/src/node/config.rs @@ -6,7 +6,7 @@ use crate::{ use sd_cloud_schema::devices::DeviceOS; use sd_core_sync::DevicePubId; -use sd_p2p::Identity; +use sd_old_p2p::Identity; use sd_utils::error::FileIOError; use std::{ @@ -149,7 +149,7 @@ pub struct NodeConfig { } mod identity_serde { - use sd_p2p::Identity; + use sd_old_p2p::Identity; use serde::{Deserialize, Deserializer, Serialize, Serializer}; pub fn serialize(identity: &Identity, serializer: S) -> Result diff --git a/core/src/p2p/events.rs b/core/src/old_p2p/events.rs similarity index 99% rename from core/src/p2p/events.rs rename to core/src/old_p2p/events.rs index 7523e64cbeb4..76694e858e94 100644 --- a/core/src/p2p/events.rs +++ b/core/src/old_p2p/events.rs @@ -1,6 +1,6 @@ use std::{collections::HashSet, net::SocketAddr, sync::Arc}; -use sd_p2p::{ +use sd_old_p2p::{ flume::bounded, hooks::QuicHandle, HookEvent, PeerConnectionCandidate, RemoteIdentity, P2P, }; use serde::Serialize; diff --git a/core/src/p2p/libraries.rs b/core/src/old_p2p/libraries.rs similarity index 98% rename from core/src/p2p/libraries.rs rename to core/src/old_p2p/libraries.rs index aa83cfcc17d5..43ebf7aedc80 100644 --- a/core/src/p2p/libraries.rs +++ b/core/src/old_p2p/libraries.rs @@ -3,7 +3,7 @@ use std::{ sync::{Arc, Mutex, PoisonError}, }; -use sd_p2p::{hooks::QuicHandle, RemoteIdentity, P2P}; +use sd_old_p2p::{hooks::QuicHandle, RemoteIdentity, P2P}; use tracing::error; use crate::library::{Libraries, LibraryManagerEvent}; diff --git a/core/src/p2p/manager.rs b/core/src/old_p2p/manager.rs similarity index 99% rename from core/src/p2p/manager.rs rename to core/src/old_p2p/manager.rs index 96ee7a26453e..a13616ce73dd 100644 --- a/core/src/p2p/manager.rs +++ b/core/src/old_p2p/manager.rs @@ -3,7 +3,7 @@ use crate::{ config::{self, P2PDiscoveryState}, HardwareModel, }, - p2p::{ + old_p2p::{ libraries::libraries_hook, operations, sync::SyncMessage, Header, OperatingSystem, SPACEDRIVE_APP_ID, }, @@ -12,12 +12,12 @@ use crate::{ use axum::routing::IntoMakeService; -use sd_p2p::{ +use sd_old_p2p::{ flume::{bounded, Receiver}, hooks::{Libp2pPeerId, Mdns, QuicHandle, QuicTransport, RelayServerEntry}, Peer, RemoteIdentity, UnicastStream, P2P, }; -use sd_p2p_tunnel::Tunnel; +use sd_old_p2p_tunnel::Tunnel; use serde::Serialize; use serde_json::json; use specta::Type; diff --git a/core/src/p2p/metadata.rs b/core/src/old_p2p/metadata.rs similarity index 100% rename from core/src/p2p/metadata.rs rename to core/src/old_p2p/metadata.rs diff --git a/core/src/p2p/mod.rs b/core/src/old_p2p/mod.rs similarity index 100% rename from core/src/p2p/mod.rs rename to core/src/old_p2p/mod.rs diff --git a/core/src/p2p/operations/library.rs b/core/src/old_p2p/operations/library.rs similarity index 90% rename from core/src/p2p/operations/library.rs rename to core/src/old_p2p/operations/library.rs index d68456cd6ddd..5998407bd020 100644 --- a/core/src/p2p/operations/library.rs +++ b/core/src/old_p2p/operations/library.rs @@ -6,8 +6,8 @@ use std::{ use sd_core_file_path_helper::IsolatedFilePathData; use sd_core_prisma_helpers::file_path_to_handle_p2p_serve_file; -use sd_p2p::{Identity, RemoteIdentity, UnicastStream, P2P}; -use sd_p2p_block::{BlockSize, Range, SpaceblockRequest, SpaceblockRequests, Transfer}; +use sd_old_p2p::{Identity, RemoteIdentity, UnicastStream, P2P}; +use sd_old_p2p_block::{BlockSize, Range, SpaceblockRequest, SpaceblockRequests, Transfer}; use sd_prisma::prisma::file_path; use tokio::{ fs::File, @@ -16,7 +16,7 @@ use tokio::{ use tracing::debug; use uuid::Uuid; -use crate::{p2p::Header, Node}; +use crate::{old_p2p::Header, Node}; /// Request a file from a remote library #[allow(unused)] @@ -41,7 +41,7 @@ pub async fn request_file( ) .await?; - let mut stream = sd_p2p_tunnel::Tunnel::initiator(stream, library_identity).await?; + let mut stream = sd_old_p2p_tunnel::Tunnel::initiator(stream, library_identity).await?; let block_size = BlockSize::from_stream(&mut stream).await?; let size = stream.read_u64_le().await?; @@ -77,7 +77,7 @@ pub(crate) async fn receiver( ); // The tunnel takes care of authentication and encrypts all traffic to the library to be certain we are talking to a node with the library. - let mut stream = sd_p2p_tunnel::Tunnel::responder(stream).await?; + let mut stream = sd_old_p2p_tunnel::Tunnel::responder(stream).await?; let library = node .libraries diff --git a/core/src/p2p/operations/mod.rs b/core/src/old_p2p/operations/mod.rs similarity index 100% rename from core/src/p2p/operations/mod.rs rename to core/src/old_p2p/operations/mod.rs diff --git a/core/src/p2p/operations/ping.rs b/core/src/old_p2p/operations/ping.rs similarity index 91% rename from core/src/p2p/operations/ping.rs rename to core/src/old_p2p/operations/ping.rs index 235e1111fbc4..e1c014b792e6 100644 --- a/core/src/p2p/operations/ping.rs +++ b/core/src/old_p2p/operations/ping.rs @@ -1,10 +1,10 @@ use std::{error::Error, sync::Arc}; -use sd_p2p::{RemoteIdentity, UnicastStream, P2P}; +use sd_old_p2p::{RemoteIdentity, UnicastStream, P2P}; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use tracing::debug; -use crate::p2p::Header; +use crate::old_p2p::Header; /// Send a ping to all peers we are connected to #[allow(unused)] diff --git a/core/src/p2p/operations/rspc.rs b/core/src/old_p2p/operations/rspc.rs similarity index 94% rename from core/src/p2p/operations/rspc.rs rename to core/src/old_p2p/operations/rspc.rs index e5e0b3cc8669..9c1b56c0ebfe 100644 --- a/core/src/p2p/operations/rspc.rs +++ b/core/src/old_p2p/operations/rspc.rs @@ -3,12 +3,12 @@ use std::{error::Error, sync::Arc}; use axum::{extract::Request, http, Router}; use hyper::{body::Incoming, client::conn::http1::handshake, server::conn::http1, Response}; use hyper_util::rt::TokioIo; -use sd_p2p::{RemoteIdentity, UnicastStream, P2P}; +use sd_old_p2p::{RemoteIdentity, UnicastStream, P2P}; use tokio::io::AsyncWriteExt; use tower_service::Service; use tracing::debug; -use crate::{p2p::Header, Node}; +use crate::{old_p2p::Header, Node}; /// Transfer an rspc query to a remote node. pub async fn remote_rspc( diff --git a/core/src/p2p/operations/spacedrop.rs b/core/src/old_p2p/operations/spacedrop.rs similarity index 97% rename from core/src/p2p/operations/spacedrop.rs rename to core/src/old_p2p/operations/spacedrop.rs index 1118a65314e0..a97aa2318c2b 100644 --- a/core/src/p2p/operations/spacedrop.rs +++ b/core/src/old_p2p/operations/spacedrop.rs @@ -8,10 +8,10 @@ use std::{ time::Duration, }; -use crate::p2p::{Header, P2PEvent, P2PManager}; +use crate::old_p2p::{Header, P2PEvent, P2PManager}; use futures::future::join_all; -use sd_p2p::{RemoteIdentity, UnicastStream}; -use sd_p2p_block::{BlockSize, Range, SpaceblockRequest, SpaceblockRequests, Transfer}; +use sd_old_p2p::{RemoteIdentity, UnicastStream}; +use sd_old_p2p_block::{BlockSize, Range, SpaceblockRequest, SpaceblockRequests, Transfer}; use thiserror::Error; use tokio::{ fs::{create_dir_all, File}, @@ -32,7 +32,7 @@ pub enum SpacedropError { #[error("error connecting to peer")] FailedPeerConnection, #[error("error creating stream: {0}")] - FailedNewStream(#[from] sd_p2p::NewStreamError), + FailedNewStream(#[from] sd_old_p2p::NewStreamError), #[error("error opening file: {0}")] FailedFileOpen(#[from] std::io::Error), } diff --git a/core/src/p2p/protocol.rs b/core/src/old_p2p/protocol.rs similarity index 96% rename from core/src/p2p/protocol.rs rename to core/src/old_p2p/protocol.rs index e6c40e3d0686..dac686a766f4 100644 --- a/core/src/p2p/protocol.rs +++ b/core/src/old_p2p/protocol.rs @@ -1,5 +1,5 @@ -use sd_p2p_block::{Range, SpaceblockRequests, SpaceblockRequestsError}; -use sd_p2p_proto::{decode, encode}; +use sd_old_p2p_block::{Range, SpaceblockRequests, SpaceblockRequestsError}; +use sd_old_p2p_proto::{decode, encode}; use thiserror::Error; use tokio::io::{AsyncRead, AsyncReadExt}; use uuid::Uuid; diff --git a/core/src/p2p/sync/mod.rs b/core/src/old_p2p/sync/mod.rs similarity index 100% rename from core/src/p2p/sync/mod.rs rename to core/src/old_p2p/sync/mod.rs diff --git a/core/src/p2p/sync/proto.rs b/core/src/old_p2p/sync/proto.rs similarity index 97% rename from core/src/p2p/sync/proto.rs rename to core/src/old_p2p/sync/proto.rs index e3c8d60f74b1..4569e2a345b2 100644 --- a/core/src/p2p/sync/proto.rs +++ b/core/src/old_p2p/sync/proto.rs @@ -1,4 +1,4 @@ -use sd_p2p_proto::decode; +use sd_old_p2p_proto::decode; use tokio::io::{AsyncRead, AsyncReadExt}; // will probs have more variants in future diff --git a/crates/ai/src/old_image_labeler/mod.rs b/crates/ai/src/old_image_labeler/mod.rs index 0ce02a8b78ab..caad651ceb85 100644 --- a/crates/ai/src/old_image_labeler/mod.rs +++ b/crates/ai/src/old_image_labeler/mod.rs @@ -27,7 +27,7 @@ pub struct LabelerOutput { pub enum ImageLabelerError { #[error("model executor failed: {0}")] ModelExecutorFailed(#[from] ort::Error), - #[error("image load failed : {0}", .1.display())] + #[error("image load failed : {0}", path = .1.display())] ImageLoadFailed(image::ImageError, Box), #[error("failed to get isolated file path data: {0}")] IsolateFilePathData(#[from] MissingFieldError), diff --git a/crates/images/src/error.rs b/crates/images/src/error.rs index df7cb64c18a9..8dce1e675ada 100644 --- a/crates/images/src/error.rs +++ b/crates/images/src/error.rs @@ -4,7 +4,7 @@ pub type Result = std::result::Result; #[derive(thiserror::Error, Debug)] pub enum Error { - #[error("there was an i/o at path '{}' error: {0}", .1.display())] + #[error("there was an i/o at path '{path}' error: {0}", path = .1.display())] Io(std::io::Error, Box), #[error("the image provided is unsupported")] diff --git a/crates/p2p/Cargo.toml b/crates/old-p2p/Cargo.toml similarity index 98% rename from crates/p2p/Cargo.toml rename to crates/old-p2p/Cargo.toml index d915e20240cb..cdfe95df7e5a 100644 --- a/crates/p2p/Cargo.toml +++ b/crates/old-p2p/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sd-p2p" +name = "sd-old-p2p" version = "0.2.0" authors = ["Oscar Beaumont "] diff --git a/crates/p2p/README.md b/crates/old-p2p/README.md similarity index 100% rename from crates/p2p/README.md rename to crates/old-p2p/README.md diff --git a/crates/p2p/crates/block/Cargo.toml b/crates/old-p2p/crates/block/Cargo.toml similarity index 84% rename from crates/p2p/crates/block/Cargo.toml rename to crates/old-p2p/crates/block/Cargo.toml index 8ac8f61fec6b..31110722ca30 100644 --- a/crates/p2p/crates/block/Cargo.toml +++ b/crates/old-p2p/crates/block/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sd-p2p-block" +name = "sd-old-p2p-block" version = "0.1.0" authors = ["Oscar Beaumont "] @@ -9,7 +9,7 @@ repository.workspace = true [dependencies] # Spacedrive Sub-crates -sd-p2p-proto = { path = "../proto" } +sd-old-p2p-proto = { path = "../proto" } # Workspace dependencies thiserror = { workspace = true } diff --git a/crates/p2p/crates/block/src/block.rs b/crates/old-p2p/crates/block/src/block.rs similarity index 100% rename from crates/p2p/crates/block/src/block.rs rename to crates/old-p2p/crates/block/src/block.rs diff --git a/crates/p2p/crates/block/src/block_size.rs b/crates/old-p2p/crates/block/src/block_size.rs similarity index 100% rename from crates/p2p/crates/block/src/block_size.rs rename to crates/old-p2p/crates/block/src/block_size.rs diff --git a/crates/p2p/crates/block/src/lib.rs b/crates/old-p2p/crates/block/src/lib.rs similarity index 100% rename from crates/p2p/crates/block/src/lib.rs rename to crates/old-p2p/crates/block/src/lib.rs diff --git a/crates/p2p/crates/block/src/sb_request.rs b/crates/old-p2p/crates/block/src/sb_request.rs similarity index 99% rename from crates/p2p/crates/block/src/sb_request.rs rename to crates/old-p2p/crates/block/src/sb_request.rs index 1384ca5ed898..f92aab1e2912 100644 --- a/crates/p2p/crates/block/src/sb_request.rs +++ b/crates/old-p2p/crates/block/src/sb_request.rs @@ -4,7 +4,7 @@ use thiserror::Error; use tokio::io::{AsyncRead, AsyncReadExt}; use uuid::Uuid; -use sd_p2p_proto::{decode, encode}; +use sd_old_p2p_proto::{decode, encode}; use super::BlockSize; diff --git a/crates/p2p/crates/proto/Cargo.toml b/crates/old-p2p/crates/proto/Cargo.toml similarity index 92% rename from crates/p2p/crates/proto/Cargo.toml rename to crates/old-p2p/crates/proto/Cargo.toml index 685aaf4ec97f..2198b1aa85ac 100644 --- a/crates/p2p/crates/proto/Cargo.toml +++ b/crates/old-p2p/crates/proto/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sd-p2p-proto" +name = "sd-old-p2p-proto" version = "0.1.0" authors = ["Oscar Beaumont "] diff --git a/crates/p2p/crates/proto/src/lib.rs b/crates/old-p2p/crates/proto/src/lib.rs similarity index 100% rename from crates/p2p/crates/proto/src/lib.rs rename to crates/old-p2p/crates/proto/src/lib.rs diff --git a/crates/p2p/crates/tunnel/Cargo.toml b/crates/old-p2p/crates/tunnel/Cargo.toml similarity index 75% rename from crates/p2p/crates/tunnel/Cargo.toml rename to crates/old-p2p/crates/tunnel/Cargo.toml index ea1af01b68f6..e9f1e0114fc4 100644 --- a/crates/p2p/crates/tunnel/Cargo.toml +++ b/crates/old-p2p/crates/tunnel/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "sd-p2p-tunnel" +name = "sd-old-p2p-tunnel" version = "0.1.0" authors = ["Oscar Beaumont "] @@ -9,8 +9,8 @@ repository.workspace = true [dependencies] # Spacedrive Sub-crates -sd-p2p = { path = "../../" } -sd-p2p-proto = { path = "../proto" } +sd-old-p2p = { path = "../../" } +sd-old-p2p-proto = { path = "../proto" } # Workspace dependencies thiserror = { workspace = true } diff --git a/crates/p2p/crates/tunnel/src/lib.rs b/crates/old-p2p/crates/tunnel/src/lib.rs similarity index 97% rename from crates/p2p/crates/tunnel/src/lib.rs rename to crates/old-p2p/crates/tunnel/src/lib.rs index 482c736c7a76..48ae2211a3b3 100644 --- a/crates/p2p/crates/tunnel/src/lib.rs +++ b/crates/old-p2p/crates/tunnel/src/lib.rs @@ -6,12 +6,12 @@ use std::{ task::{Context, Poll}, }; -use sd_p2p_proto::{decode, encode}; +use sd_old_p2p_proto::{decode, encode}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf}; use thiserror::Error; -use sd_p2p::{Identity, IdentityErr, RemoteIdentity, UnicastStream}; +use sd_old_p2p::{Identity, IdentityErr, RemoteIdentity, UnicastStream}; #[derive(Debug, Error)] pub enum TunnelError { diff --git a/crates/p2p/src/hook.rs b/crates/old-p2p/src/hook.rs similarity index 100% rename from crates/p2p/src/hook.rs rename to crates/old-p2p/src/hook.rs diff --git a/crates/p2p/src/hooks.rs b/crates/old-p2p/src/hooks.rs similarity index 100% rename from crates/p2p/src/hooks.rs rename to crates/old-p2p/src/hooks.rs diff --git a/crates/p2p/src/hooks/mdns.rs b/crates/old-p2p/src/hooks/mdns.rs similarity index 100% rename from crates/p2p/src/hooks/mdns.rs rename to crates/old-p2p/src/hooks/mdns.rs diff --git a/crates/p2p/src/hooks/quic.rs b/crates/old-p2p/src/hooks/quic.rs similarity index 100% rename from crates/p2p/src/hooks/quic.rs rename to crates/old-p2p/src/hooks/quic.rs diff --git a/crates/p2p/src/hooks/quic/handle.rs b/crates/old-p2p/src/hooks/quic/handle.rs similarity index 100% rename from crates/p2p/src/hooks/quic/handle.rs rename to crates/old-p2p/src/hooks/quic/handle.rs diff --git a/crates/p2p/src/hooks/quic/transport.rs b/crates/old-p2p/src/hooks/quic/transport.rs similarity index 100% rename from crates/p2p/src/hooks/quic/transport.rs rename to crates/old-p2p/src/hooks/quic/transport.rs diff --git a/crates/p2p/src/hooks/quic/utils.rs b/crates/old-p2p/src/hooks/quic/utils.rs similarity index 100% rename from crates/p2p/src/hooks/quic/utils.rs rename to crates/old-p2p/src/hooks/quic/utils.rs diff --git a/crates/p2p/src/identity.rs b/crates/old-p2p/src/identity.rs similarity index 100% rename from crates/p2p/src/identity.rs rename to crates/old-p2p/src/identity.rs diff --git a/crates/p2p/src/lib.rs b/crates/old-p2p/src/lib.rs similarity index 100% rename from crates/p2p/src/lib.rs rename to crates/old-p2p/src/lib.rs diff --git a/crates/p2p/src/p2p.rs b/crates/old-p2p/src/p2p.rs similarity index 100% rename from crates/p2p/src/p2p.rs rename to crates/old-p2p/src/p2p.rs diff --git a/crates/p2p/src/peer.rs b/crates/old-p2p/src/peer.rs similarity index 100% rename from crates/p2p/src/peer.rs rename to crates/old-p2p/src/peer.rs diff --git a/crates/p2p/src/smart_guards.rs b/crates/old-p2p/src/smart_guards.rs similarity index 100% rename from crates/p2p/src/smart_guards.rs rename to crates/old-p2p/src/smart_guards.rs diff --git a/crates/p2p/src/stream.rs b/crates/old-p2p/src/stream.rs similarity index 100% rename from crates/p2p/src/stream.rs rename to crates/old-p2p/src/stream.rs