dweb-dns
Issue DNS lookups for Dat archives using HTTPS requests to the target host. Keeps an in-memory cache of recent lookups.
API
var datDns = // or, if you have a custom protocolvar datDns = recordName: /* name of .well-known file */ protocolRegex: /* RegExp object for custom protocol */ hashRegex: /* RegExp object for custom hash i.e. */ txtRegex: /* RegExp object for DNS TXT record of custom protocol */ // example: var cabalDns = recordName: 'cabal' hashRegex: /^[0-9a-f]{64}?$/i protocolRegex: /^cabal:\/\//i txtRegex: /^"?cabalkey="?$/i // resolve a name: pass the hostname by itselfdatDnsdatDns // dont use cached 'misses'datDns // dont use the cache at alldatDns // dont use dns-over-httpsdatDns // dont use .well-known/datdatDns // list all entries in the cachedatDns // clear the cachedatDns // configure the DNS-over-HTTPS host usedvar datDns = dnsHost: 'dns.google.com' dnsPath: '/resolve' // use a persistent fallback cache// (this is handy for persistent dns data when offline)var datDns = persistentCache: read: async { // try lookup // if failed, you can throw the original error: throw err } write: async { // write to your cache } // emits some events, mainly useful for logging/debuggingdatDnsdatDnsdatDns
Spec
Option 1 (DNS-over-HTTPS). Create a DNS TXT record witht he following schema:
datkey={key}
Option 2 (.well-known/dat). Place a file at /.well-known/dat
with the following schema:
{dat-url}
TTL={time in seconds}
TTL is optional and will default to 3600
(one hour). If set to 0
, the entry is not cached.