r58061 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r58060 | r58061 (on ViewVC) | r58062 >
Date:18:36, 23 October 2009
Author:ialex
Status:new
Tags:
Comment:* (bug 21172) $wgSorbsUrl can now be an array with multiple DNSBL
Modified paths:

Test cases

ParserTests

559 succeeded tests.

Diff [purge]

Index: trunk/phase3/includes/User.php
===================================================================
--- trunk/phase3/includes/User.php	(revision 58060)
+++ trunk/phase3/includes/User.php	(revision 58061)
@@ -1185,10 +1185,10 @@
 	 * Whether the given IP is in a given DNS blacklist.
 	 *
 	 * @param $ip \string IP to check
-	 * @param $base \string URL of the DNS blacklist
+	 * @param $bases \string or Array of Strings: URL of the DNS blacklist
 	 * @return \bool True if blacklisted.
 	 */
-	function inDnsBlacklist( $ip, $base ) {
+	function inDnsBlacklist( $ip, $bases ) {
 		wfProfileIn( __METHOD__ );
 
 		$found = false;
@@ -1198,17 +1198,20 @@
 			# Reverse IP, bug 21255
 			$ipReversed = implode( '.', array_reverse( explode( '.', $ip ) ) );
 
-			# Make hostname
-			$host = "$ipReversed.$base";
+			foreach( (array)$bases as $base ) {
+				# Make hostname
+				$host = "$ipReversed.$base";
 
-			# Send query
-			$ipList = gethostbynamel( $host );
+				# Send query
+				$ipList = gethostbynamel( $host );
 
-			if( $ipList ) {
-				wfDebug( "Hostname $host is {$ipList[0]}, it's a proxy says $base!\n" );
-				$found = true;
-			} else {
-				wfDebug( "Requested $host, not found in $base.\n" );
+				if( $ipList ) {
+					wfDebug( "Hostname $host is {$ipList[0]}, it's a proxy says $base!\n" );
+					$found = true;
+					break;
+				} else {
+					wfDebug( "Requested $host, not found in $base.\n" );
+				}
 			}
 		}
 
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 58060)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 58061)
@@ -3531,12 +3531,16 @@
 $wgEnableTooltipsAndAccesskeys = true;
 
 /**
- * Use http.dnsbl.sorbs.net to check for open proxies
+ * Whether to use DNS blacklists in $wgSorbsUrl to check for open proxies
  */
 $wgEnableSorbs = false;
-$wgSorbsUrl = 'http.dnsbl.sorbs.net.';
 
 /**
+ * List of DNS blacklists to use, if $wgEnableSorbs is true
+ */
+$wgSorbsUrl = array( 'http.dnsbl.sorbs.net.' );
+
+/**
  * Proxy whitelist, list of addresses that are assumed to be non-proxy despite
  * what the other methods might say.
  */
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 58060)
+++ trunk/phase3/RELEASE-NOTES	(revision 58061)
@@ -90,6 +90,7 @@
 * New hook AbortNewAccountAuto, called before account creation from AuthPlugin-
   or ExtUser-driven requests.
 * $wgCapitalLinkOverrides added to configure per-namespace capitalization
+* (bug 21172) $wgSorbsUrl can now be an array with multiple DNSBL
 
 === New features in 1.16 ===
 
Views
Toolbox