I want read DNS packet catch by UDP server event on.message
How can I read fix size data
packet data manage like I want read all field of DNS packet by separately by size.
--Read nodejs buffer object bit by bit. (specific size of bit)
var s = dgram.createSocket('udp4');
s.bind(53, function() {
});
s.on('message',function(msg,rinfo){
console.log("Length = "+msg.length);
console.log(msg.toString('binary'));
console.log(msg);
console.log("-----------------------------------------------------------------------");
});
how can achieve every field data? with buffer of on.message param.
Thanks.
Please check https://www.npmjs.org/package/native-dns-packet
It provides exactly what you need:
Packet.parse(buffer) returns an instance of Packet
Packet.write(buffer, packet) writes the given packet into the buffer, truncating where appropriate
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.