1 import { lookup } from 'dns'
2 import { parse as parseIP } from 'ipaddr.js'
4 function dnsLookupAll (hostname: string) {
5 return new Promise<string[]>((res, rej) => {
6 lookup(hostname, { family: 0, all: true }, (err, adresses) => {
7 if (err) return rej(err)
9 return res(adresses.map(a => a.address))
14 async function isResolvingToUnicastOnly (hostname: string) {
15 const addresses = await dnsLookupAll(hostname)
17 for (const address of addresses) {
18 const parsed = parseIP(address)
20 if (parsed.range() !== 'unicast') return false
28 isResolvingToUnicastOnly