pass wildcard tests
This commit is contained in:
parent
bcb9f3cf86
commit
62733099ec
9
TESTS.md
9
TESTS.md
|
@ -126,4 +126,13 @@ $digcmd @$ns -p $port A doesntexist.a.example.com
|
||||||
# should return NS records in ANSWER section, nothing else
|
# should return NS records in ANSWER section, nothing else
|
||||||
$digcmd @$ns -p $port NS a.example.com
|
$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
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -29,13 +29,47 @@ function getRecords(db, qname, cb) {
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkCount() {
|
function checkCount() {
|
||||||
|
var ready;
|
||||||
|
|
||||||
count -= 1;
|
count -= 1;
|
||||||
if (count <= 0) {
|
ready = count <= 0;
|
||||||
|
|
||||||
|
if (!ready) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
myRecords = myRecords.filter(function (r) {
|
myRecords = myRecords.filter(function (r) {
|
||||||
return !delMe[r.id];
|
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) {
|
function getRecord(r) {
|
||||||
|
|
Loading…
Reference in New Issue