Skip to content

Instantly share code, notes, and snippets.

@makoto
Created May 9, 2018 12:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makoto/c533d18a48c14a2361753f690f09986a to your computer and use it in GitHub Desktop.
Save makoto/c533d18a48c14a2361753f690f09986a to your computer and use it in GitHub Desktop.
var packet = require('dns-packet')
var axios = require('axios')
let buf = packet.encode({
type: 'query',
id: 1,
flags: packet.RECURSION_DESIRED,
questions: [{
type: 'TXT',
class: 'IN',
name: '_ens.ethlab.xyz'
}],
additionals: [{
type: 'OPT',
name: '.',
udpPayloadSize: 4096,
flags: packet.DNSSEC_OK
}]
})
let response = axios.get('https://cloudflare-dns.com/dns-query?ct=application/dns-udpwireformat&dns=' + buf.toString('base64'), {
responseType:'arraybuffer'
})
.then(function (response) {
var decoded = packet.decode(response.data);
console.log('decoded!');
console.log(response.data);
console.log(decoded);
})
.catch(function (error) {
console.log(error);
});
// npm install https://github.com/Arachnid/dns-packet --save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment