fix for XFF behind haproxy with single listener :::443 v4v6

Niko PLP 1 year ago
parent 5b1c778a25
commit 9bbff2b6ca
  1. 5
      p2p-broker/src/server_ws.rs

@ -111,9 +111,12 @@ fn check_xff_is_public_or_private(
} }
} }
Some(val) => { Some(val) => {
let ip_str = val let mut ip_str = val
.to_str() .to_str()
.map_err(|_| make_error(StatusCode::FORBIDDEN))?; .map_err(|_| make_error(StatusCode::FORBIDDEN))?;
if ip_str.starts_with("::ffff:") {
ip_str = ip_str.strip_prefix("::ffff:").unwrap();
}
let ip: IpAddr = ip_str let ip: IpAddr = ip_str
.parse() .parse()
.map_err(|_| make_error(StatusCode::FORBIDDEN))?; .map_err(|_| make_error(StatusCode::FORBIDDEN))?;

Loading…
Cancel
Save