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(
"forward_uri has no port".to_string(),
))?;
Ok(SocketAddr::new(
host.parse().map_err(|_| {
format!("{host}:{port}").parse().map_err(|_| {
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>;