Add tolerance for REMOTE_ADDR without a port
This commit is contained in:
parent
fb357b59eb
commit
d8d15d8f72
11
src/lib.rs
11
src/lib.rs
|
@ -238,13 +238,14 @@ impl ServerInner {
|
||||||
.ip()
|
.ip()
|
||||||
}
|
}
|
||||||
#[cfg(feature = "scgi_srv")] {
|
#[cfg(feature = "scgi_srv")] {
|
||||||
SocketAddr::from_str(
|
let remote = request.headers()
|
||||||
request.headers()
|
|
||||||
.get("REMOTE_ADDR")
|
.get("REMOTE_ADDR")
|
||||||
.ok_or(ParseError::Malformed("REMOTE_ADDR header not received"))?
|
.ok_or(ParseError::Malformed("REMOTE_ADDR header not received"))?
|
||||||
.as_str()
|
.as_str();
|
||||||
).context("Received malformed IP address from upstream")?
|
SocketAddr::from_str(remote)
|
||||||
.ip()
|
.map(|a| a.ip())
|
||||||
|
.or_else(|_| std::net::IpAddr::from_str(remote))
|
||||||
|
.context("Received malformed IP address from upstream")?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue