Skip to content

Commit d4c4563

Browse files
fixup: remove dependency on tickets
1 parent f564cba commit d4c4563

File tree

5 files changed

+14
-52
lines changed

5 files changed

+14
-52
lines changed

Cargo.lock

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,3 @@ unexpected_cfgs = { level = "warn", check-cfg = ["cfg(iroh_docsrs)", "cfg(iroh_l
4040

4141
[workspace.lints.clippy]
4242
unused-async = "warn"
43-
44-
45-
[patch.crates-io]
46-
iroh-base = { path = "./iroh-base" }

iroh/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ tokio = { version = "1", features = [
142142
] }
143143
serde_json = "1"
144144
iroh-relay = { path = "../iroh-relay", default-features = false, features = ["test-utils", "server"] }
145-
iroh-tickets = { git = "https://github.com/n0-computer/iroh-tickets" }
146145
tracing-test = "0.2.5"
147146
clap = { version = "4", features = ["derive"] }
148147
tracing-subscriber = { version = "0.3", features = [

iroh/examples/0rtt.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ use std::{env, future::Future, str::FromStr, time::Instant};
33
use clap::Parser;
44
use data_encoding::HEXLOWER;
55
use iroh::{
6-
SecretKey,
6+
EndpointId, SecretKey,
77
endpoint::{Connecting, Connection},
88
};
9-
use iroh_tickets::endpoint::EndpointTicket;
109
use n0_future::{StreamExt, future};
1110
use n0_snafu::ResultExt;
1211
use n0_watcher::Watcher;
@@ -17,7 +16,7 @@ const PINGPONG_ALPN: &[u8] = b"0rtt-pingpong";
1716
#[derive(Parser)]
1817
struct Args {
1918
/// The endpoint id to connect to. If not set, the program will start a server.
20-
endpoint: Option<EndpointTicket>,
19+
endpoint_id: Option<EndpointId>,
2120
/// Number of rounds to run.
2221
#[clap(long, default_value = "100")]
2322
rounds: u64,
@@ -92,7 +91,7 @@ async fn pingpong_0rtt(connecting: Connecting, i: u64) -> n0_snafu::Result<Conne
9291
}
9392

9493
async fn connect(args: Args) -> n0_snafu::Result<()> {
95-
let endpoint_addr = args.endpoint.unwrap().endpoint_addr().clone();
94+
let remote_id = args.endpoint_id.unwrap();
9695
let endpoint = iroh::Endpoint::builder()
9796
.relay_mode(iroh::RelayMode::Disabled)
9897
.keylog(true)
@@ -102,7 +101,7 @@ async fn connect(args: Args) -> n0_snafu::Result<()> {
102101
for i in 0..args.rounds {
103102
let t0 = Instant::now();
104103
let connecting = endpoint
105-
.connect_with_opts(endpoint_addr.clone(), PINGPONG_ALPN, Default::default())
104+
.connect_with_opts(remote_id, PINGPONG_ALPN, Default::default())
106105
.await?;
107106
let connection = if args.disable_0rtt {
108107
let connection = connecting.await.e()?;
@@ -150,7 +149,6 @@ async fn accept(_args: Args) -> n0_snafu::Result<()> {
150149
};
151150
println!("Listening on: {addr:?}");
152151
println!("Endpoint ID: {:?}", addr.endpoint_id);
153-
println!("Ticket: {}", EndpointTicket::from(addr));
154152

155153
let accept = async move {
156154
while let Some(incoming) = endpoint.accept().await {
@@ -185,7 +183,7 @@ async fn accept(_args: Args) -> n0_snafu::Result<()> {
185183
async fn main() -> n0_snafu::Result<()> {
186184
tracing_subscriber::fmt::init();
187185
let args = Args::parse();
188-
if args.endpoint.is_some() {
186+
if args.endpoint_id.is_some() {
189187
connect(args).await?;
190188
} else {
191189
accept(args).await?;

iroh/examples/transfer.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ use clap::{Parser, Subcommand};
88
use data_encoding::HEXLOWER;
99
use indicatif::HumanBytes;
1010
use iroh::{
11-
Endpoint, EndpointAddr, EndpointId, RelayMap, RelayMode, RelayUrl, SecretKey,
11+
Endpoint, EndpointId, RelayMap, RelayMode, RelayUrl, SecretKey,
1212
discovery::{
1313
dns::DnsDiscovery,
1414
pkarr::{N0_DNS_PKARR_RELAY_PROD, N0_DNS_PKARR_RELAY_STAGING, PkarrPublisher},
1515
},
1616
dns::{DnsResolver, N0_DNS_ENDPOINT_ORIGIN_PROD, N0_DNS_ENDPOINT_ORIGIN_STAGING},
1717
endpoint::ConnectionError,
1818
};
19-
use iroh_tickets::endpoint::EndpointTicket;
2019
use n0_future::task::AbortOnDropHandle;
2120
use n0_snafu::{Result, ResultExt};
2221
use n0_watcher::Watcher as _;
@@ -146,7 +145,7 @@ enum Commands {
146145
},
147146
/// Fetch data.
148147
Fetch {
149-
ticket: String,
148+
remote_id: EndpointId,
150149
#[clap(flatten)]
151150
endpoint_args: EndpointArgs,
152151
},
@@ -167,11 +166,11 @@ async fn main() -> Result<()> {
167166
provide(endpoint, size).await?
168167
}
169168
Commands::Fetch {
170-
ticket,
169+
remote_id,
171170
endpoint_args,
172171
} => {
173172
let endpoint = endpoint_args.bind_endpoint().await?;
174-
fetch(endpoint, &ticket).await?
173+
fetch(endpoint, remote_id).await?
175174
}
176175
}
177176

@@ -302,17 +301,7 @@ impl EndpointArgs {
302301
async fn provide(endpoint: Endpoint, size: u64) -> Result<()> {
303302
let endpoint_id = endpoint.id();
304303

305-
let endpoint_addr = endpoint.addr();
306-
let ticket = EndpointTicket::new(endpoint_addr);
307-
println!("Ticket with our home relay and direct addresses:\n{ticket}\n",);
308-
309-
let mut endpoint_addr = endpoint.addr();
310-
endpoint_addr.direct_addresses = Default::default();
311-
let ticket = EndpointTicket::new(endpoint_addr);
312-
println!("Ticket with our home relay but no direct addresses:\n{ticket}\n",);
313-
314-
let ticket = EndpointTicket::new(EndpointAddr::new(endpoint_id));
315-
println!("Ticket with only our endpoint id:\n{ticket}\n");
304+
println!("Endpoint id:\n{endpoint_id}\n");
316305

317306
// accept incoming connections, returns a normal QUIC connection
318307
while let Some(incoming) = endpoint.accept().await {
@@ -383,20 +372,16 @@ async fn provide(endpoint: Endpoint, size: u64) -> Result<()> {
383372
Ok(())
384373
}
385374

386-
async fn fetch(endpoint: Endpoint, ticket: &str) -> Result<()> {
375+
async fn fetch(endpoint: Endpoint, remote_id: EndpointId) -> Result<()> {
387376
let me = endpoint.id().fmt_short();
388-
let ticket: EndpointTicket = ticket.parse()?;
389-
let remote_endpoint_id = ticket.endpoint_addr().endpoint_id;
390377
let start = Instant::now();
391378

392379
// Attempt to connect, over the given ALPN.
393380
// Returns a Quinn connection.
394-
let conn = endpoint
395-
.connect(EndpointAddr::from(ticket), TRANSFER_ALPN)
396-
.await?;
397-
println!("Connected to {remote_endpoint_id}");
381+
let conn = endpoint.connect(remote_id, TRANSFER_ALPN).await?;
382+
println!("Connected to {remote_id}");
398383
// Spawn a background task that prints connection type changes. Will be aborted on drop.
399-
let _guard = watch_conn_type(&endpoint, remote_endpoint_id);
384+
let _guard = watch_conn_type(&endpoint, remote_id);
400385

401386
// Use the Quinn API to send and recv content.
402387
let (mut send, mut recv) = conn.open_bi().await.e()?;

0 commit comments

Comments
 (0)