Skip to content

Instantly share code, notes, and snippets.

@sebmck
Last active December 11, 2015 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebmck/4588704 to your computer and use it in GitHub Desktop.
Save sebmck/4588704 to your computer and use it in GitHub Desktop.
function check(host, callback){
var dns = require('dns');
var net = require('net');
var blacklist = ['72.51.33.80'];
function resolved(err, ip){
callback(!err && blacklist.indexOf(ip) !== -1);
}
dns.resolveMx(host, function(err, results){
if (err) return callback(err);
var exchange = results[0].exchange;
if (net.isIP(exchange)) {
resolved(null, exchange);
} else {
dns.resolve(exchange, function(err, results){
resolved(err, results[0]);
});
}
});
}
var time = Date.now();
check('mailinator.com', function(result){
console.log('blacklisted:', result);
console.log('took:', (Date.now() - time) + 'ms');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment