From ada0950f3d00a76620cccc3d12aa1ed89d51b143 Mon Sep 17 00:00:00 2001 From: George Thomas Date: Thu, 1 Aug 2024 14:05:48 +0100 Subject: [PATCH] fix: pass ip version to blocklist check to ensure ipv6 accepted --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 3e27ee8..0eef90f 100644 --- a/src/index.js +++ b/src/index.js @@ -40,7 +40,9 @@ const getMiddleware = () => (req, res, next) => { || req.socket.remoteAddress || req.connection.socket.remoteAddress; // Only expect private IPs from this range - if (!blocklist.check(requestingIP)) { + const ipVersion = net.isIPv6(requestingIP) ? 'ipv6' : 'ipv4'; + + if (!blocklist.check(requestingIP, ipVersion)) { // eslint-disable-next-line no-console console.debug(`Blocking request from ${requestingIP}`);