# @algolia/dns-filter

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

Latest version **1.1.25** (published 2022-01-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @algolia/dns-filter
pnpm add @algolia/dns-filter
yarn add @algolia/dns-filter
bun add @algolia/dns-filter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.25 |
| Published | 2022-01-25 |
| First published | 2019-10-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 1 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Algolia |
| Maintainers | dhaya.b, spy-seth, alejandrouda, lukyvj, sepehrf, kosai106, marielaure, mthuret, haroenv, rayrutjes, speedblue, jerska, raphi, cbaptiste, ronanlevesque, samouss, therealwebby, francoischalifour, jonmontane, mikaa123, valentindotxyz, shipow, tkrugg, seafoox, sylvainh, clemfromspace, lorrissaintgenez, broujo, marieglr, e-krebs, eunjae-lee, kombucha, h1fra, sylvain, crawler-team, amcdaid106, devinalgolia, jvenezia, otomatik, julienbourdeau, sophiem03, mschreiber, sarahdayan, alexandremeunier, dcoates, maximehuang, netgusto, guitek, matthewbond, cyril.descossy, tatsuro, danajeremy, mathougui, xavdh, agdavid, rasemotte, plnech, shortcuts, praagyajoshi, loicsay, svensoldin, alphonseb, leodau, fabienmotte, sarahfranc, millotp |

## Links

- npm: https://www.npmjs.com/package/@algolia/dns-filter
- Repository: https://github.com/algolia/dns-filter
- Homepage: https://github.com/algolia/dns-filter#readme
- Issues: https://github.com/algolia/dns-filter/issues
- npm.io page: https://npm.io/package/@algolia/dns-filter

## Dependencies (1)

- [ip-address](https://npm.io/package/ip-address.md) 8.1.0

## Recent versions

- 1.1.25 (latest) — 2022-01-25
- 1.1.24 — 2021-11-02
- 1.1.23 — 2021-10-11
- 1.1.22 — 2021-08-16
- 1.1.19 — 2021-07-20
- 1.1.17 — 2021-05-26
- 1.1.16 — 2021-04-12
- 1.1.15 — 2021-03-22
- 1.1.14 — 2021-03-08
- 1.1.13 — 2021-03-01
- 1.1.12 — 2021-02-25
- 1.1.11 — 2020-11-24
- 1.1.3 — 2019-10-23
- 0.0.3 — 2019-10-23
- 0.0.2 — 2019-10-23
- … 1 more at https://npm.io/package/@algolia/dns-filter/versions

## README

# 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

```js
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: 
```bash
yarn build
yarn publish
```

---
_Source: https://npm.io/package/@algolia/dns-filter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
