UNPKG

ip-restrictor

Version:

Easily allow or block internal IPs in Node.js and Express apps. A simple middleware for IP filtering and network security.

12 lines (9 loc) 315 B
const getClientIP = require("./getClientIP"); const blockOnly = (blockedIPs) => (req, res, next) => { const clientIP = getClientIP(req); if (blockedIPs.includes(clientIP)) { return res.status(403).send("Forbidden: Your IP is blocked."); } next(); }; module.exports = blockOnly;