WIP some local responses work

This commit is contained in:
AJ ONeal 2017-10-06 18:31:59 -06:00
parent d7e208d3f7
commit d26b671176
3 changed files with 15 additions and 7 deletions

View File

@ -257,7 +257,7 @@ cli.main(function (args, cli) {
id: query.header.id // require('crypto').randomBytes(2).readUInt16BE(0)
, qr: 0
, opcode: 0
, aa: query.header.aa ? 1 : 0 // NA? not sure what this would do
, aa: 0 // query.header.aa ? 1 : 0 // NA? not sure what this would do
, tc: 0 // NA
, rd: 1
, ra: 0 // NA
@ -363,8 +363,11 @@ cli.main(function (args, cli) {
}
// TODO get local answer first, if available
require('../lib/dns-store').query(cli.input, query, function (err, resp) {
if (err) { console.log('[DEV] answer not found in local db, recursing'); recurse(); return; }
var path = require('path');
require('../lib/dns-store').query(path.resolve(cli.input), query, function (err, resp) {
if (err) { console.log('[DEV] answer not found in local db, recursing'); console.error(err); recurse(); return; }
if (SERVFAIL === resp.header.rcode) { console.log('[DEV] local cache miss, recursing'); recurse(); return; }
sendResponse(resp);
});

View File

@ -6,7 +6,7 @@ module.exports.ask = function (query, cb) {
};
*/
var SUCCESS = 0;
var NOERROR = 0;
var NXDOMAIN = 3;
var REFUSED = 5;
@ -182,7 +182,7 @@ module.exports.query = function (input, query, cb) {
, tc: 0
, rd: query.header.rd // duh
, ra: 0 // will be changed by cli.norecurse
, rcode: SUCCESS // 0 SUCCESS, 3 NXDOMAIN, 5 REFUSED
, rcode: NOERROR // 0 NOERROR, 3 NXDOMAIN, 5 REFUSED
}
, question: [], answer: [], authority: [], additional: []
};
@ -193,6 +193,8 @@ module.exports.query = function (input, query, cb) {
myRecords.forEach(function (r) {
results.answer.push(dbToResourceRecord(r));
});
results.header.rcode = NOERROR;
cb(null, results);
return;
}

View File

@ -1,14 +1,17 @@
'use strict';
module.exports = {
"domain": [
"domains": [
{ "id": "daplie.me", "revokedAt": 0 }
, { "id": "oneal.daplie.me", "revokedAt": 0 }
, { "id": "aj.oneal.daplie.me", "revokedAt": 0 }
]
, "records": [
// zone daplie.me should be able to have some records on its own
{ "zone": "daplie.me", "type": "A", "domain": "www.daplie.me"
{ "zone": "daplie.me", "type": "A", "domain": "daplie.me"
, "tld": "me", "sld": "daplie", "sub": "", "value": "23.228.168.108", "aname": "tardigrade.devices.daplie.me" }
, { "zone": "daplie.me", "type": "A", "domain": "www.daplie.me"
, "tld": "me", "sld": "daplie", "sub": "www", "value": "23.228.168.108", "aname": "tardigrade.devices.daplie.me" }
, { "zone": "daplie.me", "type": "CNAME", "domain": "email.daplie.me"