From 1b005d0345ec24709c7cd8915cdb30cb30f59c91 Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 18 Mar 2025 01:42:44 +0200 Subject: [api] exported function checkIfAllowedIP --- api/routes/getRemotePeers/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'api/routes/getRemotePeers') diff --git a/api/routes/getRemotePeers/index.js b/api/routes/getRemotePeers/index.js index 78dbba4..c75a98a 100644 --- a/api/routes/getRemotePeers/index.js +++ b/api/routes/getRemotePeers/index.js @@ -6,6 +6,7 @@ const { spawn } = require('child_process'); const config = require("../../config.js"); +const checkIfAllowedIP = require('../../lib/checkIfAllowedIP/index.js'); module.exports = (req, res) => { var args = req.url.split("/"); @@ -14,8 +15,7 @@ module.exports = (req, res) => { { ip = args[3]; } - var test = /^fc[0-9a-z]{1,2}:([0-9a-z]{1,4}:){1,6}[0-9a-z]{1,4}/ - if (test.test(ip)) + if (checkIfAllowedIP(ip)) { const command = spawn("curl", ["--retry-max-time","3","-s",`http://[${ip}]:8610/v0/peers`]); var buffer = ""; -- cgit v1.2.3