{"id":13540956,"url":"https://github.com/dat-ecosystem-archive/dat-dns","last_synced_at":"2025-04-02T08:30:53.154Z","repository":{"id":42362293,"uuid":"81690503","full_name":"dat-ecosystem-archive/dat-dns","owner":"dat-ecosystem-archive","description":"Issue DNS lookups for Dat archives using HTTPS requests to the target host. [ DEPRECATED - see https://github.com/martinheidegger/hyper-dns for similar functionality. More info on active projects and modules at https://dat-ecosystem.org/ ]","archived":false,"fork":false,"pushed_at":"2023-04-18T05:08:16.000Z","size":132,"stargazers_count":57,"open_issues_count":8,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-05-16T13:14:37.251Z","etag":null,"topics":["dat","dns"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dat-ecosystem-archive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-11T23:44:05.000Z","updated_at":"2024-07-25T09:12:45.624Z","dependencies_parsed_at":"2024-07-25T09:25:06.759Z","dependency_job_id":null,"html_url":"https://github.com/dat-ecosystem-archive/dat-dns","commit_stats":null,"previous_names":["datprotocol/dat-dns"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fdat-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fdat-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fdat-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dat-ecosystem-archive%2Fdat-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dat-ecosystem-archive","download_url":"https://codeload.github.com/dat-ecosystem-archive/dat-dns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246531968,"owners_count":20792736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dat","dns"],"created_at":"2024-08-01T10:00:36.589Z","updated_at":"2025-04-02T08:30:52.703Z","avatar_url":"https://github.com/dat-ecosystem-archive.png","language":"JavaScript","funding_links":[],"categories":["Using Dat","JavaScript"],"sub_categories":["Dat Link Utilties"],"readme":"[![deprecated](http://badges.github.io/stability-badges/dist/deprecated.svg)](github.com/martinheidegger/hyper-dns) See [hyper-dns](https://github.com/martinheidegger/hyper-dns) for similar functionality. \n\nMore info on active projects and modules at [dat-ecosystem.org](https://dat-ecosystem.org/) \u003cimg src=\"https://i.imgur.com/qZWlO1y.jpg\" width=\"30\" height=\"30\" /\u003e \n\n---\n\n# dat-dns\n\nIssue DNS lookups for Dat archives using HTTPS requests to the target host. Keeps an in-memory cache of recent lookups.\n\n## API\n\n```js\nvar datDns = require('dat-dns')()\n\n// or, if you have a custom protocol\nvar datDns = require('dat-dns')({\n    recordName: /* name of .well-known file */\n    protocolRegex: /* RegExp object for custom protocol */,\n    hashRegex: /* RegExp object for custom hash i.e. */,\n    txtRegex: /* RegExp object for DNS TXT record of custom protocol */,\n})\n\n// example: \nvar cabalDns = require('dat-dns')({\n    recordName: 'cabal',\n    hashRegex: /^[0-9a-f]{64}?$/i,\n    protocolRegex: /^cabal:\\/\\/([0-9a-f]{64})/i,\n    txtRegex: /^\"?cabalkey=([0-9a-f]{64})\"?$/i\n})\n\n// resolve a name: pass the hostname by itself\ndatDns.resolveName('foo.com', function (err, key) { ... })\ndatDns.resolveName('foo.com').then(key =\u003e ...)\n\n// dont use cached 'misses'\ndatDns.resolveName('foo.com', {ignoreCachedMiss: true})\n\n// dont use the cache at all\ndatDns.resolveName('foo.com', {ignoreCache: true})\n\n// dont use dns-over-https\ndatDns.resolveName('foo.com', {noDnsOverHttps: true})\n\n// dont use .well-known/dat\ndatDns.resolveName('foo.com', {noWellknownDat: true})\n\n// list all entries in the cache\ndatDns.listCache()\n\n// clear the cache\ndatDns.flushCache()\n\n// configure the DNS-over-HTTPS host used\nvar datDns = require('dat-dns')({\n  dnsHost: 'dns.google.com',\n  dnsPath: '/resolve'\n})\n\n// use a persistent fallback cache\n// (this is handy for persistent dns data when offline)\nvar datDns = require('dat-dns')({\n  persistentCache: {\n    read: async (name, err) =\u003e {\n      // try lookup\n      // if failed, you can throw the original error:\n      throw err\n    },\n    write: async (name, key, ttl) =\u003e {\n      // write to your cache\n    }\n  }\n})\n\n// emits some events, mainly useful for logging/debugging\ndatDns.on('resolved', ({method, name, key}) =\u003e {...})\ndatDns.on('failed', ({method, name, err}) =\u003e {...})\ndatDns.on('cache-flushed', () =\u003e {...})\n```\n\n## Spec\n\n[In detail.](https://www.datprotocol.com/deps/0005-dns/)\n\n**Option 1 (DNS-over-HTTPS).** Create a DNS TXT record witht he following schema:\n\n```\ndatkey={key}\n```\n\n**Option 2 (.well-known/dat).** Place a file at `/.well-known/dat` with the following schema:\n\n```\n{dat-url}\nTTL={time in seconds}\n```\n\nTTL is optional and will default to `3600` (one hour). If set to `0`, the entry is not cached.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdat-ecosystem-archive%2Fdat-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdat-ecosystem-archive%2Fdat-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdat-ecosystem-archive%2Fdat-dns/lists"}