From 68ba08463aa38e9b02d81ed70f3bd06eff776ba5 Mon Sep 17 00:00:00 2001 From: David Flatz Date: Mon, 27 Jun 2022 11:02:07 +0200 Subject: suppress errors of dns_get_record but retry to maybe work around temporary problems --- it.class | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index e634d44..5797e75 100644 --- a/it.class +++ b/it.class @@ -443,10 +443,13 @@ static function is_private_ip($host) else { $ips = []; - foreach (dns_get_record($host, DNS_A) as $record) - $ips[] = $record['ip']; - foreach (dns_get_record($host, DNS_AAAA) as $record) - $ips[] = $record['ipv6']; + foreach ([DNS_A, DNS_AAAA] as $type) + { + $records = false; + for ($try = 0; $try < 3 && $records === false; $try++) + foreach ((array)($records = @dns_get_record($host, $type)) as $record) + $ips[] = $record[$type == DNS_A ? 'ip' : 'ipv6']; + } } foreach ($ips as $ip) -- cgit v1.2.3