Browse Source

make bins executable

v1
AJ ONeal 7 years ago
parent
commit
4ffce1d405
  1. 1
      bin/dns-pack.js
  2. 1
      bin/dns-parse.js
  3. 35
      bin/dns-test.js
  4. 10
      bin/mdns-capture.js
  5. 8
      package.json

1
bin/dns-pack.js

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

1
bin/dns-parse.js

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

35
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 <path/to/sample.json|.bin>");
console.error("Example: node bin/dns-test.js ./samples/services-0.mdns.json");
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 ./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) {

10
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 <type> [count]");
console.error("Example: node aj-listener.js _service 0");
console.error("Usage: mdns-capture.js <filename-prefix> [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');
};

8
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"
},

Loading…
Cancel
Save