make bins executable

This commit is contained in:
AJ ONeal 2017-09-27 17:29:27 -06:00
parent 49b588c7a6
commit 4ffce1d405
5 changed files with 41 additions and 14 deletions

1
bin/dns-pack.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env node
'use strict'; 'use strict';
// EXAMPLE: // EXAMPLE:

1
bin/dns-parse.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env node
'use strict'; 'use strict';
// EXAMPLE: // EXAMPLE:

35
bin/dns-test.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env node
'use strict'; 'use strict';
// EXAMPLE: // EXAMPLE:
@ -12,20 +13,12 @@ if (!filename || /(-h)|(--help)/.test(process.argv.join(' '))) {
console.error(""); 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("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("");
console.error("Usage: node bin/dns-test.js <path/to/sample.json|.bin>"); console.error("Usage: node bin/dns-test.js <path/to/sample.json|.bin> <path/to/sample.bin|.json>");
console.error("Example: node bin/dns-test.js ./samples/services-0.mdns.json"); console.error("Example: node bin/dns-test.js ./samples/services-0.mdns.json ./samples/services-0.mdns.bin");
process.exit(1); process.exit(1);
return; 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 PromiseA = require('bluebird');
var fs = PromiseA.promisifyAll(require('fs')); var fs = PromiseA.promisifyAll(require('fs'));
var dnsjs = require('../').DNSPacket; var dnsjs = require('../').DNSPacket;
@ -51,6 +44,17 @@ function testJsonAsync(nb) {
} }
console.log("[OK] JSON -> binary -> JSON"); 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) { function testBinAsync(nb) {
@ -88,6 +92,17 @@ function testBinAsync(nb) {
console.log("[OK] binary -> JSON -> binary -> JSON"); 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)"); 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) { if ('json' === extname) {

8
bin/mdns-capture.js Normal file → Executable file
View File

@ -1,11 +1,13 @@
#!/usr/bin/env node
'use strict'; 'use strict';
// pass a terminal arg // pass a terminal arg
var type = process.argv[2]; 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: mdns-capture.js <filename-prefix> [start-number]");
console.error("Example: node aj-listener.js _service 0"); console.error("Example: mdns-capture.js _service 0");
console.error("Output: _service-0.mdns.bin");
process.exit(1); process.exit(1);
} }
@ -41,6 +43,8 @@ handlers.onListening = function () {
server.setBroadcast(true); server.setBroadcast(true);
server.addMembership('224.0.0.251'); server.addMembership('224.0.0.251');
console.log('CTRL+C to quit');
}; };

View File

@ -1,8 +1,14 @@
{ {
"name": "dns-suite", "name": "dns-suite",
"version": "1.1.2", "version": "1.2.0",
"description": "testing dns", "description": "testing dns",
"main": "dns.js", "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": { "scripts": {
"test": "node test/parser.js && node test/packer.js" "test": "node test/parser.js && node test/packer.js"
}, },