Giter Club home page Giter Club logo

dohdec's Introduction

dohdec

Retrieve and decode DNS records using DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT).

Pointers

This is a monorepo that holds a few related packages:

If you want to use the command line, you MUST now install dohdec-cli:

npm install -g dohdec-cli

Apologies; I didn't think anyone would want to use the library on its own when I built this originally.

Tooling

  • Install with pnpm install -r, see. The important thing (for example) is that the dohdec-cli package ends up depending on the local version of dohdec.

Supported Node.js versions

This project now only supports versions of Node that the Node team is currently supporting. Ava's support statement is what we will be using as well. Currently, that means Node 12+ is required. Only ES6 modules (import) are supported.

Tests codecov

License

MPL-2.0

dohdec's People

Contributors

gnarea avatar hildjj avatar imcotton avatar zdeneksvarc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dohdec's Issues

`lookup` types do not match documentation

The dohdec README says:

await doh.lookup('ietf.org', 'AAAA') // JSON result from CloudFlare

Meaning that the first argument of lookup can take a string.

However, the types say:

lookup(name: object | DOH_LookupOptions, opts?: packet.RecordType | DOH_LookupOptions): Promise<Buffer | string | object>;

Meaning that the first argument of lookup can only be of type object | DOH_LookupOptions

With DOH_LookupOptions being defined as an object too:

export type DOH_LookupOptions = {

README and types definition should match.

Missing declarations in upgrade from v3 to v5

Dependabot created a PR to upgrade from v3 to v5.0.1, but the tests are breaking due to some missing types:

node_modules/dohdec/types/dnsUtils.d.ts:193:25 - error TS7016: Could not find a declaration file for module 'dns-packet'. '/home/runner/work/relaynet-core-js/relaynet-core-js/node_modules/dns-packet/index.js' implicitly has an 'any' type.
  Try `npm install @types/dns-packet` if it exists or add a new declaration (.d.ts) file containing `declare module 'dns-packet';`

193 import * as packet from "dns-packet";
                            ~~~~~~~~~~~~

node_modules/dohdec/types/doh.d.ts:146:25 - error TS7016: Could not find a declaration file for module 'dns-packet'. '/home/runner/work/relaynet-core-js/relaynet-core-js/node_modules/dns-packet/index.js' implicitly has an 'any' type.
  Try `npm install @types/dns-packet` if it exists or add a new declaration (.d.ts) file containing `declare module 'dns-packet';`

146 import * as packet from "dns-packet";
                            ~~~~~~~~~~~~

node_modules/dohdec/types/dot.d.ts:48:43 - error TS2694: Namespace '"crypto"' has no exported member 'X509Certificate'.

48     static hashCert(cert: Buffer | crypto.X509Certificate, hashAlg?: string): string;
                                             ~~~~~~~~~~~~~~~

node_modules/dohdec/types/dot.d.ts:188:25 - error TS7016: Could not find a declaration file for module 'dns-packet'. '/home/runner/work/relaynet-core-js/relaynet-core-js/node_modules/dns-packet/index.js' implicitly has an 'any' type.
  Try `npm install @types/dns-packet` if it exists or add a new declaration (.d.ts) file containing `declare module 'dns-packet';`

188 import * as packet from "dns-packet";
                            ~~~~~~~~~~~~


Found 4 errors.

Add -x support

reverse bytes, do a PTR lookup. make sure ipv6 works.

Wrong content type sent to Google's DoH resolver

Google is refusing the request with an HTTP 415 because the request has the wrong content type.

Here's how to reproduce it:

const dohdec = require("dohdec")

# This works:
const cfDOH = new dohdec.DNSoverHTTPS({url: 'https://cloudflare-dns.com/dns-query'});
const cfResult = await cfDOH.getDNS({name: 'example.com', decode: true});

# This doesn't work
const gDOH = new dohdec.DNSoverHTTPS({url: 'https://dns.google/dns-query'});
const gResult = await gDOH.getDNS({name: 'example.com', decode: true});

https://runkit.com/gnarea/5fe388a32aabda001a46f76e

How to use POST method in dohdec-cli ?

How to trigger the dohdec-cli uses POST request for getting response from DoH servers ?
I saw the option
Options: -g, --get Force http GET for DNS-format lookups (default: true)

and tried all the ways as below:

dohdec -dv www.cloudflare.com aaaa
dohdec -dv www.cloudflare.com aaaa -g 0
dohdec -dv www.cloudflare.com aaaa -g false

the program always shows

DNSoverHTTPS options: {
  contentType: 'application/dns-message',
  http2: true,
  preferPost: false,
  url: 'https://cloudflare-dns.com/dns-query',
  userAgent: 'dohdec v5.0.3'
}
...
HTTP GET URL: https://cloudflare-dns.com/dns-query?dns=AAABAAABAAAAAAABA3d3dwpjbG91ZGZsYXJlA2NvbQAAHAABAAApEAAAAAAAAFEADABNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

So how can I make dohdec-cli use the POST method to get the response from DoH servers?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.