Skip to content

Commit 9634ca8

Browse files
feat(timeout): Add config for timeout
1 parent 31a4d9b commit 9634ca8

File tree

17 files changed

+50
-40
lines changed

17 files changed

+50
-40
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ jobs:
107107
fi
108108
109109
- name: Create Tag ${{ github.event.inputs.tag_name }}
110-
uses: actions/github-script@v3
110+
uses: actions/github-script@v6
111111
with:
112112
github-token: ${{ github.token }}
113113
script: |
114-
github.git.createRef({
114+
github.rest.git.createRef({
115115
owner: context.repo.owner,
116116
repo: context.repo.repo,
117117
ref: "refs/tags/${{ github.event.inputs.tag_name }}",

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
}
2020
},
2121
"require": {
22-
"crowdsec/bouncer": "0.34.0",
22+
"crowdsec/bouncer": "0.35.0",
2323
"symfony/polyfill-mbstring": "1.20.0",
2424
"symfony/service-contracts": "2.4.1"
2525
},

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

inc/Bounce.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getBouncerInstance(array $settings): Bouncer
5252
'api_url' => $this->escape($this->getStringSettings('crowdsec_api_url')),
5353
'use_curl' => $this->getBoolSettings('crowdsec_use_curl'),
5454
'api_user_agent' => Constants::CROWDSEC_BOUNCER_USER_AGENT,
55-
'api_timeout' => Constants::API_TIMEOUT,
55+
'api_timeout' => $this->getIntegerSettings('crowdsec_api_timeout')?:Constants::API_TIMEOUT,
5656
// Debug
5757
'debug_mode' => $this->getBoolSettings('crowdsec_debug_mode'),
5858
'disable_prod_log' => $this->getBoolSettings('crowdsec_disable_prod_log'),

inc/admin/settings.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ function adminSettings()
6767
'crowdsec_settings', 'crowdsec_admin_connection', function () {}, function () {}, '<p>If checked, calls to Local API will be done with <i>cURL</i> (be sure to have <i>cURL</i> enabled on your system before enabling).
6868
<br>If not checked, calls are done with <i>file_get_contents</i> method (<i>allow_url_fopen</i> is required for this).</p>');
6969

70+
// Field "timeout"
71+
addFieldString('crowdsec_api_timeout', 'Local Api request timeout', 'crowdsec_plugin_settings', 'crowdsec_settings',
72+
'crowdsec_admin_connection', function ($input) {
73+
if ((int) $input === 0) {
74+
add_settings_error('Local API timeout', 'crowdsec_error', 'Local API timeout: Must be different than 0.');
75+
76+
return Constants::API_TIMEOUT;
77+
}
78+
79+
return (int) $input !== 0 ? (int) $input : Constants::API_TIMEOUT ;
80+
}, ' seconds. <p>Authorized timeout for a Local API request.<br> Set a negative value to allow unlimited timeout.<br> Default to' . Constants::API_TIMEOUT .'.',
81+
Constants::API_TIMEOUT, 'width: 115px;', 'number');
82+
7083
/************************************
7184
** Section "Bouncing refinements" **
7285
***********************************/

inc/bouncer-instance.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function getDatabaseSettings(): array
3030
'api_url' => esc_attr(get_option('crowdsec_api_url')),
3131
'use_curl' => !empty(get_option('crowdsec_use_curl')),
3232
'api_user_agent' => Constants::CROWDSEC_BOUNCER_USER_AGENT,
33-
'api_timeout' => Constants::API_TIMEOUT,
33+
'api_timeout' => (int)get_option('crowdsec_api_timeout') ?:Constants::API_TIMEOUT,
3434
// Debug
3535
'debug_mode' => !empty(get_option('crowdsec_debug_mode')),
3636
'log_directory_path' => Constants::CROWDSEC_LOG_BASE_PATH,

inc/options-config.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function getCrowdSecOptionsConfig()
1212
['name' => 'crowdsec_tls_ca_cert_path', 'default' => '', 'autoInit' => true],
1313
['name' => 'crowdsec_api_key', 'default' => '', 'autoInit' => true],
1414
['name' => 'crowdsec_use_curl', 'default' => '', 'autoInit' => true],
15+
['name' => 'crowdsec_api_timeout', 'default' => Constants::API_TIMEOUT, 'autoInit' => true],
1516
['name' => 'crowdsec_bouncing_level', 'default' => Constants::BOUNCING_LEVEL_DISABLED, 'autoInit' => true],
1617
['name' => 'crowdsec_public_website_only', 'default' => 'on', 'autoInit' => true],
1718
['name' => 'crowdsec_stream_mode', 'default' => '', 'autoInit' => true],

inc/templates/settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function updateTlsDisplay () {
5858
?>
5959
</form>
6060
<h2><?php echo __("Test your settings");?></h2>
61-
<p><?php echo __("Here you can check if your saved settings are correct.");?></p>
61+
<p><?php echo __("Here you can check if your <b>saved</b> settings are correct.");?></p>
6262
<p><?php echo __("Click the 'Test bouncing' button and the bouncer will try to get the remediation for the following IP:");?></p>
6363
<form action="admin-post.php" method="post" id="crowdsec_action_test_connection">
6464
<input type="hidden" name="action" value="crowdsec_test_connection"/>

vendor/composer/installed.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,17 @@
8181
},
8282
{
8383
"name": "crowdsec/bouncer",
84-
"version": "v0.34.0",
85-
"version_normalized": "0.34.0.0",
84+
"version": "v0.35.0",
85+
"version_normalized": "0.35.0.0",
8686
"source": {
8787
"type": "git",
8888
"url": "https://github.com/crowdsecurity/php-cs-bouncer.git",
89-
"reference": "2334a9ca93cad280641659cdb5077601c75980c2"
89+
"reference": "ed00473fe3ca065062b836ffb7fa939baecafcc3"
9090
},
9191
"dist": {
9292
"type": "zip",
93-
"url": "https://api.github.com/repos/crowdsecurity/php-cs-bouncer/zipball/2334a9ca93cad280641659cdb5077601c75980c2",
94-
"reference": "2334a9ca93cad280641659cdb5077601c75980c2",
93+
"url": "https://api.github.com/repos/crowdsecurity/php-cs-bouncer/zipball/ed00473fe3ca065062b836ffb7fa939baecafcc3",
94+
"reference": "ed00473fe3ca065062b836ffb7fa939baecafcc3",
9595
"shasum": ""
9696
},
9797
"require": {
@@ -112,7 +112,7 @@
112112
"suggest": {
113113
"ext-curl": "*"
114114
},
115-
"time": "2022-11-24T04:29:36+00:00",
115+
"time": "2022-12-16T09:50:47+00:00",
116116
"type": "library",
117117
"installation-source": "dist",
118118
"autoload": {
@@ -151,7 +151,7 @@
151151
],
152152
"support": {
153153
"issues": "https://github.com/crowdsecurity/php-cs-bouncer/issues",
154-
"source": "https://github.com/crowdsecurity/php-cs-bouncer/tree/v0.34.0"
154+
"source": "https://github.com/crowdsecurity/php-cs-bouncer/tree/v0.35.0"
155155
},
156156
"install-path": "../crowdsec/bouncer"
157157
},

vendor/composer/installed.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
'name' => 'crowdsec/wordpress-bouncer',
44
'pretty_version' => 'dev-main',
55
'version' => 'dev-main',
6-
'reference' => '7145a1b0f7e850c6bf780d2073b0400e2a72d317',
6+
'reference' => '31a4d9b3cc01cae0fb981c3b405e1d69fbccbb7a',
77
'type' => 'project',
88
'install_path' => __DIR__ . '/../../',
99
'aliases' => array(),
@@ -20,9 +20,9 @@
2020
'dev_requirement' => false,
2121
),
2222
'crowdsec/bouncer' => array(
23-
'pretty_version' => 'v0.34.0',
24-
'version' => '0.34.0.0',
25-
'reference' => '2334a9ca93cad280641659cdb5077601c75980c2',
23+
'pretty_version' => 'v0.35.0',
24+
'version' => '0.35.0.0',
25+
'reference' => 'ed00473fe3ca065062b836ffb7fa939baecafcc3',
2626
'type' => 'library',
2727
'install_path' => __DIR__ . '/../crowdsec/bouncer',
2828
'aliases' => array(),
@@ -31,7 +31,7 @@
3131
'crowdsec/wordpress-bouncer' => array(
3232
'pretty_version' => 'dev-main',
3333
'version' => 'dev-main',
34-
'reference' => '7145a1b0f7e850c6bf780d2073b0400e2a72d317',
34+
'reference' => '31a4d9b3cc01cae0fb981c3b405e1d69fbccbb7a',
3535
'type' => 'project',
3636
'install_path' => __DIR__ . '/../../',
3737
'aliases' => array(),

0 commit comments

Comments
 (0)