- Core\CidrMatcher (IPv4/IPv6), Core\CloudflareRanges (published ranges, filterable) - ClientIp 'auto' mode, default for new installs; diagnostics show whether the connection is from Cloudflare Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
26 lines
1.1 KiB
PHP
26 lines
1.1 KiB
PHP
<?php
|
|
declare( strict_types=1 );
|
|
|
|
namespace StreamGoals\Core;
|
|
|
|
/**
|
|
* Cloudflare's published proxy address ranges (https://www.cloudflare.com/ips-v4 and /ips-v6), fetched 2026-11-15.
|
|
* They change very rarely. Sites can extend them with the `streamgoals_cloudflare_ranges` filter.
|
|
* Used ONLY to decide whether a connection really comes from Cloudflare, so a forged CF-Connecting-IP header
|
|
* from anywhere else is ignored.
|
|
*/
|
|
final class CloudflareRanges {
|
|
|
|
public const RANGES = array(
|
|
'173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18',
|
|
'190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15', '104.16.0.0/13',
|
|
'104.24.0.0/14', '172.64.0.0/13', '131.0.72.0/22',
|
|
'2400:cb00::/32', '2606:4700::/32', '2803:f800::/32', '2405:b500::/32', '2405:8100::/32', '2a06:98c0::/29', '2c0f:f248::/32',
|
|
);
|
|
|
|
/** @param string[]|null $extra additional ranges (from the filter) */
|
|
public static function isCloudflare( string $ip, ?array $extra = null ): bool {
|
|
return CidrMatcher::contains( $ip, array_merge( self::RANGES, $extra ?? array() ) );
|
|
}
|
|
}
|