Reedy has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172558

Change subject: Add IP::isInRanges()
......................................................................

Add IP::isInRanges()

cf 
https://github.com/wikimedia/operations-mediawiki-config/blob/master/wmf-config/throttle.php#L43-L58

Change-Id: I8ae145035de9d349710971f17551da637e4d2242
---
M includes/utils/IP.php
1 file changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/58/172558/1

diff --git a/includes/utils/IP.php b/includes/utils/IP.php
index 0e2db8c..77f9cd1 100644
--- a/includes/utils/IP.php
+++ b/includes/utils/IP.php
@@ -629,6 +629,25 @@
        }
 
        /**
+        * Determines if an IP address is a list of CIDR a.b.c.d/n ranges.
+        *
+        * @since 1.25
+        *
+        * @param string $ip the IP to check
+        * @param array $ranges the IP ranges, each element a range
+        *
+        * @return bool true if the specified adress belongs to the specified 
range; otherwise, false.
+        */
+       public static function isInRanges( $ip, $ranges ) {
+               foreach ( $ranges as $range ) {
+                       if ( self::isInRange( $ip, $range ) ) {
+                               return true;
+                       }
+               }
+               return false;
+       }
+
+       /**
         * Convert some unusual representations of IPv4 addresses to their
         * canonical dotted quad representation.
         *

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ae145035de9d349710971f17551da637e4d2242
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Reedy <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to