Split rangeblock error message, allow configuring max size of IPv6 blocks as well...
authorOverlordQ <overlordq@users.mediawiki.org>
Tue, 5 Jan 2010 05:44:31 +0000 (05:44 +0000)
committerOverlordQ <overlordq@users.mediawiki.org>
Tue, 5 Jan 2010 05:44:31 +0000 (05:44 +0000)
includes/DefaultSettings.php
includes/specials/SpecialBlockip.php
languages/messages/MessagesEn.php

index 01510fb..74c8785 100644 (file)
@@ -1302,7 +1302,10 @@ $wgSysopRangeBans       = true; # Allow sysops to ban IP ranges
 $wgAutoblockExpiry      = 86400; # Number of seconds before autoblock entries expire
 $wgBlockAllowsUTEdit    = false; # Default setting for option on block form to allow self talkpage editing whilst blocked
 $wgSysopEmailBans       = true; # Allow sysops to ban users from accessing Emailuser
-$wgBlockCIDRLimit       = 16; # Blocks larger than a /16 (64k addresses) will not be allowed
+$wgBlockCIDRLimit = array(
+       'IPv4' => 16, # Blocks larger than a /16 (64k addresses) will not be allowed
+       'IPv6' => 64, # 2^64 = ~1.8x10^19 addresses
+);
 
 # Pages anonymous user may see as an array, e.g.:
 # array ( "Main Page", "Wikipedia:Help");
index dbd67ec..ceef42d 100644 (file)
@@ -383,8 +383,10 @@ class IPBlockForm {
                        if( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) {
                                # IPv4
                                if( $wgSysopRangeBans ) {
-                                       if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < $wgBlockCIDRLimit || $matches[2] > 32 ) {
+                                       if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] > 32 ) {
                                                return array( 'ip_range_invalid' );
+                                       } elseif ( $matches[2] < $wgBlockCIDRLimit['IPv4'] ) {
+                                               return array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv4'] );
                                        }
                                        $this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
                                } else {
@@ -394,8 +396,10 @@ class IPBlockForm {
                        } elseif( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) {
                                # IPv6
                                if( $wgSysopRangeBans ) {
-                                       if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) {
+                                       if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] > 128 ) {
                                                return array( 'ip_range_invalid' );
+                                       } elseif( $matches[2] < $wgBlockCIDRLimit['IPv6'] ) {
+                                               return array( 'ip_range_toolarge', $wgBlockCIDRLimit['IPv6'] );
                                        }
                                        $this->BlockAddress = Block::normaliseRange( $this->BlockAddress );
                                } else {
index 7abc68d..aabfe0b 100644 (file)
@@ -2958,6 +2958,7 @@ It may have been unblocked already.',
 'ipb_blocked_as_range'            => 'Error: The IP address $1 is not blocked directly and cannot be unblocked.
 It is, however, blocked as part of the range $2, which can be unblocked.',
 'ip_range_invalid'                => 'Invalid IP range.',
+'ip_range_toolarge'               => 'Range blocks larger than /$1 are not allowed.',
 'blockme'                         => 'Block me',
 'proxyblocker'                    => 'Proxy blocker',
 'proxyblocker-disabled'           => 'This function is disabled.',