jenkins-bot has submitted this change and it was merged.

Change subject: Use the ProxyLookup service if possible
......................................................................


Use the ProxyLookup service if possible

Change-Id: Ic2b585834887364cbf08e4fca3bb8e9a96630207
---
M CheckUser.hooks.php
1 file changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Aaron Schulz: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CheckUser.hooks.php b/CheckUser.hooks.php
index 9c812d4..4797c99 100755
--- a/CheckUser.hooks.php
+++ b/CheckUser.hooks.php
@@ -1,4 +1,7 @@
 <?php
+
+use MediaWiki\MediaWikiServices;
+
 class CheckUserHooks {
        /**
         * Hook function for RecentChange_save
@@ -297,6 +300,13 @@
                $ipchain = array_map( 'trim', explode( ',', $xff ) );
                $ipchain = array_reverse( $ipchain );
 
+               if ( class_exists( ProxyLookup::class ) ) { // MW 1.28+
+                       $proxyLookup = 
MediaWikiServices::getInstance()->getProxyLookup();
+               } else {
+                       // This is kind of sketch, but is good enough for 
back-compat
+                       $proxyLookup = new IP();
+               }
+
                $client = null; // best guess of the client IP
                $isSquidOnly = false; // all proxy servers where site 
Squid/Varnish servers?
                # Step through XFF list and find the last address in the list 
which is a
@@ -308,7 +318,7 @@
                        if ( $curIP === null ) {
                                break; // not a valid IP address
                        }
-                       $curIsSquid = IP::isConfiguredProxy( $curIP );
+                       $curIsSquid = $proxyLookup->isConfiguredProxy( $curIP );
                        if ( $client === null ) {
                                $client = $curIP;
                                $isSquidOnly = $curIsSquid;

-- 
To view, visit https://gerrit.wikimedia.org/r/312161
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic2b585834887364cbf08e4fca3bb8e9a96630207
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CheckUser
Gerrit-Branch: master
Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to