Query DNS-based blacklists
Support both IPv4 and IPv6 queries.
$ npm install --save dnsbl
const dnsbl = require('dnsbl');
dnsbl.lookup('127.0.0.2', 'zen.spamhaus.org').then(function(listed) {
console.log(listed);
//=> true
});
const dnsbl = require('dnsbl');
dnsbl.batch(
['1.2.3.4', '5.6.7.8']
['dnsbl.somelist.net', 'dnsbl.someotherlist.net']
).then(function(err, results) {
console.log(results);
//=> [
//=> { blacklist: 'dnsbl.somelist.net', address: '1.2.3.4', listed: true },
//=> { blacklist: 'dnsbl.somelist.net', address: '5.6.7.8', listed: false },
//=> { blacklist: 'dnsbl.someotherlist.net', address: '1.2.3.4', listed: true },
//=> { blacklist: 'dnsbl.someotherlist.net', address: '5.6.7.8', listed: false }
//=> ]
});
address
: string an IPv4 address to lookup.blacklist
: string a DNS suffix to use.
Returns a promise that resolves to true
or false
, indicating if the address is listed (e.g. the DNS query returned a non-empty result).
addresses
string or Array - one or more IPv4 addresses to lookup.blacklists
string or Array - one or more DNSBL addresses to use.
Returns a promise that resolve to a results
object (see below).
server
string - the DNS server to use. Default:'208.67.220.220'
.port
number - the port to use. Default:53
.timeout
number - timout in milliseconds. Default:10000
.
The results` object is an array of objects with these properies:
address
string - the IPv4 address looked up.blacklist
string - the DNSBL address looked up.listed
boolean - a boolean indicating if the address is listed on the blacklist.
© silverwind, distributed under BSD licence