Skip to content

Commit

Permalink
fix: format socket addr so that it does not need to be escaped (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
rklaehn committed May 17, 2023
1 parent 252a04b commit 7c87b94
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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::<Vec<_>>()
.join(" ");
println!(
Expand Down

0 comments on commit 7c87b94

Please sign in to comment.