[Web] Expand IPv6 addresses for better comparison
This commit is contained in:
parent
ad3cd1be02
commit
a6af7cbc2e
@ -94,7 +94,7 @@ if ($_SESSION['mailcow_cc_role'] == "admin") {
|
||||
$records[] = array(
|
||||
$mailcow_hostname,
|
||||
'AAAA',
|
||||
$ip6
|
||||
expand_ipv6($ip6)
|
||||
);
|
||||
$records[] = array(
|
||||
$ptr6,
|
||||
@ -335,6 +335,11 @@ foreach ($records as $record) {
|
||||
}
|
||||
unset($current);
|
||||
}
|
||||
elseif ($record[1] == 'AAAA') {
|
||||
foreach ($currents as &$current) {
|
||||
$current['ipv6'] = expand_ipv6($current['ipv6']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($record[1] == 'CNAME' && count($currents) == 0) {
|
||||
@ -346,8 +351,8 @@ foreach ($records as $record) {
|
||||
$currents = array(array('host' => $record[0], 'class' => 'IN', 'type' => 'CNAME', 'target' => $record[2]));
|
||||
$aaaa = dns_get_record($record[0], DNS_AAAA);
|
||||
$cname = dns_get_record($record[2], DNS_AAAA);
|
||||
if (count($aaaa) == 0 || count($cname) == 0 || $aaaa[0]['ipv6'] != $cname[0]['ipv6']) {
|
||||
$currents[0]['target'] = $aaaa[0]['ipv6'] . ' <sup>1</sup>';
|
||||
if (count($aaaa) == 0 || count($cname) == 0 || expand_ipv6($aaaa[0]['ipv6']) != expand_ipv6($cname[0]['ipv6'])) {
|
||||
$currents[0]['target'] = expand_ipv6($aaaa[0]['ipv6']) . ' <sup>1</sup>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -355,6 +355,11 @@ function pem_to_der($pem_key) {
|
||||
unset($lines[0]);
|
||||
return base64_decode(implode('', $lines));
|
||||
}
|
||||
function expand_ipv6($ip) {
|
||||
$hex = unpack("H*hex", inet_pton($ip));
|
||||
$ip = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
|
||||
return $ip;
|
||||
}
|
||||
function generate_tlsa_digest($hostname, $port, $starttls = null) {
|
||||
if (!is_valid_domain_name($hostname)) {
|
||||
return "Not a valid hostname";
|
||||
|
@ -1,12 +1,6 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
|
||||
function expand_ipv6($ip) {
|
||||
$hex = unpack("H*hex", inet_pton($ip));
|
||||
$ip = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
|
||||
return $ip;
|
||||
}
|
||||
|
||||
function get_spf_allowed_hosts($check_domain)
|
||||
{
|
||||
$hosts = array();
|
||||
|
Loading…
Reference in New Issue
Block a user