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 |
void
autoBlacklist.block(ip) ⇒ Add IP to the LRU blocklist
Kind: instance method of AutoBlacklist
Param | Type |
---|---|
ip | string |
boolean
autoBlacklist.strike(ip) ⇒ Apply strike to IP
Kind: instance method of AutoBlacklist
Param | Type |
---|---|
ip | string |
void
autoBlacklist.whitelistIP(ip) ⇒ Whitelist an IP
Kind: instance method of AutoBlacklist
Param | Type |
---|---|
ip | string |
void
autoBlacklist.blacklistIP(ip) ⇒ Blacklist an IP
Kind: instance method of AutoBlacklist
Param | Type |
---|---|
ip | string |
boolean
autoBlacklist.isBlocked(ip, path) ⇒ Check if request should be blocked
Kind: instance method of AutoBlacklist
Param | Type |
---|---|
ip | string |
path | string |