From 4ffce1d4051bfc33ddbc759fe32f811daecf974c Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 27 Sep 2017 17:29:27 -0600 Subject: [PATCH] make bins executable --- bin/dns-pack.js | 1 + bin/dns-parse.js | 1 + bin/dns-test.js | 35 +++++++++++++++++++++++++---------- bin/mdns-capture.js | 10 +++++++--- package.json | 8 +++++++- 5 files changed, 41 insertions(+), 14 deletions(-) mode change 100644 => 100755 bin/dns-pack.js mode change 100644 => 100755 bin/dns-parse.js mode change 100644 => 100755 bin/dns-test.js mode change 100644 => 100755 bin/mdns-capture.js diff --git a/bin/dns-pack.js b/bin/dns-pack.js old mode 100644 new mode 100755 index ddb6973..4bfb6c2 --- a/bin/dns-pack.js +++ b/bin/dns-pack.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node 'use strict'; // EXAMPLE: diff --git a/bin/dns-parse.js b/bin/dns-parse.js old mode 100644 new mode 100755 index b5d6023..221f350 --- a/bin/dns-parse.js +++ b/bin/dns-parse.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node 'use strict'; // EXAMPLE: diff --git a/bin/dns-test.js b/bin/dns-test.js old mode 100644 new mode 100755 index f10d8d7..4169245 --- a/bin/dns-test.js +++ b/bin/dns-test.js @@ -1,3 +1,4 @@ +#!/usr/bin/env node 'use strict'; // EXAMPLE: @@ -12,20 +13,12 @@ if (!filename || /(-h)|(--help)/.test(process.argv.join(' '))) { console.error(""); console.error("Accepts a DNS packet (binary or json), converts it, and then converts it back to verify the function of the parser and packer"); console.error(""); - console.error("Usage: node bin/dns-test.js "); - console.error("Example: node bin/dns-test.js ./samples/services-0.mdns.json"); + console.error("Usage: node bin/dns-test.js "); + console.error("Example: node bin/dns-test.js ./samples/services-0.mdns.json ./samples/services-0.mdns.bin"); process.exit(1); return; } -if (!outname) { - console.warn(''); - console.warn( - "Usage: node bin/dns-pack.js '" + filename + "' './" + path.basename(filename).replace(path.extname(filename), '') + ".bin'" - ); - console.warn(''); -} - var PromiseA = require('bluebird'); var fs = PromiseA.promisifyAll(require('fs')); var dnsjs = require('../').DNSPacket; @@ -51,6 +44,17 @@ function testJsonAsync(nb) { } console.log("[OK] JSON -> binary -> JSON"); + + if (!outname) { + console.warn(''); + console.warn( + "Usage: node bin/dns-test.js '" + filename + "' './" + path.basename(filename).replace(path.extname(filename), '.bin') + "'" + ); + console.warn(''); + return; + } + + fs.writeFileSync(path.basename(filename).replace(path.extname(filename), '.bin'), packet, null); } function testBinAsync(nb) { @@ -88,6 +92,17 @@ function testBinAsync(nb) { console.log("[OK] binary -> JSON -> binary -> JSON"); console.log("(compression pointer support needs to be improved in order to support direct bin -> JSON -> bin testing)"); + + if (!outname) { + console.warn(''); + console.warn( + "Usage: node bin/dns-test.js '" + filename + "' './" + path.basename(filename).replace(path.extname(filename), '.json') + "'" + ); + console.warn(''); + return; + } + + fs.writeFileSync(path.basename(filename).replace(path.extname(filename), '.json'), JSON.stringify(json, null, 2), null); } if ('json' === extname) { diff --git a/bin/mdns-capture.js b/bin/mdns-capture.js old mode 100644 new mode 100755 index beae2a4..c126973 --- a/bin/mdns-capture.js +++ b/bin/mdns-capture.js @@ -1,11 +1,13 @@ +#!/usr/bin/env node 'use strict'; // pass a terminal arg var type = process.argv[2]; var count = parseInt(process.argv[3]) || 0; if (!type) { - console.error("Usage: node aj-listener.js [count]"); - console.error("Example: node aj-listener.js _service 0"); + console.error("Usage: mdns-capture.js [start-number]"); + console.error("Example: mdns-capture.js _service 0"); + console.error("Output: _service-0.mdns.bin"); process.exit(1); } @@ -38,9 +40,11 @@ handlers.onListening = function () { /*jshint validthis:true*/ var server = this; console.log(server.address()); - + server.setBroadcast(true); server.addMembership('224.0.0.251'); + + console.log('CTRL+C to quit'); }; diff --git a/package.json b/package.json index 4000ccf..43582af 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,14 @@ { "name": "dns-suite", - "version": "1.1.2", + "version": "1.2.0", "description": "testing dns", "main": "dns.js", + "bin": { + "dns-pack.js": "bin/dns-pack.js", + "dns-parse.js": "bin/dns-parse.js", + "dns-test.js": "bin/dns-test.js", + "mdns-capture.js": "bin/mdns-capture.js", + }, "scripts": { "test": "node test/parser.js && node test/packer.js" },