capture some dns packets
This commit is contained in:
parent
d5a36adeec
commit
23beebf751
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// pass a terminal arg
|
// pass a terminal arg
|
||||||
var type = process.argv[2] || 'unknown';
|
var type = process.argv[2];
|
||||||
var count = parseInt(process.argv[3]) || 0;
|
var count = parseInt(process.argv[3]) || 0;
|
||||||
if (!type) {
|
if (!type) {
|
||||||
console.error("Usage: node aj-listener.js <type> [count]");
|
console.error("Usage: node aj-listener.js <type> [count]");
|
||||||
|
@ -24,15 +24,8 @@ handlers.onError = function (err) {
|
||||||
server.close();
|
server.close();
|
||||||
};
|
};
|
||||||
handlers.onMessage = function (buffer) {
|
handlers.onMessage = function (buffer) {
|
||||||
var name;
|
var name = type + '-' + count + '.mdns.bin';
|
||||||
|
count += 1;
|
||||||
if (!count) {
|
|
||||||
name = type + '-' + count + '.mdns.bin';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// probably the same device name responding
|
|
||||||
name = type + '-' + buffer.length + '.mdns.bin';
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileAsync(name, buffer).then(function () {
|
fs.writeFileAsync(name, buffer).then(function () {
|
||||||
console.log('wrote ' + buffer.length + ' bytes to ' + name);
|
console.log('wrote ' + buffer.length + ' bytes to ' + name);
|
||||||
|
@ -54,4 +47,4 @@ server.on('listening', handlers.onListening);
|
||||||
|
|
||||||
// 53 dns
|
// 53 dns
|
||||||
// 5353 mdns
|
// 5353 mdns
|
||||||
server.bind(5353);
|
server.bind(5353);
|
Loading…
Reference in New Issue