From 224f7bef5af284eb4278b1e9517b1cd111f789fb Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Tue, 5 Mar 2024 21:14:14 +0100 Subject: [PATCH] Fix get_upstream_addr to support ipv6 --- src/lib.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index cb76112..d019bde 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -286,12 +286,9 @@ fn get_upstream_addr(forward_uri: &hyper::Uri) -> Result let port = forward_uri.port_u16().ok_or(ProxyError::UpstreamError( "forward_uri has no port".to_string(), ))?; - Ok(SocketAddr::new( - host.parse().map_err(|_| { - ProxyError::UpstreamError("forward_uri host must be an IP address".to_string()) - })?, - port, - )) + format!("{host}:{port}").parse().map_err(|_| { + ProxyError::UpstreamError("forward_uri host must be an IP address".to_string()) + }) } type ResponseBody = http_body_util::combinators::UnsyncBoxBody;