Skip to content

Commit a9371d3

Browse files
feat(*): Move forced_test_ip from configurations to settings
1 parent f21026f commit a9371d3

File tree

4 files changed

+5
-8
lines changed

4 files changed

+5
-8
lines changed

src/AbstractBounce.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ protected function initLoggerHelper($logDirectoryPath, $loggerName): void
110110
protected function bounceCurrentIp()
111111
{
112112
$ip = $this->getRemoteIp();
113-
114113
// X-Forwarded-For override
115114
$XForwardedForHeader = $this->getHttpRequestHeader('X-Forwarded-For');
116115
if (null !== $XForwardedForHeader) {
@@ -129,8 +128,9 @@ protected function bounceCurrentIp()
129128

130129
try {
131130
$this->getBouncerInstance();
132-
$remediation = $this->bouncer->getRemediationForIp($ip);
133-
$this->handleRemediation($remediation, $ip);
131+
$ipToCheck = !empty($this->settings['forced_test_ip']) ? $this->settings['forced_test_ip'] : $ip;
132+
$remediation = $this->bouncer->getRemediationForIp($ipToCheck);
133+
$this->handleRemediation($remediation, $ipToCheck);
134134
} catch (Exception $e) {
135135
$this->logger->warning('', [
136136
'type' => 'UNKNOWN_EXCEPTION_WHILE_BOUNCING',

src/Bouncer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ private function capRemediationLevel(string $remediation): string
115115
*/
116116
public function getRemediationForIp(string $ip): string
117117
{
118-
$ipToCheck = !empty($this->config['forced_test_ip']) ? $this->config['forced_test_ip'] : $ip;
119-
$address = Factory::parseAddressString($ipToCheck, ParseStringFlag::MAY_INCLUDE_ZONEID);
118+
$address = Factory::parseAddressString($ip, ParseStringFlag::MAY_INCLUDE_ZONEID);
120119
if (null === $address) {
121-
throw new BouncerException("IP $ipToCheck format is invalid.");
120+
throw new BouncerException("IP $ip format is invalid.");
122121
}
123122
$remediation = $this->apiCache->get($address);
124123

src/Configuration.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function getConfigTreeBuilder(): TreeBuilder
3333
->scalarNode('api_user_agent')->defaultValue(Constants::BASE_USER_AGENT)->end()
3434
->integerNode('api_timeout')->defaultValue(Constants::API_TIMEOUT)->end()
3535
->booleanNode('stream_mode')->defaultValue(false)->end()
36-
->scalarNode('forced_test_ip')->defaultValue('')->end()
3736
->enumNode('max_remediation_level')
3837
->values(Constants::ORDERED_REMEDIATIONS)
3938
->defaultValue(Constants::REMEDIATION_BAN)

src/StandAloneBounce.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ public function getBouncerInstance(): Bouncer
153153
'cache_expiration_for_clean_ip' => $cleanIpCacheDuration,
154154
'cache_expiration_for_bad_ip' => $badIpCacheDuration,
155155
'geolocation' => $geolocation,
156-
'forced_test_ip' => $forcedTestIp,
157156
]);
158157

159158
return $this->bouncer;

0 commit comments

Comments
 (0)