@@ -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 ,
@@ -1005,38 +1005,24 @@ impl Endpoint {
10051005 //
10061006 // Partially they return things passed into the builder.
10071007
1008- /// Returns a [`Watcher`] that reports the current connection type and any changes for
1009- /// given remote endpoint.
1008+ /// Information about a remote endpoint.
10101009 ///
1011- /// This watcher allows observing a stream of [`ConnectionType`] items by calling
1012- /// [`Watcher::stream()`]. If the underlying connection to a remote endpoint changes, it will
1013- /// yield a new item. These connection changes are when the connection switches between
1014- /// using the Relay server and a direct connection.
1010+ /// From the [`RemoteInfo`] you can watch which path is selected, get the current
1011+ /// round-trip time (latency), and get a list of [`ConnectionInfo`].
10151012 ///
1016- /// Note that this does not guarantee each connection change is yielded in the stream.
1017- /// If the connection type changes several times before this stream is polled, only the
1018- /// last recorded state is returned. This can be observed e.g. right at the start of a
1019- /// connection when the switch from a relayed to a direct connection can be so fast that
1020- /// the relayed state is never exposed.
1021- ///
1022- /// If there is currently a connection with the remote endpoint, then using [`Watcher::get`]
1023- /// will immediately return either [`ConnectionType::Relay`], [`ConnectionType::Direct`]
1024- /// or [`ConnectionType::Mixed`].
1025- ///
1026- /// It is possible for the connection type to be [`ConnectionType::None`] if you've
1027- /// recently connected to this endpoint id but previous methods of reaching the endpoint have
1028- /// become inaccessible.
1029- ///
1030- /// Will return `None` if we do not have any address information for the given `endpoint_id`.
1031- pub fn conn_type ( & self , endpoint_id : EndpointId ) -> Option < n0_watcher:: Direct < ConnectionType > > {
1032- self . msock . conn_type ( endpoint_id)
1013+ /// Returns `None` if we don't have any state for this remote.
1014+ pub fn remote_info ( & self , endpoint_id : EndpointId ) -> Option < RemoteInfo > {
1015+ self . msock . endpoint_map . remote_info ( endpoint_id)
10331016 }
10341017
1035- /// Returns the currently lowest latency for this endpoint.
1018+ /// Returns a list of all remote endpoints that this endpoint is dealing with.
1019+ ///
1020+ /// This includes all endpoints to which we have active connections. It also may include endpoints
1021+ /// to which we are in the process of connecting, or have recently been connected to.
10361022 ///
1037- /// Will return `None` if we do not have any address information for the given `endpoint_id` .
1038- pub async fn latency ( & self , endpoint_id : EndpointId ) -> Option < Duration > {
1039- self . msock . latency ( endpoint_id ) . await
1023+ /// TODO: Expand docs .
1024+ pub fn remotes ( & self ) -> Vec < RemoteInfo > {
1025+ self . msock . endpoint_map . remotes ( )
10401026 }
10411027
10421028 /// Returns the DNS resolver used in this [`Endpoint`].
0 commit comments