Support for SORBS DNSBL
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 28 Mar 2005 15:19:24 +0000 (15:19 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 28 Mar 2005 15:19:24 +0000 (15:19 +0000)
includes/DefaultSettings.php
includes/User.php
languages/Language.php

index 755c091..a8e6bce 100644 (file)
@@ -1217,6 +1217,11 @@ $wgSortSpecialPages = true;
  */
 $wgDisabledActions = array();
 
+/**
+ * Use http.dnsbl.sorbs.net to check for open proxies
+ */
+$wgEnableSorbs = true;
+
 } else {
        die();
 }
index 9fb1fd0..5f0e2c2 100644 (file)
@@ -251,8 +251,8 @@ class User {
         * just slightly outta sync and soon corrected - safer to block slightly more that less.
         * And it's cheaper to check slave first, then master if needed, than master always.
         */
-       function getBlockedStatus( $bFromSlave = false ) {
-               global $wgIP, $wgBlockCache, $wgProxyList;
+       function getBlockedStatus() {
+               global $wgIP, $wgBlockCache, $wgProxyList, $wgEnableSorbs;
 
                if ( -1 != $this->mBlockedby ) { return; }
 
@@ -292,8 +292,46 @@ class User {
                                $this->mBlockreason = wfMsg( 'proxyblockreason' );
                        }
                }
+
+               # DNSBL
+               if ( !$this->mBlockedby && $wgEnableSorbs ) {
+                       if ( $this->inSorbsBlacklist( $wgIP ) ) {
+                               $this->mBlockedBy = wfMsg( 'sorbs' );
+                               $this->mBlockereason = wfMsg( 'sorbsreason' );
+                       }
+               }
+                       
        }
 
+       function inSorbsBlacklist( $ip ) {
+               $fname = 'User::inSorbsBlacklist';
+               wfProfileIn( $fname );
+               
+               $found = false;
+               $host = '';
+               
+               if ( preg_match( '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip, $m ) ) {
+                       # Make hostname
+                       for ( $i=4; $i>=1; $i-- ) {
+                               $host .= $m[$i] . '.';
+                       }
+                       $host .= 'http.dnsbl.sorbs.net.';
+
+                       # Send query
+                       $ipList = gethostbynamel( $host );
+                       
+                       if ( $ipList ) {
+                               wfDebug( "Hostname $host is {$ipList[0]}, it's a proxy!\n" );
+                               $found = true;
+                       } else {
+                               wfDebug( "Requested $host, not found.\n" );
+                       }
+               }
+
+               wfProfileOut( $fname );
+               return $found;
+       }
+       
        /**
         * Check if user is blocked
         * @return bool True if blocked, false otherwise
index 6895de8..4059730 100644 (file)
@@ -1412,6 +1412,9 @@ the list of currently operational bans and blocks.',
 'proxyblocker' => 'Proxy blocker',
 'proxyblockreason'     => 'Your IP address has been blocked because it is an open proxy. Please contact your Internet service provider or tech support and inform them of this serious security problem.',
 'proxyblocksuccess'    => "Done.\n",
+'sorbs'         => 'SORBS DNSBL',
+'sorbsreason'   => 'Your IP address is listed as an open proxy in the [http://www.sorbs.net SORBS] DNSBL.',
+
 
 # Developer tools
 #