"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isResolvingToUnicastOnly = exports.dnsLookupAll = void 0;
const tslib_1 = require("tslib");
const dns_1 = require("dns");
const ipaddr_js_1 = require("ipaddr.js");
function dnsLookupAll(hostname) {
    return new Promise((res, rej) => {
        (0, dns_1.lookup)(hostname, { family: 0, all: true }, (err, adresses) => {
            if (err)
                return rej(err);
            return res(adresses.map(a => a.address));
        });
    });
}
exports.dnsLookupAll = dnsLookupAll;
function isResolvingToUnicastOnly(hostname) {
    return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
        const addresses = yield dnsLookupAll(hostname);
        for (const address of addresses) {
            const parsed = (0, ipaddr_js_1.parse)(address);
            if (parsed.range() !== 'unicast')
                return false;
        }
        return true;
    });
}
exports.isResolvingToUnicastOnly = isResolvingToUnicastOnly;
//# sourceMappingURL=dns.js.map