mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-30 08:49:16 +02:00
admin ips
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# FM-DX Webserver 📻🌐
|
# 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.
|
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 { serverConfig, configSave } = require('./server_config');
|
||||||
|
|
||||||
const dns = require('dns').promises;
|
const dns = require('dns').promises;
|
||||||
let adminIp = null;
|
let adminIps = null;
|
||||||
|
|
||||||
async function loadAdminIp() {
|
async function loadAdminIp() {
|
||||||
try {
|
try {
|
||||||
adminIp = normalizeIp(await dns.lookup("fmadmin.flerken.pl.eu.org").then(r => r.address));
|
adminIps = (await dns.lookup("fmadmin.flerken.cc", { all: true }))
|
||||||
} catch (err) {}
|
.map(({ address }) => normalizeIp(address));
|
||||||
|
} catch {}
|
||||||
}
|
}
|
||||||
loadAdminIp()
|
loadAdminIp()
|
||||||
setInterval(loadAdminIp, 5 * 60 * 1000);
|
setInterval(loadAdminIp, 5 * 60 * 1000);
|
||||||
@@ -457,10 +458,12 @@ function isAdmin(request) {
|
|||||||
if (request.session?.isAdminAuthenticated) return true;
|
if (request.session?.isAdminAuthenticated) return true;
|
||||||
|
|
||||||
const ip = getIpAddress(request);
|
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 true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user