Эх сурвалжийг харах

net/connector: Log effective transport routes

x 2 долоо хоног өмнө
parent
commit
a4cb738cbe

+ 24 - 0
src/net/connector.rs

@@ -115,6 +115,10 @@ fn sanitized_url(url: &Url) -> String {
     sanitized.to_string()
     sanitized.to_string()
 }
 }
 
 
+fn route_description(canonical: &Url, endpoint: &Url) -> String {
+    format!("peer [{}] via route [{}]", sanitized_url(canonical), sanitized_url(endpoint))
+}
+
 fn summarize_failures(failures: &DialFailures) -> String {
 fn summarize_failures(failures: &DialFailures) -> String {
     failures
     failures
         .iter()
         .iter()
@@ -185,10 +189,17 @@ impl Connector {
         let routes = build_dial_routes(endpoints, &settings);
         let routes = build_dial_routes(endpoints, &settings);
         drop(settings);
         drop(settings);
 
 
+        let canonical = url.clone();
         let result = try_dial_routes(routes, &self.stop_signal, |endpoint, timeout| {
         let result = try_dial_routes(routes, &self.stop_signal, |endpoint, timeout| {
             let datastore = datastore.clone();
             let datastore = datastore.clone();
             let i2p_socks5_proxy = i2p_socks5_proxy.clone();
             let i2p_socks5_proxy = i2p_socks5_proxy.clone();
+            let canonical = canonical.clone();
             async move {
             async move {
+                verbose!(
+                    target: "net::connector::connect",
+                    "[P2P] Connecting {}",
+                    route_description(&canonical, &endpoint),
+                );
                 let dialer = Dialer::new(endpoint, datastore, Some(i2p_socks5_proxy), true).await?;
                 let dialer = Dialer::new(endpoint, datastore, Some(i2p_socks5_proxy), true).await?;
                 dialer.dial(Some(timeout)).await
                 dialer.dial(Some(timeout)).await
             }
             }
@@ -242,6 +253,19 @@ mod tests {
         (Url::parse(url).unwrap(), true, Duration::from_secs(timeout))
         (Url::parse(url).unwrap(), true, Duration::from_secs(timeout))
     }
     }
 
 
+    #[test]
+    fn test_route_description_reports_effective_transport_without_credentials() {
+        let canonical = Url::parse("tcp+tls://irc.dark.fi:9600").unwrap();
+        let endpoint = Url::parse("tor+tls://alice:secret@irc.dark.fi:9600?token=hidden").unwrap();
+
+        let description = route_description(&canonical, &endpoint);
+
+        assert_eq!(
+            description,
+            "peer [tcp+tls://irc.dark.fi:9600/] via route [tor+tls://irc.dark.fi:9600/]"
+        );
+    }
+
     #[test]
     #[test]
     fn test_mixed_routes_skip_blacklisted_endpoint() {
     fn test_mixed_routes_skip_blacklisted_endpoint() {
         let endpoints = vec![
         let endpoints = vec![

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

@@ -386,7 +386,7 @@ impl Slot {
 
 
             verbose!(
             verbose!(
                 target: "net::outbound_session::try_connect",
                 target: "net::outbound_session::try_connect",
-                "[P2P] Connecting outbound slot #{slot} [{host}]"
+                "[P2P] Selected peer for outbound slot #{slot} [{host}]"
             );
             );
 
 
             dnetev!(self, OutboundSlotConnecting, {
             dnetev!(self, OutboundSlotConnecting, {