@@ -26,7 +26,7 @@ use url::Url;
2626
2727pub use super :: magicsock:: {
2828 AddEndpointAddrError , ConnectionType , DirectAddr , DirectAddrType , PathInfo , PathsInfo ,
29- endpoint_map:: Source ,
29+ RemoteInfo , endpoint_map:: Source ,
3030} ;
3131#[ cfg( wasm_browser) ]
3232use crate :: discovery:: pkarr:: PkarrResolver ;
@@ -55,8 +55,8 @@ pub use quinn::{
5555 AcceptBi , AcceptUni , AckFrequencyConfig , ApplicationClose , Chunk , ClosedStream ,
5656 ConnectionClose , ConnectionError , ConnectionStats , MtuDiscoveryConfig , OpenBi , OpenUni ,
5757 ReadDatagram , ReadError , ReadExactError , ReadToEndError , RecvStream , ResetError , RetryError ,
58- SendDatagramError , SendStream , ServerConfig , StoppedError , StreamId , TransportConfig , VarInt ,
59- WeakConnectionHandle , WriteError ,
58+ SendDatagramError , SendStream , ServerConfig , Side , StoppedError , StreamId , TransportConfig ,
59+ VarInt , WeakConnectionHandle , WriteError ,
6060} ;
6161pub use quinn_proto:: {
6262 FrameStats , PathStats , TransportError , TransportErrorCode , UdpStats , Written ,
@@ -69,8 +69,8 @@ pub use quinn_proto::{
6969
7070pub use self :: connection:: {
7171 Accept , Accepting , AlpnError , AuthenticationError , Connecting , ConnectingError , Connection ,
72- Incoming , IncomingZeroRttConnection , OutgoingZeroRttConnection , RemoteEndpointIdError ,
73- ZeroRttStatus ,
72+ ConnectionInfo , Incoming , IncomingZeroRttConnection , OutgoingZeroRttConnection ,
73+ RemoteEndpointIdError , ZeroRttStatus ,
7474} ;
7575
7676/// The delay to fall back to discovery when direct addresses fail.
@@ -98,7 +98,7 @@ pub enum PathSelection {
9898/// new [`EndpointId`].
9999///
100100/// To create the [`Endpoint`] call [`Builder::bind`].
101- #[ derive( Debug ) ]
101+ #[ derive( derive_more :: Debug ) ]
102102pub struct Builder {
103103 secret_key : Option < SecretKey > ,
104104 relay_mode : RelayMode ,
@@ -963,38 +963,24 @@ impl Endpoint {
963963 //
964964 // Partially they return things passed into the builder.
965965
966- /// Returns a [`Watcher`] that reports the current connection type and any changes for
967- /// given remote endpoint.
968- ///
969- /// This watcher allows observing a stream of [`ConnectionType`] items by calling
970- /// [`Watcher::stream()`]. If the underlying connection to a remote endpoint changes, it will
971- /// yield a new item. These connection changes are when the connection switches between
972- /// using the Relay server and a direct connection.
973- ///
974- /// Note that this does not guarantee each connection change is yielded in the stream.
975- /// If the connection type changes several times before this stream is polled, only the
976- /// last recorded state is returned. This can be observed e.g. right at the start of a
977- /// connection when the switch from a relayed to a direct connection can be so fast that
978- /// the relayed state is never exposed.
966+ /// Information about a remote endpoint.
979967 ///
980- /// If there is currently a connection with the remote endpoint, then using [`Watcher::get`]
981- /// will immediately return either [`ConnectionType::Relay`], [`ConnectionType::Direct`]
982- /// or [`ConnectionType::Mixed`].
968+ /// From the [`RemoteInfo`] you can watch which path is selected, get the current
969+ /// round-trip time (latency), and get a list of [`ConnectionInfo`].
983970 ///
984- /// It is possible for the connection type to be [`ConnectionType::None`] if you've
985- /// recently connected to this endpoint id but previous methods of reaching the endpoint have
986- /// become inaccessible.
987- ///
988- /// Will return `None` if we do not have any address information for the given `endpoint_id`.
989- pub fn conn_type ( & self , endpoint_id : EndpointId ) -> Option < n0_watcher:: Direct < ConnectionType > > {
990- self . msock . conn_type ( endpoint_id)
971+ /// Returns `None` if we don't have any state for this remote.
972+ pub fn remote_info ( & self , endpoint_id : EndpointId ) -> Option < RemoteInfo > {
973+ self . msock . endpoint_map . remote_info ( endpoint_id)
991974 }
992975
993- /// Returns the currently lowest latency for this endpoint.
976+ /// Returns a list of all remote endpoints that this endpoint is dealing with.
977+ ///
978+ /// This includes all endpoints to which we have active connections. It also may include endpoints
979+ /// to which we are in the process of connecting, or have recently been connected to.
994980 ///
995- /// Will return `None` if we do not have any address information for the given `endpoint_id` .
996- pub async fn latency ( & self , endpoint_id : EndpointId ) -> Option < Duration > {
997- self . msock . latency ( endpoint_id ) . await
981+ /// TODO: Expand docs .
982+ pub fn remotes ( & self ) -> Vec < RemoteInfo > {
983+ self . msock . endpoint_map . remotes ( )
998984 }
999985
1000986 /// Returns the DNS resolver used in this [`Endpoint`].
0 commit comments