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
+30-20Lines changed: 30 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -20,24 +20,26 @@ function adminAdvancedSettings()
20
20
unscheduleBlocklistRefresh();
21
21
}, '
22
22
<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>
23
-
<p>Note: This method has one limit: for maximum 60 seconds, all the new decisions may not be taken into account.</p>'.
24
-
(get_option("crowdsec_stream_mode") ?
23
+
<p>Note: This method has one limit: for maximum 60 seconds, all the new decisions may not be taken into account.</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.');
33
+
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.');
34
+
34
35
return$input;
35
36
}
36
37
37
38
// Update wp-cron schedule.
38
-
if ((bool)get_option("crowdsec_stream_mode")) {
39
+
if ((bool)get_option('crowdsec_stream_mode')) {
39
40
scheduleBlocklistRefresh();
40
41
}
42
+
41
43
return$input;
42
44
}, ' seconds. <p>Our advice is 60 seconds (according to WP_CRON_LOCK_TIMEOUT).</p>', '...', 'width: 115px;', 'number');
43
45
@@ -46,7 +48,7 @@ function adminAdvancedSettings()
46
48
********************/
47
49
48
50
add_settings_section('crowdsec_admin_advanced_cache', 'Caching configuration <input style="margin-left: 7px;margin-top: -3px;" type="button" value="Clear now" class="button button-secondary button-small" onclick="if (confirm(\'Are you sure you want to completely clear the cache?\')) document.getElementById(\'crowdsec_ation_clear_cache\').submit();">', function () {
49
-
?>
51
+
?>
50
52
<p>Polish the decisions cache settings by selecting the best technology or the cache durations best suited to your use.</p>
51
53
<?php
52
54
}, 'crowdsec_advanced_settings');
@@ -55,27 +57,26 @@ function adminAdvancedSettings()
55
57
addFieldSelect('crowdsec_cache_system', 'Technology', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_cache', function ($input) {
56
58
if (!in_array($input, [CROWDSEC_CACHE_SYSTEM_PHPFS, CROWDSEC_CACHE_SYSTEM_REDIS, CROWDSEC_CACHE_SYSTEM_MEMCACHED])) {
$message = __('Cache system changed. Previous cache data has been cleared.');
64
66
65
67
// Update wp-cron schedule if stream mode is enabled
66
-
if ((bool)get_option("crowdsec_stream_mode")) {
68
+
if ((bool)get_option('crowdsec_stream_mode')) {
67
69
$bouncer = getBouncerInstance($input); // Reload bouncer instance with the new cache system
68
70
$result = $bouncer->warmBlocklistCacheUp();
69
-
$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.');
71
+
$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.');
}, ' seconds. <p>The duration (in seconds) between re-asking LAPI about an already checked clean IP.<br>Minimum 1 second.', '...', 'width: 115px;', 'number');
103
110
104
111
// Field "crowdsec_bad_ip_cache_duration"
105
112
addFieldString('crowdsec_bad_ip_cache_duration', 'Recheck bad IPs each', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_cache', function ($input) {
106
-
if ((int)$input <= 0) {
107
-
add_settings_error("Recheck bad IPs each", "crowdsec_error", "Recheck bad IPs each: Minimum is 1 second.");
108
-
return"1";
113
+
if ((int) $input <= 0) {
114
+
add_settings_error('Recheck bad IPs each', 'crowdsec_error', 'Recheck bad IPs each: Minimum is 1 second.');
115
+
116
+
return'1';
109
117
}
118
+
110
119
return$input;
111
120
}, ' seconds. <p>The duration (in seconds) between re-asking LAPI about an already checked bad IP.<br>Minimum 1 second.', '...', 'width: 115px;', 'number');
112
121
@@ -115,7 +124,7 @@ function adminAdvancedSettings()
115
124
**************************/
116
125
117
126
add_settings_section('crowdsec_admin_advanced_remediations', 'Remediations', function () {
118
-
echo"Configuration some details about remediations.";
127
+
echo'Configuration some details about remediations.';
119
128
}, 'crowdsec_advanced_settings');
120
129
121
130
// Field "crowdsec_fallback_remediation"
@@ -126,8 +135,9 @@ function adminAdvancedSettings()
126
135
addFieldSelect('crowdsec_fallback_remediation', 'Fallback to', 'crowdsec_plugin_advanced_settings', 'crowdsec_advanced_settings', 'crowdsec_admin_advanced_remediations', function ($input) {
127
136
if (!in_array($input, Constants::ORDERED_REMEDIATIONS)) {
128
137
$input = CROWDSEC_BOUNCING_LEVEL_DISABLED;
129
-
add_settings_error("Fallback to", "crowdsec_error", "Fallback to: Incorrect Fallback selected.");
138
+
add_settings_error('Fallback to', 'crowdsec_error', 'Fallback to: Incorrect Fallback selected.');
130
139
}
140
+
131
141
return$input;
132
142
}, '<p>Which remediation to apply when CrowdSec advises unhandled remediation.</p>', $choice);
0 commit comments