Forráskód Böngészése

net,rpc,event_graph,dht: use channel display address for UI scenarios (e.g. logging, dnet)

oars 9 hónapja
szülő
commit
404dc9d9f0

+ 1 - 1
src/dht/tasks.rs

@@ -51,7 +51,7 @@ pub async fn channel_task<H: DhtHandler>(handler: Arc<H>) -> Result<()> {
         let ping_res = handler.ping(channel.clone()).await;
 
         if let Err(e) = ping_res {
-            warn!(target: "dht::channel_task()", "Error while pinging (requesting node id) {}: {e}", channel.address());
+            warn!(target: "dht::channel_task()", "Error while pinging (requesting node id) {}: {e}", channel.display_address());
             // channel.stop().await;
             continue;
         }

+ 2 - 2
src/event_graph/mod.rs

@@ -229,7 +229,7 @@ impl EventGraph {
         // Let's first ask all of our peers for their tips and collect them
         // in our hashmap above.
         for channel in channels.iter() {
-            let url = channel.address();
+            let url = channel.display_address();
 
             let tip_rep_sub = match channel.subscribe_msg::<TipRep>().await {
                 Ok(v) => v,
@@ -324,7 +324,7 @@ impl EventGraph {
             let mut found_event = false;
 
             for channel in channels.iter() {
-                let url = channel.address();
+                let url = channel.display_address();
 
                 debug!(
                     target: "event_graph::dag_sync()",

+ 9 - 9
src/event_graph/proto.rs

@@ -202,7 +202,7 @@ impl ProtocolEventGraph {
             error!(
                 target: "event_graph::protocol::handle_event_put()",
                 "[EVENTGRAPH] Peer {} reached malicious threshold. Dropping connection.",
-                self.channel.address(),
+                self.channel.display_address(),
             );
             self.channel.stop().await;
             return Err(Error::ChannelStopped)
@@ -210,7 +210,7 @@ impl ProtocolEventGraph {
 
         warn!(
             target: "event_graph::protocol::handle_event_put()",
-            "[EVENTGRAPH] Peer {} sent us a malicious event", self.channel.address(),
+            "[EVENTGRAPH] Peer {} sent us a malicious event", self.channel.display_address(),
         );
 
         Ok(())
@@ -230,7 +230,7 @@ impl ProtocolEventGraph {
             };
             trace!(
                  target: "event_graph::protocol::handle_event_put()",
-                 "Got EventPut: {} [{}]", event.id(), self.channel.address(),
+                 "Got EventPut: {} [{}]", event.id(), self.channel.display_address(),
             );
 
             // Check if node has finished syncing its DAG
@@ -349,7 +349,7 @@ impl ProtocolEventGraph {
                         error!(
                             target: "event_graph::protocol::handle_event_put()",
                             "[EVENTGRAPH] Timeout while waiting for parents {missing_parents:?} from {}",
-                            self.channel.address(),
+                            self.channel.display_address(),
                         );
                         self.channel.stop().await;
                         return Err(Error::ChannelStopped)
@@ -363,7 +363,7 @@ impl ProtocolEventGraph {
                             error!(
                                 target: "event_graph::protocol::handle_event_put()",
                                 "[EVENTGRAPH] Peer {} replied with a wrong event: {}",
-                                self.channel.address(), parent.id(),
+                                self.channel.display_address(), parent.id(),
                             );
                             self.channel.stop().await;
                             return Err(Error::ChannelStopped)
@@ -448,7 +448,7 @@ impl ProtocolEventGraph {
             };
             trace!(
                 target: "event_graph::protocol::handle_event_req()",
-                "Got EventReq: {event_ids:?} [{}]", self.channel.address(),
+                "Got EventReq: {event_ids:?} [{}]", self.channel.display_address(),
             );
 
             // Check if node has finished syncing its DAG
@@ -479,7 +479,7 @@ impl ProtocolEventGraph {
                         error!(
                             target: "event_graph::protocol::handle_event_req()",
                             "[EVENTGRAPH] Peer {} reached malicious threshold. Dropping connection.",
-                            self.channel.address(),
+                            self.channel.display_address(),
                         );
                         self.channel.stop().await;
                         return Err(Error::ChannelStopped)
@@ -488,7 +488,7 @@ impl ProtocolEventGraph {
                     warn!(
                         target: "event_graph::protocol::handle_event_req()",
                         "[EVENTGRAPH] Peer {} requested an unexpected event {event_id:?}",
-                        self.channel.address()
+                        self.channel.display_address()
                     );
                     continue
                 }
@@ -544,7 +544,7 @@ impl ProtocolEventGraph {
             self.tip_req_sub.receive().await?;
             trace!(
                 target: "event_graph::protocol::handle_tip_req()",
-                "Got TipReq [{}]", self.channel.address(),
+                "Got TipReq [{}]", self.channel.display_address(),
             );
 
             // Check if node has finished syncing its DAG

+ 11 - 5
src/net/channel.rs

@@ -412,7 +412,7 @@ impl Channel {
                         info!(
                             target: "net::channel::main_receive_loop()",
                             "[P2P] Channel {} disconnected",
-                            self.address()
+                            self.display_address()
                         );
                     } else if let Error::MessageInvalid = err {
                         // The command name length has exceeded the limit, this is possibly a malicious attack so ban it
@@ -426,7 +426,7 @@ impl Channel {
                         error!(
                             target: "net::channel::main_receive_loop()",
                             "[P2P] Read error on channel {}: {err}",
-                            self.address()
+                            self.display_address()
                         );
                     }
 
@@ -487,7 +487,7 @@ impl Channel {
     /// Ban a malicious peer and stop the channel.
     pub async fn ban(&self) {
         debug!(target: "net::channel::ban()", "START {self:?}");
-        debug!(target: "net::channel::ban()", "Peer: {:?}", self.address());
+        debug!(target: "net::channel::ban()", "Peer: {:?}", self.display_address());
 
         // Just store the hostname if this is an inbound session.
         // This will block all ports from this peer by setting
@@ -495,7 +495,7 @@ impl Channel {
         let peer = {
             if self.session_type_id() & SESSION_INBOUND != 0 {
                 if self.address().host().is_none() {
-                    error!("[P2P] ban() caught Url without host: {:?}", self.address());
+                    error!("[P2P] ban() caught Url without host: {:?}", self.display_address());
                     return
                 }
 
@@ -548,6 +548,12 @@ impl Channel {
         &self.info.connect_addr
     }
 
+    /// Returns the address used for UI purposes like in logging or tools like dnet.
+    /// For transport_mixed connection shows the mixed address.
+    pub fn display_address(&self) -> &Url {
+        self.info.resolve_addr.as_ref().unwrap_or(&self.info.connect_addr)
+    }
+
     /// Returns the socket address that has undergone transport
     /// processing, if it exists. Returns None otherwise.
     pub fn resolve_addr(&self) -> Option<Url> {
@@ -602,6 +608,6 @@ impl Channel {
 
 impl fmt::Debug for Channel {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "<Channel addr='{}' id={}>", self.address(), self.info.id)
+        write!(f, "<Channel addr='{}' id={}>", self.display_address(), self.info.id)
     }
 }

+ 1 - 1
src/net/p2p.rs

@@ -302,7 +302,7 @@ async fn broadcast_serialized_to<M: Message>(
                     error!(
                         target: "net::p2p::broadcast()",
                         "[P2P] Broadcasting message to {} failed: {e}",
-                        channel.address()
+                        channel.display_address()
                     );
                     // If the channel is stopped then it should automatically die
                     // and the session will remove it from p2p.

+ 9 - 9
src/net/protocol/protocol_address.rs

@@ -105,14 +105,14 @@ impl ProtocolAddress {
     async fn handle_receive_addrs(self: Arc<Self>) -> Result<()> {
         debug!(
             target: "net::protocol_address::handle_receive_addrs()",
-            "[START] address={}", self.channel.address(),
+            "[START] address={}", self.channel.display_address(),
         );
 
         loop {
             let addrs_msg = self.addrs_sub.receive().await?;
             debug!(
                 target: "net::protocol_address::handle_receive_addrs()",
-                "Received {} addrs from {}", addrs_msg.addrs.len(), self.channel.address(),
+                "Received {} addrs from {}", addrs_msg.addrs.len(), self.channel.display_address(),
             );
 
             debug!(
@@ -130,7 +130,7 @@ impl ProtocolAddress {
     async fn handle_receive_get_addrs(self: Arc<Self>) -> Result<()> {
         debug!(
             target: "net::protocol_address::handle_receive_get_addrs()",
-            "[START] address={}", self.channel.address(),
+            "[START] address={}", self.channel.display_address(),
         );
 
         loop {
@@ -138,7 +138,7 @@ impl ProtocolAddress {
 
             debug!(
                 target: "net::protocol_address::handle_receive_get_addrs()",
-                "Received GetAddrs({}) message from {}", get_addrs_msg.max, self.channel.address(),
+                "Received GetAddrs({}) message from {}", get_addrs_msg.max, self.channel.display_address(),
             );
 
             // Filter out transports not meant to be shared like Socks5 and Socks5+tls
@@ -207,7 +207,7 @@ impl ProtocolAddress {
 
             debug!(
                 target: "net::protocol_address::handle_receive_get_addrs()",
-                "Sending {} addresses to {}", addrs.len(), self.channel.address(),
+                "Sending {} addresses to {}", addrs.len(), self.channel.display_address(),
             );
 
             let addrs_msg = AddrsMessage { addrs };
@@ -220,7 +220,7 @@ impl ProtocolAddress {
     async fn send_my_addrs(self: Arc<Self>) -> Result<()> {
         debug!(
             target: "net::protocol_address::send_my_addrs",
-            "[START] channel address={}", self.channel.address(),
+            "[START] channel address={}", self.channel.display_address(),
         );
 
         if self.channel.session_type_id() != SESSION_OUTBOUND {
@@ -258,7 +258,7 @@ impl ProtocolAddress {
 
         debug!(
             target: "net::protocol_address::send_my_addrs",
-            "[END] channel address={}", self.channel.address(),
+            "[END] channel address={}", self.channel.display_address(),
         );
 
         Ok(())
@@ -274,7 +274,7 @@ impl ProtocolBase for ProtocolAddress {
     async fn start(self: Arc<Self>, ex: Arc<Executor<'_>>) -> Result<()> {
         debug!(
             target: "net::protocol_address::start()",
-            "START => address={}", self.channel.address(),
+            "START => address={}", self.channel.display_address(),
         );
 
         let settings = self.settings.read().await;
@@ -300,7 +300,7 @@ impl ProtocolBase for ProtocolAddress {
 
         debug!(
             target: "net::protocol_address::start()",
-            "END => address={}", self.channel.address(),
+            "END => address={}", self.channel.display_address(),
         );
 
         Ok(())

+ 1 - 1
src/net/protocol/protocol_jobs_manager.rs

@@ -76,7 +76,7 @@ impl ProtocolJobsManager {
         debug!(
             target: "net::protocol_jobs_manager",
             "ProtocolJobsManager::close_all_tasks() [START, name={}, addr={}]",
-            self.name, self.channel.address(),
+            self.name, self.channel.display_address(),
         );
 
         let tasks = std::mem::take(&mut *self.tasks.lock().await);

+ 9 - 9
src/net/protocol/protocol_ping.rs

@@ -80,7 +80,7 @@ impl ProtocolPing {
     async fn run_ping_pong(self: Arc<Self>) -> Result<()> {
         debug!(
             target: "net::protocol_ping::run_ping_pong()",
-            "START => address={}", self.channel.address(),
+            "START => address={}", self.channel.display_address(),
         );
 
         loop {
@@ -116,7 +116,7 @@ impl ProtocolPing {
                     // so close the connection.
                     warn!(
                         target: "net::protocol_ping::run_ping_pong()",
-                        "[P2P] Ping-Pong protocol timed out for {}", self.channel.address(),
+                        "[P2P] Ping-Pong protocol timed out for {}", self.channel.display_address(),
                     );
                     self.channel.stop().await;
                     return Err(Error::ChannelStopped)
@@ -127,7 +127,7 @@ impl ProtocolPing {
                 error!(
                     target: "net::protocol_ping::run_ping_pong()",
                     "[P2P] Wrong nonce in pingpong, disconnecting {}",
-                    self.channel.address(),
+                    self.channel.display_address(),
                 );
                 self.channel.stop().await;
                 return Err(Error::ChannelStopped)
@@ -136,7 +136,7 @@ impl ProtocolPing {
             debug!(
                 target: "net::protocol_ping::run_ping_pong()",
                 "Received Pong from {}: {:?}",
-                self.channel.address(),
+                self.channel.display_address(),
                 timer.elapsed(),
             );
 
@@ -150,7 +150,7 @@ impl ProtocolPing {
     async fn reply_to_ping(self: Arc<Self>) -> Result<()> {
         debug!(
             target: "net::protocol_ping::reply_to_ping()",
-            "START => address={}", self.channel.address(),
+            "START => address={}", self.channel.display_address(),
         );
 
         loop {
@@ -158,7 +158,7 @@ impl ProtocolPing {
             let ping = self.ping_sub.receive().await?;
             debug!(
                 target: "net::protocol_ping::reply_to_ping()",
-                "Received Ping from {}", self.channel.address(),
+                "Received Ping from {}", self.channel.display_address(),
             );
 
             // Send pong message
@@ -167,7 +167,7 @@ impl ProtocolPing {
 
             debug!(
                 target: "net::protocol_ping::reply_to_ping()",
-                "Sent Pong reply to {}", self.channel.address(),
+                "Sent Pong reply to {}", self.channel.display_address(),
             );
         }
     }
@@ -183,11 +183,11 @@ impl ProtocolBase for ProtocolPing {
     /// protocol task manager, then queues the reply. Sends out a ping and
     /// waits for pong reply. Waits for ping and replies with a pong.
     async fn start(self: Arc<Self>, ex: Arc<Executor<'_>>) -> Result<()> {
-        debug!(target: "net::protocol_ping::start()", "START => address={}", self.channel.address());
+        debug!(target: "net::protocol_ping::start()", "START => address={}", self.channel.display_address());
         self.jobsman.clone().start(ex.clone());
         self.jobsman.clone().spawn(self.clone().run_ping_pong(), ex.clone()).await;
         self.jobsman.clone().spawn(self.clone().reply_to_ping(), ex).await;
-        debug!(target: "net::protocol_ping::start()", "END => address={}", self.channel.address());
+        debug!(target: "net::protocol_ping::start()", "END => address={}", self.channel.display_address());
         Ok(())
     }
 

+ 5 - 5
src/net/protocol/protocol_seed.rs

@@ -59,7 +59,7 @@ impl ProtocolSeed {
     pub async fn send_my_addrs(&self) -> Result<()> {
         debug!(
             target: "net::protocol_seed::send_my_addrs",
-            "[START] channel address={}", self.channel.address(),
+            "[START] channel address={}", self.channel.display_address(),
         );
 
         let external_addrs = self.channel.hosts().external_addrs().await;
@@ -89,7 +89,7 @@ impl ProtocolSeed {
 
         debug!(
             target: "net::protocol_seed::send_my_addrs",
-            "[END] channel address={}", self.channel.address(),
+            "[END] channel address={}", self.channel.display_address(),
         );
 
         Ok(())
@@ -103,7 +103,7 @@ impl ProtocolBase for ProtocolSeed {
     /// to the seed server.  Sends a get-address message and receives an
     /// address messsage.
     async fn start(self: Arc<Self>, _ex: Arc<Executor<'_>>) -> Result<()> {
-        debug!(target: "net::protocol_seed::start()", "START => address={}", self.channel.address());
+        debug!(target: "net::protocol_seed::start()", "START => address={}", self.channel.display_address());
 
         // Send own address to the seed server
         self.send_my_addrs().await?;
@@ -125,7 +125,7 @@ impl ProtocolBase for ProtocolSeed {
         let addrs_msg = self.addr_sub.receive().await?;
         debug!(
             target: "net::protocol_seed::start()",
-            "Received {} addrs from {}", addrs_msg.addrs.len(), self.channel.address(),
+            "Received {} addrs from {}", addrs_msg.addrs.len(), self.channel.display_address(),
         );
 
         if !addrs_msg.addrs.is_empty() {
@@ -136,7 +136,7 @@ impl ProtocolBase for ProtocolSeed {
             self.hosts.insert(HostColor::Grey, &addrs_msg.addrs).await;
         }
 
-        debug!(target: "net::protocol_seed::start()", "END => address={}", self.channel.address());
+        debug!(target: "net::protocol_seed::start()", "END => address={}", self.channel.display_address());
         Ok(())
     }
 

+ 11 - 11
src/net/protocol/protocol_version.rs

@@ -65,7 +65,7 @@ impl ProtocolVersion {
     /// info and wait for version ack. Wait for version info and send
     /// version ack.
     pub async fn run(self: Arc<Self>, executor: Arc<Executor<'_>>) -> Result<()> {
-        debug!(target: "net::protocol_version::run()", "START => address={}", self.channel.address());
+        debug!(target: "net::protocol_version::run()", "START => address={}", self.channel.display_address());
         let timeout =
             Timer::after(Duration::from_secs(self.settings.read().await.channel_handshake_timeout));
         let version = self.clone().exchange_versions(executor);
@@ -79,7 +79,7 @@ impl ProtocolVersion {
         match select(version, timeout).await {
             Either::Left((Ok(_), _)) => {
                 debug!(target: "net::protocol_version::run()", "END => address={}",
-                self.channel.address());
+                self.channel.display_address());
 
                 Ok(())
             }
@@ -87,7 +87,7 @@ impl ProtocolVersion {
                 error!(
                     target: "net::protocol_version::run()",
                     "[P2P] Version Exchange failed [{}]: {e}",
-                    self.channel.address()
+                    self.channel.display_address()
                 );
 
                 self.channel.stop().await;
@@ -98,7 +98,7 @@ impl ProtocolVersion {
                 error!(
                     target: "net::protocol_version::run()",
                     "[P2P] Version Exchange timed out [{}]",
-                    self.channel.address(),
+                    self.channel.display_address(),
                 );
 
                 self.channel.stop().await;
@@ -111,7 +111,7 @@ impl ProtocolVersion {
     async fn exchange_versions(self: Arc<Self>, executor: Arc<Executor<'_>>) -> Result<()> {
         debug!(
             target: "net::protocol_version::exchange_versions()",
-            "START => address={}", self.channel.address(),
+            "START => address={}", self.channel.display_address(),
         );
 
         let send = executor.spawn(self.clone().send_version());
@@ -136,7 +136,7 @@ impl ProtocolVersion {
 
         debug!(
             target: "net::protocol_version::exchange_versions()",
-            "END => address={}", self.channel.address(),
+            "END => address={}", self.channel.display_address(),
         );
         Ok(())
     }
@@ -146,7 +146,7 @@ impl ProtocolVersion {
     async fn send_version(self: Arc<Self>) -> Result<()> {
         debug!(
             target: "net::protocol_version::send_version()",
-            "START => address={}", self.channel.address(),
+            "START => address={}", self.channel.display_address(),
         );
 
         let settings = self.settings.read().await;
@@ -187,7 +187,7 @@ impl ProtocolVersion {
             error!(
                 target: "net::protocol_version::send_version()",
                 "[P2P] Version mismatch from {}. Disconnecting...",
-                self.channel.address(),
+                self.channel.display_address(),
             );
 
             self.channel.stop().await;
@@ -197,7 +197,7 @@ impl ProtocolVersion {
         // Versions are compatible
         debug!(
             target: "net::protocol_version::send_version()",
-            "END => address={}", self.channel.address(),
+            "END => address={}", self.channel.display_address(),
         );
         Ok(())
     }
@@ -207,7 +207,7 @@ impl ProtocolVersion {
     async fn recv_version(self: Arc<Self>) -> Result<()> {
         debug!(
             target: "net::protocol_version::recv_version()",
-            "START => address={}", self.channel.address(),
+            "START => address={}", self.channel.display_address(),
         );
 
         // Receive version message
@@ -224,7 +224,7 @@ impl ProtocolVersion {
 
         debug!(
             target: "net::protocol_version::recv_version()",
-            "END => address={}", self.channel.address(),
+            "END => address={}", self.channel.display_address(),
         );
         Ok(())
     }

+ 1 - 1
src/net/session/inbound_session.rs

@@ -176,7 +176,7 @@ impl InboundSession {
     ) {
         info!(
              target: "net::inbound_session::setup_channel",
-             "[P2P] Connected Inbound #{index} [{}]", channel.address()
+             "[P2P] Connected Inbound #{index} [{}]", channel.display_address()
         );
 
         dnetev!(self, InboundConnected, {

+ 4 - 2
src/net/session/manual_session.rs

@@ -188,7 +188,8 @@ impl Slot {
                 Ok((url, channel)) => {
                     info!(
                         target: "net::manual_session",
-                        "[P2P] Manual outbound connected [{url}]"
+                        "[P2P] Manual outbound connected [{}]",
+                        channel.display_address()
                     );
 
                     let stop_sub = channel.subscribe_stop().await?;
@@ -203,7 +204,8 @@ impl Slot {
 
                             info!(
                                 target: "net::manual_session",
-                                "[P2P] Manual outbound disconnected [{url}]"
+                                "[P2P] Manual outbound disconnected [{}]",
+                                channel.display_address()
                             );
                         }
                         Err(e) => {

+ 10 - 8
src/net/session/mod.rs

@@ -68,14 +68,16 @@ pub async fn remove_sub_on_stop(
 
     debug!(
         target: "net::session::remove_sub_on_stop()",
-        "Received stop event. Removing channel {addr}"
+        "Received stop event. Removing channel {}",
+        channel.display_address()
     );
 
     // Downgrade to greylist if this is a outbound session.
     if type_id & SESSION_OUTBOUND != 0 {
         debug!(
             target: "net::session::remove_sub_on_stop()",
-            "Downgrading {addr}"
+            "Downgrading {}",
+            channel.display_address()
         );
 
         // If the host we are downgrading has been moved to blacklist,
@@ -85,12 +87,12 @@ pub async fn remove_sub_on_stop(
             Some(last_seen) => {
                 if let Err(e) = hosts.move_host(addr, last_seen, HostColor::Grey).await {
                     error!(target: "net::session::remove_sub_on_stop()",
-            "Failed to move host {} to Greylist! Err={e}", addr.clone());
+            "Failed to move host {} to Greylist! Err={e}", channel.display_address());
                 }
             }
             None => {
                 error!(target: "net::session::remove_sub_on_stop()",
-               "Failed to fetch last seen for {addr}");
+               "Failed to fetch last seen for {}", channel.display_address());
             }
         }
     }
@@ -141,7 +143,7 @@ pub trait Session: Sync {
         let protocol_version = ProtocolVersion::new(channel.clone(), p2p.settings().clone()).await;
         debug!(
             target: "net::session::register_channel()",
-            "Performing handshake protocols {}", channel.clone().address(),
+            "Performing handshake protocols {}", channel.clone().display_address(),
         );
 
         let handshake_task =
@@ -154,11 +156,11 @@ pub trait Session: Sync {
         match handshake_task.await {
             Ok(()) => {
                 debug!(target: "net::session::register_channel()",
-                "Handshake successful {}", channel.clone().address());
+                "Handshake successful {}", channel.clone().display_address());
             }
             Err(e) => {
                 debug!(target: "net::session::register_channel()",
-                "Handshake error {e} {}", channel.clone().address());
+                "Handshake error {e} {}", channel.clone().display_address());
 
                 return Err(e)
             }
@@ -198,7 +200,7 @@ pub trait Session: Sync {
                 if self.type_id() & SESSION_OUTBOUND != 0 {
                     debug!(
                         target: "net::session::perform_handshake_protocols()",
-                        "Upgrading {}", channel.address(),
+                        "Upgrading {}", channel.display_address(),
                     );
 
                     let last_seen = UNIX_EPOCH.elapsed().unwrap().as_secs();

+ 5 - 3
src/net/session/outbound_session.rs

@@ -330,12 +330,13 @@ impl Slot {
 
             info!(
                 target: "net::outbound_session::try_connect()",
-                "[P2P] Outbound slot #{slot} connected [{addr}]"
+                "[P2P] Outbound slot #{slot} connected [{}]",
+                channel.display_address()
             );
 
             dnetev!(self, OutboundSlotConnected, {
                 slot: self.slot,
-                addr: addr.clone(),
+                addr: channel.display_address().clone(),
                 channel_id: channel.info.id
             });
 
@@ -357,7 +358,8 @@ impl Slot {
 
                 warn!(
                     target: "net::outbound_session::try_connect()",
-                    "[P2P] Suspending addr=[{addr}] slot #{slot}"
+                    "[P2P] Suspending addr=[{}] slot #{slot}",
+                    channel.display_address()
                 );
 
                 // Peer disconnected during the registry process. We'll downgrade this peer now.

+ 4 - 2
src/net/session/seedsync_session.rs

@@ -216,7 +216,8 @@ impl Slot {
                 Ok((url, ch)) => {
                     info!(
                         target: "net::session::seedsync_session",
-                        "[P2P] Connected seed [{url}]",
+                        "[P2P] Connected seed [{}]",
+                        ch.display_address()
                     );
 
                     match self.session().register_channel(ch.clone(), ex.clone()).await {
@@ -225,7 +226,8 @@ impl Slot {
 
                             info!(
                                 target: "net::session::seedsync_session",
-                                "[P2P] Disconnecting from seed [{url}]"
+                                "[P2P] Disconnecting from seed [{}]",
+                                ch.display_address()
                             );
                             ch.stop().await;
 

+ 1 - 1
src/rpc/from_impl.rs

@@ -26,7 +26,7 @@ use crate::event_graph;
 impl From<net::channel::ChannelInfo> for JsonValue {
     fn from(info: net::channel::ChannelInfo) -> JsonValue {
         json_map([
-            ("addr", JsonStr(info.connect_addr.to_string())),
+            ("addr", JsonStr(info.resolve_addr.unwrap_or(info.connect_addr).to_string())),
             ("id", JsonNum(info.id.into())),
         ])
     }

+ 2 - 8
src/rpc/p2p_method.rs

@@ -37,16 +37,10 @@ pub trait HandlerP2p: Sync + Send {
                 net::session::SESSION_SEED => "seed",
                 _ => panic!("invalid result from channel.session_type_id()"),
             };
+
             // For transport mixed connections send the mixed url to aid in debugging
-            // TODO: make this a function in channel that returns the url String
-            let url = if channel.info.transport_mixed {
-                // TODO: don't blindly unwrap() here, do it like channel.address()
-                channel.resolve_addr().unwrap().to_string()
-            } else {
-                channel.address().to_string()
-            };
             channels.push(json_map([
-                ("url", JsonStr(url)),
+                ("url", JsonStr(channel.display_address().to_string())),
                 ("session", json_str(session)),
                 ("id", JsonNum(channel.info.id.into())),
             ]));