Skip to content

Commit bed6ad9

Browse files
feat(*): Do not bounce admin ajax request and fix bad and clean resync value reset
1 parent ec06c90 commit bed6ad9

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77

8+
## [2.1.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.1.0) - 2023-02-16
9+
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v2.0.0...v2.1.0)
10+
11+
### Changed
12+
13+
- Do not bounce admin AJAX request
14+
15+
### Fixed
16+
- Fix bad memcached dsn check
17+
- Fix clean and bad ip resync values when disabling stream mode
18+
19+
20+
---
21+
822
## [2.0.0](https://github.com/crowdsecurity/cs-wordpress-bouncer/releases/tag/v2.0.0) - 2023-02-09
923
[_Compare with previous release_](https://github.com/crowdsecurity/cs-wordpress-bouncer/compare/v1.11.0...v2.0.0)
1024

inc/Bouncer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ public function shouldBounceCurrentIp(): bool
267267
if (PHP_SAPI === 'cli') {
268268
return false;
269269
}
270+
// Don't bounce admin ajax request
271+
if(defined('DOING_AJAX')){
272+
return false;
273+
}
270274

271275
// when the "crowdsec_public_website_only" is disabled...
272276
if ($this->shouldNotBounceWpAdmin) {

inc/admin/advanced-settings.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,24 +190,34 @@ function adminAdvancedSettings()
190190

191191
// Field "crowdsec_clean_ip_cache_duration"
192192
addFieldString('crowdsec_clean_ip_cache_duration', 'Recheck clean IPs each<br>(live mode only)', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_cache', function ($input) {
193-
if (!get_option('crowdsec_stream_mode') && (int) $input <= 0) {
194-
add_settings_error('Recheck clean IPs each', 'crowdsec_error', 'Recheck clean IPs each: Minimum is 1 second.');
193+
if(!empty($input)){
194+
if (!get_option('crowdsec_stream_mode') && (int) $input <= 0) {
195+
add_settings_error('Recheck clean IPs each', 'crowdsec_error', 'Recheck clean IPs each: Minimum is 1 second.');
195196

196-
return '1';
197+
return '1';
198+
}
199+
200+
return (int) $input > 0 ? (int) $input : 1 ;
197201
}
202+
$saved = (int) get_option('crowdsec_clean_ip_cache_duration');
203+
return $saved > 0 ? $saved : 1;
198204

199-
return (int) $input > 0 ? (int) $input : 1 ;
200205
}, ' seconds. <p>The duration between re-asking Local API about an already checked clean IP.<br>Minimum 1 second.<br> Note that this setting can not be apply in stream mode.', '...', 'width: 115px;', 'number', (bool) get_option('crowdsec_stream_mode'));
201206

202207
// Field "crowdsec_bad_ip_cache_duration"
203208
addFieldString('crowdsec_bad_ip_cache_duration', 'Recheck bad IPs each<br>(live mode only)', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_cache', function ($input) {
204-
if (!get_option('crowdsec_stream_mode') && (int) $input <= 0) {
205-
add_settings_error('Recheck bad IPs each', 'crowdsec_error', 'Recheck bad IPs each: Minimum is 1 second.');
209+
if(!empty($input)) {
210+
if (!get_option('crowdsec_stream_mode') && !empty($input) && (int)$input <= 0) {
211+
add_settings_error('Recheck bad IPs each', 'crowdsec_error', 'Recheck bad IPs each: Minimum is 1 second.');
212+
213+
return '1';
214+
}
206215

207-
return '1';
216+
return (int)$input > 0 ? (int)$input : 1;
208217
}
218+
$saved = (int) get_option('crowdsec_bad_ip_cache_duration');
219+
return $saved > 0 ? $saved : 1;
209220

210-
return (int) $input > 0 ? (int) $input : 1 ;
211221
}, ' seconds. <p>The duration between re-asking Local API about an already checked bad IP.<br>Minimum 1 second.<br> Note that this setting can not be apply in stream mode.', '...', 'width: 115px;', 'number', (bool) get_option('crowdsec_stream_mode'));
212222

213223
// Field "crowdsec_captcha_cache_duration"

0 commit comments

Comments
 (0)