white-black-ip
v1.0.0
Published
By using this package you can Black-list or White-list the IP address.
Downloads
2
Maintainers
Readme
white-black-ip
This Package of white-black-ip helps you to Whitelist/Blacklist specific IP address in order to allow a network to access your files, data or app.
In order to use this package-install the package using command
npm i white-black-ip
OR
yarn add white-black-ip
Implementation Code
const express = require('express');
const app = express();
const whiteBlackIp = require('white-black-ip');
const address = require('address');
// Blacklist IP address
app.get("/blacklist/ip",(req,res) => {
const ip_address = address.ip();
whiteBlackIp.blacklist(ip_address);
res.send("IP address is blacklisted");
})
// Whitelist IP address
app.get("/whitelist/ip",(req,res) => {
const ip_address = address.ip();
whiteBlackIp.whitelist(ip_address);
res.send("IP address is whitelisted");
})
// Check whether IP address is blacklisted or not
app.get("/check/ip",(req,res) => {
const ip_address = address.ip();
whiteBlackIp.check(ip_address);
res.send("IP address is checked");
})
app.listen(3001,() => {
console.log("Server runs like a charm on port 3001");
})
NOTE