normalize ipv6 addresses to avoid possible comparison problems; fixes #965

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2021-07-26 17:53:44 +02:00
parent ed42d4e3df
commit c7b7c67ff4
7 changed files with 40 additions and 7 deletions

View File

@@ -247,6 +247,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$docroot = '';
}
// always use compressed ipv6 format
$ip = inet_ntop(inet_pton($ip));
$result_checkfordouble_stmt = Database::prepare("
SELECT `id` FROM `" . TABLE_PANEL_IPSANDPORTS . "`
WHERE `ip` = :ip AND `port` = :port");
@@ -462,6 +465,9 @@ class IpsAndPorts extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\Resour
$docroot = '';
}
// always use compressed ipv6 format
$ip = inet_ntop(inet_pton($ip));
if ($result['ip'] != $ip && $result['ip'] == Settings::Get('system.ipaddress') && $result_sameipotherport == false) {
\Froxlor\UI\Response::standard_error('cantchangesystemip', '', true);
} elseif ($result_checkfordouble && $result_checkfordouble['id'] != '' && $result_checkfordouble['id'] != $id) {

View File

@@ -10,7 +10,7 @@ final class Froxlor
const VERSION = '0.10.27';
// Database version (YYYYMMDDC where C is a daily counter)
const DBVERSION = '202107210';
const DBVERSION = '202107260';
// Distribution branding-tag (used for Debian etc.)
const BRANDING = '';

View File

@@ -241,10 +241,14 @@ class PhpHelper
$ips = array();
foreach ($dns as $record) {
if ($record["type"] == "A") {
$ips[] = $record["ip"];
// always use compressed ipv6 format
$ip = inet_ntop(inet_pton($record["ip"]));
$ips[] = $ip;
}
if ($record["type"] == "AAAA") {
$ips[] = $record["ipv6"];
// always use compressed ipv6 format
$ip = inet_ntop(inet_pton($record["ipv6"]));
$ips[] = $ip;
}
}
if (count($ips) < 1) {