network: ipv4 can be disabled
This commit is contained in:
19
src/dns.js
19
src/dns.js
@@ -127,11 +127,13 @@ async function checkDnsRecords(subdomain, domain) {
|
||||
const cnameRecords = await getDnsRecords(subdomain, domain, 'CNAME');
|
||||
if (cnameRecords.length !== 0) return { needsOverwrite: true };
|
||||
|
||||
const ipv4Records = await getDnsRecords(subdomain, domain, 'A');
|
||||
const ipv4 = await network.getIPv4();
|
||||
if (ipv4) {
|
||||
const ipv4Records = await getDnsRecords(subdomain, domain, 'A');
|
||||
|
||||
// if empty OR exactly one record with the ip, we don't need to overwrite
|
||||
if (ipv4Records.length !== 0 && (ipv4Records.length !== 1 || ipv4Records[0] !== ipv4)) return { needsOverwrite: true };
|
||||
// if empty OR exactly one record with the ip, we don't need to overwrite
|
||||
if (ipv4Records.length !== 0 && (ipv4Records.length !== 1 || ipv4Records[0] !== ipv4)) return { needsOverwrite: true };
|
||||
}
|
||||
|
||||
const ipv6 = await network.getIPv6();
|
||||
if (ipv6) {
|
||||
@@ -198,8 +200,11 @@ async function waitForLocations(locations, progressCallback) {
|
||||
const { subdomain, domain } = location;
|
||||
progressCallback({ message: `Waiting for propagation of ${fqdn(subdomain, domain)}` });
|
||||
|
||||
const [error] = await safe(waitForDnsRecord(subdomain, domain, 'A', ipv4, { times: 240 }));
|
||||
if (error) throw new BoxError(BoxError.DNS_ERROR, `DNS A Record is not synced yet: ${error.message}`, { ipv4, subdomain, domain });
|
||||
if (ipv4) {
|
||||
const [error] = await safe(waitForDnsRecord(subdomain, domain, 'A', ipv4, { times: 240 }));
|
||||
if (error) throw new BoxError(BoxError.DNS_ERROR, `DNS A Record is not synced yet: ${error.message}`, { ipv4, subdomain, domain });
|
||||
}
|
||||
|
||||
if (ipv6) {
|
||||
const [error] = await safe(waitForDnsRecord(subdomain, domain, 'AAAA', ipv6, { times: 240 }));
|
||||
if (error) throw new BoxError(BoxError.DNS_ERROR, `DNS AAAA Record is not synced yet: ${error.message}`, { ipv6, subdomain, domain });
|
||||
@@ -262,7 +267,7 @@ async function registerLocations(locations, options, progressCallback) {
|
||||
await removeDnsRecords(location.subdomain, location.domain, 'CNAME', values);
|
||||
}
|
||||
|
||||
await registerLocation(location, options, 'A', ipv4);
|
||||
if (ipv4) await registerLocation(location, options, 'A', ipv4);
|
||||
if (ipv6) await registerLocation(location, options, 'AAAA', ipv6);
|
||||
});
|
||||
}
|
||||
@@ -289,7 +294,7 @@ async function unregisterLocations(locations, progressCallback) {
|
||||
progressCallback({ message: `Unregistering location: ${location.subdomain ? (location.subdomain + '.') : ''}${location.domain}` });
|
||||
|
||||
await promiseRetry({ times: 30, interval: 5000, debug, retry: (error) => error.retryable }, async function () {
|
||||
await unregisterLocation(location, 'A', ipv4);
|
||||
if (ipv4) await unregisterLocation(location, 'A', ipv4);
|
||||
if (ipv6) await unregisterLocation(location, 'AAAA', ipv6);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user