+ protected function isValidIPRange( $value ) {
+ $cidrIPRanges = $this->mParams['iprangelimits'];
+
+ if ( !IP::isValidBlock( $value ) ) {
+ return false;
+ }
+
+ list( $ip, $range ) = explode( '/', $value, 2 );
+
+ if (
+ ( IP::isIPv4( $ip ) && $cidrIPRanges['IPv4'] == 32 ) ||
+ ( IP::isIPv6( $ip ) && $cidrIPRanges['IPv6'] == 128 )
+ ) {
+ // Range block effectively disabled
+ return $this->msg( 'ip_range_toolow' )->parse();
+ }
+
+ if (
+ ( IP::isIPv4( $ip ) && $range > 32 ) ||
+ ( IP::isIPv6( $ip ) && $range > 128 )
+ ) {
+ // Dodgy range
+ return $this->msg( 'ip_range_invalid' )->parse();
+ }
+
+ if ( IP::isIPv4( $ip ) && $range < $cidrIPRanges['IPv4'] ) {
+ return $this->msg( 'ip_range_exceeded', $cidrIPRanges['IPv4'] )->parse();
+ }
+
+ if ( IP::isIPv6( $ip ) && $range < $cidrIPRanges['IPv6'] ) {
+ return $this->msg( 'ip_range_exceeded', $cidrIPRanges['IPv6'] )->parse();
+ }
+
+ return true;
+ }
+