@@ -20,8 +20,12 @@ use iroh::{
20
20
} ;
21
21
use iroh_blobs:: HashAndFormat ;
22
22
23
- use crate :: protocol:: {
24
- AnnounceKind , Query , QueryResponse , Request , Response , SignedAnnounce , ALPN , REQUEST_SIZE_LIMIT ,
23
+ use crate :: {
24
+ protocol:: {
25
+ AnnounceKind , Query , QueryResponse , Request , Response , SignedAnnounce , ALPN ,
26
+ REQUEST_SIZE_LIMIT ,
27
+ } ,
28
+ tls_utils,
25
29
} ;
26
30
27
31
/// Announce to a tracker.
@@ -33,7 +37,7 @@ use crate::protocol::{
33
37
/// `content` is the content to announce.
34
38
/// `kind` is the kind of the announcement. We can claim to have the complete data or only some of it.
35
39
pub async fn announce_quinn (
36
- connection : iroh_quinn :: Connection ,
40
+ connection : quinn :: Connection ,
37
41
signed_announce : SignedAnnounce ,
38
42
) -> anyhow:: Result < ( ) > {
39
43
let ( mut send, mut recv) = connection. open_bi ( ) . await ?;
@@ -119,14 +123,14 @@ async fn query_iroh_one(
119
123
120
124
/// A connection provider that can be used to connect to a tracker.
121
125
///
122
- /// This can either be a [`iroh_quinn ::Endpoint`] where connections are created on demand,
126
+ /// This can either be a [`quinn ::Endpoint`] where connections are created on demand,
123
127
/// or some sort of connection pool.
124
128
pub trait QuinnConnectionProvider < Addr > : Clone {
125
- fn connect ( & self , addr : Addr ) -> BoxFuture < anyhow:: Result < iroh_quinn :: Connection > > ;
129
+ fn connect ( & self , addr : Addr ) -> BoxFuture < anyhow:: Result < quinn :: Connection > > ;
126
130
}
127
131
128
- impl QuinnConnectionProvider < SocketAddr > for iroh_quinn :: Endpoint {
129
- fn connect ( & self , addr : SocketAddr ) -> BoxFuture < anyhow:: Result < iroh_quinn :: Connection > > {
132
+ impl QuinnConnectionProvider < SocketAddr > for quinn :: Endpoint {
133
+ fn connect ( & self , addr : SocketAddr ) -> BoxFuture < anyhow:: Result < quinn :: Connection > > {
130
134
async move { Ok ( self . connect ( addr, "localhost" ) ?. await ?) } . boxed ( )
131
135
}
132
136
}
@@ -229,7 +233,7 @@ pub async fn query_iroh(
229
233
230
234
/// Assume an existing connection to a tracker and query it for peers for some content.
231
235
pub async fn query_quinn (
232
- connection : iroh_quinn :: Connection ,
236
+ connection : quinn :: Connection ,
233
237
args : Query ,
234
238
) -> anyhow:: Result < QueryResponse > {
235
239
tracing:: info!( "connected to {:?}" , connection. remote_address( ) ) ;
@@ -252,12 +256,13 @@ pub fn create_quinn_client(
252
256
bind_addr : SocketAddr ,
253
257
alpn_protocols : Vec < Vec < u8 > > ,
254
258
keylog : bool ,
255
- ) -> anyhow:: Result < iroh_quinn :: Endpoint > {
259
+ ) -> anyhow:: Result < quinn :: Endpoint > {
256
260
let secret_key = iroh:: SecretKey :: generate ( rand:: thread_rng ( ) ) ;
257
- let tls_client_config = tls:: make_client_config ( & secret_key, None , alpn_protocols, keylog) ?;
258
- let mut client_config = iroh_quinn:: ClientConfig :: new ( Arc :: new ( tls_client_config) ) ;
259
- let mut endpoint = iroh_quinn:: Endpoint :: client ( bind_addr) ?;
260
- let mut transport_config = iroh_quinn:: TransportConfig :: default ( ) ;
261
+ let tls_client_config =
262
+ tls_utils:: make_client_config ( & secret_key, None , alpn_protocols, keylog) ?;
263
+ let mut client_config = quinn:: ClientConfig :: new ( Arc :: new ( tls_client_config) ) ;
264
+ let mut endpoint = quinn:: Endpoint :: client ( bind_addr) ?;
265
+ let mut transport_config = quinn:: TransportConfig :: default ( ) ;
261
266
transport_config. keep_alive_interval ( Some ( Duration :: from_secs ( 1 ) ) ) ;
262
267
client_config. transport_config ( Arc :: new ( transport_config) ) ;
263
268
endpoint. set_default_client_config ( client_config) ;
@@ -340,7 +345,7 @@ pub async fn connect(
340
345
341
346
pub enum Connection {
342
347
Iroh ( iroh:: endpoint:: Connection ) ,
343
- Quinn ( iroh_quinn :: Connection ) ,
348
+ Quinn ( quinn :: Connection ) ,
344
349
}
345
350
346
351
/// Create a iroh endpoint and connect to a tracker using the [crate::protocol::ALPN] protocol.
@@ -363,7 +368,7 @@ async fn connect_iroh(
363
368
async fn connect_socket (
364
369
tracker : SocketAddr ,
365
370
local_addr : SocketAddr ,
366
- ) -> anyhow:: Result < iroh_quinn :: Connection > {
371
+ ) -> anyhow:: Result < quinn :: Connection > {
367
372
let endpoint = create_quinn_client ( local_addr, vec ! [ ALPN . to_vec( ) ] , false ) ?;
368
373
tracing:: info!( "trying t?o )connect to tracker at {:?}" , tracker) ;
369
374
let connection = endpoint. connect ( tracker, "localhost" ) ?. await ?;
0 commit comments