Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res1 += "<ul>";
res1 += "<li>Target Resolver: " + resolver + "</li>";
res1 += "<li>Recursive's Hostname in Certificate (SubjectName): " + hostname + "</li>";
res1 += "</ul>";
res1 += "<h2>Checking for</h2>";
res1 += "<ol>";
res1 += "<li>Successful TCP connection</li>";
res1 += "<li>Successful TLS connection</li>";
res1 += "<li>Successful TLS Authentication (Hostname match to server certificate)</li>";
res1 += "<li>Opportunistic TLS with fallback to TCP available</li>";
res1 += "</ol>";
res1 += "<h2>Result</h2>";
context.general(query, getdns.RRTYPE_A, (err0, result0) => {
if (err0) {
// NOTE: TLS auth error.
context.destroy();
context1.general(query, getdns.RRTYPE_A, (err1, result1) => {
if (err1) {
// NOTE: Try TLS no auth.
context1.destroy();
context2.general(query, getdns.RRTYPE_A, (err2, result2) => {
if (err2) {
// NOTE: TCP only failed.
/* eslint-disable no-console */
console.error("Error2 = " + JSON.stringify(err2));
/* eslint-enable no-console */
res1 += "<p>❌ No TCP, no TLS!</p>";
} else if (result2.status === 900) {
context.general(query, getdns.RRTYPE_A, (err0, result0) => {
if (err0) {
// NOTE: TLS auth error.
context.destroy();
context1.general(query, getdns.RRTYPE_A, (err1, result1) => {
if (err1) {
// NOTE: Try TLS no auth.
context1.destroy();
context2.general(query, getdns.RRTYPE_A, (err2, result2) => {
if (err2) {
// NOTE: TCP only failed.
/* eslint-disable no-console */
console.error("Error2 = " + JSON.stringify(err2));
/* eslint-enable no-console */
res1 += "<p>❌ No TCP, no TLS!</p>";
} else if (result2.status === 900) {
// NOTE: TCP worked.
/* eslint-disable no-console */
console.log("In callback TCP fallback worked " + JSON.stringify(result2.replies_tree));
"8.8.8.8",
],
// Always return dnssec status.
return_dnssec_status: true,
};
// Create the context with the above options.
// When done with a context, it must be explicitly destroyed, for example in a callback.
const context = getdns.createContext(options);
// Getdns general.
// Third argument may be a dictionary for extensions.
// Last argument must be a callback.
// Returns a transaction id, which may be used to cancel the request.
/* eslint-disable no-unused-vars */
const transactionId = context.general("labs.verisigninc.com", getdns.RRTYPE_A, generalCallback);
/* eslint-enable no-unused-vars */
// Cancel a request.
//context.cancel(transactionId);
// Other getdns context methods.
// NOTE: don't destroy context in callback so it can be reused.
// Extensions are passed as dictionaries where the value for on/off are normal booleans.
context.address("nlnetlabs.nl", { dnssec_return_only_secure: true }, addressCallback);
context.service("dnssec-name-and-shame.com", serviceCallback);
context.hostname("8.8.8.8", hostnameCallback);
process.on("beforeExit", () => {
// NOTE: remember to explicitly destroy the context after being done with lookups.
context.destroy();
});