Skip to content

Commit

Permalink
feat: add Connection::id to get a stable ID for a connection
Browse files Browse the repository at this point in the history
This just proxies the underlying `quinn::Connection::stable_id`. This is
actually implemented in `quinn` as the address in memory of the
underlying shared connection reference, so although it is stable for the
lifetime of a connection it is not comparable across peers. It's still
useful for tracking connections within a single peer.
  • Loading branch information
Chris Connelly authored and connec committed Oct 28, 2021
1 parent 7788fda commit a86e558
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ impl Connection {
)
}

/// A stable identifier for the connection.
///
/// This ID will not change for the lifetime of the connection. Note that the connection ID will
/// be different at each peer, so this is most useful for tracing connection activity within a
/// single peer.
pub fn id(&self) -> usize {
self.inner.stable_id()
}

/// The address of the remote peer.
pub fn remote_address(&self) -> SocketAddr {
self.inner.remote_address()
Expand Down

0 comments on commit a86e558

Please sign in to comment.