Automatic Cloudflare detection for rate limiting (trusts CF-Connecting-IP only from Cloudflare ranges)
Test and Release / test (push) Successful in 1m19s
Test and Release / release (push) Failing after 5s

- 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>
This commit is contained in:
shadowdaoandClaude Sonnet 5.5 committed 2026-11-15 12:54:10 -08:00
1 parent 5ea1e1d273
commit 43106d9edc
8 files changed
+171 -6

No files matched your search

+1 -1
View File
@@ -284,7 +284,7 @@ final class DonateController {
$server[ $k ] = sanitize_text_field( wp_unslash( $_SERVER[ $k ] ) );
}
}
$ip = \StreamGoals\Core\ClientIp::resolve( $server, (string) \StreamGoals\Core\Settings::get( 'visitor_ip_header', '' ) );
$ip = \StreamGoals\Core\ClientIp::resolve( $server, (string) \StreamGoals\Core\Settings::get( 'visitor_ip_header', 'auto' ), (array) apply_filters( 'streamgoals_cloudflare_ranges', array() ) );
if ( ( new RateLimiter( new WpCache() ) )->allow( $bucket . '|' . $ip, $max, $window ) ) {
return null;
}