Git Product home page Git Product logo

dnsbl's Introduction

dnsbl

Query DNS-based blackhole lists

Support both IPv4 and IPv6 queries.

Installation

$ npm i dnsbl

Usage

import {lookup, batch} from 'dnsbl';

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

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

await 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

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.

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. Pass a falsy value to use the system resolvers. Default: ['208.67.220.220', '208.67.222.222', '2620:119:35::35', '2620:119:53::53'].
  • 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

dnsbl's People

Contributors

manelpb avatar moshemal avatar silverwind avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dnsbl's Issues

Caching

It would be great to have caching added somehow to reduce HTTP requests when bots spam servers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.