Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

ip-checker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-checker

Check client ip for koa & express.

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

ip-checker

Check client ip for koa & express.

Quick Start

  • npm install ip-checker to install ip-checker;
  • express

var express = require('express')
  , app     = express();
app.use(require('ip-checker')({
  default: '*',
  allow: ['127.0.0.1']
}));
app.listen(3000)

  • koa
var app = require('koa')()
app.use(require('ip-checker')({
  default: '*',
  allow: ['127.0.0.1'],
  mode: 'koa'
}))
app.listen(3000)
  • test
curl -H 'x-forwarded-for: 127.0.0.2' -i  http://localhost:3000/
curl -H 'x-forwarded-for: 127.0.0.1' -i  http://localhost:3000/

Config

NameDescriptionDefault value
defaultAction for unknown ip. * for allow all unknown ips, x for block all unknown ips.*
checkerA string or function to check request ip. Return allow string to allow request, block string to block request, empty string to tell ip-checker it's an unknown requestx-forwarded-for
disableDisable ip-checker or not.false
allowA string array that means request is allowed if client ip is in this set.[]
blockA string array that means request is blocked if client ip is in this set.[]
modeexpress or koa mode.express
emitterYou can emit a disable event with a bool value to switch disable value.
process.env.IP_CHECKER_DEBUGSet this value to true to show debug log

Keywords

ip

FAQs

Package last updated on 28 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts