[Web] Expand IPv6 addresses for better comparison

This commit is contained in:
andryyy
2020-05-26 20:04:22 +02:00
parent ad3cd1be02
commit a6af7cbc2e
3 changed files with 13 additions and 9 deletions

View File

@@ -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";