Refactors the check if a particular IP is in the list of configured squid servers...
authorArthur Richards <awjrichards@users.mediawiki.org>
Tue, 21 Feb 2012 22:00:58 +0000 (22:00 +0000)
committerArthur Richards <awjrichards@users.mediawiki.org>
Tue, 21 Feb 2012 22:00:58 +0000 (22:00 +0000)
includes/ProxyTools.php

index bdab3be..aa4ce44 100644 (file)
@@ -53,11 +53,20 @@ function wfGetIP() {
  * @return bool
  */
 function wfIsTrustedProxy( $ip ) {
-       global $wgSquidServers, $wgSquidServersNoPurge;
+       $trusted = wfIsConfiguredProxy( $ip );
+       wfRunHooks( 'IsTrustedProxy', array( &$ip, &$trusted ) );
+       return $trusted;
+}
 
+/**
+ * Checks if an IP matches a proxy we've configured.
+ * @param $ip String
+ * @return bool
+ */
+function wfIsConfiguredProxy( $ip ) {
+       global $wgSquidServers, $wgSquidServersNoPurge;
        $trusted = in_array( $ip, $wgSquidServers ) ||
                in_array( $ip, $wgSquidServersNoPurge );
-       wfRunHooks( 'IsTrustedProxy', array( &$ip, &$trusted ) );
        return $trusted;
 }