Move throttle range sizes to class constants

Change-Id: Iac436578f94022762b7f67959af894261c59fc66
This commit is contained in:
Daimona Eaytoy 2022-03-06 16:37:11 +01:00
parent dad1fff238
commit 4b6fff36e1

View file

@ -36,6 +36,9 @@ class Throttle extends Consequence implements ConsequencesDisablerConsequence {
/** @var bool|null */
private $hitThrottle;
private const IPV4_RANGE = '16';
private const IPV6_RANGE = '64';
/**
* @param Parameters $parameters
* @param array $throttleParams
@ -180,7 +183,7 @@ class Throttle extends Consequence implements ConsequencesDisablerConsequence {
$identifier = $user->getId();
break;
case 'range':
$range = IPUtils::isIPv6( $this->requestIP ) ? 64 : 16;
$range = IPUtils::isIPv6( $this->requestIP ) ? self::IPV6_RANGE : self::IPV4_RANGE;
$identifier = IPUtils::sanitizeRange( "{$this->requestIP}/$range" );
break;
case 'creationdate':