Connect middleware to define a whitelist/blacklist of IPv4 ranges.
In the terminal inside the project's folder.
npm install connect-purgatory --save
then in the server's file:
var http = require('http'), connect = require('connect'), purgatory = require('connect-purgatory'); var server = connect() .use(purgatory([ "220.127.116.11/32", "18.104.22.168/32", "22.214.171.124/32", "126.96.36.199/32", "188.8.131.52/27", "184.108.40.206/22" ]).bless()); http.createServer(server) .listen(3000);
thanks to @gnclmorais & @carlosdavidepto for helping understanding IP ranges and
for providing a model function to verify if an IP belong to a range.
Selectively mirror the npm registry inside your firewall. Filter packages based on security, licensing, code quality and more. Build awesome stuff faster. Try npm Enterprise for free…
how? learn more