{"id":17655956,"url":"https://github.com/sagi/node-dns-over-tls","last_synced_at":"2025-05-05T21:16:31.634Z","repository":{"id":32927302,"uuid":"146361078","full_name":"sagi/node-dns-over-tls","owner":"sagi","description":"DNS-over-TLS API for Node.js","archived":false,"fork":false,"pushed_at":"2023-03-02T21:14:14.000Z","size":1878,"stargazers_count":19,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T21:16:25.960Z","etag":null,"topics":["dns","dns-over-tls","dnstls","nodejs","privacy","security","tls"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/sagi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-27T22:26:31.000Z","updated_at":"2024-06-26T13:34:27.000Z","dependencies_parsed_at":"2024-06-18T21:21:59.448Z","dependency_job_id":"4a3da5ec-058f-4b07-8a46-6105803644e6","html_url":"https://github.com/sagi/node-dns-over-tls","commit_stats":{"total_commits":82,"total_committers":4,"mean_commits":20.5,"dds":0.2195121951219512,"last_synced_commit":"49bf8c3726b3d9fae2fe7d3c00f55daa1bf461fa"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagi%2Fnode-dns-over-tls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagi%2Fnode-dns-over-tls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagi%2Fnode-dns-over-tls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagi%2Fnode-dns-over-tls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sagi","download_url":"https://codeload.github.com/sagi/node-dns-over-tls/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252577027,"owners_count":21770721,"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":["dns","dns-over-tls","dnstls","nodejs","privacy","security","tls"],"created_at":"2024-10-23T13:09:17.596Z","updated_at":"2025-05-05T21:16:31.613Z","avatar_url":"https://github.com/sagi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dns-over-tls\n\n[`dns-over-tls`](https://www.npmjs.com/package/dns-over-tls) is a Node.js DNS-over-TLS API. Here's a [blog post](https://sagi.io/2018/09/dns-over-tls---thoughts-and-implementation/) that explains how it works.\n\n[![CircleCI](https://circleci.com/gh/sagi/node-dns-over-tls.svg?style=svg)](https://circleci.com/gh/sagi/node-dns-over-tls)\n[![Coverage Status](https://coveralls.io/repos/github/sagi/node-dns-over-tls/badge.svg?branch=master)](https://coveralls.io/github/sagi/node-dns-over-tls?branch=master)\n[![MIT License](https://img.shields.io/npm/l/dns-over-tls.svg?style=flat-square)](http://opensource.org/licenses/MIT)\n[![version](https://img.shields.io/npm/v/dns-over-tls.svg?style=flat-square)](http://npm.im/dns-over-tls)\n\n## Installation\n\n~~~\n$ npm install dns-over-tls\n~~~\n\n## API\n\nWe import as follows:\n~~~js\nconst dnstls = require('dns-over-tls')\n~~~\n\nAll API usages return a `Promise` that resolves to a `DNS` response object.\n\n####  dnstls.query(name)\n~~~js\n(async () =\u003e {\n  const dnsResponse  = await dnstls.query('sagi.io')\n})()\n~~~\n\nSends a DNS-over-TLS request of `domain name`  `'sagi.io'` to\n[Cloudflare](https://developers.cloudflare.com/1.1.1.1/dns-over-tls/)'s\n`dns-over-tls` server (`host` is `'1.1.1.1'` and `servername` is `'cloudflare-dns.com'`).\n\n####  dnstls.query(host, servername, name)\n~~~js\n(async () =\u003e {\n  const dnsResponse  = await dnstls.query('9.9.9.9', 'dns.quad9.net', 'sagi.io')\n})()\n~~~\nSends a DNS-over-TLS request of `domain name` `'sagi.io'` to `host` `'9.9.9.9'` with\n`servername` `'dns.quad9.net'`.\n\n####  dnstls.query({ host, servername, name, klass = 'IN', type = 'A', port = 853 })\nAllows for more advanced `DNS` queries.\n\n~~~js\n(async () =\u003e {\n  const options = {\n    name: 'authors.bind',\n    host: '145.100.185.15',\n    servername: 'dnsovertls.sinodun.com',\n    klass: 'CH',\n    type: 'TXT'\n  };\n\n  const dnsResponse = await dnstls.query(options)\n})\n~~~\nSends a DNS-over-TLS request of `domain name` `'authors.bind'` to `host` `'145.100.185.15'` with\n`servername` `'dnsovertls.sinodun.com'`, `class` `'CH'` and type `'TXT'`.\n\n## Example\n\nSay we'd like to get the `NS` records of domain `sagi.io`:\n~~~js\n  const options = {\n    name: 'sagi.io',\n    host: '1.1.1.1',\n    servername: 'cloudflare-dns.com',\n    type: 'NS',\n  };\n  const dnsResponse = await dnstls.query(options);\n  console.log(JSON.stringify(dnsResponse, null, 2));\n~~~\n\nCode from [`example`](https://github.com/sagi/node-dns-over-tls/tree/master/example).\n\nOutput:\n~~~json\n{\n  \"id\": 46597,\n  \"type\": \"response\",\n  \"flags\": 384,\n  \"flag_qr\": true,\n  \"opcode\": \"QUERY\",\n  \"flag_aa\": false,\n  \"flag_tc\": false,\n  \"flag_rd\": true,\n  \"flag_ra\": true,\n  \"flag_z\": false,\n  \"flag_ad\": false,\n  \"flag_cd\": false,\n  \"rcode\": \"NOERROR\",\n  \"questions\": [\n    {\n      \"name\": \"sagi.io\",\n      \"type\": \"NS\",\n      \"class\": \"IN\"\n    }\n  ],\n  \"answers\": [\n    {\n      \"name\": \"sagi.io\",\n      \"type\": \"NS\",\n      \"ttl\": 10703,\n      \"class\": \"IN\",\n      \"flush\": false,\n      \"data\": \"cass.ns.cloudflare.com\"\n    },\n    {\n      \"name\": \"sagi.io\",\n      \"type\": \"NS\",\n      \"ttl\": 10703,\n      \"class\": \"IN\",\n      \"flush\": false,\n      \"data\": \"dave.ns.cloudflare.com\"\n    }\n  ],\n  \"authorities\": [],\n  \"additionals\": []\n}\n~~~\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagi%2Fnode-dns-over-tls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagi%2Fnode-dns-over-tls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagi%2Fnode-dns-over-tls/lists"}