summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2020-04-16 12:38:25 +0200
committerSimon Rettberg2020-05-07 12:42:09 +0200
commit4aa80be8c952b562f710637179ed45e6da8a9563 (patch)
tree9fa77e80ee1cd4f7ecf04cfead8c357eb5619f97
parent[statistics] Make sort order in client list match the location tree (diff)
downloadslx-admin-4aa80be8c952b562f710637179ed45e6da8a9563.tar.gz
slx-admin-4aa80be8c952b562f710637179ed45e6da8a9563.tar.xz
slx-admin-4aa80be8c952b562f710637179ed45e6da8a9563.zip
[inc/IpUtil] parseCidr(): Handle IP-only param just like /32
-rw-r--r--inc/iputil.inc.php11
1 files changed, 9 insertions, 2 deletions
diff --git a/inc/iputil.inc.php b/inc/iputil.inc.php
index 5cdd583c..69311d7f 100644
--- a/inc/iputil.inc.php
+++ b/inc/iputil.inc.php
@@ -50,8 +50,15 @@ class IpUtil
public static function parseCidr($cidr)
{
$parts = explode('/', $cidr);
- if (count($parts) !== 2)
- return false;
+ if (count($parts) !== 2) {
+ $ip = ip2long($cidr);
+ if ($ip === false)
+ return false;
+ if (PHP_INT_SIZE === 4) {
+ $ip = sprintf('%u', $ip);
+ }
+ return ['start' => $ip, 'end' => $ip];
+ }
$ip = $parts[0];
$bits = $parts[1];
if (!is_numeric($bits) || $bits < 0 || $bits > 32)