Merge branch 'v1' of git.daplie.com:Daplie/digd.js into v1

This commit is contained in:
AJ ONeal 2017-11-02 11:32:51 -06:00
commit f67788f9db
5 changed files with 65 additions and 9 deletions

View File

@ -1 +1,6 @@
dig @localhost -p 65053 ANY aaaa.example.com
# Using the wrong type (A instead of AAAA) results in an erroneous packet
{ "zone": "example.com", "name": "aaaa.example.com", "tld": "com", "sld": "example", "sub": "aaaa"
, "type": "A", "address": "::1" }

View File

@ -126,4 +126,13 @@ $digcmd @$ns -p $port A doesntexist.a.example.com
# should return NS records in ANSWER section, nothing else
$digcmd @$ns -p $port NS a.example.com
# Test:
# wildcard record should match after static records
$digcmd @$ns -p $port ANY wild.example.com # no record
$digcmd @$ns -p $port ANY exists.wild.example.com # static record, before wildcard
$digcmd @$ns -p $port ANY foo.exists.wild.example.com # no record
$digcmd @$ns -p $port ANY doesntexist.wild.example.com # single-level wildcard
$digcmd @$ns -p $port ANY alsedoesntexist.wild.example.com # single-level wildcard
$digcmd @$ns -p $port ANY foo.doesntexist.wild.example.com # no second-level wildcard
```

View File

@ -29,13 +29,47 @@ function getRecords(db, qname, cb) {
});
function checkCount() {
var ready;
count -= 1;
if (count <= 0) {
myRecords = myRecords.filter(function (r) {
return !delMe[r.id];
});
cb(null, myRecords);
ready = count <= 0;
if (!ready) {
return;
}
myRecords = myRecords.filter(function (r) {
return !delMe[r.id];
});
// There are a number of ways to interpret the wildcard rules
var hasWild = false;
var hasMatch = false;
myRecords.some(function (r) {
if (qname === r.name) {
hasMatch = true;
return true;
}
if ('*' === r.name[0]) {
hasWild = true;
}
});
if (hasMatch) {
myRecords = myRecords.filter(function (r) {
if ('*' !== r.name[0]) { return true; }
});
}
/*
// no need to filter out records if wildcard is used
else {
records = records.filter(function (r) {
if ('*' === r.name[0]) { return true; }
});
}
*/
cb(null, myRecords);
}
function getRecord(r) {

View File

@ -1,6 +1,6 @@
{
"name": "digd.js",
"version": "1.1.0",
"version": "1.1.4",
"description": "A lightweight DNS / mDNS daemon (server) for creating and capturing DNS and mDNS query and response packets to disk as binary and/or JSON. Options are similar to the Unix dig command.",
"main": "bin/digd.js",
"bin": {
@ -46,7 +46,7 @@
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com)",
"license": "MIT OR Apache-2.0",
"dependencies": {
"dig.js": "^1.2.1",
"hexdump.js": "^1.0.4"
"dig.js": "git+https://git.daplie.com/Daplie/dig.js#v1.3",
"hexdump.js": "git+https://git.daplie.com/Daplie/hexdump.js#v1.0.4"
}
}

View File

@ -29,7 +29,7 @@ module.exports = {
, { "zone": "example.com", "name": "a.example.com", "tld": "com", "sld": "example", "sub": "a"
, "type": "A", "address": "4.3.2.1" }
, { "zone": "example.com", "name": "aaaa.example.com", "tld": "com", "sld": "example", "sub": "aaaa"
, "type": "A", "address": "::1" }
, "type": "AAAA", "address": "::1" }
, { "zone": "example.com", "name": "aname.example.com", "tld": "com", "sld": "example", "sub": "aname"
, "type": "A", "aname": "amazon.com" }
, { "zone": "example.com", "name": "devname.example.com", "tld": "com", "sld": "example", "sub": "devname"
@ -57,6 +57,14 @@ module.exports = {
, { "zone": "example.com", "name": "email.example.com", "tld": "com", "sld": "example", "sub": "email"
, "type": "CNAME", "data": "mailgun.org" }
// a wildcard domain
// wild.example.com does NOT match
// exists.wild.example.com DOES match, statically
// doesntexist.wild.example.com DOES match, wildly
, { "zone": "example.com", "name": "*.wild.example.com", "tld": "com", "sld": "example", "sub": "*.wild"
, "type": "A", "address": "12.34.56.78" }
, { "zone": "example.com", "name": "exists.wild.example.com", "tld": "com", "sld": "example", "sub": "exists.wild"
, "type": "A", "address": "123.0.0.45" }
// Out-delegated Domains
, { "zone": "example.com", "type": "NS", "name": "out-delegated.example.com"