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
+2 -4
View File
@@ -16,7 +16,6 @@ const assert = require('assert'),
dig = require('../dig.js'),
dns = require('../dns.js'),
safe = require('safetydance'),
settings = require('../settings.js'),
sysinfo = require('../sysinfo.js'),
waitForDns = require('./waitfordns.js');
@@ -87,13 +86,12 @@ async function verifyDomainConfig(domainObject) {
const ipv4 = await sysinfo.getServerIPv4();
if (ipv4Result.length !== 1 || ipv4 !== ipv4Result[0]) throw new BoxError(BoxError.EXTERNAL_ERROR, `Domain resolves to ${JSON.stringify(ipv4Result)} instead of IPv4 ${ipv4}`);
const ipv6Enabled = await settings.getIPv6Config();
if (ipv6Enabled) {
const ipv6 = await sysinfo.getServerIPv6(); // both should be RFC 5952 format
if (ipv6) {
const [ipv6Error, ipv6Result] = await safe(dig.resolve(fqdn, 'AAAA', { server: '127.0.0.1', timeout: 5000 }));
if (ipv6Error && ipv6Error.code === 'ENOTFOUND') throw new BoxError(BoxError.BAD_FIELD, `Unable to resolve IPv6 of ${fqdn}`);
if (ipv6Error || !ipv6Result) throw new BoxError(BoxError.BAD_FIELD, ipv6Error ? ipv6Error.message : `Unable to resolve IPv6 of ${fqdn}`);
const ipv6 = await sysinfo.getServerIPv6(); // both should be RFC 5952 format
if (ipv6Result.length !== 1 || ipv6 !== ipv6Result[0]) throw new BoxError(BoxError.EXTERNAL_ERROR, `Domain resolves to ${JSON.stringify(ipv6Result)} instead of IPv6 ${ipv6}`);
}