Add tolerance for REMOTE_ADDR without a port

docs
Emi Tatsuo 2 years ago
parent fb357b59eb
commit d8d15d8f72
Signed by: Emi
GPG Key ID: 68FAB2E2E6DFC98B

@ -238,13 +238,14 @@ impl ServerInner {
.ip()
}
#[cfg(feature = "scgi_srv")] {
SocketAddr::from_str(
request.headers()
.get("REMOTE_ADDR")
.ok_or(ParseError::Malformed("REMOTE_ADDR header not received"))?
.as_str()
).context("Received malformed IP address from upstream")?
.ip()
let remote = request.headers()
.get("REMOTE_ADDR")
.ok_or(ParseError::Malformed("REMOTE_ADDR header not received"))?
.as_str();
SocketAddr::from_str(remote)
.map(|a| a.ip())
.or_else(|_| std::net::IpAddr::from_str(remote))
.context("Received malformed IP address from upstream")?
}
};

Loading…
Cancel
Save