@@ -8,15 +8,14 @@ use clap::{Parser, Subcommand};
88use data_encoding:: HEXLOWER ;
99use indicatif:: HumanBytes ;
1010use 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 ;
2019use n0_future:: task:: AbortOnDropHandle ;
2120use n0_snafu:: { Result , ResultExt } ;
2221use 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 {
302301async 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