MediaWiki r43784 - Code Review

Jump to: navigation, search
Repository:MediaWiki
Revision:r43783‎ | r43784 (on ViewVC)‎ | r43785 >
Date:23:30, 20 November 2008
Author:charlie
Status:ok
Tags:
Comment:
Added a new configuration option ($wgUsePrivateIPs) to force MediaWiki to use forwarded Private IPs from a Proxy server
Modified paths:

Diff [purge]

Index: trunk/phase3/includes/ProxyTools.php
===================================================================
--- trunk/phase3/includes/ProxyTools.php	(revision 43783)
+++ trunk/phase3/includes/ProxyTools.php	(revision 43784)
@@ -67,7 +67,7 @@
  * @return string
  */
 function wfGetIP() {
-	global $wgIP;
+	global $wgIP, $wgUsePrivateIPs;
 
 	# Return cached result
 	if ( !empty( $wgIP ) ) {
@@ -97,8 +97,10 @@
 	foreach ( $ipchain as $i => $curIP ) {
 		$curIP = IP::canonicalize( $curIP );
 		if ( wfIsTrustedProxy( $curIP ) ) {
-			if ( isset( $ipchain[$i + 1] ) && IP::isPublic( $ipchain[$i + 1] ) ) {
-				$ip = $ipchain[$i + 1];
+			if ( isset( $ipchain[$i + 1] ) ) {
+				if( $wgUsePrivateIPs || IP::isPublic( $ipchain[$i + 1 ] ) ) {
+					$ip = $ipchain[$i + 1];
+				}
 			}
 		} else {
 			break;
Index: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php	(revision 43783)
+++ trunk/phase3/includes/DefaultSettings.php	(revision 43784)
@@ -1590,6 +1590,9 @@
 # $wgHTCPMulticastAddress = "224.0.0.85";
 $wgHTCPMulticastAddress = false;
 
+/** Should forwarded Private IPs be accepted? */
+$wgUsePrivateIPs = false;
+
 # Cookie settings:
 #
 /**
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 43783)
+++ trunk/phase3/RELEASE-NOTES	(revision 43784)
@@ -63,6 +63,8 @@
 * Image namespace and accompanying talk namespace renamed to File. For backward
   compatibility purposes, Image still works. External tools may need to be
   updated.
+* MediaWiki can be forced to use private IPs forwarded by a proxy server by
+  using $wgUsePrivateIPs.
 
 === Migrated extensions ===
 The following extensions are migrated into MediaWiki 1.14:

Status & tagging log

Personal tools
Namespaces
Variants
Views
Actions
Site
Support
Download
Development
Communication
Toolbox