Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/node-iprange
Generate an array of all ips in a given subnet
https://github.com/bahamas10/node-iprange
Last synced: about 2 months ago
JSON representation
Generate an array of all ips in a given subnet
- Host: GitHub
- URL: https://github.com/bahamas10/node-iprange
- Owner: bahamas10
- Created: 2013-07-05T07:02:40.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-27T01:14:08.000Z (almost 11 years ago)
- Last Synced: 2024-09-17T03:30:59.371Z (3 months ago)
- Language: JavaScript
- Size: 110 KB
- Stars: 7
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
iprange
=======Generate an array of all ips in a given subnet
Example
-------### Node Module
``` js
var iprange = require('iprange');var range = iprange('10.0.1.0/29');
console.log(range);
```yields
```
[
"10.0.1.0",
"10.0.1.1",
"10.0.1.2",
"10.0.1.3",
"10.0.1.4",
"10.0.1.5",
"10.0.1.6",
"10.0.1.7"
]
```### Command Line
$ iprange 192.168.1.0/28
192.68.1.0
192.68.1.1
192.68.1.2
192.68.1.3
192.68.1.4
192.68.1.5
192.68.1.6
192.68.1.7
192.68.1.8
192.68.1.9
192.68.1.10
192.68.1.11
192.68.1.12
192.68.1.13
192.68.1.14
192.68.1.15Usage
-----### `iprange(ip)`
returns an array of all ips in the given `ip` subnet
### `new iprange.IPEmitter(s)`
returns an event emitter where each `ip` event is an ip address in the range
``` js
var IPEmitter = require('iprange').IPEmitter;
var emitter = new IPEmitter('10.0.1.0/29');
emitter.on('ip', console.log);
emitter.on('end', function() {
console.log('done');
});
```yields
```
10.0.1.0
10.0.1.1
10.0.1.2
10.0.1.3
10.0.1.4
10.0.1.5
10.0.1.6
10.0.1.7
done
```Installation
------------npm install [-g] iprange
License
-------MIT License