@@ -17,10 +17,10 @@ use futures_util::{
1717 select, stream,
1818} ;
1919#[ cfg( rustls) ]
20- use quinn_proto :: crypto:: rustls:: HandshakeData ;
21- use quinn_proto :: {
22- ConnectionHandle , ConnectionStats , Dir , EndpointEvent , Side , StreamEvent , StreamId , VarInt ,
23- congestion:: Controller ,
20+ use noq_proto :: crypto:: rustls:: HandshakeData ;
21+ use noq_proto :: {
22+ ConnectionHandle , ConnectionStats , Dir , EndpointEvent , PathId , Side , StreamEvent , StreamId ,
23+ VarInt , congestion:: Controller ,
2424} ;
2525use rustc_hash:: FxHashMap as HashMap ;
2626use thiserror:: Error ;
@@ -36,12 +36,12 @@ use crate::{
3636#[ derive( Debug ) ]
3737pub ( crate ) enum ConnectionEvent {
3838 Close ( VarInt , Bytes ) ,
39- Proto ( quinn_proto :: ConnectionEvent ) ,
39+ Proto ( noq_proto :: ConnectionEvent ) ,
4040}
4141
4242#[ derive( Debug ) ]
4343pub ( crate ) struct ConnectionState {
44- pub ( crate ) conn : quinn_proto :: Connection ,
44+ pub ( crate ) conn : noq_proto :: Connection ,
4545 pub ( crate ) error : Option < ConnectionError > ,
4646 connected : bool ,
4747 worker : Option < JoinHandle < ( ) > > ,
@@ -134,7 +134,7 @@ fn implicit_close(this: &Shared<ConnectionInner>) {
134134impl ConnectionInner {
135135 fn new (
136136 handle : ConnectionHandle ,
137- conn : quinn_proto :: Connection ,
137+ conn : noq_proto :: Connection ,
138138 socket : Socket ,
139139 events_tx : Sender < ( ConnectionHandle , EndpointEvent ) > ,
140140 events_rx : Receiver < ConnectionEvent > ,
@@ -246,7 +246,7 @@ impl ConnectionInner {
246246 }
247247
248248 while let Some ( event) = state. conn . poll ( ) {
249- use quinn_proto :: Event :: * ;
249+ use noq_proto :: Event :: * ;
250250 match event {
251251 HandshakeDataReady => {
252252 if let Some ( waker) = state. on_handshake_data . take ( ) {
@@ -282,6 +282,16 @@ impl ConnectionInner {
282282 . for_each ( Waker :: wake) ,
283283 DatagramReceived => state. datagram_received . drain ( ..) . for_each ( Waker :: wake) ,
284284 DatagramsUnblocked => state. datagrams_unblocked . drain ( ..) . for_each ( Waker :: wake) ,
285+
286+ HandshakeConfirmed => {
287+ todo ! ( )
288+ }
289+ Path ( _) => {
290+ todo ! ( )
291+ }
292+ NatTraversal ( _) => {
293+ todo ! ( )
294+ }
285295 }
286296 }
287297
@@ -313,19 +323,37 @@ macro_rules! conn_fn {
313323 /// This will return `None` for clients, or when the platform does not
314324 /// expose this information.
315325 pub fn local_ip( & self ) -> Option <IpAddr > {
316- self . 0 . state( ) . conn. local_ip( )
326+ let state = self . 0 . state( ) ;
327+
328+ state
329+ . conn
330+ . paths( )
331+ . iter( )
332+ . filter_map( |id| state. conn. network_path( * id) . ok( ) )
333+ . next( )
334+ . unwrap( )
335+ . local_ip
317336 }
318337
319338 /// The peer's UDP address.
320339 ///
321340 /// Will panic if called after `poll` has returned `Ready`.
322341 pub fn remote_address( & self ) -> SocketAddr {
323- self . 0 . state( ) . conn. remote_address( )
342+ let state = self . 0 . state( ) ;
343+
344+ state
345+ . conn
346+ . paths( )
347+ . iter( )
348+ . filter_map( |id| state. conn. network_path( * id) . ok( ) )
349+ . next( )
350+ . unwrap( )
351+ . remote
324352 }
325353
326354 /// Current best estimate of this connection's latency (round-trip-time).
327- pub fn rtt( & self ) -> Duration {
328- self . 0 . state( ) . conn. rtt( )
355+ pub fn rtt( & self , path_id : PathId ) -> Option < Duration > {
356+ self . 0 . state( ) . conn. rtt( path_id )
329357 }
330358
331359 /// Connection statistics.
@@ -335,8 +363,12 @@ macro_rules! conn_fn {
335363
336364 /// Current state of the congestion control algorithm. (For debugging
337365 /// purposes)
338- pub fn congestion_state( & self ) -> Box <dyn Controller > {
339- self . 0 . state( ) . conn. congestion_state( ) . clone_box( )
366+ pub fn congestion_state( & self , path_id: PathId ) -> Option <Box <dyn Controller >> {
367+ self . 0
368+ . state( )
369+ . conn
370+ . congestion_state( path_id)
371+ . map( |state| state. clone_box( ) )
340372 }
341373
342374 /// Cryptographic identity of the peer.
@@ -375,7 +407,7 @@ macro_rules! conn_fn {
375407 output: & mut [ u8 ] ,
376408 label: & [ u8 ] ,
377409 context: & [ u8 ] ,
378- ) -> Result <( ) , quinn_proto :: crypto:: ExportKeyingMaterialError > {
410+ ) -> Result <( ) , noq_proto :: crypto:: ExportKeyingMaterialError > {
379411 self . 0
380412 . state( )
381413 . conn
@@ -395,7 +427,7 @@ impl Connecting {
395427
396428 pub ( crate ) fn new (
397429 handle : ConnectionHandle ,
398- conn : quinn_proto :: Connection ,
430+ conn : noq_proto :: Connection ,
399431 socket : Socket ,
400432 events_tx : Sender < ( ConnectionHandle , EndpointEvent ) > ,
401433 events_rx : Receiver < ConnectionEvent > ,
@@ -573,14 +605,14 @@ impl Connection {
573605 state. wake ( ) ;
574606 }
575607
576- /// See [`quinn_proto ::TransportConfig::send_window()`]
608+ /// See [`noq_proto ::TransportConfig::send_window()`]
577609 pub fn set_send_window ( & self , send_window : u64 ) {
578610 let mut state = self . 0 . state ( ) ;
579611 state. conn . set_send_window ( send_window) ;
580612 state. wake ( ) ;
581613 }
582614
583- /// See [`quinn_proto ::TransportConfig::receive_window()`]
615+ /// See [`noq_proto ::TransportConfig::receive_window()`]
584616 pub fn set_receive_window ( & self , receive_window : VarInt ) {
585617 let mut state = self . 0 . state ( ) ;
586618 state. conn . set_receive_window ( receive_window) ;
@@ -685,7 +717,7 @@ impl Connection {
685717 cx : Option < & mut Context > ,
686718 data : Bytes ,
687719 ) -> Result < ( ) , Result < SendDatagramError , Bytes > > {
688- use quinn_proto :: SendDatagramError :: * ;
720+ use noq_proto :: SendDatagramError :: * ;
689721 let mut state = self . 0 . try_state ( ) . map_err ( |e| Ok ( e. into ( ) ) ) ?;
690722 state
691723 . conn
@@ -945,13 +977,13 @@ pub enum ConnectionError {
945977 /// The peer violated the QUIC specification as understood by this
946978 /// implementation
947979 #[ error( transparent) ]
948- TransportError ( #[ from] quinn_proto :: TransportError ) ,
980+ TransportError ( #[ from] noq_proto :: TransportError ) ,
949981 /// The peer's QUIC stack aborted the connection automatically
950982 #[ error( "aborted by peer: {0}" ) ]
951- ConnectionClosed ( quinn_proto :: ConnectionClose ) ,
983+ ConnectionClosed ( noq_proto :: ConnectionClose ) ,
952984 /// The peer closed the connection
953985 #[ error( "closed by peer: {0}" ) ]
954- ApplicationClosed ( quinn_proto :: ApplicationClose ) ,
986+ ApplicationClosed ( noq_proto :: ApplicationClose ) ,
955987 /// The peer is unable to continue processing this connection, usually due
956988 /// to having restarted
957989 #[ error( "reset by peer" ) ]
@@ -961,8 +993,8 @@ pub enum ConnectionError {
961993 ///
962994 /// If neither side is sending keep-alives, a connection will time out after
963995 /// a long enough idle period even if the peer is still reachable. See
964- /// also [`TransportConfig::max_idle_timeout()`](quinn_proto ::TransportConfig::max_idle_timeout())
965- /// and [`TransportConfig::keep_alive_interval()`](quinn_proto ::TransportConfig::keep_alive_interval()).
996+ /// also [`TransportConfig::max_idle_timeout()`](noq_proto ::TransportConfig::max_idle_timeout())
997+ /// and [`TransportConfig::keep_alive_interval()`](noq_proto ::TransportConfig::keep_alive_interval()).
966998 #[ error( "timed out" ) ]
967999 TimedOut ,
9681000 /// The local application closed the connection
@@ -976,9 +1008,9 @@ pub enum ConnectionError {
9761008 CidsExhausted ,
9771009}
9781010
979- impl From < quinn_proto :: ConnectionError > for ConnectionError {
980- fn from ( value : quinn_proto :: ConnectionError ) -> Self {
981- use quinn_proto :: ConnectionError :: * ;
1011+ impl From < noq_proto :: ConnectionError > for ConnectionError {
1012+ fn from ( value : noq_proto :: ConnectionError ) -> Self {
1013+ use noq_proto :: ConnectionError :: * ;
9821014
9831015 match value {
9841016 VersionMismatch => ConnectionError :: VersionMismatch ,
0 commit comments