# rir-parser

> Parser for RIR Statistics Files (IP address assignment by country)

Latest version **0.1.0** (published 2014-08-08) · BSD-3-Clause license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install rir-parser
pnpm add rir-parser
yarn add rir-parser
bun add rir-parser
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2014-08-08 |
| First published | 2014-08-08 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Nate Silva |
| Maintainers | natevancouver |
| Keywords | country, ip, geoip |

## Links

- npm: https://www.npmjs.com/package/rir-parser
- Repository: https://github.com/natesilva/rir-parser
- Issues: https://github.com/natesilva/rir-parser/issues
- npm.io page: https://npm.io/package/rir-parser

## Dependencies (2)

- [ip](https://npm.io/package/ip.md) ^0.3.1
- [bluebird](https://npm.io/package/bluebird.md) ^2.2.2

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2014-08-08

## README

# rir-parser

    npm install rir-parser    

## About

* **What it is:** A Node.js parser for RIR Statistics Files (IP address assignment by country, published daily by each Regional Internet Registry)
* **Why to use it:** This module can be part of a geo-IP system that maps IP addresses to the country in which they are located.
* **Why not to use it:** This is a low-level module that **does not include geo-IP** functionality. It’s an important building block for a geo-IP module, but does not itself provide that functionality (the author intends to publish such a module).

## More information
Five Regional Internet Registries ([AfriNIC](http://www.afrinic.net/), [APNIC](https://www.apnic.net/), [ARIN](https://www.arin.net/), [LACNIC](http://lacnic.net/) and [RIPENCC](http://www.ripe.net/)),  control the assignment of IP addresses worldwide.

These RIRs publish lists (called *RIR statistics*) showing which addresses have been assigned, and to which country they are assigned. These lists can be obtained from several locations, including the [Number Resource Organization](https://www.nro.net/statistics) and via FTP from [ARIN](ftp://ftp.arin.net/pub/stats) and [RIPE](ftp://ftp.ripe.net/pub/stats).

This module parses those lists, consolidating adjacent IPv4 ranges and returning a minimal list of IP ranges (both IPv4 and IPv6) and the country to which the range is assigned.

## Usage

This module exposes one class, `RirParser`, which is a Node.js [Transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform).

To use it, create an instance of `RirParser` and pipe the list to it. The `RirParser` will output a series of JavaScript objects of the form:

```js
{range: …, kind: ['ipv4'|'ipv6'], country: [two-letter country code]}
```

Example:

```js
var RirParser = require('rir-parser');

var parser = new RirParser();

parser.on('readable', function() {
  var ipRange;
  do {
    ipRange = parser.read();
    if (ipRange) { console.log(ipRange); }
  } while (ipRange);
});

someIncomingRirDataFileStream.pipe(parser);
```

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