From d270d609298b12263b984cbfad4b6e656115e05e Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Fri, 10 May 2024 17:26:44 +0200 Subject: [PATCH] Log connection type changes --- iroh-net/src/magicsock/node_map/node_state.rs | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/iroh-net/src/magicsock/node_map/node_state.rs b/iroh-net/src/magicsock/node_map/node_state.rs index dfdf1ebe07..336d325bfa 100644 --- a/iroh-net/src/magicsock/node_map/node_state.rs +++ b/iroh-net/src/magicsock/node_map/node_state.rs @@ -296,21 +296,15 @@ impl NodeState { (addr, self.relay_url()) } }; - match (best_addr, relay_url.clone()) { - (Some(best_addr), Some(relay_url)) => { - let _ = self - .conn_type - .update(ConnectionType::Mixed(best_addr, relay_url)); - } - (Some(best_addr), None) => { - let _ = self.conn_type.update(ConnectionType::Direct(best_addr)); - } - (None, Some(relay_url)) => { - let _ = self.conn_type.update(ConnectionType::Relay(relay_url)); - } - (None, None) => { - let _ = self.conn_type.update(ConnectionType::None); - } + let typ = match (best_addr, relay_url.clone()) { + (Some(best_addr), Some(relay_url)) => ConnectionType::Mixed(best_addr, relay_url), + (Some(best_addr), None) => ConnectionType::Direct(best_addr), + (None, Some(relay_url)) => ConnectionType::Relay(relay_url), + (None, None) => ConnectionType::None, + }; + if self.conn_type.update(typ).is_ok() { + let typ = self.conn_type.get(); + info!(%typ, "new connection type"); } (best_addr, relay_url) }