dns-packet
npm install dns-packetUsage
var packet = require('dns-packet')
var dgram = require('dgram')
var socket = dgram.createSocket('udp4')
var buf = packet.encode({
type: 'query',
id: 1,
flags: packet.RECURSION_DESIRED,
questions: [{
type: 'A',
name: 'google.com'
}]
})
socket.on('message', function (message) {
console.log(packet.decode(message)) // prints out a response from google dns
})
socket.send(buf, 0, buf.length, 53, '8.8.8.8')API
var buf = packets.encode(packet, [buf], [offset])
var buf = packets.encode(packet, [buf], [offset])var packet = packets.decode(buf, [offset])
var packet = packets.decode(buf, [offset])var len = packets.encodingLength(packet)
var len = packets.encodingLength(packet)Packets
A
AAAAA
AAAATXT
TXTNS
NSNULL
NULLSOA
SOASRV
SRVHINFO
HINFOPTR
PTRCNAME
CNAMEDNAME
DNAMECAA
CAALicense
Last updated