build: update iroh to 0.92.0

This commit is contained in:
link2xt
2025-10-02 13:39:49 +00:00
parent 459aa66ed0
commit 1092b3bd1a
4 changed files with 48 additions and 54 deletions

View File

@@ -66,8 +66,8 @@ humansize = "2"
hyper = "1" hyper = "1"
hyper-util = "0.1.16" hyper-util = "0.1.16"
image = { version = "0.25.6", default-features=false, features = ["gif", "jpeg", "ico", "png", "pnm", "webp", "bmp"] } 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-gossip = { version = "0.92", default-features = false, features = ["net"] }
iroh = { version = "0.35", default-features = false } iroh = { version = "0.92", default-features = false }
kamadak-exif = "0.6.1" kamadak-exif = "0.6.1"
libc = { workspace = true } libc = { workspace = true }
mail-builder = { version = "0.4.4", default-features = false } mail-builder = { version = "0.4.4", default-features = false }

View File

@@ -7,6 +7,9 @@ ignore = [
# <https://rustsec.org/advisories/RUSTSEC-2023-0071> # <https://rustsec.org/advisories/RUSTSEC-2023-0071>
"RUSTSEC-2023-0071", "RUSTSEC-2023-0071",
# Archived repository
"RUSTSEC-2023-0089",
# Unmaintained instant # Unmaintained instant
"RUSTSEC-2024-0384", "RUSTSEC-2024-0384",
@@ -52,8 +55,8 @@ skip = [
{ name = "heck", version = "0.4.1" }, { name = "heck", version = "0.4.1" },
{ name = "http", version = "0.2.12" }, { name = "http", version = "0.2.12" },
{ name = "linux-raw-sys", version = "0.4.14" }, { name = "linux-raw-sys", version = "0.4.14" },
{ name = "lru", version = "0.12.5" }, { name = "netdev", version = "0.36.0" },
{ name = "netlink-packet-route", version = "0.17.1" }, { name = "netlink-packet-route", version = "0.22.0" },
{ name = "nom", version = "7.1.3" }, { name = "nom", version = "7.1.3" },
{ name = "rand_chacha", version = "0.3.1" }, { name = "rand_chacha", version = "0.3.1" },
{ name = "rand_core", version = "0.6.4" }, { name = "rand_core", version = "0.6.4" },
@@ -63,8 +66,6 @@ skip = [
{ name = "serdect", version = "0.2.0" }, { name = "serdect", version = "0.2.0" },
{ name = "socket2", version = "0.5.9" }, { name = "socket2", version = "0.5.9" },
{ name = "spin", version = "0.9.8" }, { 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 = "syn", version = "1.0.109" },
{ name = "thiserror-impl", version = "1.0.69" }, { name = "thiserror-impl", version = "1.0.69" },
{ name = "thiserror", version = "1.0.69" }, { name = "thiserror", version = "1.0.69" },
@@ -79,6 +80,7 @@ skip = [
{ name = "windows_i686_msvc" }, { name = "windows_i686_msvc" },
{ name = "windows-implement" }, { name = "windows-implement" },
{ name = "windows-interface" }, { name = "windows-interface" },
{ name = "windows-link" },
{ name = "windows-result" }, { name = "windows-result" },
{ name = "windows-strings" }, { name = "windows-strings" },
{ name = "windows-sys" }, { name = "windows-sys" },

View File

@@ -33,7 +33,7 @@ use std::task::Poll;
use anyhow::{Context as _, Result, bail, format_err}; use anyhow::{Context as _, Result, bail, format_err};
use futures_lite::FutureExt; use futures_lite::FutureExt;
use iroh::{Endpoint, RelayMode}; use iroh::{Endpoint, RelayMode, Watcher as _};
use tokio::fs; use tokio::fs;
use tokio::task::JoinHandle; use tokio::task::JoinHandle;
use tokio_util::sync::CancellationToken; use tokio_util::sync::CancellationToken;
@@ -96,12 +96,11 @@ impl BackupProvider {
pub async fn prepare(context: &Context) -> Result<Self> { pub async fn prepare(context: &Context) -> Result<Self> {
let relay_mode = RelayMode::Disabled; let relay_mode = RelayMode::Disabled;
let endpoint = Endpoint::builder() let endpoint = Endpoint::builder()
.tls_x509() // For compatibility with iroh <0.34.0
.alpns(vec![BACKUP_ALPN.to_vec()]) .alpns(vec![BACKUP_ALPN.to_vec()])
.relay_mode(relay_mode) .relay_mode(relay_mode)
.bind() .bind()
.await?; .await?;
let node_addr = endpoint.node_addr().await?; let node_addr = endpoint.node_addr().initialized().await;
// Acquire global "ongoing" mutex. // Acquire global "ongoing" mutex.
let cancel_token = context.alloc_ongoing().await?; let cancel_token = context.alloc_ongoing().await?;
@@ -304,11 +303,7 @@ pub async fn get_backup2(
) -> Result<()> { ) -> Result<()> {
let relay_mode = RelayMode::Disabled; let relay_mode = RelayMode::Disabled;
let endpoint = Endpoint::builder() let endpoint = Endpoint::builder().relay_mode(relay_mode).bind().await?;
.tls_x509() // For compatibility with iroh <0.34.0
.relay_mode(relay_mode)
.bind()
.await?;
let conn = endpoint.connect(node_addr, BACKUP_ALPN).await?; let conn = endpoint.connect(node_addr, BACKUP_ALPN).await?;
let (mut send_stream, mut recv_stream) = conn.open_bi().await?; let (mut send_stream, mut recv_stream) = conn.open_bi().await?;

View File

@@ -26,8 +26,10 @@
use anyhow::{Context as _, Result, anyhow, bail}; use anyhow::{Context as _, Result, anyhow, bail};
use data_encoding::BASE32_NOPAD; use data_encoding::BASE32_NOPAD;
use futures_lite::StreamExt; use futures_lite::StreamExt;
use iroh::Watcher as _;
use iroh::{Endpoint, NodeAddr, NodeId, PublicKey, RelayMode, RelayUrl, SecretKey}; 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 iroh_gossip::proto::TopicId;
use parking_lot::Mutex; use parking_lot::Mutex;
use std::collections::{BTreeSet, HashMap}; use std::collections::{BTreeSet, HashMap};
@@ -124,6 +126,7 @@ impl Iroh {
let (gossip_sender, gossip_receiver) = self let (gossip_sender, gossip_receiver) = self
.gossip .gossip
.subscribe_with_opts(topic, JoinOptions::with_bootstrap(node_ids)) .subscribe_with_opts(topic, JoinOptions::with_bootstrap(node_ids))
.await?
.split(); .split();
let ctx = ctx.clone(); let ctx = ctx.clone();
@@ -142,7 +145,7 @@ impl Iroh {
pub async fn maybe_add_gossip_peer(&self, topic: TopicId, peer: NodeAddr) -> Result<()> { pub async fn maybe_add_gossip_peer(&self, topic: TopicId, peer: NodeAddr) -> Result<()> {
if self.iroh_channels.read().await.get(&topic).is_some() { if self.iroh_channels.read().await.get(&topic).is_some() {
self.router.endpoint().add_node_addr(peer.clone())?; 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(()) Ok(())
} }
@@ -190,7 +193,9 @@ impl Iroh {
/// as it is the only way to reach the node /// as it is the only way to reach the node
/// without global discovery mechanisms. /// without global discovery mechanisms.
pub(crate) async fn get_node_addr(&self) -> Result<NodeAddr> { pub(crate) async fn get_node_addr(&self) -> Result<NodeAddr> {
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(); addr.direct_addresses = BTreeSet::new();
debug_assert!(addr.relay_url().is_some()); debug_assert!(addr.relay_url().is_some());
Ok(addr) Ok(addr)
@@ -219,11 +224,11 @@ pub(crate) struct ChannelState {
/// The subscribe loop handle. /// The subscribe loop handle.
subscribe_loop: JoinHandle<()>, subscribe_loop: JoinHandle<()>,
sender: iroh_gossip::net::GossipSender, sender: GossipSender,
} }
impl ChannelState { impl ChannelState {
fn new(subscribe_loop: JoinHandle<()>, sender: iroh_gossip::net::GossipSender) -> Self { fn new(subscribe_loop: JoinHandle<()>, sender: GossipSender) -> Self {
Self { Self {
subscribe_loop, subscribe_loop,
sender, sender,
@@ -253,7 +258,6 @@ impl Context {
}; };
let endpoint = Endpoint::builder() let endpoint = Endpoint::builder()
.tls_x509() // For compatibility with iroh <0.34.0
.secret_key(secret_key) .secret_key(secret_key)
.alpns(vec![GOSSIP_ALPN.to_vec()]) .alpns(vec![GOSSIP_ALPN.to_vec()])
.relay_mode(relay_mode) .relay_mode(relay_mode)
@@ -267,8 +271,7 @@ impl Context {
let gossip = Gossip::builder() let gossip = Gossip::builder()
.max_message_size(128 * 1024) .max_message_size(128 * 1024)
.spawn(endpoint.clone()) .spawn(endpoint.clone());
.await?;
let router = iroh::protocol::Router::builder(endpoint) let router = iroh::protocol::Router::builder(endpoint)
.accept(GOSSIP_ALPN, gossip.clone()) .accept(GOSSIP_ALPN, gossip.clone())
@@ -536,45 +539,39 @@ pub(crate) fn iroh_topic_from_str(topic: &str) -> Result<TopicId> {
#[expect(clippy::arithmetic_side_effects)] #[expect(clippy::arithmetic_side_effects)]
async fn subscribe_loop( async fn subscribe_loop(
context: &Context, context: &Context,
mut stream: iroh_gossip::net::GossipReceiver, mut stream: GossipReceiver,
topic: TopicId, topic: TopicId,
msg_id: MsgId, msg_id: MsgId,
join_tx: oneshot::Sender<()>, join_tx: oneshot::Sender<()>,
) -> Result<()> { ) -> 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? { while let Some(event) = stream.try_next().await? {
match event { match event {
Event::Gossip(event) => match event { GossipEvent::NeighborUp(node) => {
GossipEvent::Joined(nodes) => { info!(context, "IROH_REALTIME: NeighborUp: {}", node.to_string());
if let Some(join_tx) = join_tx.take() { iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?;
// Try to notify that at least one peer joined, }
// but ignore the error if receiver is dropped and nobody listens. GossipEvent::NeighborDown(_node) => {}
join_tx.send(()).ok(); GossipEvent::Received(message) => {
} info!(context, "IROH_REALTIME: Received realtime data");
context.emit_event(EventType::WebxdcRealtimeData {
for node in nodes { msg_id,
iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?; data: message
} .content
} .get(0..message.content.len() - 4 - PUBLIC_KEY_LENGTH)
GossipEvent::NeighborUp(node) => { .context("too few bytes in iroh message")?
info!(context, "IROH_REALTIME: NeighborUp: {}", node.to_string()); .into(),
iroh_add_peer_for_topic(context, msg_id, topic, node, None).await?; });
} }
GossipEvent::NeighborDown(_node) => {} GossipEvent::Lagged => {
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 => {
warn!(context, "Gossip lost some messages"); warn!(context, "Gossip lost some messages");
} }
}; };