respond without ra on timeout
This commit is contained in:
parent
df78e13ef2
commit
f945da161b
29
bin/digd.js
29
bin/digd.js
|
@ -211,7 +211,7 @@ cli.main(function (args, cli) {
|
||||||
}
|
}
|
||||||
|
|
||||||
server.send(newAb, rinfo.port, rinfo.address, function () {
|
server.send(newAb, rinfo.port, rinfo.address, function () {
|
||||||
console.log('[DEV] response sent (empty)');
|
console.log('[DEV] response sent (empty)', rinfo.port, rinfo.address);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ cli.main(function (args, cli) {
|
||||||
}
|
}
|
||||||
|
|
||||||
server.send(newAb, rinfo.port, rinfo.address, function () {
|
server.send(newAb, rinfo.port, rinfo.address, function () {
|
||||||
console.log('[DEV] response sent (local query)');
|
console.log('[DEV] response sent (local query)', rinfo.port, rinfo.address);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ cli.main(function (args, cli) {
|
||||||
var newAb;
|
var newAb;
|
||||||
count -= 1;
|
count -= 1;
|
||||||
|
|
||||||
if (!count) {
|
if (count <= 0) {
|
||||||
try {
|
try {
|
||||||
newAb = dnsjs.DNSPacket.write(newResponse);
|
newAb = dnsjs.DNSPacket.write(newResponse);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
@ -285,7 +285,7 @@ cli.main(function (args, cli) {
|
||||||
}
|
}
|
||||||
|
|
||||||
server.send(newAb, rinfo.port, rinfo.address, function () {
|
server.send(newAb, rinfo.port, rinfo.address, function () {
|
||||||
console.log('[DEV] response sent');
|
console.log('[DEV] response sent', rinfo.port, rinfo.address);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,6 +295,8 @@ cli.main(function (args, cli) {
|
||||||
updateCount();
|
updateCount();
|
||||||
}
|
}
|
||||||
, onMessage: function (packet) {
|
, onMessage: function (packet) {
|
||||||
|
// yay! recursion was available after all!
|
||||||
|
newResponse.header.ra = 1;
|
||||||
|
|
||||||
(packet.answer||[]).forEach(function (a) {
|
(packet.answer||[]).forEach(function (a) {
|
||||||
// TODO copy each relevant property
|
// TODO copy each relevant property
|
||||||
|
@ -323,18 +325,21 @@ cli.main(function (args, cli) {
|
||||||
console.log('request sent to', res.nameserver);
|
console.log('request sent to', res.nameserver);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
console.log('[DEV] response sent (recurse)');
|
console.log('[DEV] query sent (recurse)', rinfo.port, rinfo.address);
|
||||||
}
|
}
|
||||||
, onTimeout: function (res) {
|
, onTimeout: function (res) {
|
||||||
console.log(";; [" + q.name + "] connection timed out; no servers could be reached");
|
console.log(";; [" + q.name + "] connection timed out; no servers could be reached");
|
||||||
console.log(";; [timed out after " + res.timeout + "ms and 1 tries]");
|
console.log(";; [timed out after " + res.timeout + "ms and 1 tries]");
|
||||||
|
|
||||||
|
count = 1;
|
||||||
|
updateCount();
|
||||||
}
|
}
|
||||||
, onClose: function () {
|
, onClose: function () {
|
||||||
console.log('');
|
console.log('');
|
||||||
}
|
}
|
||||||
, mdns: cli.mdns
|
, mdns: cli.mdns
|
||||||
, nameserver: cli.nameserver
|
, nameserver: cli.chosenNameserver
|
||||||
, port: cli.port
|
, port: cli.resolverPort || 53 // TOODO accept resolverPort
|
||||||
, timeout: cli.timeout
|
, timeout: cli.timeout
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -346,7 +351,7 @@ cli.main(function (args, cli) {
|
||||||
}
|
}
|
||||||
|
|
||||||
count = query.question.length;
|
count = query.question.length;
|
||||||
if (!count) {
|
if (count <= 0) {
|
||||||
sendEmptyResponse(query);
|
sendEmptyResponse(query);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -363,14 +368,14 @@ cli.main(function (args, cli) {
|
||||||
handlers.onListening = function () {
|
handlers.onListening = function () {
|
||||||
/*jshint validthis:true*/
|
/*jshint validthis:true*/
|
||||||
var server = this;
|
var server = this;
|
||||||
var nameserver = cli.nameserver;
|
cli.chosenNameserver = cli.nameserver;
|
||||||
var index;
|
var index;
|
||||||
|
|
||||||
if (!nameserver) {
|
if (!cli.chosenNameserver) {
|
||||||
index = crypto.randomBytes(2).readUInt16BE(0) % defaultNameservers.length;
|
index = crypto.randomBytes(2).readUInt16BE(0) % defaultNameservers.length;
|
||||||
nameserver = defaultNameservers[index];
|
cli.chosenNameserver = defaultNameservers[index];
|
||||||
if (cli.debug) {
|
if (cli.debug) {
|
||||||
console.log(index, defaultNameservers);
|
console.log('index, defaultNameservers', index, defaultNameservers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue