ip-ban-list
v0.3.2
Published
Shared IP ban list backed by Hyperbee2, seedable over Hyperswarm
Maintainers
Readme
ip-ban-list
Shared IP ban list backed by Hyperbee2, seedable over Hyperswarm.
Install
npm install ip-ban-listUsage
API
const banList = new IpBanList(store, [opts])
Create a new IP ban list.
store: Corestore instanceopts.key: Hypercore public key to open an existing ban list read-only (default:null)
await banList.ready()
Initialize the ban list.
await banList.close()
Close the ban list.
await banList.ban(ip)
Ban an IP address.
ip: IP address string (e.g.'1.2.3.4')
await banList.unban(ip)
Remove an IP address from the ban list.
ip: IP address string
const banned = banList.isBanned(ip)
Check if an IP address is banned. Returns true or false from an
in-memory cache that is loaded on ready() and updated from Hyperbee.
banList.on('cache-updated')
Emitted when the in-memory cache is updated from Hyperbee. Fires once
during ready() and after later local or replicated updates.
banList.on('cache-update-error', error)
Emitted when updating the in-memory cache from Hyperbee fails.
error: Error thrown while refreshing the cache
banList.key
The Hypercore public key for the ban list (32 bytes).
banList.discoveryKey
The discovery key for swarming (32 bytes).
License
Apache-2.0
