Chunk DNS lookups as well

This commit is contained in:
Niklas Keller
2016-06-28 22:05:36 +02:00
parent e9d2a59eca
commit 74b275cf07

View File

@@ -174,17 +174,25 @@ class Issue implements Command {
}
private function checkDnsRecords($domains) {
$promises = [];
$errors = [];
foreach ($domains as $domain) {
$promises[$domain] = \Amp\Dns\resolve($domain, [
"types" => [Record::A],
"hosts" => false,
]);
$domainChunks = array_chunk($domains, 10, true);
foreach ($domainChunks as $domainChunk) {
$promises = [];
foreach ($domainChunk as $domain) {
$promises[$domain] = \Amp\Dns\resolve($domain, [
"types" => [Record::A],
"hosts" => false,
]);
}
list($chunkErrors) = (yield \Amp\any($promises));
$errors += $chunkErrors;
}
list($errors) = (yield \Amp\any($promises));
if (!empty($errors)) {
throw new AcmeException("Couldn't resolve the following domains to an IPv4 record: " . implode(", ", array_keys($errors)));
}
@@ -239,4 +247,4 @@ class Issue implements Command {
],
];
}
}
}