small refactor

This commit is contained in:
AJ ONeal 2017-09-25 15:12:58 -06:00
parent 6d0f9b1588
commit 083df5755b
1 changed files with 102 additions and 101 deletions

View File

@ -169,20 +169,19 @@ cli.main(function (args, cli) {
});
}
count = query.question.length;
if (!count) {
function recurse() {
if (!query.header.rd) {
console.log("[Could not answer. Sent empty response.]");
sendEmptyResponse(query);
return;
}
// TODO get local answer first, if available
if (query.header.rd) {
if (cli.norecurse) {
console.log("[Could not answer. Sent empty response.]");
sendEmptyResponse(query);
return;
} else {
}
// ANY, A, AAAA, CNAME, MX, NAPTR, NS, PTR, SOA, SRV, TXT
newQuery = {
header: {
@ -195,14 +194,7 @@ cli.main(function (args, cli) {
, ra: 0 // NA
, rcode: 0 // NA
}
, question: [
/*
{ name: cli.query
, typeName: cli.type
, className: cli.class
}
*/
]
, question: []
, answer: []
, authority: []
, additional: []
@ -276,7 +268,16 @@ cli.main(function (args, cli) {
console.log(';' + q.name + '.', ' ', q.className, q.typeName);
});
}
count = query.question.length;
if (!count) {
sendEmptyResponse(query);
return;
}
// TODO get local answer first, if available
recurse();
};
handlers.onListening = function () {
@ -305,7 +306,7 @@ cli.main(function (args, cli) {
console.log('');
if (!cli.nocmd) {
console.log('; <<>> dig.js ' + 'v0.0.0' + ' <<>> ' + process.argv.slice(2));
console.log('; <<>> digd.js ' + 'v0.0.0' + ' <<>> ' + process.argv.slice(2));
console.log(';; global options: +cmd');
}