Skip to content

Commit a1694ac

Browse files
committed
Convert IPv6-mapped IPv4 addresses to IPv4 addresses
1 parent 16fd556 commit a1694ac

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/cli/src/app_state.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,13 @@ fn infer_client_ip(
293293
// Each intermediate proxy is supposed to add the client's IP address to front
294294
// of the list. We are effectively adding the IP we got from the socket to the
295295
// front of the list.
296-
let peer_list: Vec<IpAddr> = peer.into_iter().chain(peers_from_header).collect();
296+
// We also call `to_canonical` so that IPv6-mapped IPv4 addresses
297+
// (::ffff:A.B.C.D) are converted to IPv4.
298+
let peer_list: Vec<IpAddr> = peer
299+
.into_iter()
300+
.chain(peers_from_header)
301+
.map(|ip| ip.to_canonical())
302+
.collect();
297303

298304
// We'll fallback to the first IP in the list if all the IPs we got are trusted
299305
let fallback = peer_list.first().copied();

0 commit comments

Comments
 (0)