DNS Over HTTPS

Cloudflare's DNS over HTTPS endpoint also supports JSON format for querying DNS data. For lack of an agreed upon JSON schema for DNS over HTTPS in the IETF, Cloudflare has chosen to follow the same schema as Google's DNS over HTTPS resolver. post

async function dns(domain) { let name = domain.split(/:/)[0] let site = `https://cloudflare-dns.com` let url = `${site}/dns-query?name=${name}&type=A` let headers = {accept: 'application/dns-json'} let record = await fetch(url,{headers}) .then(res => res.json()) if (record.Answer) { let addrs = record.Answer .filter(addr => addr.type == 1) .map(addr => addr.data) console.log({domain, addrs}) return addrs } else { console.log({record}) return [] } }

The 1.7 release adds a new Deno.resolveDns API. It can be used to query DNS records from a DNS resolver. At the moment only DNS over UDP/TCP is supported (no DNS over HTTPS nor DNS over TLS). One can specify a custom nameserver (for example Cloudflare's 1.1.1.1 or Google's 8.8.8.8) to use, but by default we will use the system resolver (e.g. /etc/resolv.conf on Linux). post discord