Browse Source

rpc/p2p_method: show the mixed url of transport mixed connections to aid in debugging in dnet and other tools

oars 1 year ago
parent
commit
e9415643fb
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/rpc/p2p_method.rs

+ 9 - 1
src/rpc/p2p_method.rs

@@ -37,8 +37,16 @@ pub trait HandlerP2p: Sync + Send {
                 net::session::SESSION_SEED => "seed",
                 net::session::SESSION_SEED => "seed",
                 _ => panic!("invalid result from channel.session_type_id()"),
                 _ => 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([
             channels.push(json_map([
-                ("url", JsonStr(channel.address().clone().into())),
+                ("url", JsonStr(url)),
                 ("session", json_str(session)),
                 ("session", json_str(session)),
                 ("id", JsonNum(channel.info.id.into())),
                 ("id", JsonNum(channel.info.id.into())),
             ]));
             ]));