Comparing version 1.2.3 to 1.3.0
35
index.js
@@ -29,9 +29,28 @@ "use strict"; | ||
// resolve a CAA record, possibly via recursion | ||
const resolve = async ({name, query, server, port}) => { | ||
const [cname, dname, caa] = await Promise.all([ | ||
query({questions: [{name, type: "CNAME"}]}, port, server).then(parseAnswers).catch(noop), | ||
query({questions: [{name, type: "DNAME"}]}, port, server).then(parseAnswers).catch(noop), | ||
query({questions: [{name, type: "CAA"}]}, port, server).then(parseAnswers).catch(noop), | ||
]); | ||
const resolve = async ({name, query, server, port, opts}) => { | ||
const todo = [ | ||
query({questions: [{name, type: "CAA"}]}, port, server).then(parseAnswers).catch(noop) | ||
]; | ||
if (!opts.ignoreCNAME) { | ||
todo.push(query({questions: [{name, type: "CNAME"}]}, port, server).then(parseAnswers).catch(noop)); | ||
} | ||
if (!opts.ignoreDNAME) { | ||
todo.push(query({questions: [{name, type: "DNAME"}]}, port, server).then(parseAnswers).catch(noop)); | ||
} | ||
const res = await Promise.all(todo); | ||
const caa = res[0]; | ||
let cname, dname; | ||
if (!opts.ignoreCNAME && !opts.ignoreDNAME) { | ||
cname = res[1]; | ||
dname = res[2]; | ||
} else if (opts.ignoreCNAME && !opts.ignoreDNAME) { | ||
dname = res[1]; | ||
} else if (opts.ignoreDNAME && !opts.ignoreCNAME) { | ||
cname = res[2]; | ||
} | ||
// If CAA(X) is not empty, R(X) = CAA (X) | ||
@@ -59,3 +78,3 @@ let alias; | ||
const parent = parts.splice(1).join("."); | ||
return await resolve({name: parent, query, server, port}); | ||
return await resolve({name: parent, query, server, port, opts}); | ||
} else { | ||
@@ -83,3 +102,3 @@ return []; | ||
const port = opts.port || 53; | ||
const caa = await resolve({name, query, server, port}); | ||
const caa = await resolve({name, query, server, port, opts}); | ||
socket.destroy(); | ||
@@ -86,0 +105,0 @@ return caa || []; |
{ | ||
"name": "caa", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "rfc6844-conform CAA record lookup", | ||
@@ -28,5 +28,5 @@ "author": "silverwind <me@silverwind.io>", | ||
"eslint": "^5.3.0", | ||
"eslint-config-silverwind": "^1.0.45", | ||
"eslint-config-silverwind": "^1.0.46", | ||
"updates": "^4.1.2" | ||
} | ||
} |
@@ -27,7 +27,7 @@ # caa | ||
### caa(name, {server, port}) | ||
### caa(name, [opts]) | ||
Retrieve the CAA records which apply to the given `name`. Returns a [`CAA` object](https://github.com/mafintosh/dns-packet/#caa). | ||
### caa.matches(name, ca, {server, port}) | ||
### caa.matches(name, ca, [opts]) | ||
@@ -38,3 +38,6 @@ Test if the CAA record for a given `name` matches a given `ca`. | ||
Optionally, a DNS `server` and `port` can be supplied, defaulting to the first system resolver (or `8.8.8.8` if none is configured) and port 53. | ||
- `server`: The DNS server to use. Defaults to the first system resolver or `8.8.8.8` if none is configured). | ||
- `port`: The port on the DNS server to use. Defaults to port 53. | ||
- `ignoreCNAME`: Don't issue CNAME queries. | ||
- `ignoreDNAME`: Don't issue DNAME queries. | ||
@@ -41,0 +44,0 @@ ## License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6336
100
45