diff --git a/Cargo.toml b/Cargo.toml index 41c32dbd9..1fbc5e146 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,8 +66,8 @@ humansize = "2" hyper = "1" hyper-util = "0.1.16" image = { version = "0.25.6", default-features=false, features = ["gif", "jpeg", "ico", "png", "pnm", "webp", "bmp"] } -iroh-gossip = { version = "0.35", default-features = false, features = ["net"] } -iroh = { version = "0.35", default-features = false } +iroh-gossip = { version = "0.92", default-features = false, features = ["net"] } +iroh = { version = "0.92", default-features = false } kamadak-exif = "0.6.1" libc = { workspace = true } mail-builder = { version = "0.4.4", default-features = false } diff --git a/deny.toml b/deny.toml index 79c09c9a1..a29c3f2f9 100644 --- a/deny.toml +++ b/deny.toml @@ -7,6 +7,9 @@ ignore = [ # "RUSTSEC-2023-0071", + # Archived repository + "RUSTSEC-2023-0089", + # Unmaintained instant "RUSTSEC-2024-0384", @@ -52,8 +55,8 @@ skip = [ { name = "heck", version = "0.4.1" }, { name = "http", version = "0.2.12" }, { name = "linux-raw-sys", version = "0.4.14" }, - { name = "lru", version = "0.12.5" }, - { name = "netlink-packet-route", version = "0.17.1" }, + { name = "netdev", version = "0.36.0" }, + { name = "netlink-packet-route", version = "0.22.0" }, { name = "nom", version = "7.1.3" }, { name = "rand_chacha", version = "0.3.1" }, { name = "rand_core", version = "0.6.4" }, @@ -63,8 +66,6 @@ skip = [ { name = "serdect", version = "0.2.0" }, { name = "socket2", version = "0.5.9" }, { name = "spin", version = "0.9.8" }, - { name = "strum_macros", version = "0.26.2" }, - { name = "strum", version = "0.26.2" }, { name = "syn", version = "1.0.109" }, { name = "thiserror-impl", version = "1.0.69" }, { name = "thiserror", version = "1.0.69" }, @@ -79,6 +80,7 @@ skip = [ { name = "windows_i686_msvc" }, { name = "windows-implement" }, { name = "windows-interface" }, + { name = "windows-link" }, { name = "windows-result" }, { name = "windows-strings" }, { name = "windows-sys" }, diff --git a/src/imex/transfer.rs b/src/imex/transfer.rs index 67206abe9..1befc4b4a 100644 --- a/src/imex/transfer.rs +++ b/src/imex/transfer.rs @@ -33,7 +33,7 @@ use std::task::Poll; use anyhow::{Context as _, Result, bail, format_err}; use futures_lite::FutureExt; -use iroh::{Endpoint, RelayMode}; +use iroh::{Endpoint, RelayMode, Watcher as _}; use tokio::fs; use tokio::task::JoinHandle; use tokio_util::sync::CancellationToken; @@ -96,12 +96,11 @@ impl BackupProvider { pub async fn prepare(context: &Context) -> Result { let relay_mode = RelayMode::Disabled; let endpoint = Endpoint::builder() - .tls_x509() // For compatibility with iroh <0.34.0 .alpns(vec![BACKUP_ALPN.to_vec()]) .relay_mode(relay_mode) .bind() .await?; - let node_addr = endpoint.node_addr().await?; + let node_addr = endpoint.node_addr().initialized().await; // Acquire global "ongoing" mutex. let cancel_token = context.alloc_ongoing().await?; @@ -304,11 +303,7 @@ pub async fn get_backup2( ) -> Result<()> { let relay_mode = RelayMode::Disabled; - let endpoint = Endpoint::builder() - .tls_x509() // For compatibility with iroh <0.34.0 - .relay_mode(relay_mode) - .bind() - .await?; + let endpoint = Endpoint::builder().relay_mode(relay_mode).bind().await?; let conn = endpoint.connect(node_addr, BACKUP_ALPN).await?; let (mut send_stream, mut recv_stream) = conn.open_bi().await?; diff --git a/src/peer_channels.rs b/src/peer_channels.rs index 618bf03d0..cd47283f2 100644 --- a/src/peer_channels.rs +++ b/src/peer_channels.rs @@ -26,8 +26,10 @@ use anyhow::{Context as _, Result, anyhow, bail}; use data_encoding::BASE32_NOPAD; use futures_lite::StreamExt; +use iroh::Watcher as _; use iroh::{Endpoint, NodeAddr, NodeId, PublicKey, RelayMode, RelayUrl, SecretKey}; -use iroh_gossip::net::{Event, GOSSIP_ALPN, Gossip, GossipEvent, JoinOptions}; +use iroh_gossip::api::{Event as GossipEvent, GossipReceiver, GossipSender, JoinOptions}; +use iroh_gossip::net::{GOSSIP_ALPN, Gossip}; use iroh_gossip::proto::TopicId; use parking_lot::Mutex; use std::collections::{BTreeSet, HashMap}; @@ -124,6 +126,7 @@ impl Iroh { let (gossip_sender, gossip_receiver) = self .gossip .subscribe_with_opts(topic, JoinOptions::with_bootstrap(node_ids)) + .await? .split(); let ctx = ctx.clone(); @@ -142,7 +145,7 @@ impl Iroh { pub async fn maybe_add_gossip_peer(&self, topic: TopicId, peer: NodeAddr) -> Result<()> { if self.iroh_channels.read().await.get(&topic).is_some() { self.router.endpoint().add_node_addr(peer.clone())?; - self.gossip.subscribe(topic, vec![peer.node_id])?; + self.gossip.subscribe(topic, vec![peer.node_id]).await?; } Ok(()) } @@ -190,7 +193,9 @@ impl Iroh { /// as it is the only way to reach the node /// without global discovery mechanisms. pub(crate) async fn get_node_addr(&self) -> Result { - let mut addr = self.router.endpoint().node_addr().await?; + // Wait until home relay connection is established. + let _relay_url = self.router.endpoint().home_relay().initialized().await; + let mut addr = self.router.endpoint().node_addr().initialized().await; addr.direct_addresses = BTreeSet::new(); debug_assert!(addr.relay_url().is_some()); Ok(addr) @@ -219,11 +224,11 @@ pub(crate) struct ChannelState { /// The subscribe loop handle. subscribe_loop: JoinHandle<()>, - sender: iroh_gossip::net::GossipSender, + sender: GossipSender, } impl ChannelState { - fn new(subscribe_loop: JoinHandle<()>, sender: iroh_gossip::net::GossipSender) -> Self { + fn new(subscribe_loop: JoinHandle<()>, sender: GossipSender) -> Self { Self { subscribe_loop, sender, @@ -253,7 +258,6 @@ impl Context { }; let endpoint = Endpoint::builder() - .tls_x509() // For compatibility with iroh <0.34.0 .secret_key(secret_key) .alpns(vec![GOSSIP_ALPN.to_vec()]) .relay_mode(relay_mode) @@ -267,8 +271,7 @@ impl Context { let gossip = Gossip::builder() .max_message_size(128 * 1024) - .spawn(endpoint.clone()) - .await?; + .spawn(endpoint.clone()); let router = iroh::protocol::Router::builder(endpoint) .accept(GOSSIP_ALPN, gossip.clone()) @@ -536,45 +539,39 @@ pub(crate) fn iroh_topic_from_str(topic: &str) -> Result { #[expect(clippy::arithmetic_side_effects)] async fn subscribe_loop( context: &Context, - mut stream: iroh_gossip::net::GossipReceiver, + mut stream: GossipReceiver, topic: TopicId, msg_id: MsgId, join_tx: oneshot::Sender<()>, ) -> Result<()> { - let mut join_tx = Some(join_tx); + stream.joined().await?; + // Try to notify that at least one peer joined, + // but ignore the error if receiver is dropped and nobody listens. + join_tx.send(()).ok(); + + for node in stream.neighbors() { + iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?; + } while let Some(event) = stream.try_next().await? { match event { - Event::Gossip(event) => match event { - GossipEvent::Joined(nodes) => { - if let Some(join_tx) = join_tx.take() { - // Try to notify that at least one peer joined, - // but ignore the error if receiver is dropped and nobody listens. - join_tx.send(()).ok(); - } - - for node in nodes { - iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?; - } - } - GossipEvent::NeighborUp(node) => { - info!(context, "IROH_REALTIME: NeighborUp: {}", node.to_string()); - iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?; - } - GossipEvent::NeighborDown(_node) => {} - GossipEvent::Received(message) => { - info!(context, "IROH_REALTIME: Received realtime data"); - context.emit_event(EventType::WebxdcRealtimeData { - msg_id, - data: message - .content - .get(0..message.content.len() - 4 - PUBLIC_KEY_LENGTH) - .context("too few bytes in iroh message")? - .into(), - }); - } - }, - Event::Lagged => { + GossipEvent::NeighborUp(node) => { + info!(context, "IROH_REALTIME: NeighborUp: {}", node.to_string()); + iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?; + } + GossipEvent::NeighborDown(_node) => {} + GossipEvent::Received(message) => { + info!(context, "IROH_REALTIME: Received realtime data"); + context.emit_event(EventType::WebxdcRealtimeData { + msg_id, + data: message + .content + .get(0..message.content.len() - 4 - PUBLIC_KEY_LENGTH) + .context("too few bytes in iroh message")? + .into(), + }); + } + GossipEvent::Lagged => { warn!(context, "Gossip lost some messages"); } };