From 92c9870a542af370edb676deda2444aa7c15a47d Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Sun, 24 Mar 2024 09:45:37 +0100 Subject: [PATCH] [mirotalksfu] - fix host_protection --- app/src/Server.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/Server.js b/app/src/Server.js index 1a2f7aac..0b7f2e1a 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -308,8 +308,13 @@ function startServer() { // main page app.get(['/'], (req, res) => { if (hostCfg.protected) { - hostCfg.authenticated = false; - res.sendFile(views.login); + let ip = getIP(req); + if (allowedIP(ip)) { + res.sendFile(views.landing); + } else { + hostCfg.authenticated = false; + res.sendFile(views.login); + } } else { res.sendFile(views.landing); } @@ -1978,6 +1983,8 @@ function startServer() { return req.headers['x-forwarded-for'] || req.socket.remoteAddress; } function allowedIP(ip) { + const allowedIPs = authHost.getAuthorizedIPs(); + log.info('Allowed IPs', { ip: ip, allowedIPs: allowedIPs }); return authHost != null && authHost.isAuthorizedIP(ip); } function removeIP(socket) {