diff --git a/CHANGELOG.md b/CHANGELOG.md index 0035f8e..c531bcf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,14 @@ The public API of this library consists of all public or protected methods, prop --- +## [1.1.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v1.1.0) - 2023-02-16 +[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v1.0.1...v1.1.0) + +### Changed +- Add more log messages during bouncing process + +--- + ## [1.0.1](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v1.0.1) - 2023-02-10 [_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v1.0.0...v1.0.1) diff --git a/src/AbstractBouncer.php b/src/AbstractBouncer.php index 2b3a28a..9c994a5 100644 --- a/src/AbstractBouncer.php +++ b/src/AbstractBouncer.php @@ -84,6 +84,9 @@ public function bounceCurrentIp(): void $forcedTestIp = $this->getConfig('forced_test_ip'); $ip = $forcedTestIp ?: $this->getRemoteIp(); $ip = $this->handleForwardedFor($ip, $this->configs); + $this->logger->info('Bouncing current IP', [ + 'ip' => $ip, + ]); $remediation = $this->getRemediationForIp($ip); $this->handleRemediation($remediation, $ip); } @@ -356,9 +359,15 @@ protected function handleRemediation(string $remediation, string $ip): void { switch ($remediation) { case Constants::REMEDIATION_CAPTCHA: + $this->logger->debug('Will display a captcha wall', [ + 'ip' => $ip, + ]); $this->handleCaptchaRemediation($ip); break; case Constants::REMEDIATION_BAN: + $this->logger->debug('Will display a ban wall', [ + 'ip' => $ip, + ]); $this->handleBanRemediation(); break; case Constants::REMEDIATION_BYPASS: @@ -454,11 +463,19 @@ private function capRemediationLevel(string $remediation): string $maxRemediationLevel, $orderedRemediations ); + $finalRemediation = $remediation; if ($currentIndex < $maxIndex) { - return $orderedRemediations[$maxIndex]; + $finalRemediation = $orderedRemediations[$maxIndex]; + $this->logger->debug('Original remediation has been capped', [ + 'origin' => $remediation, + 'final' => $finalRemediation + ]); } + $this->logger->info('Final remediation', [ + 'remediation' => $finalRemediation, + ]); - return $remediation; + return $finalRemediation; } /** @@ -614,6 +631,9 @@ private function handleCaptchaRemediation(string $ip): void if (null === $cachedCaptchaVariables['has_to_be_resolved']) { // Set up the first captcha remediation. $mustResolve = true; + $this->logger->debug('First captcha resolution', [ + 'ip' => $ip, + ]); $this->initCaptchaResolution($ip); } diff --git a/src/Constants.php b/src/Constants.php index c537ed2..3f23a9d 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -39,7 +39,7 @@ class Constants extends RemConstants /** @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 = 'v1.0.1'; + public const VERSION = 'v1.1.0'; /** @var string The "disabled" x-forwarded-for setting */ public const X_FORWARDED_DISABLED = 'no_forward'; }