You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: inc/admin/advanced-settings.php
+24-16Lines changed: 24 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -15,34 +15,47 @@ function adminAdvancedSettings()
15
15
// Field "crowdsec_stream_mode"
16
16
addFieldCheckbox('crowdsec_stream_mode', 'Enable the "Stream" mode', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_stream_mode', function () {
17
17
// Stream mode just activated.
18
+
$bouncer = getBouncerInstance();
19
+
$result = $bouncer->warmBlocklistCacheUp();
20
+
$message = __('As the stream mode is enabled, the cache has just been warmed up, '.($result > 0 ? 'there are now '.$result.' decisions' : 'there is now '.$result.' decision').' in cache.');
21
+
AdminNotice::displaySuccess($message);
18
22
scheduleBlocklistRefresh();
19
23
}, function () {
20
24
// Stream mode just deactivated.
21
25
unscheduleBlocklistRefresh();
22
26
}, '
23
27
<p>With the stream mode, every decision is retrieved in an asynchronous way. 3 advantages: <br> 1) Inivisible latency when loading pages<br> 2) The IP verifications works even if your CrowdSec is not reachable.<br> 3) The API can never be overloaded by the WordPress traffic</p>
24
-
<p>Note: This method has one limit: for maximum 60 seconds, all the new decisions may not be taken into account.</p>'.
28
+
<p>Note: This method has one limit: all the decisions updates since the previous resync will not be taken in account until the next resync.</p>'.
add_settings_error('Resync decisions each', 'crowdsec_error', 'The "Resync decisions each" value should be more than 60sec (WP_CRON_LOCK_TIMEOUT). We just reset the frequency to 60 seconds.');
36
+
if ($input < 1) {
37
+
$input = 1;
38
+
add_settings_error('Resync decisions each', 'crowdsec_error', 'The "Resync decisions each" value should be more than 1sec (WP_CRON_LOCK_TIMEOUT). We just reset the frequency to 1 seconds.');
35
39
36
40
return$input;
37
41
}
38
42
39
43
// Update wp-cron schedule.
40
44
if ((bool) get_option('crowdsec_stream_mode')) {
45
+
$bouncer = getBouncerInstance();
46
+
$result = $bouncer->warmBlocklistCacheUp();
47
+
$message = __('As the stream mode refresh duration changed, the cache has just been warmed up, '.($result > 0 ? 'there are now '.$result.' decisions' : 'there is now '.$result.' decision').' in cache.');
48
+
AdminNotice::displaySuccess($message);
41
49
scheduleBlocklistRefresh();
42
50
}
43
51
44
52
return$input;
45
-
}, ' seconds. <p>Our advice is 60 seconds (according to WP_CRON_LOCK_TIMEOUT).</p>', '...', 'width: 115px;', 'number');
53
+
}, ' seconds. <p>Our advice is 60 seconds (as WordPress ignores durations under this value <a href="https://wordpress.stackexchange.com/questions/100104/better-handling-of-wp-cron-server-load-abuse" target="_blank">see WP_CRON_LOCK_TIMEOUT</a>).<br>'.
54
+
' If you need a shorter delay between each resync, you can <strong>go down to 1 sec</strong>.<br>'.
55
+
' But as mentionned is the WordPress Developer Documentation, you should considere hooking WP-Cron Into the System Task Scheduler'.
56
+
' by yourself and reduce the WP_CRON_LOCK_TIMEOUT value to the same value as you set here. '.
}, ' seconds. <p>The duration (in seconds) between re-asking LAPI about an already checked clean IP.<br>Minimum 1 second.', '...', 'width: 115px;', 'number');
160
+
}, ' seconds. <p>The duration between re-asking LAPI 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'));
148
161
149
162
// Field "crowdsec_bad_ip_cache_duration"
150
-
addFieldString('crowdsec_bad_ip_cache_duration', 'Recheck bad IPs each', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_cache', function ($input) {
163
+
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) {
151
164
if ((int) $input <= 0) {
152
165
add_settings_error('Recheck bad IPs each', 'crowdsec_error', 'Recheck bad IPs each: Minimum is 1 second.');
153
166
154
167
return'1';
155
168
}
156
169
157
170
return$input;
158
-
}, ' seconds. <p>The duration (in seconds) between re-asking LAPI about an already checked bad IP.<br>Minimum 1 second.', '...', 'width: 115px;', 'number');
171
+
}, ' seconds. <p>The duration between re-asking LAPI 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'));
159
172
160
173
/***************************
161
174
** Section "Remediation" **
@@ -215,6 +228,7 @@ function convertInlineIpRangesToLongArray(string $inlineIpRanges): array
Copy file name to clipboardExpand all lines: inc/admin/settings.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -62,5 +62,5 @@ function adminSettings()
62
62
}, function () {
63
63
// Stream mode just deactivated.
64
64
unscheduleBlocklistRefresh();
65
-
}, '<p>If enabled, this wp-admin is not bounced, only the public website.</p>');
65
+
}, '<p>If enabled, the wp-admin is not bounced, only the public website</p><p><strong>Important note:</strong> the login page is a common page to both sections. If you want to bounce it, you have to disable "Public website only".</p>');
0 commit comments