1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

bugfixes / sporadic e logging

This commit is contained in:
Marek Farkaš
2025-02-09 17:46:12 +01:00
parent b4928bcff8
commit ceb6e1bd11
14 changed files with 211 additions and 86 deletions

View File

@@ -21,11 +21,13 @@ router.get('/', (req, res) => {
let requestIp = req.headers['x-forwarded-for'] || req.connection.remoteAddress;
const normalizedIp = requestIp?.replace(/^::ffff:/, '');
const isBanned = serverConfig.webserver.banlist.some(banEntry => banEntry[0] === normalizedIp);
const ipList = normalizedIp.split(',').map(ip => ip.trim()); // in case there are multiple IPs (proxy), we need to check all of them
const isBanned = ipList.some(ip => serverConfig.webserver.banlist.some(banEntry => banEntry[0] === ip));
if (isBanned) {
res.render('403');
logInfo(`Web client (${requestIp}) is banned`);
logInfo(`Web client (${normalizedIp}) is banned`);
return;
}
@@ -391,7 +393,8 @@ router.get('/log_fmlist', (req, res) => {
client: {
request_ip: clientIp
},
log_msg: "Logged PS: " + dataHandler.dataToSend.ps.replace(/\s+/g, '_') + ", PI: " + dataHandler.dataToSend.pi + ", Signal: " + dataHandler.dataToSend.sig.toFixed(0) + " dBf",
type: req.query.type ? req.query.type : 'tropo',
log_msg: "Logged PS: " + dataHandler.dataToSend.ps.replace(/\s+/g, '_') + ", PI: " + dataHandler.dataToSend.pi + ", Signal: " + (dataHandler.dataToSend.sig - 11.25).toFixed(0) + " dBµV",
});
const options = {