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([ "126.96.36.199/32", "188.8.131.52/32", "184.108.40.206/32", "220.127.116.11/32", "18.104.22.168/27", "22.214.171.124/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