From a83333c4a51e44b9f3e94b85d9f7d8860a34115e Mon Sep 17 00:00:00 2001 From: Charles Melbye Date: Thu, 20 Nov 2008 23:30:08 +0000 Subject: [PATCH] Added a new configuration option ($wgUsePrivateIPs) to force MediaWiki to use forwarded Private IPs from a Proxy server --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 3 +++ includes/ProxyTools.php | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 2337e54810..d06dd2d22c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -63,6 +63,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * 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: diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 32c04fc308..154b7d67b0 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1590,6 +1590,9 @@ $wgHTCPMulticastTTL = 1; # $wgHTCPMulticastAddress = "224.0.0.85"; $wgHTCPMulticastAddress = false; +/** Should forwarded Private IPs be accepted? */ +$wgUsePrivateIPs = false; + # Cookie settings: # /** diff --git a/includes/ProxyTools.php b/includes/ProxyTools.php index 759857d683..771fd57796 100644 --- a/includes/ProxyTools.php +++ b/includes/ProxyTools.php @@ -67,7 +67,7 @@ function wfGetAgent() { * @return string */ function wfGetIP() { - global $wgIP; + global $wgIP, $wgUsePrivateIPs; # Return cached result if ( !empty( $wgIP ) ) { @@ -97,8 +97,10 @@ function wfGetIP() { 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; -- 2.20.1