diff options
author | Simon Rettberg | 2020-04-16 12:38:25 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-04-16 12:38:25 +0200 |
commit | 689688c31efe0de037ecd4cc2233f60e9aefffc0 (patch) | |
tree | 5cea09453be7654b5c026851b634ecb448ce189b /inc/iputil.inc.php | |
parent | [rebootcontrol] wakeMachines(): Return machines that can't be reached (diff) | |
download | slx-admin-689688c31efe0de037ecd4cc2233f60e9aefffc0.tar.gz slx-admin-689688c31efe0de037ecd4cc2233f60e9aefffc0.tar.xz slx-admin-689688c31efe0de037ecd4cc2233f60e9aefffc0.zip |
[inc/IpUtil] parseCidr(): Handle IP-only param just like /32
Diffstat (limited to 'inc/iputil.inc.php')
-rw-r--r-- | inc/iputil.inc.php | 11 |
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) |