{"id":24143308,"url":"https://github.com/little-core-labs/dns-over-http","last_synced_at":"2025-09-19T11:32:03.025Z","repository":{"id":57213688,"uuid":"129145788","full_name":"little-core-labs/dns-over-http","owner":"little-core-labs","description":"HTTP(s) middleware and client for DNS over HTTPS (DoH)","archived":false,"fork":false,"pushed_at":"2019-03-22T18:55:22.000Z","size":11,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-31T17:39:16.450Z","etag":null,"topics":["dns","dns-over-https","dns-server","doh"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/little-core-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-11T19:47:28.000Z","updated_at":"2020-09-19T00:27:12.000Z","dependencies_parsed_at":"2022-08-24T21:01:43.376Z","dependency_job_id":null,"html_url":"https://github.com/little-core-labs/dns-over-http","commit_stats":null,"previous_names":["jwerle/dns-over-http"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/little-core-labs/dns-over-http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fdns-over-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fdns-over-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fdns-over-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fdns-over-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/little-core-labs","download_url":"https://codeload.github.com/little-core-labs/dns-over-http/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/little-core-labs%2Fdns-over-http/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275927964,"owners_count":25554311,"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","status":"online","status_checked_at":"2025-09-19T02:00:09.700Z","response_time":108,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dns","dns-over-https","dns-server","doh"],"created_at":"2025-01-12T05:14:59.909Z","updated_at":"2025-09-19T11:32:02.591Z","avatar_url":"https://github.com/little-core-labs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"dns-over-http\n==============\n\nHTTP(s) middleware and client for DNS over HTTPS (DoH)\n\n# Abstract\n\nDNS over HTTPS (DoH) is protocol designed for performing remote Domain\nName System resolution over HTTPS. Requests are made of HTTP to increase\nuser security and privacy. See [DNS over\nHTTPS](https://en.wikipedia.org/wiki/DNS_over_HTTPS) for more\ninformation.\n\nThis module provides a middleware function that can be directly passed\nto the `http.createServer()` and `https.createServer()` functions for\nhandling DNS resolution. This module will use centralized DNS servers\nfor DNS queries and will cache answers from them for subsequent\nrequests. This module is a ***work-in-progres***.\n\n# Installation\n\n```sh\n$ npm install dns-over-http\n```\n\n# Usage\n\n***Creating a server***\n\n```js\nconst https = require('https')\nconst doh = require('dns-over-http')\n\nconst serverOptions = getServerOptions() // with cert and key\nconst server = https.createServer(serverOptions, doh({\n  maxAge: 1000 * 60 * 10, // 10 minute max TTL for any DNS record\n  // centralized DNS servers\n  servers: [\n    '9.9.9.9', // quad9\n    '8.8.8.8', // google\n    '1.1.1.1', // cloudflare\n  ]\n}))\n\nserver.listen(3000)\n```\n\nYou can also use the `http` module and position it behind a load\nbalancer or nginx instance configured SSL certificates.\n\n\n****Querying for DNS resolution***\n\n\n```js\nconst doh = require('dns-over-http')\nconst url = 'https://dns.google.com:443/experimental'\n\nconst results = []\nconst lookups = [\n  {type: 'A', name: 'google.com'},\n  {type: 'A', name: 'littlstar.com'},\n  {type: 'A', name: 'twitter.com'},\n]\n\nfor (const lookup of lookups) {\n  doh.query({url}, [lookup], (err, res) =\u003e {\n    if (err) { throw err }\n    results.push(res.answers)\n    if (results.length == lookups.length) {\n      console.log(results)\n    }\n  })\n}\n```\n\n# API\n\n## `doh(opts)`\n\nReturns a function handle suitable for a http server request callback\nwhere `opts` can be:\n\n```js\n{\n  servers: ['dns.example.com'], // centralized DNS servers\n  store: null, // an optional storage interface\n}\n```\n\n## `doh.query(opts, questions, cb)`\n\nMake a DNS resolution query request. Options are passed directly to the\n`http.request` function. `questions` are given to a\n[dns-packet](https://github.com/mafintosh/dns-packet) encoding and sent\nas a `POST` request with a `'application/dns-udpwireformat'` content\ntype.\n\n# See Also\n\n* [dns-packet](https://github.com/mafintosh/dns-packet)\n* [dns-socket](https://github.com/mafintosh/dns-socket)\n* [DNS over HTTPS](https://en.wikipedia.org/wiki/DNS_over_HTTPS)\n* [1.1.1.1](https://developers.cloudflare.com/1.1.1.1/dns-over-https/)\n* [Google Public DNS](https://dns.google.com/)\n\n# License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fdns-over-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flittle-core-labs%2Fdns-over-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flittle-core-labs%2Fdns-over-http/lists"}