@algolia/dns-filter
TypeScript icon, indicating that this package has built-in type declarations

1.1.25 • Public • Published

dns-filter

A small utility library to test whether requests try to access predefined IPs

WARNING This project is not an officially maintained Algolia project. This repository should not be used for any production project. Bug reports and feature requests will most likely be ignored.

Usage

const { validateURL, NetworkError, PRIVATE_IP_PREFIXES } = require('@algolia/dns-filter');

const restricted = process.env.NODE_ENV === 'development'
  ? [] // allow everything in dev
  : PRIVATE_IP_PREFIXES; // no private IPs otherwise

const url = 'http://localhost/admin';
try {
  await validateURL({
    url,
    ipPrefixes: restricted,
    context: { some: 'metadata' },
  });
}
catch (err) {
  log.error(err); // log error
  throw new NetworkError(); // throw generic error
}

Contributing

To release this package, wait for semantic-release to finish, then:

  • Make sure you're logged in with npm login
  • Run:
yarn build
yarn publish

Readme

Keywords

none

Package Sidebar

Install

npm i @algolia/dns-filter

Weekly Downloads

11

Version

1.1.25

License

MIT

Unpacked Size

21.2 kB

Total Files

24

Last publish

Collaborators

  • wwalser
  • jkaho
  • mprevell97
  • louishousiaux
  • antoine.gilles
  • eventexperiences_algolia
  • jsok_algolia
  • bhinchley-algolia
  • hugowit
  • alg-admin
  • aymeric.giraudet
  • gavinwade12
  • bhcastle
  • rishi_algolia
  • jasonberry
  • scyganek-algolia
  • drodriguln
  • abodelot
  • leviwhalen
  • sfaiqh
  • valentindotxyz
  • fluf
  • instantsearch-bot
  • taylorcjohnson_algolia
  • pjankowski5312
  • raed-algolia
  • dylantientcheu
  • catalgolia
  • morgan-algolia
  • algabet
  • andy_ds
  • bengreenbank
  • alg-bgastinne
  • daltondickalgolia
  • jcohonner-algolia
  • robertmogos
  • mariaalungu
  • emmanuel.fortin
  • ejaldorau
  • dhaya.b
  • lukyvj
  • marielaure
  • haroenv
  • rayrutjes
  • jerska
  • ronanlevesque
  • samouss
  • therealwebby
  • francoischalifour
  • jonmontane
  • tkrugg
  • seafoox
  • sylvainh
  • clemfromspace
  • lorrissaintgenez
  • broujo
  • e-krebs
  • kombucha
  • sylvain
  • crawler-team
  • amcdaid106
  • devinalgolia
  • jvenezia
  • otomatik
  • sophiem03
  • sarahdayan
  • dcoates
  • maximehuang
  • guitek
  • matthewbond
  • cyril.descossy
  • tatsuro
  • danajeremy
  • mathougui
  • xavdh
  • agdavid
  • rasemotte
  • plnech
  • shortcuts
  • praagyajoshi
  • loicsay
  • svensoldin
  • alphonseb
  • leodau
  • fabienmotte
  • sarahfranc
  • millotp