Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function(errr, stdout) {
var expected = stdout.substr(0, stdout.length - 1).split('\n');
var reversing = dns.reverse(myIp, function(error, domains, ttl, cname) {
if (error) domains = [];
cmpResults(expected, domains, ttl, cname);
});
}
}
resolution.addCallback(function (addresses, ttl, cname) {
puts("addresses: " + JSON.stringify(addresses));
puts("ttl: " + JSON.stringify(ttl));
puts("cname: " + JSON.stringify(cname));
for (var i = 0; i < addresses.length; i++) {
var a = addresses[i];
var reversing = dns.reverse(a);
reversing.addCallback( function (domains, ttl, cname) {
puts("reverse for " + a + ": " + JSON.stringify(domains));
});
reversing.addErrback( function (code, msg) {
puts("reverse for " + a + " failed: " + msg);
});
}
});
function reverse_addr(addr) {
var e = new events.EventEmitter();
dns.reverse(addr, function(err, domains) {
if (err) {
if (err.errno == dns.NOTFOUND)
e.emit('response', addr, 'NOTFOUND');
else
e.emit('error', addr, err);
} else
e.emit('response', addr, domains);
});
return e;
}
function dnsReverse( ip, callback ) {
try {
dns.reverse( ip, function(err,doms) {
if (err) {
doms = null;
console.log("unable to resolve ip: " + err.toString() );
}
callback(doms);
});
}
catch(exn) {
console.log("unable to resolve ip: " + exn.toString() );
callback(null);
}
}
function reverseDnsLookup(ip, callback) {
dns.reverse(ip, (err, hostnames) => {
if (!err && hostnames.length) {
return callback(hostnames[0]);
}
callback(ip);
});
}