From 19423c9644c7eea2ead002b750cc566faa482e54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maurice=20Preu=C3=9F=20=28envoyr=29?= Date: Fri, 20 Jan 2023 21:26:24 +0100 Subject: [PATCH] normalize (compress) ip addresses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maurice Preuß (envoyr) --- lib/Froxlor/PhpHelper.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Froxlor/PhpHelper.php b/lib/Froxlor/PhpHelper.php index 2250df31..820f14a7 100644 --- a/lib/Froxlor/PhpHelper.php +++ b/lib/Froxlor/PhpHelper.php @@ -258,23 +258,23 @@ class PhpHelper // set the default nameservers to use, use the system default if none are provided $resolver = new Net_DNS2_Resolver($nameserver ? ['nameservers' => [$nameserver]] : []); - // get all ip addresses from the A record + // get all ip addresses from the A record and normalize them if ($try_a) { try { $answer = $resolver->query($host, 'A')->answer; foreach ($answer as $rr) { - $ips[] = $rr->address; + $ips[] = inet_ntop(inet_pton($rr->address)); } } catch (Net_DNS2_Exception $e) { // we can't do anything here, just continue } } - // get all ip addresses from the AAAA record + // get all ip addresses from the AAAA record and normalize them try { $answer = $resolver->query($host, 'AAAA')->answer; foreach ($answer as $rr) { - $ips[] = $rr->address; + $ips[] = inet_ntop(inet_pton($rr->address)); } } catch (Net_DNS2_Exception $e) { // we can't do anything here, just continue @@ -284,18 +284,18 @@ class PhpHelper // problems if the system's dns is not configured correctly; for example, the acme pre-check // will fail because some providers put a local ip in /etc/hosts - // get all ip addresses from the A record + // get all ip addresses from the A record and normalize them if ($try_a) { $answer = @dns_get_record($host, DNS_A); foreach ($answer as $rr) { - $ips[] = $rr['ip']; + $ips[] = inet_ntop(inet_pton($rr['ip'])); } } - // get all ip addresses from the AAAA record + // get all ip addresses from the AAAA record and normalize them $answer = @dns_get_record($host, DNS_AAAA); foreach ($answer as $rr) { - $ips[] = $rr['ipv6']; + $ips[] = inet_ntop(inet_pton($rr['ipv6'])); } }