@xtrctio/express-auto-blacklist
v0.0.3
Published
Automatically blacklist IPs based on request patterns
Downloads
6
Readme
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 |