Created
May 9, 2018 12:01
-
-
Save makoto/c533d18a48c14a2361753f690f09986a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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