make bins executable
This commit is contained in:
parent
49b588c7a6
commit
4ffce1d405
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// EXAMPLE:
|
// EXAMPLE:
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// EXAMPLE:
|
// EXAMPLE:
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +40,11 @@ handlers.onListening = function () {
|
||||||
/*jshint validthis:true*/
|
/*jshint validthis:true*/
|
||||||
var server = this;
|
var server = this;
|
||||||
console.log(server.address());
|
console.log(server.address());
|
||||||
|
|
||||||
server.setBroadcast(true);
|
server.setBroadcast(true);
|
||||||
server.addMembership('224.0.0.251');
|
server.addMembership('224.0.0.251');
|
||||||
|
|
||||||
|
console.log('CTRL+C to quit');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue