Skip to content

Commit a0958ac

Browse files
feat(config): Set some default values
1 parent fe04118 commit a0958ac

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

inc/Bounce.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public function getBouncerInstance(array $settings): Bouncer
5656
'forced_test_forwarded_ip' => $this->getStringSettings('crowdsec_forced_test_forwarded_ip'),
5757
'display_errors' => $this->getBoolSettings('crowdsec_display_errors'),
5858
// Bouncer
59-
'bouncing_level' => $this->getStringSettings('crowdsec_bouncing_level'),
59+
'bouncing_level' => $this->getStringSettings('crowdsec_bouncing_level')?:Constants::BOUNCING_LEVEL_DISABLED,
6060
'trust_ip_forward_array' => $this->getArraySettings('crowdsec_trust_ip_forward_array'),
6161
'fallback_remediation' => $this->getStringSettings('crowdsec_fallback_remediation'),
6262
// Cache settings
6363
'stream_mode' => $this->getBoolSettings('crowdsec_stream_mode'),
64-
'cache_system' => $this->escape($this->getStringSettings('crowdsec_cache_system')),
64+
'cache_system' => $this->escape($this->getStringSettings('crowdsec_cache_system'))?:Constants::CACHE_SYSTEM_PHPFS,
6565
'fs_cache_path' => Constants::CROWDSEC_CACHE_PATH,
6666
'redis_dsn' => $this->escape($this->getStringSettings('crowdsec_redis_dsn')),
6767
'memcached_dsn' => $this->escape($this->getStringSettings('crowdsec_memcached_dsn')),

inc/bouncer-instance.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ function getDatabaseSettings(): array
3333
'forced_test_forwarded_ip' => esc_attr(get_option('crowdsec_forced_test_forwarded_ip')),
3434
'display_errors' => !empty(get_option('crowdsec_display_errors')),
3535
// Bouncer
36-
'bouncing_level' => esc_attr(get_option('crowdsec_bouncing_level')),
36+
'bouncing_level' => esc_attr(get_option('crowdsec_bouncing_level'))?:Constants::BOUNCING_LEVEL_DISABLED,
3737
'trust_ip_forward_array' => get_option('crowdsec_trust_ip_forward_array'),
3838
'fallback_remediation' => esc_attr(get_option('crowdsec_fallback_remediation')),
3939
// Cache settings
4040
'stream_mode' => !empty(get_option('crowdsec_stream_mode')),
41-
'cache_system' => esc_attr(get_option('crowdsec_cache_system')),
41+
'cache_system' => esc_attr(get_option('crowdsec_cache_system'))?:Constants::CACHE_SYSTEM_PHPFS,
4242
'fs_cache_path' => Constants::CROWDSEC_CACHE_PATH,
4343
'redis_dsn' => esc_attr(get_option('crowdsec_redis_dsn')),
4444
'memcached_dsn' => esc_attr(get_option('crowdsec_memcached_dsn')),
@@ -53,10 +53,10 @@ function getDatabaseSettings(): array
5353
// Geolocation
5454
'geolocation' => [
5555
'enabled' => !empty(get_option('crowdsec_geolocation_enabled')),
56-
'type' => esc_attr(get_option('crowdsec_geolocation_type')),
56+
'type' => esc_attr(get_option('crowdsec_geolocation_type')) ?: Constants::GEOLOCATION_TYPE_MAXMIND,
5757
'save_result' => !empty(get_option('crowdsec_geolocation_save_result')),
5858
'maxmind' => [
59-
'database_type' => esc_attr(get_option('crowdsec_geolocation_maxmind_database_type')),
59+
'database_type' => esc_attr(get_option('crowdsec_geolocation_maxmind_database_type')) ?: Constants::MAXMIND_COUNTRY,
6060
'database_path' => Constants::CROWDSEC_BOUNCER_GEOLOCATION_DIR. '/'.ltrim(esc_attr(get_option('crowdsec_geolocation_maxmind_database_path')), '/'),
6161
]
6262
]

0 commit comments

Comments
 (0)