diff --git a/src/client/connect/dns.rs b/src/client/connect/dns.rs index 0036fa2d8c..03f504291f 100644 --- a/src/client/connect/dns.rs +++ b/src/client/connect/dns.rs @@ -191,7 +191,6 @@ impl SocketAddrs { iter: vec![SocketAddr::V4(addr)].into_iter(), }); } - let host = host.trim_start_matches('[').trim_end_matches(']'); if let Ok(addr) = host.parse::() { let addr = SocketAddrV6::new(addr, port, 0, 0); return Some(SocketAddrs { diff --git a/src/client/connect/http.rs b/src/client/connect/http.rs index 50bb3309a0..8616c4a6ea 100644 --- a/src/client/connect/http.rs +++ b/src/client/connect/http.rs @@ -326,6 +326,7 @@ where let config = &self.config; let (host, port) = get_host_port(config, &dst)?; + let host = host.trim_start_matches('[').trim_end_matches(']'); // If the host is already an IP addr (v4 or v6), // skip resolving the dns and start connecting right away.