From 7c87b944da095c096880c56c6bb36be605710899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=BCdiger=20Klaehn?= Date: Wed, 17 May 2023 11:25:43 +0200 Subject: [PATCH] fix: format socket addr so that it does not need to be escaped (#1019) --- src/doctor.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/doctor.rs b/src/doctor.rs index e12258c7eb..d1bec9b0e2 100644 --- a/src/doctor.rs +++ b/src/doctor.rs @@ -550,6 +550,15 @@ async fn connect( Ok(()) } +/// format a socket addr so that it does not have to be escaped on the console +fn format_addr(addr: SocketAddr) -> String { + if addr.is_ipv6() { + format!("'{}'", addr) + } else { + format!("{}", addr) + } +} + async fn accept( private_key: SecretKey, config: TestConfig, @@ -560,7 +569,7 @@ async fn accept( let endpoints = conn.local_endpoints().await?; let remote_addrs = endpoints .iter() - .map(|endpoint| format!("--remote-endpoint {}", endpoint.addr)) + .map(|endpoint| format!("--remote-endpoint {}", format_addr(endpoint.addr))) .collect::>() .join(" "); println!(