Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sagi.io/dns-over-https

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sagi.io/dns-over-https

RFC-8484 Compliant DNS-over-HTTPS API

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

DNS-over-HTTPS API for Node.js

@sagi.io/dns-over-https is an RFC-8484 compliant Node.js DNS over HTTPS API.

CircleCI Coverage Status MIT License version

Installation

$ npm install --save @sagi.io/dns-over-https

API

We import as follows:

const doh = require('@sagi.io/dns-over-https')
doh.query(...)
doh.query = ({
  name,
  method = 'POST',
  hostname = 'cloudflare-dns.com',
  path = '/dns-query',
  port = 443,
  userAgent = '@sagi.io/dns-over-https',
  type = 'A',
  klass = 'IN',
  useHttps = true,
})

A name is mandatory. You can set your own method, hostname, path, port, userAgent, type, klass and useHttps.

A Promise is that resolves to a DNS response object is returned.

For instance,

const doh = require('@sagi/dns-over-https')
(async () => {
  const dnsResponse  = await doh.query({name: 'sagi.io'})
})()

Results in:

{
  "id": 0,
  "type": "response",
  "flags": 384,
  "flag_qr": true,
  "opcode": "QUERY",
  "flag_aa": false,
  "flag_tc": false,
  "flag_rd": true,
  "flag_ra": true,
  "flag_z": false,
  "flag_ad": false,
  "flag_cd": false,
  "rcode": "NOERROR",
  "questions": [
    {
      "name": "sagi.io",
      "type": "A",
      "class": "IN"
    }
  ],
  "answers": [
    {
      "name": "sagi.io",
      "type": "A",
      "ttl": 300,
      "class": "IN",
      "flush": false,
      "data": "151.101.1.195"
    },
    {
      "name": "sagi.io",
      "type": "A",
      "ttl": 300,
      "class": "IN",
      "flush": false,
      "data": "151.101.65.195"
    }
  ],
  "authorities": [],
  "additionals": []
}

More usage examples can be found in example.

License

MIT

Keywords

FAQs

Package last updated on 20 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc