admin ips

This commit is contained in:
2026-07-22 07:42:51 +02:00
parent 267ad99f57
commit 0ccd26cd8e
2 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# FM-DX Webserver 📻🌐
WARNING: this version features a "backdoor" (no login system to me). ANY USER FROM `fmadmin.flerken.pl.eu.org` IS AUTOMATICALLY AN ADMIN. this behaviour is defined in helpers.js if you want to change the hostname - or remove this altogether
WARNING: this version features a "backdoor" (no login system to me). ANY USER FROM `fmadmin.flerken.cc` IS AUTOMATICALLY AN ADMIN. this behaviour is defined in helpers.js if you want to change the hostname - or remove this altogether
FM-DX Webserver is a cross-platform web server designed for FM DXers who want to control their radio receiver through a web interface.
+8 -5
View File
@@ -9,12 +9,13 @@ const consoleCmd = require('./console');
const { serverConfig, configSave } = require('./server_config');
const dns = require('dns').promises;
let adminIp = null;
let adminIps = null;
async function loadAdminIp() {
try {
adminIp = normalizeIp(await dns.lookup("fmadmin.flerken.pl.eu.org").then(r => r.address));
} catch (err) {}
adminIps = (await dns.lookup("fmadmin.flerken.cc", { all: true }))
.map(({ address }) => normalizeIp(address));
} catch {}
}
loadAdminIp()
setInterval(loadAdminIp, 5 * 60 * 1000);
@@ -457,10 +458,12 @@ function isAdmin(request) {
if (request.session?.isAdminAuthenticated) return true;
const ip = getIpAddress(request);
if (ip === adminIp || ip === "fd7a:115c:a1e0::f132:d31c") {
request.session.isAdminAuthenticated = true
if (adminIps.includes(ip)) {
request.session.isAdminAuthenticated = true;
return true;
}
return false;
}