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