From 23beebf7515da1e50e9698eeee957ae412d2b5d9 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 21 Jan 2017 03:16:08 -0700 Subject: [PATCH] capture some dns packets --- mdns-udp-capturer.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mdns-udp-capturer.js b/mdns-udp-capturer.js index 9b2901e..fdab9c7 100644 --- a/mdns-udp-capturer.js +++ b/mdns-udp-capturer.js @@ -1,7 +1,7 @@ 'use strict'; // pass a terminal arg -var type = process.argv[2] || 'unknown'; +var type = process.argv[2]; var count = parseInt(process.argv[3]) || 0; if (!type) { console.error("Usage: node aj-listener.js [count]"); @@ -24,15 +24,8 @@ handlers.onError = function (err) { server.close(); }; handlers.onMessage = function (buffer) { - var name; - - if (!count) { - name = type + '-' + count + '.mdns.bin'; - } - else { - // probably the same device name responding - name = type + '-' + buffer.length + '.mdns.bin'; - } + var name = type + '-' + count + '.mdns.bin'; + count += 1; fs.writeFileAsync(name, buffer).then(function () { console.log('wrote ' + buffer.length + ' bytes to ' + name); @@ -54,4 +47,4 @@ server.on('listening', handlers.onListening); // 53 dns // 5353 mdns -server.bind(5353); +server.bind(5353); \ No newline at end of file