Giter Club home page Giter Club logo

express-ipfilter's Introduction

express-ipfilter: 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.

Circle CI

Version

0.0.24

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:

// Init dependencies
var express = require('express')
    , ipfilter = require('express-ipfilter')
    , app = express.createServer()
    ;

// Blacklist the following IPs
var ips = ['127.0.0.1'];

// Create the server
app.use(ipfilter(ips));
app.listen(3000);

Whitelisting certain IP addresses, while denying all other IPs:

// Init dependencies
var express = require('express')
    , ipfilter = require('express-ipfilter')
    , app = express.createServer()
    ;

// Whitelist the following IPs
var ips = ['127.0.0.1'];

// Create the server
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);

Using CIDR subnet masks for ranges:

var ips = ['127.0.0.1/24'];

// Create the server
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);

Using IP ranges:

var ips = [['127.0.0.1','127.0.0.10']];

// Create the server
app.use(ipfilter(ips, {mode: 'allow'}));
app.listen(3000);

Options

Property Description Type Default
mode whether to deny or allow to the IPs provided string deny
log console log actions boolean true
errorCode the HTTP status code to use when denying access number 401
errorMessage the error message to use when denying access string Unauthorized
excluding routes that should be excluded from ip filtering array []

Contributing

Building from source

You can run grunt to build the source. This will run eslint and babel against src/ipfilter.js.

There is an included example project that will load the package from the local build for testing.

Running Tests

Run tests by using

grunt test

This will run eslint,babel, and mocha and output coverage data into coverage. Any pull request you submit needs to be accompanied by a test.

Changelog

0.0.24

  • Added lib to version control

0.0.23

  • added codio x-real-ip header

0.0.22

  • Added IPv6 Support
  • Added build tools
  • Added test coverage and reporting

0.0.20

  • Added a setting to explicitly allow CloudFlare and Forwarded IPs. By default they are set to not allow these headers. Thanks to @longstone!

0.0.19

0.0.18

  • Fixing bug when array of CIDR blocks are used

0.0.16

  • Fixing bug when no IP address can be determined

0.0.15

  • Minor bug fix

0.0.14

  • Adding the ability to have exclusion urls

0.0.12

  • Diagnostic Options

0.0.11

  • Bug Fix for port logic

0.0.10

  • Added support for IPs with port numbers

0.0.9

  • Fixing deploy issues

0.0.8

  • Auto deploys for npm

0.0.7

  • Add support ip ranges.

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

  • First revision

Credits

BaM Interactive - code.bamideas.com

express-ipfilter's People

Contributors

ryanbillingsley avatar longstone avatar lafama avatar thii avatar eggman64 avatar

Watchers

James Cloos avatar David avatar ramy rais avatar Qiong Wu avatar Patrick Wieth avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.