dns-suite.js/examples/dns-pack.js

28 lines
363 B
JavaScript
Raw Normal View History

2019-10-20 05:52:59 +00:00
'use strict';
var DNSPacket = require('../').DNSPacket;
var rnd = Math.floor(Math.random() * 65536);
var query = {
header: {
id: rnd,
qr: 0,
opcode: 0,
aa: 0,
rd: 1,
ra: 0,
rcode: 0
},
question: [
{
name: 'google.com',
typeName: 'A',
className: 'IN'
}
]
};
var buffer = DNSPacket.pack(query);
console.info(Buffer.from(buffer));