1.0.1 • Published 6 years ago
ip-accesscontrol v1.0.1
Welcome to IP ACCESS CONTROL!
Used to check whether an IP address is in the IP whitelist. Supports IP pattern, IP range ...
Install
npm install ip-accesscontrol
Using
Supports the format of the pattern:
- Simple IP: 192.168.0.1 219.214.222.34
- character support is for all. 192.168. * // allows all IPs with prefixes of 192.168 169
- IP range support: 192.168.1.0-100 // allow the IPs from 192.168.1.0 to 192.168.100 192.168-169. * // allow IPs from 192.168.xxx.xxx to 192.169.xxx.xxx
More: 192. 192.0-199.2-8.
in js file:
import IPAccessControl from 'ip-accesscontrol'
......
let pattern = "192.168.*"
IPAccessControl.check("192.168.20.1", pattern) //true
IPAccessControl.check("192.168.254.19", pattern) //true
IPAccessControl.check("192.39.13.6", pattern) //false
let arrayPattern = ["192.*", "169.0-1.10"]
IPAccessControl.check("192.168.20.1", arrayPattern) //true
IPAccessControl.check("169.0.10.1", arrayPattern) //true
IPAccessControl.check("169.1.10.1", arrayPattern) //true
IPAccessControl.check("169.1.20.1", arrayPattern) //false
NgocHip