diff --git a/README.md b/README.md index ad0d344..2a8e4da 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ dig.js --mdns _services._dns-sd._udp.local Really the `--mdns` option is just an alias for setting all of these options as the default: ```bash -dig.js -p 5353 @224.0.0.251 PTR _services._dns-sd._udp.local +dig.js -p 5353 @224.0.0.251 PTR _services._dns-sd._udp.local +time=3 ``` ### Moar Examples diff --git a/bin/dig.js b/bin/dig.js index 54e548a..729243b 100755 --- a/bin/dig.js +++ b/bin/dig.js @@ -21,8 +21,7 @@ cli.parse({ , 'query': [ 'q', 'a superfluous explicit option to set the query as a command line flag' ] }); -var PromiseA = require('bluebird'); -var fs = PromiseA.promisifyAll(require('fs')); +var fs = require('fs'); var dgram = require('dgram'); var commonTypes = [ 'A', 'AAAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT' ]; var commonPrinters = { @@ -101,10 +100,10 @@ function writeQuery(opts, query, queryAb) { jsonpath = path.join(opts.output, jsonname); } - fs.writeFileAsync(binpath, Buffer.from(queryAb)).then(function () { + fs.writeFile(binpath, Buffer.from(queryAb), null, function () { console.log('wrote ' + queryAb.byteLength + ' bytes to ' + binpath); }); - fs.writeFileAsync(jsonpath, json).then(function () { + fs.writeFile(jsonpath, json, null, function () { console.log('wrote ' + json.length + ' bytes to ' + jsonpath); }); } @@ -124,10 +123,10 @@ function writeResponse(opts, query, nb, packet) { count += 1; - fs.writeFileAsync(binpath, nb).then(function () { + fs.writeFile(binpath, nb, null, function () { console.log('wrote ' + nb.byteLength + ' bytes to ' + binpath); }); - fs.writeFileAsync(jsonpath, json).then(function () { + fs.writeFile(jsonpath, json, null, function () { console.log('wrote ' + json.length + ' bytes to ' + jsonpath); }); } @@ -321,6 +320,9 @@ cli.main(function (args, cli) { if (!cli.query) { cli.query = '_services._dns-sd._udp.local'; } + if (!cli.timeout) { + cli.timeout = 3000; + } } if (!cli.type) { diff --git a/package.json b/package.json index cf912e1..f9fee42 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "author": "AJ ONeal (https://coolaj86.com/)", "license": "(MIT OR Apache-2.0)", "dependencies": { + "cli": "^1.0.1", "dns-suite": "git+https://git@git.daplie.com:Daplie/dns-suite#v1" } }