dns: unregister domains if type is disabled
This commit is contained in:
29
src/dns.js
29
src/dns.js
@@ -222,6 +222,11 @@ function makeWildcard(fqdn) {
|
||||
}
|
||||
|
||||
async function registerLocation(location, options, recordType, recordValue) {
|
||||
assert.strictEqual(typeof location, 'object');
|
||||
assert.strictEqual(typeof options, 'object');
|
||||
assert.strictEqual(typeof recordType, 'string');
|
||||
assert.strictEqual(typeof recordValue, 'string');
|
||||
|
||||
const overwriteDns = options.overwriteDns || false;
|
||||
|
||||
// get the current record before updating it
|
||||
@@ -267,13 +272,28 @@ async function registerLocations(locations, options, progressCallback) {
|
||||
await removeDnsRecords(location.subdomain, location.domain, 'CNAME', values);
|
||||
}
|
||||
|
||||
if (ipv4) await registerLocation(location, options, 'A', ipv4);
|
||||
if (ipv6) await registerLocation(location, options, 'AAAA', ipv6);
|
||||
if (ipv4) {
|
||||
await registerLocation(location, options, 'A', ipv4);
|
||||
} else {
|
||||
const [error, values] = await safe(getDnsRecords(location.subdomain, location.domain, 'A'));
|
||||
if (!error && values.length) await safe(removeDnsRecords(location.subdomain, location.domain, 'A', values), { debug });
|
||||
}
|
||||
|
||||
if (ipv6) {
|
||||
await registerLocation(location, options, 'AAAA', ipv6);
|
||||
} else {
|
||||
const [error, values] = await safe(getDnsRecords(location.subdomain, location.domain, 'AAAA'));
|
||||
if (!error && values.length) await safe(removeDnsRecords(location.subdomain, location.domain, 'AAAA', values), { debug });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function unregisterLocation(location, recordType, recordValue) {
|
||||
assert.strictEqual(typeof location, 'object');
|
||||
assert.strictEqual(typeof recordType, 'string');
|
||||
assert.strictEqual(typeof recordValue, 'string');
|
||||
|
||||
const [error] = await safe(removeDnsRecords(location.subdomain, location.domain, recordType, [ recordValue ]));
|
||||
if (!error || error.reason === BoxError.NOT_FOUND) return;
|
||||
|
||||
@@ -313,9 +333,8 @@ async function syncDnsRecords(options, progressCallback) {
|
||||
const { domain:mailDomain, fqdn:mailFqdn, subdomain:mailSubdomain } = await mailServer.getLocation();
|
||||
const dashboardLocation = await dashboard.getLocation();
|
||||
|
||||
const allApps = await apps.list();
|
||||
|
||||
let progress = 1, errors = [];
|
||||
const allApps = await apps.list(), errors = [];
|
||||
let progress = 1;
|
||||
|
||||
// we sync by domain only to get some nice progress
|
||||
for (const domain of allDomains) {
|
||||
|
||||
Reference in New Issue
Block a user