white-black-ip

1.0.0 • Public • Published

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


You can also get IP address from Frontend and pass it to the package.

Package Sidebar

Install

npm i white-black-ip

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

4.19 kB

Total Files

4

Last publish

Collaborators

  • potabattiram