diff --git a/Cargo.lock b/Cargo.lock index b599df9d1..331afee48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -319,16 +319,14 @@ dependencies = [ ] [[package]] -name = "backoff" -version = "0.4.0" +name = "backon" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" +checksum = "49fef586913a57ff189f25c9b3d034356a5bf6b3fa9a7f067588fe1698ba1f5d" dependencies = [ - "futures-core", - "getrandom 0.2.15", - "instant", - "pin-project-lite", - "rand 0.8.5", + "fastrand", + "gloo-timers", + "tokio", ] [[package]] @@ -843,6 +841,7 @@ checksum = "f55bf8e7b65898637379c1b74eb1551107c8294ed26d855ceb9fd1a09cfc9bc0" dependencies = [ "const-oid", "der_derive", + "pem-rfc7468", "zeroize", ] @@ -1404,6 +1403,18 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + [[package]] name = "governor" version = "0.7.0" @@ -1985,13 +1996,13 @@ checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" [[package]] name = "iroh" version = "0.33.0" -source = "git+https://github.com/n0-computer/iroh.git?branch=main#493083765083c77fd74c7575236d8b7696b61754" +source = "git+https://github.com/n0-computer/iroh.git?branch=main#ef3645e8b7d5700e309de3cd13b745bbf352f151" dependencies = [ "aead", "anyhow", "atomic-waker", "axum", - "backoff", + "backon", "bytes", "cfg_aliases", "concurrent-queue", @@ -2045,7 +2056,7 @@ dependencies = [ [[package]] name = "iroh-base" version = "0.33.0" -source = "git+https://github.com/n0-computer/iroh.git?branch=main#493083765083c77fd74c7575236d8b7696b61754" +source = "git+https://github.com/n0-computer/iroh.git?branch=main#ef3645e8b7d5700e309de3cd13b745bbf352f151" dependencies = [ "curve25519-dalek", "data-encoding", @@ -2188,7 +2199,7 @@ dependencies = [ [[package]] name = "iroh-net-report" version = "0.33.0" -source = "git+https://github.com/n0-computer/iroh.git?branch=main#493083765083c77fd74c7575236d8b7696b61754" +source = "git+https://github.com/n0-computer/iroh.git?branch=main#ef3645e8b7d5700e309de3cd13b745bbf352f151" dependencies = [ "anyhow", "bytes", @@ -2271,7 +2282,7 @@ dependencies = [ [[package]] name = "iroh-relay" version = "0.33.0" -source = "git+https://github.com/n0-computer/iroh.git?branch=main#493083765083c77fd74c7575236d8b7696b61754" +source = "git+https://github.com/n0-computer/iroh.git?branch=main#ef3645e8b7d5700e309de3cd13b745bbf352f151" dependencies = [ "anyhow", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 8b5e4475c..537e3d271 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,10 +40,10 @@ genawaiter = { version = "0.99.1", features = ["futures03"] } hashlink = { version = "0.9.0", optional = true } hex = "0.4.3" indicatif = { version = "0.17.8", optional = true } -iroh-base = { version = "0.33" } +iroh-base = { version = "0.34" } iroh-io = { version = "0.6.0", features = ["stats"] } -iroh-metrics = { version = "0.31", default-features = false } -iroh = "0.33" +iroh-metrics = { version = "0.32", default-features = false } +iroh = "0.34" nested_enum_utils = { version = "0.1.0", optional = true } num_cpus = "1.15.0" oneshot = "0.1.8" @@ -54,8 +54,8 @@ postcard = { version = "1", default-features = false, features = [ "use-std", "experimental-derive", ] } -quic-rpc = { version = "0.18.3", optional = true } -quic-rpc-derive = { version = "0.18", optional = true } +quic-rpc = { version = "0.19", optional = true } +quic-rpc-derive = { version = "0.19", optional = true } rand = "0.8" range-collections = "0.4.0" redb = { version = "2.2.0", optional = true } @@ -80,7 +80,7 @@ tracing-test = "0.2.5" [dev-dependencies] http-body = "1.0" -iroh = { version = "0.33", features = ["test-utils"] } +iroh = { version = "0.34", features = ["test-utils"] } quinn = { package = "iroh-quinn", version = "0.13", features = ["ring"] } futures-buffered = "0.2.4" proptest = "1.0.0" @@ -149,7 +149,7 @@ name = "hello-world-provide" required-features = ["example-iroh"] [[example]] -name = "local-swarm-discovery" +name = "discovery-local-network" required-features = ["example-iroh"] [[example]] @@ -184,8 +184,3 @@ debug-assertions = false opt-level = 3 panic = 'abort' incremental = false - -[patch.crates-io] -iroh = { git = "https://github.com/n0-computer/iroh.git", branch = "main" } -iroh-base = { git = "https://github.com/n0-computer/iroh.git", branch = "main" } -quic-rpc = { git = "https://github.com/n0-computer/quic-rpc", branch = "main" } diff --git a/deny.toml b/deny.toml index 722e547ba..fd814582d 100644 --- a/deny.toml +++ b/deny.toml @@ -34,11 +34,7 @@ ignore = [ "RUSTSEC-2024-0370", # unmaintained, no upgrade available "RUSTSEC-2024-0384", # unmaintained, no upgrade available "RUSTSEC-2024-0436", # unmaintained paste - "RUSTSEC-2025-0012", # unmaintained backoff ] [sources] -allow-git = [ - "https://github.com/n0-computer/iroh.git", - "https://github.com/n0-computer/quic-rpc.git" -] +allow-git = [] diff --git a/examples/custom-protocol.rs b/examples/custom-protocol.rs index 5baef3c9c..2537562fe 100644 --- a/examples/custom-protocol.rs +++ b/examples/custom-protocol.rs @@ -44,7 +44,7 @@ use anyhow::Result; use clap::Parser; use futures_lite::future::Boxed as BoxedFuture; use iroh::{ - endpoint::Connecting, + endpoint::Connection, protocol::{ProtocolHandler, Router}, Endpoint, NodeId, }; @@ -142,12 +142,10 @@ impl ProtocolHandler for BlobSearch { /// /// The returned future runs on a newly spawned tokio task, so it can run as long as /// the connection lasts. - fn accept(&self, connecting: Connecting) -> BoxedFuture<Result<()>> { + fn accept(&self, connection: Connection) -> BoxedFuture<Result<()>> { let this = self.clone(); // We have to return a boxed future from the handler. Box::pin(async move { - // Wait for the connection to be fully established. - let connection = connecting.await?; // We can get the remote's node id from the connection. let node_id = connection.remote_node_id()?; println!("accepted connection from {node_id}"); diff --git a/examples/local-swarm-discovery.rs b/examples/discovery-local-network.rs similarity index 93% rename from examples/local-swarm-discovery.rs rename to examples/discovery-local-network.rs index f91e2f077..44ef6e9b7 100644 --- a/examples/local-swarm-discovery.rs +++ b/examples/discovery-local-network.rs @@ -1,17 +1,17 @@ //! Example that runs and iroh node with local node discovery and no relay server //! //! Run the follow command to run the "accept" side, that hosts the content: -//! $ cargo run --example local_swarm_discovery --features="discovery-local-network" -- accept [FILE_PATH] +//! $ cargo run --example discovery_local_network --features="discovery-local-network" -- accept [FILE_PATH] //! Wait for output that looks like the following: -//! $ cargo run --example local_swarm_discovery --features="discovery-local-network" -- connect [NODE_ID] [HASH] -o [FILE_PATH] +//! $ cargo run --example discovery_local_network --features="discovery-local-network" -- connect [NODE_ID] [HASH] -o [FILE_PATH] //! Run that command on another machine in the same local network, replacing [FILE_PATH] to the path on which you want to save the transferred content. use std::path::PathBuf; use anyhow::ensure; use clap::{Parser, Subcommand}; use iroh::{ - discovery::local_swarm_discovery::LocalSwarmDiscovery, protocol::Router, Endpoint, NodeAddr, - PublicKey, RelayMode, SecretKey, + discovery::mdns::MdnsDiscovery, protocol::Router, Endpoint, NodeAddr, PublicKey, RelayMode, + SecretKey, }; use iroh_blobs::{net_protocol::Blobs, rpc::client::blobs::WrapOption, Hash}; use tracing_subscriber::{prelude::*, EnvFilter}; @@ -60,9 +60,9 @@ async fn main() -> anyhow::Result<()> { let cli = Cli::parse(); let key = SecretKey::generate(rand::rngs::OsRng); - let discovery = LocalSwarmDiscovery::new(key.public())?; + let discovery = MdnsDiscovery::new(key.public())?; - println!("Starting iroh node with local node discovery..."); + println!("Starting iroh node with mdns discovery..."); // create a new node let endpoint = Endpoint::builder() .secret_key(key) @@ -94,7 +94,7 @@ async fn main() -> anyhow::Result<()> { ) .await?; let outcome = stream.finish().await?; - println!("To fetch the blob:\n\tcargo run --example local_swarm_discovery --features=\"local-swarm-discovery\" -- connect {} {} -o [FILE_PATH]", node.endpoint().node_id(), outcome.hash); + println!("To fetch the blob:\n\tcargo run --example discovery_local_network --features=\"discovery-local-network\" -- connect {} {} -o [FILE_PATH]", node.endpoint().node_id(), outcome.hash); tokio::signal::ctrl_c().await?; node.shutdown().await?; std::process::exit(0); diff --git a/src/net_protocol.rs b/src/net_protocol.rs index c8b0d83b8..9fc8ba7ee 100644 --- a/src/net_protocol.rs +++ b/src/net_protocol.rs @@ -13,7 +13,7 @@ use std::{ use anyhow::{bail, Result}; use futures_lite::future::Boxed as BoxedFuture; use futures_util::future::BoxFuture; -use iroh::{endpoint::Connecting, protocol::ProtocolHandler, Endpoint, NodeAddr}; +use iroh::{endpoint::Connection, protocol::ProtocolHandler, Endpoint, NodeAddr}; use serde::{Deserialize, Serialize}; use tracing::debug; @@ -318,13 +318,13 @@ impl<S: crate::store::Store> Blobs<S> { } impl<S: crate::store::Store> ProtocolHandler for Blobs<S> { - fn accept(&self, conn: Connecting) -> BoxedFuture<Result<()>> { + fn accept(&self, conn: Connection) -> BoxedFuture<Result<()>> { let db = self.store().clone(); let events = self.events().clone(); let rt = self.rt().clone(); Box::pin(async move { - crate::provider::handle_connection(conn.await?, db, events, rt).await; + crate::provider::handle_connection(conn, db, events, rt).await; Ok(()) }) }