@@ -294,7 +294,7 @@ private function saveRemediations(array $decisions): array
294
294
295
295
if ('Ip ' === $ decision ['scope ' ]) {
296
296
$ address = Factory::addressFromString ($ decision ['value ' ]);
297
- $ this ->addRemediationToCacheItem (Bouncer:: formatIpAsCacheKey ( $ address ), $ type , $ exp , $ id );
297
+ $ this ->addRemediationToCacheItem ($ address-> toString ( ), $ type , $ exp , $ id );
298
298
} elseif ('Range ' === $ decision ['scope ' ]) {
299
299
$ range = Subnet::fromString ($ decision ['value ' ]);
300
300
@@ -310,11 +310,11 @@ private function saveRemediations(array $decisions): array
310
310
311
311
$ comparableEndAddress = $ range ->getComparableEndString ();
312
312
$ address = $ range ->getStartAddress ();
313
- $ this ->addRemediationToCacheItem (Bouncer:: formatIpAsCacheKey ( $ address ), $ type , $ exp , $ id );
313
+ $ this ->addRemediationToCacheItem ($ address-> toString ( ), $ type , $ exp , $ id );
314
314
$ ipCount = 1 ;
315
315
do {
316
316
$ address = $ address ->getNextAddress ();
317
- $ this ->addRemediationToCacheItem (Bouncer:: formatIpAsCacheKey ( $ address ), $ type , $ exp , $ id );
317
+ $ this ->addRemediationToCacheItem ($ address-> toString ( ), $ type , $ exp , $ id );
318
318
++$ ipCount ;
319
319
if ($ ipCount >= 1000 ) {
320
320
throw new BouncerException ("Unable to store the decision $ {$ decision ['id ' ]}, the IP range: $ {$ decision ['value ' ]} is too large and can cause storage problem. Decision ignored. " );
@@ -333,7 +333,7 @@ private function removeRemediations(array $decisions): array
333
333
foreach ($ decisions as $ decision ) {
334
334
if ('Ip ' === $ decision ['scope ' ]) {
335
335
$ address = Factory::addressFromString ($ decision ['value ' ]);
336
- if (!$ this ->removeDecisionFromRemediationItem (Bouncer:: formatIpAsCacheKey ( $ address ), $ decision ['id ' ])) {
336
+ if (!$ this ->removeDecisionFromRemediationItem ($ address-> toString ( ), $ decision ['id ' ])) {
337
337
$ this ->logger ->debug ('' , ['type ' => 'DECISION_TO_REMOVE_NOT_FOUND_IN_CACHE ' , 'decision ' => $ decision ['id ' ]]);
338
338
} else {
339
339
$ this ->logger ->debug ('' , [
@@ -356,14 +356,14 @@ private function removeRemediations(array $decisions): array
356
356
357
357
$ comparableEndAddress = $ range ->getComparableEndString ();
358
358
$ address = $ range ->getStartAddress ();
359
- if (!$ this ->removeDecisionFromRemediationItem (Bouncer:: formatIpAsCacheKey ( $ address ), $ decision ['id ' ])) {
359
+ if (!$ this ->removeDecisionFromRemediationItem ($ address-> toString ( ), $ decision ['id ' ])) {
360
360
$ this ->logger ->debug ('' , ['type ' => 'DECISION_TO_REMOVE_NOT_FOUND_IN_CACHE ' , 'decision ' => $ decision ['id ' ]]);
361
361
}
362
362
$ ipCount = 1 ;
363
363
$ success = true ;
364
364
do {
365
365
$ address = $ address ->getNextAddress ();
366
- if (!$ this ->removeDecisionFromRemediationItem (Bouncer:: formatIpAsCacheKey ( $ address ), $ decision ['id ' ])) {
366
+ if (!$ this ->removeDecisionFromRemediationItem ($ address-> toString ( ), $ decision ['id ' ])) {
367
367
$ success = false ;
368
368
}
369
369
++$ ipCount ;
@@ -532,7 +532,7 @@ private function hit(string $ip): string
532
532
*/
533
533
public function get (AddressInterface $ address ): string
534
534
{
535
- $ cacheKey = Bouncer:: formatIpAsCacheKey ( $ address );
535
+ $ cacheKey = $ address-> toString ( );
536
536
$ this ->logger ->debug ('' , ['type ' => 'START_IP_CHECK ' , 'ip ' => $ cacheKey ]);
537
537
if (!$ this ->liveMode && !$ this ->warmedUp ) {
538
538
throw new BouncerException ('CrowdSec Bouncer configured in "stream" mode. Please warm the cache up before trying to access it. ' );
0 commit comments