fold sysinfo into network

the backends are network backends
This commit is contained in:
Girish Ramakrishnan
2023-08-03 13:38:42 +05:30
parent a4d57e7b08
commit 47d57a3971
23 changed files with 143 additions and 161 deletions
+3 -3
View File
@@ -15,8 +15,8 @@ const assert = require('assert'),
debug = require('debug')('box:dns/manual'),
dig = require('../dig.js'),
dns = require('../dns.js'),
network = require('../network.js'),
safe = require('safetydance'),
sysinfo = require('../sysinfo.js'),
waitForDns = require('./waitfordns.js');
function removePrivateFields(domainObject) {
@@ -84,10 +84,10 @@ async function verifyDomainConfig(domainObject) {
if (ipv4Error) throw new BoxError(BoxError.BAD_FIELD, `Unable to resolve IPv4 of ${fqdn}: ${ipv4Error.message}`);
if (!ipv4Result) throw new BoxError(BoxError.BAD_FIELD, `Unable to resolve IPv4 of ${fqdn}`);
const ipv4 = await sysinfo.getServerIPv4();
const ipv4 = await network.getIPv4();
if (ipv4Result.length !== 1 || ipv4 !== ipv4Result[0]) throw new BoxError(BoxError.EXTERNAL_ERROR, `Domain resolves to ${JSON.stringify(ipv4Result)} instead of IPv4 ${ipv4}`);
const ipv6 = await sysinfo.getServerIPv6(); // both should be RFC 5952 format
const ipv6 = await network.getIPv6(); // 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' || ipv6Error.code === 'ENODATA')) throw new BoxError(BoxError.BAD_FIELD, `Unable to resolve IPv6 of ${fqdn}`);