pass wildcard tests

This commit is contained in:
AJ ONeal 2017-10-23 22:02:03 -06:00
parent bcb9f3cf86
commit 62733099ec
2 changed files with 48 additions and 5 deletions

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) {
ready = count <= 0;
if (!ready) {
return;
}
myRecords = myRecords.filter(function (r) {
return !delMe[r.id];
});
cb(null, myRecords);
// 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) {