fix: refactor DNS record retrieval logic to optimize zone scanning.
This commit is contained in:
+11
-9
@@ -25,18 +25,20 @@ export async function scanDnsZones(
|
||||
if (!zone.name) continue;
|
||||
if (config.dnsZones && !config.dnsZones.includes(zone.name)) continue;
|
||||
|
||||
const zoneName = zone.name;
|
||||
|
||||
if (isAcmeTagged(zone.tags)) {
|
||||
addDomain(results, seen, zone.name, rg, false);
|
||||
addDomain(results, seen, `*.${zone.name}`, rg, true);
|
||||
addDomain(results, seen, zoneName, rg, false);
|
||||
addDomain(results, seen, `*.${zoneName}`, rg, true);
|
||||
}
|
||||
|
||||
for (const recordType of ['A', 'AAAA', 'CNAME'] as const) {
|
||||
for await (const record of client.recordSets.listByType(rg, zone.name, recordType)) {
|
||||
if (!record.name) continue;
|
||||
if (!isAcmeTagged(record.metadata)) continue;
|
||||
const fqdn = record.name === '@' ? zone.name : `${record.name}.${zone.name}`;
|
||||
addDomain(results, seen, fqdn, rg, false);
|
||||
}
|
||||
for await (const record of client.recordSets.listByDnsZone(rg, zoneName)) {
|
||||
if (!record.name) continue;
|
||||
if (!isAcmeTagged(record.metadata)) continue;
|
||||
const recordType = record.type?.split('/').pop();
|
||||
if (recordType !== 'A' && recordType !== 'AAAA' && recordType !== 'CNAME') continue;
|
||||
const fqdn = record.name === '@' ? zoneName : `${record.name}.${zoneName}`;
|
||||
addDomain(results, seen, fqdn, rg, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user