From c40f52a21e922e6d269c09bf693a5b2ece169c3b Mon Sep 17 00:00:00 2001 From: Miraty Date: Mon, 14 Aug 2023 17:24:16 +0200 Subject: [PATCH] zone-add: Try 1 => 3 name servers --- pg-act/ns/zone-add.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pg-act/ns/zone-add.php b/pg-act/ns/zone-add.php index fb1fcb5..420c200 100644 --- a/pg-act/ns/zone-add.php +++ b/pg-act/ns/zone-add.php @@ -12,7 +12,17 @@ if ($parent_authoritatives === []) foreach ($parent_authoritatives as $parent_authoritative) checkAbsoluteDomainFormat($parent_authoritative); -$ns_records = array_column(kdig(name: $domain, type: 'NS', server: (CONF['ns']['local_only_check'] ? CONF['reg']['address'] : $parent_authoritatives[0]))['authorityRRs'], 'rdataNS'); +foreach ($parent_authoritatives as $i => $parent_authoritative) { + if ($i === 3) + output(403, sprintf(_('The %s first tried name servers failed to answer.'), $i)); + try { + $results = kdig(name: $domain, type: 'NS', server: (CONF['ns']['local_only_check'] ? CONF['reg']['address'] : $parent_authoritative)); + } catch (KdigException) { + continue; + } + break; +} +$ns_records = array_column($results['authorityRRs'] ?? [], 'rdataNS'); if (preg_match('/^(?[0-9a-f]{8})-(?[0-9a-f]{32})\._domain-verification\.' . preg_quote(SERVER_NAME, '/') . '\.$/Dm', implode(LF, $ns_records), $matches) !== 1) output(403, _('NS authentication record not found.'));