Fix get_upstream_addr to support ipv6

This commit is contained in:
Brian Picciano 2024-03-05 21:14:14 +01:00
parent 1a9e3430dd
commit 224f7bef5a

View File

@ -286,12 +286,9 @@ fn get_upstream_addr(forward_uri: &hyper::Uri) -> Result<SocketAddr, ProxyError>
let port = forward_uri.port_u16().ok_or(ProxyError::UpstreamError( let port = forward_uri.port_u16().ok_or(ProxyError::UpstreamError(
"forward_uri has no port".to_string(), "forward_uri has no port".to_string(),
))?; ))?;
Ok(SocketAddr::new( format!("{host}:{port}").parse().map_err(|_| {
host.parse().map_err(|_| {
ProxyError::UpstreamError("forward_uri host must be an IP address".to_string()) ProxyError::UpstreamError("forward_uri host must be an IP address".to_string())
})?, })
port,
))
} }
type ResponseBody = http_body_util::combinators::UnsyncBoxBody<hyper::body::Bytes, std::io::Error>; type ResponseBody = http_body_util::combinators::UnsyncBoxBody<hyper::body::Bytes, std::io::Error>;