mirror of
https://github.com/nextcloud/server.git
synced 2025-02-26 01:40:18 +00:00
fix: do not query CNAME if A succeeded already
Signed-off-by: georglauterbach <44545919+georglauterbach@users.noreply.github.com>
This commit is contained in:
parent
de30fadaf5
commit
387cd8b771
2 changed files with 8 additions and 3 deletions
|
@ -57,17 +57,21 @@ class DnsPinMiddleware {
|
|||
|
||||
$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'])) {
|
||||
|
|
|
@ -537,10 +537,11 @@ class DnsPinMiddlewareTest extends TestCase {
|
|||
['nextcloud' => ['allow_local_address' => false]]
|
||||
);
|
||||
|
||||
$this->assertCount(4, $dnsQueries);
|
||||
$this->assertCount(3, $dnsQueries);
|
||||
$this->assertContains('example.com' . DNS_SOA, $dnsQueries);
|
||||
$this->assertContains('subsubdomain.subdomain.example.com' . DNS_A, $dnsQueries);
|
||||
$this->assertContains('subsubdomain.subdomain.example.com' . DNS_AAAA, $dnsQueries);
|
||||
$this->assertContains('subsubdomain.subdomain.example.com' . DNS_CNAME, $dnsQueries);
|
||||
// CNAME should not be queried if A or AAAA succeeded already
|
||||
$this->assertNotContains('subsubdomain.subdomain.example.com' . DNS_CNAME, $dnsQueries);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue