Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including dnsbl with all npm packages installed. Try it out:

var dnsbl = require("dnsbl")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

dnsbl v3.2.0

Query DNS-based blackhole lists

dnsbl

Query DNS-based blackhole lists

Support both IPv4 and IPv6 queries.

Installation

$ npm i dnsbl

Usage

const dnsbl = require('dnsbl');

await dnsbl.lookup('127.0.0.2', 'zen.spamhaus.org');
// true

await dnsbl.lookup('127.0.0.2', 'zen.spamhaus.org', {includeTxt: true});
// {
//   listed: true,
//   txt: [['some txt'], ['another txt']]
// }

await dnsbl.batch(['1.2.3.4', '5.6.7.8'], ['dnsbl.somelist.net', 'dnsbl.someotherlist.net']);
// [
//   { 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 }
// ]

API

dnsbl.lookup(address, blacklist, [options])

  • address: string an IP address.
  • blacklist: string the hostname of the blacklist to query.

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). Will reject on error.

If the includeTxt option is set, it will return an Object with these properties:

  • listed boolean - a boolean indicating if the address is listed on the blacklist.
  • txt string[] - an array of resolved TXT records for the address.

dnsbl.batch(addresses, blacklists, [options])

  • addresses string or Array - one or more IP addresses.
  • blacklists string or Array - one or more blacklist hostnames.

Returns a Promise that resolve to a results object (see below).

options object

  • servers string or Array - DNS servers to use. Default: ['208.67.220.220'].
  • timeout number - timout in milliseconds. Default: 5000.
  • concurrency number - number of concurrent queries. Default: 64.
  • includeTxt boolean - include txt records if IP is blacklisted. Default: false.

results object

The results object is an array of objects with these properies:

  • address string - the IP address.
  • blacklist string - the blacklist hostname.
  • listed boolean - a boolean indicating if the address is listed on the blacklist.
  • txt string[] - an array of resolved TXT records for the address.

© silverwind, distributed under BSD licence

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free