fix mdns
This commit is contained in:
parent
50cfa7d8a6
commit
b89789f631
|
@ -77,4 +77,6 @@ Options
|
|||
-c <class> default IN
|
||||
-p <port> default 53 (mdns default: 5353) (listener is random for DNS and 5353 for mDNS)
|
||||
-q <query> (superfluous) required (ex: daplie.com)
|
||||
|
||||
+time=<seconds> Sets the timeout for a query in seconds.
|
||||
```
|
||||
|
|
23
bin/dig.js
23
bin/dig.js
|
@ -12,6 +12,7 @@ cli.parse({
|
|||
//, 'json': [ false, 'output results as json', 'string' ]
|
||||
//, 'lint': [ false, 'attack (in the metaphorical sense) a nameserver with all sorts of queries to test for correct responses', 'string', false ]
|
||||
, 'mdns': [ false, "Alias for setting defaults to -p 5353 @224.0.0.251 -t PTR -q _services._dns-sd._udp.local and waiting for multiple responses", 'boolean', false ]
|
||||
, 'timeout': [ false, "Alias for setting defaults to -p 5353 @224.0.0.251 -t PTR -q _services._dns-sd._udp.local and waiting for multiple responses", 'boolean', false ]
|
||||
, 'output': [ 'o', 'output prefix to use for writing query and response(s) to disk', 'file' ]
|
||||
, 'port': [ 'p', 'port (defaults to 53 for dns and 5353 for mdns)', 'int' ]
|
||||
//, 'serve': [ 's', 'path to json file with array of responses to issue for given queries', 'string' ]
|
||||
|
@ -257,7 +258,15 @@ function request(query, opts) {
|
|||
// 0 dns request
|
||||
// 53 dns server
|
||||
// 5353 mdns
|
||||
server.bind(0);
|
||||
if (opts.mdns) {
|
||||
server.bind(5353);
|
||||
setTimeout(function () {
|
||||
server.close();
|
||||
}, opts.timeout || (5 * 1000));
|
||||
}
|
||||
else {
|
||||
server.bind(0);
|
||||
}
|
||||
}
|
||||
|
||||
cli.main(function (args, cli) {
|
||||
|
@ -271,6 +280,15 @@ cli.main(function (args, cli) {
|
|||
cli.type = cli.t = arg.toUpperCase();
|
||||
}
|
||||
|
||||
if (/^\+time=/.test(arg)) {
|
||||
if (cli.timeout) {
|
||||
console.error("'+time=' was specified more than once");
|
||||
process.exit(1);
|
||||
return;
|
||||
}
|
||||
cli.timeout = Math.round(parseInt(arg.replace(/\+time=/, ''), 10) * 1000);
|
||||
}
|
||||
|
||||
if (/^@/.test(arg)) {
|
||||
if (cli.nameserver) {
|
||||
console.error("'@server' was specified more than once");
|
||||
|
@ -299,6 +317,9 @@ cli.main(function (args, cli) {
|
|||
if (!cli.nameserver) {
|
||||
cli.nameserver = '224.0.0.251';
|
||||
}
|
||||
if (!cli.query) {
|
||||
cli.query = '_services._dns-sd._udp.local';
|
||||
}
|
||||
}
|
||||
|
||||
if (!cli.type) {
|
||||
|
|
Loading…
Reference in New Issue