WIP some local responses work
This commit is contained in:
parent
d7e208d3f7
commit
d26b671176
|
@ -257,7 +257,7 @@ cli.main(function (args, cli) {
|
||||||
id: query.header.id // require('crypto').randomBytes(2).readUInt16BE(0)
|
id: query.header.id // require('crypto').randomBytes(2).readUInt16BE(0)
|
||||||
, qr: 0
|
, qr: 0
|
||||||
, opcode: 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
|
, tc: 0 // NA
|
||||||
, rd: 1
|
, rd: 1
|
||||||
, ra: 0 // NA
|
, ra: 0 // NA
|
||||||
|
@ -363,8 +363,11 @@ cli.main(function (args, cli) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO get local answer first, if available
|
// TODO get local answer first, if available
|
||||||
require('../lib/dns-store').query(cli.input, query, function (err, resp) {
|
var path = require('path');
|
||||||
if (err) { console.log('[DEV] answer not found in local db, recursing'); recurse(); return; }
|
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);
|
sendResponse(resp);
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ module.exports.ask = function (query, cb) {
|
||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var SUCCESS = 0;
|
var NOERROR = 0;
|
||||||
var NXDOMAIN = 3;
|
var NXDOMAIN = 3;
|
||||||
var REFUSED = 5;
|
var REFUSED = 5;
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ module.exports.query = function (input, query, cb) {
|
||||||
, tc: 0
|
, tc: 0
|
||||||
, rd: query.header.rd // duh
|
, rd: query.header.rd // duh
|
||||||
, ra: 0 // will be changed by cli.norecurse
|
, 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: []
|
, question: [], answer: [], authority: [], additional: []
|
||||||
};
|
};
|
||||||
|
@ -193,6 +193,8 @@ module.exports.query = function (input, query, cb) {
|
||||||
myRecords.forEach(function (r) {
|
myRecords.forEach(function (r) {
|
||||||
results.answer.push(dbToResourceRecord(r));
|
results.answer.push(dbToResourceRecord(r));
|
||||||
});
|
});
|
||||||
|
results.header.rcode = NOERROR;
|
||||||
|
cb(null, results);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
"domain": [
|
"domains": [
|
||||||
{ "id": "daplie.me", "revokedAt": 0 }
|
{ "id": "daplie.me", "revokedAt": 0 }
|
||||||
, { "id": "oneal.daplie.me", "revokedAt": 0 }
|
, { "id": "oneal.daplie.me", "revokedAt": 0 }
|
||||||
, { "id": "aj.oneal.daplie.me", "revokedAt": 0 }
|
, { "id": "aj.oneal.daplie.me", "revokedAt": 0 }
|
||||||
]
|
]
|
||||||
, "records": [
|
, "records": [
|
||||||
// zone daplie.me should be able to have some records on its own
|
// 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" }
|
, "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"
|
, { "zone": "daplie.me", "type": "CNAME", "domain": "email.daplie.me"
|
||||||
|
|
Loading…
Reference in New Issue