Last active
December 11, 2015 10:39
-
-
Save sebmck/4588704 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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