Skip to content

Commit

Permalink
do not query CNAME if A succeeded already
Browse files Browse the repository at this point in the history
  • Loading branch information
georglauterbach committed Oct 13, 2024
1 parent de30fad commit fe0e0d5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/private/Http/Client/DnsPinMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,21 @@ private function dnsResolve(string $target, int $recursionCount) : array {

$soaDnsEntry = $this->soaRecord($target);
$dnsNegativeTtl = $soaDnsEntry['minimum-ttl'] ?? null;
$canHaveCnameRecord = true;

$dnsTypes = \defined('AF_INET6') || @inet_pton('::1')
? [DNS_A, DNS_AAAA, DNS_CNAME]
: [DNS_A, DNS_CNAME];
foreach ($dnsTypes as $dnsType) {
if ($canHaveCnameRecord === false && $dnsType === DNS_CNAME) {
continue;
}

if ($this->negativeDnsCache->isNegativeCached($target, $dnsType)) {
continue;
}

$dnsResponses = $this->dnsGetRecord($target, $dnsType);
$canHaveCnameRecord = true;
if ($dnsResponses !== false && count($dnsResponses) > 0) {
foreach ($dnsResponses as $dnsResponse) {
if (isset($dnsResponse['ip'])) {
Expand Down

0 comments on commit fe0e0d5

Please sign in to comment.