From 33a27bf9d2c73c45af29b231ee450d2fe26f725b 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..1fe72b4 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 ipVerion = net.isIPv6(requestingIP) ? 'ipv6' : 'ipv4'; + + if (!blocklist.check(requestingIP, ipVerion)) { // eslint-disable-next-line no-console console.debug(`Blocking request from ${requestingIP}`);