npm.io
0.0.2 • Published 7 years ago

ip-range-middleware

Licence
ISC
Version
0.0.2
Deps
0
Size
8 kB
Vulns
0
Weekly
0

Expressjs Middleware Block or Allow IP Range

without dependencies

how to use middleware in expressjs

Getting Started

const IPRange = require('ip-range-middleware')

Usage

Allow only 127.0.0.1

app.use(IPRange([
  [127], [0], [0], [1]
]))

Allow only the range from 192.168.178.1 to 192.168.178.128

app.use(IPRange([
  [192], [168], [178], [1, 128]
]))

Allow only two addresses

app.use(IPRange([
  [[192], [168], [178], [2]],
  [[127], [0], [0], [1]]
]))

Allow only ::1

app.use(IPRange([], { allow: ['::1'] }))

Keywords