make ipv4 and ipv6 settings separate

This commit is contained in:
Girish Ramakrishnan
2022-02-15 12:31:55 -08:00
parent 0dbe8ee8f2
commit c6da8c8167
14 changed files with 102 additions and 68 deletions

View File

@@ -128,10 +128,9 @@ async function checkDnsRecords(subdomain, domain) {
// 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 ipv6Enabled = await settings.getIPv6Config();
if (ipv6Enabled) {
const ipv6 = await sysinfo.getServerIPv6();
if (ipv6) {
const ipv6Records = await getDnsRecords(subdomain, domain, 'AAAA');
const ipv6 = await sysinfo.getServerIPv6();
// if empty OR exactly one record with the ip, we don't need to overwrite
if (ipv6Records.length !== 0 && (ipv6Records.length !== 1 || ipaddr.parse(ipv6Records[0]).toRFC5952String() !== ipv6)) return { needsOverwrite: true };
@@ -222,15 +221,14 @@ async function registerLocations(locations, options, progressCallback) {
debug(`registerLocations: Will register ${JSON.stringify(locations)} with options ${JSON.stringify(options)}`);
const ipv4 = await sysinfo.getServerIPv4();
const ipv6Enabled = await settings.getIPv6Config();
const ipv6 = ipv6Enabled ? await sysinfo.getServerIPv6() : null;
const ipv6 = await sysinfo.getServerIPv6();
for (const location of locations) {
progressCallback({ message: `Registering location: ${location.subdomain ? (location.subdomain + '.') : ''}${location.domain}` });
await promiseRetry({ times: 200, interval: 5000, debug, retry: (error) => error.retryable }, async function () {
await registerLocation(location, options, 'A', ipv4);
if (ipv6Enabled) await registerLocation(location, options, 'AAAA', ipv6);
if (ipv6) await registerLocation(location, options, 'AAAA', ipv6);
});
}
}
@@ -250,15 +248,14 @@ async function unregisterLocations(locations, progressCallback) {
assert.strictEqual(typeof progressCallback, 'function');
const ipv4 = await sysinfo.getServerIPv4();
const ipv6Enabled = await settings.getIPv6Config();
const ipv6 = ipv6Enabled ? await sysinfo.getServerIPv6() : null;
const ipv6 = await sysinfo.getServerIPv6();
for (const location of locations) {
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 (ipv6Enabled) await unregisterLocation(location, 'AAAA', ipv6);
if (ipv6) await unregisterLocation(location, 'AAAA', ipv6);
});
}
}