diff --git a/CHANGELOG.md b/CHANGELOG.md index 97ee6fd..8ea6afe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [0.33.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v0.33.0) - 2022-11-10 +[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v0.32.0...v0.33.0) + +### Fixed +- In stream mode, a clean IP decision (`bypass`) was not cached at all. The decision is now cached for ten years as expected. + +--- + ## [0.32.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v0.32.0) - 2022-09-29 [_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v0.31.0...v0.32.0) diff --git a/src/AbstractCache.php b/src/AbstractCache.php index 64f15d8..d30d9f0 100644 --- a/src/AbstractCache.php +++ b/src/AbstractCache.php @@ -339,17 +339,15 @@ protected function defferUpdateCacheConfig(array $config): void protected function formatRemediationFromDecision(?array $decision): array { if (!$decision) { - $duration = time() + $this->cacheExpirationForCleanIp; - if ($this->streamMode) { - /** - * In stream mode we consider a clean IP forever... until the next resync. - * in this case, forever is 10 years as PHP_INT_MAX will cause trouble with the Memcached Adapter - * (int to float unwanted conversion) - * */ - $duration = 315360000; - } - - return [Constants::REMEDIATION_BYPASS, $duration, 0]; + /** + * In stream mode we consider a clean IP forever... until the next resync. + * in this case, forever is 10 years as PHP_INT_MAX will cause trouble with the Memcached Adapter + * (int to float unwanted conversion) + * + */ + $duration = $this->streamMode ? 315360000 : $this->cacheExpirationForCleanIp; + + return [Constants::REMEDIATION_BYPASS, time() + $duration, 0]; } $duration = self::parseDurationToSeconds($decision['duration']); diff --git a/src/Constants.php b/src/Constants.php index 8f0910a..e78fda9 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -76,7 +76,7 @@ class Constants /** @var string Path for html templates folder (e.g. ban and captcha wall) */ public const TEMPLATES_DIR = __DIR__ . "/templates"; /** @var string The last version of this library */ - public const VERSION = 'v0.32.0'; + public const VERSION = 'v0.33.0'; /** @var string The "disabled" x-forwarded-for setting */ public const X_FORWARDED_DISABLED = 'no_forward'; }