@xtrctio/express-auto-blacklist

0.0.3 • Public • Published

express-auto-blacklist

Automatically blacklist IPs based on request patterns

Use:

const AutoBlacklist = require('@xtrctio/auto-blacklist');

const autoBlacklist = new AutoBlacklist([/some-blacklist-url/]);
app.use(autoBlacklist.check);

AutoBlacklist

Kind: global class

new AutoBlacklist([blockPatterns], [maxStrikes], [strikeAgeMs], [maxBlockedIPs], [whitelist], [blacklist])

Param Type Default
[blockPatterns] Array.<RegExp> []
[maxStrikes] number 2
[strikeAgeMs] number (1000 * 60 * 5)
[maxBlockedIPs] number 100000
[whitelist] Array.<string> []
[blacklist] Array.<string> []

autoBlacklist.setBlockedCallback(callback)

Set callback for when an IP is blocked

Kind: instance method of AutoBlacklist

Param
callback

autoBlacklist.check(req, res, next) ⇒ *

Check if request should be blocked

Kind: instance method of AutoBlacklist

Param Type
req Request
res Response
next function

autoBlacklist.block(ip) ⇒ void

Add IP to the LRU blocklist

Kind: instance method of AutoBlacklist

Param Type
ip string

autoBlacklist.strike(ip) ⇒ boolean

Apply strike to IP

Kind: instance method of AutoBlacklist

Param Type
ip string

autoBlacklist.whitelistIP(ip) ⇒ void

Whitelist an IP

Kind: instance method of AutoBlacklist

Param Type
ip string

autoBlacklist.blacklistIP(ip) ⇒ void

Blacklist an IP

Kind: instance method of AutoBlacklist

Param Type
ip string

autoBlacklist.isBlocked(ip, path) ⇒ boolean

Check if request should be blocked

Kind: instance method of AutoBlacklist

Param Type
ip string
path string

Package Sidebar

Install

npm i @xtrctio/express-auto-blacklist

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

9.2 kB

Total Files

5

Last publish

Collaborators

  • ehacke