speedtest/backend
Matthew Kobayashi f1f48ae53e
fix: return client IPv6 address via cloudflared (#757)
* fix: return client IPv6 address via cloudflared

The cloudflared reverse proxy populates the X-Forwarded-For header for origin IPv4 addresses, however origin IPv6 addresses are added in a different header: Cf-Connecting-Ipv6. This updates the getIP.php mechanism to retrieve the value of this header and to prefer it over other client IP headers (in both cases only if the Cf-Connecting-Ipv6 header exists and is not empty).

* fix: Validate and normalise IP addresses from request headers

getClientIp() used HTTP_CF_CONNECTING_IPV6 and other headers verbatim, allowing malformed values to reach ISP lookups and the offline DB.

Add normalizeCandidateIp() helper that trims whitespace, extracts the first comma-separated token, and validates via filter_var(). Require FILTER_FLAG_IPV6 for the CF header and fall through to the next source on failure.

Written with assistance from OpenCode using Claude Opus 4.6.
2026-03-05 23:52:59 +01:00
..
country_asn.mmdb Updated ipinfo offline db 2024-09-26 06:40:24 +02:00
empty.php Fixed typo in results/index.php 2021-04-13 10:27:36 +02:00
garbage.php Revert "Use random_bytes when available (#487)" 2024-05-05 22:25:19 +08:00
geoip2.phar Release 5.4 (#645) 2024-08-04 07:06:27 +00:00
getIP.php Fix PHP version check for geoip2.phar compatibility (#754) 2026-01-31 21:45:28 +01:00
getIP_ipInfo_apikey.php Fixed typo in results/index.php 2021-04-13 10:27:36 +02:00
getIP_util.php fix: return client IPv6 address via cloudflared (#757) 2026-03-05 23:52:59 +01:00