Skip to content

Commit

Permalink
refactor: display the socket addr and relay for a `ConnectionType::Mi…
Browse files Browse the repository at this point in the history
…xed` (#2793)

## Description

Each time a `ConnectionType::Mixed` has a different SocketAddr or
RelayUrl, we correctly resend a `ConnectionType::Mixed` event to
`Endpoint::conn_type_stream`. However, when we print those changes in
something like `iroh doctor`, we only print the name of the connection
type, we don't print the socket address or relay url, so it looke like
we are sending extra `Mixed` events erroneously.

Adding more details to the `Display` of `ConnectionType`, so that it
prints the socket addrs and or relay urls.

## Change checklist

- [x] Self-review.
  • Loading branch information
ramfox authored Oct 7, 2024
1 parent 43f5fed commit c349c43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion iroh-net/src/discovery/local_swarm_discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//! .iter()
//! .any(|(source, duration)| {
//! if let Source::Discovery { name } = source {
//! name == iroh_net::discovery::local_swarm_discovery::NAME && *duration >= recent
//! name == iroh_net::discovery::local_swarm_discovery::NAME && *duration <= recent
//! } else {
//! false
//! }
Expand Down
6 changes: 3 additions & 3 deletions iroh-net/src/magicsock/node_map/node_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1389,16 +1389,16 @@ impl RemoteInfo {
#[derive(derive_more::Display, Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
pub enum ConnectionType {
/// Direct UDP connection
#[display("direct")]
#[display("direct({_0})")]
Direct(SocketAddr),
/// Relay connection over relay
#[display("relay")]
#[display("relay({_0})")]
Relay(RelayUrl),
/// Both a UDP and a relay connection are used.
///
/// This is the case if we do have a UDP address, but are missing a recent confirmation that
/// the address works.
#[display("mixed")]
#[display("mixed(udp: {_0}, relay: {_1})")]
Mixed(SocketAddr, RelayUrl),
/// We have no verified connection to this PublicKey
#[display("none")]
Expand Down

0 comments on commit c349c43

Please sign in to comment.