hildjj / dohdec

Lookup and decode DNS records using DNS-over-HTTPS (DoH)
MIT License
19 stars 5 forks source link

Wrong content type sent to Google's DoH resolver #13

Closed gnarea closed 3 years ago

gnarea commented 3 years ago

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

hildjj commented 3 years ago

I'm looking into this. In the meantime, this works for me:

const gDOH = new dohdec.DNSoverHTTPS({
  url: 'https://dns.google/dns-query',
  preferPost: false
});
const gResult = await gDOH.lookup({
  name: 'example.com',
  json: false
});

https://runkit.com/hildjj/5fe3b11a12aa9400134fa826

hildjj commented 3 years ago

@gnarea: good catch, great but report. Thank you.

gnarea commented 3 years ago

Thanks @hildjj! Much appreciated