29 use Wikimedia\IPUtils;
86 $userObj = $this->userFactory->newFromUserIdentity( $target );
87 if ( IPUtils::isValid( $target->getName() ) ) {
92 } elseif ( $target ===
null ) {
93 return [
null, null ];
96 $target = trim( $target );
98 if ( IPUtils::isValid( $target ) ) {
102 $this->userFactory->newFromName(
103 IPUtils::sanitizeIP( $target ),
104 UserFactory::RIGOR_NONE
109 } elseif ( IPUtils::isValidRange( $target ) ) {
116 if ( strpos( $target,
'/' ) !==
false ) {
118 $target = explode(
'/', $target )[0];
121 $userObj = $this->userFactory->newFromName( $target );
122 if ( $userObj instanceof
User ) {
127 } elseif ( preg_match(
'/^#\d+$/', $target ) ) {
131 return [
null, null ];
149 if ( $target->isAnon() ) {
158 list( $ip, $range ) = explode(
'/', $target,
'2' );
160 if ( IPUtils::isIPv4( $ip ) ) {
162 } elseif ( IPUtils::isIPv6( $ip ) ) {
166 $status->fatal(
'badipaddress' );
175 $status->fatal(
'badipaddress' );
191 $blockCIDRLimit = $this->options->get(
'BlockCIDRLimit' );
193 if ( $blockCIDRLimit[
'IPv4'] == 32 ) {
195 $status->fatal(
'range_block_disabled' );
196 } elseif ( $range > 32 ) {
198 $status->fatal(
'ip_range_invalid' );
199 } elseif ( $range < $blockCIDRLimit[
'IPv4'] ) {
200 $status->fatal(
'ip_range_toolarge', $blockCIDRLimit[
'IPv4'] );
215 $blockCIDRLimit = $this->options->get(
'BlockCIDRLimit' );
217 if ( $blockCIDRLimit[
'IPv6'] == 128 ) {
219 $status->fatal(
'range_block_disabled' );
220 } elseif ( $range > 128 ) {
222 $status->fatal(
'ip_range_invalid' );
223 } elseif ( $range < $blockCIDRLimit[
'IPv6'] ) {
224 $status->fatal(
'ip_range_toolarge', $blockCIDRLimit[
'IPv6'] );