From 9bbff2b6ca14040f7d039058fa9013ac19d98509 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Sun, 25 Jun 2023 13:50:33 +0300 Subject: [PATCH] fix for XFF behind haproxy with single listener :::443 v4v6 --- p2p-broker/src/server_ws.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/p2p-broker/src/server_ws.rs b/p2p-broker/src/server_ws.rs index fa5bffd..9773d4b 100644 --- a/p2p-broker/src/server_ws.rs +++ b/p2p-broker/src/server_ws.rs @@ -111,9 +111,12 @@ fn check_xff_is_public_or_private( } } Some(val) => { - let ip_str = val + let mut ip_str = val .to_str() .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 .parse() .map_err(|_| make_error(StatusCode::FORBIDDEN))?;