IP Filter: A light-weight IP address based filtering system
This package provides easy IP based access control. This can be achieved either by blacklisting certain IPs and whitelisting all others, or whitelisting certain IPs and blacklisting all others.
Version
0.0.10
Installation
Recommended installation is with npm. To add node-ipfilter to your project, do:
npm install express-ipfilter
Usage with Express
Blacklisting certain IP addresses, while allowing all other IPs:
var express = require('express')
, ipfilter = require('ipfilter')
, app = express.createServer()
;
var ips = ['127.0.0.1'];
app.use(ipfilter(ips));
app.listen(3000);
Whitelisting certain IP addresses, while denying all other IPs:
var express = require('express')
, ipfilter = require('ipfilter')
, app = express.createServer()
;
var ips = ['127.0.0.1'];
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);
Using CIDR subnet masks for ranges:
var ips = ['127.0.0.1/24'];
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);
Using IP ranges:
var ips = [['127.0.0.1','127.0.0.10']];
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);
Changelog
0.0.10
- Added support for IPs with port numbers
0.0.9
0.0.8
0.0.7
0.0.6
- Fixed a bug when using console output
0.0.5
- Added ability to block by subnet mask (i.e. 127.0.0.1/24)
- Added tests for cidr functionality
0.0.4
- Add tests
- Update docs
- Refactor, and restyle
0.0.1
Credits
BaM Interactive - code.bamideas.com