Skip to content

Commit 7f3d972

Browse files
authored
Merge pull request #22 from n0-computer/iroh-v0.30.0
chore: upgrade to iroh v0.30.0
2 parents 74c38f7 + 2831c40 commit 7f3d972

File tree

23 files changed

+849
-59
lines changed

23 files changed

+849
-59
lines changed

content-discovery/Cargo.toml

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ members = [
33
"iroh-mainline-content-discovery",
44
"iroh-mainline-content-discovery-cli",
55
"iroh-mainline-tracker",
6+
"tls",
67
]
78
resolver = "2"
89

@@ -26,5 +27,6 @@ missing_debug_implementations = "warn"
2627
unused-async = "warn"
2728

2829
[workspace.dependencies]
29-
iroh = "0.29"
30-
iroh-blobs = "0.29"
30+
iroh = "0.30"
31+
iroh-base = "0.30"
32+
iroh-blobs = { version = "0.30", features = ["rpc"] }

content-discovery/iroh-mainline-content-discovery-cli/src/args.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Command line arguments.
22
use clap::{Parser, Subcommand};
3-
use iroh::{ticket::BlobTicket, NodeId};
3+
use iroh::NodeId;
4+
use iroh_blobs::ticket::BlobTicket;
45
use iroh_blobs::{Hash, HashAndFormat};
56
use std::{
67
fmt::Display,

content-discovery/iroh-mainline-content-discovery-cli/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async fn announce(args: AnnounceArgs) -> anyhow::Result<()> {
2424
eprintln!("ANNOUNCE_SECRET environment variable must be set to a valid secret key");
2525
anyhow::bail!("ANNOUNCE_SECRET env var not set");
2626
};
27-
let Ok(key) = iroh::key::SecretKey::from_str(&key) else {
27+
let Ok(key) = iroh::SecretKey::from_str(&key) else {
2828
anyhow::bail!("ANNOUNCE_SECRET env var is not a valid secret key");
2929
};
3030
let content = args.content.hash_and_format();

content-discovery/iroh-mainline-content-discovery/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ license = "MIT OR Apache-2.0"
1212
#
1313
# The protocol is using postcard, but we don't need a postcard dependency for just the type definitions
1414
iroh = { workspace = true }
15+
iroh-base = { workspace = true }
1516
iroh-blobs = { workspace = true }
17+
rand = "0.8.5"
1618
serde = { version = "1", features = ["derive"] }
1719
derive_more = { version = "1.0.0-beta.1", features = ["debug", "display", "from", "try_into"] }
1820
serde-big-array = "0.5.1"
@@ -30,7 +32,8 @@ rustls = { version = "0.23", default-features = false, features = ["ring"], opti
3032
genawaiter = { version = "0.99.1", features = ["futures03"], optional = true }
3133
tokio = { version = "1.36.0", optional = true }
3234
flume = "0.11.0"
35+
tls = { path = "../tls", optional = true }
3336

3437
[features]
35-
client = ["mainline", "iroh-quinn", "tracing", "anyhow", "rcgen", "genawaiter", "rustls", "futures", "postcard", "tokio"]
38+
client = ["mainline", "iroh-quinn", "tracing", "anyhow", "rcgen", "genawaiter", "rustls", "futures", "postcard", "tokio", "tls"]
3639
default = ["client"]

content-discovery/iroh-mainline-content-discovery/src/client.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,8 @@ pub fn create_quinn_client(
210210
alpn_protocols: Vec<Vec<u8>>,
211211
keylog: bool,
212212
) -> anyhow::Result<iroh_quinn::Endpoint> {
213-
let secret_key = iroh::key::SecretKey::generate();
214-
let tls_client_config =
215-
iroh::tls::make_client_config(&secret_key, None, alpn_protocols, keylog)?;
213+
let secret_key = iroh::SecretKey::generate(rand::thread_rng());
214+
let tls_client_config = tls::make_client_config(&secret_key, None, alpn_protocols, keylog)?;
216215
let mut client_config = iroh_quinn::ClientConfig::new(Arc::new(tls_client_config));
217216
let mut endpoint = iroh_quinn::Endpoint::client(bind_addr)?;
218217
let mut transport_config = iroh_quinn::TransportConfig::default();
@@ -223,7 +222,7 @@ pub fn create_quinn_client(
223222
}
224223

225224
async fn create_endpoint(
226-
key: iroh::key::SecretKey,
225+
key: iroh::SecretKey,
227226
ipv4_addr: SocketAddrV4,
228227
ipv6_addr: SocketAddrV6,
229228
publish: bool,
@@ -301,7 +300,7 @@ async fn connect_iroh(
301300
// todo: uncomment once the connection problems are fixed
302301
// for now, a random node id is more reliable.
303302
// let key = load_secret_key(tracker_path(CLIENT_KEY)?).await?;
304-
let key = iroh::key::SecretKey::generate();
303+
let key = iroh::SecretKey::generate(rand::thread_rng());
305304
let endpoint = create_endpoint(key, local_ipv4_addr, local_ipv6_addr, false).await?;
306305
tracing::info!("trying to connect to tracker at {:?}", tracker);
307306
let connection = endpoint.connect(tracker, ALPN).await?;

content-discovery/iroh-mainline-content-discovery/src/protocol.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ impl Deref for SignedAnnounce {
118118

119119
impl SignedAnnounce {
120120
/// Create a new signed announce.
121-
pub fn new(announce: Announce, secret_key: &iroh::key::SecretKey) -> anyhow::Result<Self> {
121+
pub fn new(announce: Announce, secret_key: &iroh::SecretKey) -> anyhow::Result<Self> {
122122
let announce_bytes = postcard::to_allocvec(&announce)?;
123123
let signature = secret_key.sign(&announce_bytes).to_bytes();
124124
Ok(Self {
@@ -130,7 +130,7 @@ impl SignedAnnounce {
130130
/// Verify the announce, and return the announce if it's valid.
131131
pub fn verify(&self) -> anyhow::Result<()> {
132132
let announce_bytes = postcard::to_allocvec(&self.announce)?;
133-
let signature = iroh::key::Signature::from_bytes(&self.signature);
133+
let signature = iroh_base::Signature::from_bytes(&self.signature);
134134
self.announce.host.verify(&announce_bytes, &signature)?;
135135
Ok(())
136136
}

content-discovery/iroh-mainline-tracker/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ url = "2.5.0"
4141
flume = "0.11.0"
4242
genawaiter = { version = "0.99.1", features = ["futures03"] }
4343
iroh-mainline-content-discovery = { path = "../iroh-mainline-content-discovery", features = ["client"] }
44+
tls = { path = "../tls" }
4445

4546
clap = { version = "4", features = ["derive"], optional = true }
4647
serde-big-array = "0.5.1"

content-discovery/iroh-mainline-tracker/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async fn await_relay_region(endpoint: &Endpoint) -> anyhow::Result<()> {
6262
}
6363

6464
async fn create_endpoint(
65-
key: iroh::key::SecretKey,
65+
key: iroh::SecretKey,
6666
ipv4_addr: SocketAddrV4,
6767
publish: bool,
6868
) -> anyhow::Result<Endpoint> {
@@ -187,18 +187,18 @@ async fn main() -> anyhow::Result<()> {
187187

188188
/// Returns default server configuration along with its certificate.
189189
#[allow(clippy::field_reassign_with_default)] // https://github.com/rust-lang/rust-clippy/issues/6527
190-
fn configure_server(secret_key: &iroh::key::SecretKey) -> anyhow::Result<iroh_quinn::ServerConfig> {
190+
fn configure_server(secret_key: &iroh::SecretKey) -> anyhow::Result<iroh_quinn::ServerConfig> {
191191
make_server_config(secret_key, 8, 1024, vec![ALPN.to_vec()])
192192
}
193193

194194
/// Create a [`quinn::ServerConfig`] with the given secret key and limits.
195195
pub fn make_server_config(
196-
secret_key: &iroh::key::SecretKey,
196+
secret_key: &iroh::SecretKey,
197197
max_streams: u64,
198198
max_connections: u32,
199199
alpn_protocols: Vec<Vec<u8>>,
200200
) -> anyhow::Result<iroh_quinn::ServerConfig> {
201-
let tls_server_config = iroh::tls::make_server_config(secret_key, alpn_protocols, false)?;
201+
let tls_server_config = tls::make_server_config(secret_key, alpn_protocols, false)?;
202202
let mut server_config = iroh_quinn::ServerConfig::with_crypto(Arc::new(tls_server_config));
203203
let mut transport_config = iroh_quinn::TransportConfig::default();
204204
transport_config

content-discovery/tls/Cargo.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "tls"
3+
version = "0.1.0"
4+
edition = "2021"
5+
description = "create tls configuration for quic connections"
6+
license = "MIT OR Apache-2.0"
7+
8+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9+
10+
[dependencies]
11+
iroh-base = { workspace = true }
12+
der = { version = "0.7", features = ["alloc", "derive"] }
13+
derive_more = { version = "1.0.0-beta.1", features = ["debug", "display", "from", "try_into"] }
14+
quinn = { package = "iroh-quinn", version = "0.12.0" }
15+
rand = "0.8.5"
16+
rcgen = "0.13"
17+
ring = "0.17"
18+
rustls = { version = "0.23", default-features = false, features = ["ring"] }
19+
thiserror = "2"
20+
tracing = "0.1"
21+
webpki = { package = "rustls-webpki", version = "0.102" }
22+
x509-parser = "0.16"

0 commit comments

Comments
 (0)