toxy
rule to filter by IP v4
/v6
addresses, supporting CIDR, subnets and custom/public/reserved IP ranges.
toxy | +0.3 |
Name | ip |
Poison Phase | incoming / outgoing |
Installation
npm install toxy-ip [--save]
Usage
const toxy = const ip = const proxy = proxy all'/' proxy all'/download' proxy all'/intranet' proxy all'/custom-range' proxy all'/private' proxy all'/local' proxy
API
const ip =
function (req, res, next)
ip(opts) => Available options:
- address
string
- Matches an IP address using a equality comparison. Supports CIDR expressions for ranges. - network
string|array
- List of CIDR addresses to filter. Array can contain multiple CIDR addresses. - range
array
- Pair of IP range to match. - privateAddress
boolean
- Matches if the client address is a reserved private range. Defaultfalse
- publicAddress
boolean
- Matches if the client address is a non-reserved IP range. Defaultfalse
- loopback
boolean
- Matches if the client address is a loopback valid address. Defaultfalse
boolean
ip.evalRange(range, ip) => Evaluates if the IP is inside the given range.
range
must be an array
with two items representing the IP range.
boolean
ip.evalNetwork(networks, ip) => Evaluates if the IP is inside a
boolean
ip.evalType(opts, ip) => Evaluates if the IP is public, private or loopback IP address.
ip.ip
Exposes node-ip
module API.
License
MIT - Tomas Aparicio