mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-29 08:19:19 +02:00
admin ips
This commit is contained in:
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user