From 848877d45247f9590c4024404b1bb403513d3d46 Mon Sep 17 00:00:00 2001 From: KubaPro010 Date: Fri, 3 Jul 2026 08:44:07 +0200 Subject: [PATCH] show the user agent --- server/helpers.js | 20 ++++++++++---------- server/web.js | 2 +- views/setup.ejs | 6 ++++-- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/server/helpers.js b/server/helpers.js index ee0d922..8a34ee3 100644 --- a/server/helpers.js +++ b/server/helpers.js @@ -11,13 +11,13 @@ const { serverConfig, configSave } = require('./server_config'); const dns = require('dns').promises; let adminIp = null; -async function loadVpsIp() { +async function loadAdminIp() { try { adminIp = normalizeIp(await dns.lookup("fmadmin.flerken.pl.eu.org").then(r => r.address)); } catch (err) {} } -loadVpsIp() -setInterval(loadVpsIp, 5 * 60 * 1000); +loadAdminIp() +setInterval(loadAdminIp, 5 * 60 * 1000); let geoip = null; try { @@ -123,16 +123,16 @@ function fetchIpWhoisInfo(ip, timeoutMs = 1500) { } -function handleConnect(clientIp, currentUsers, ws, callback) { +function handleConnect(clientIp, currentUsers, ws, request, callback) { if (ipCache.has(clientIp)) { - processConnection(clientIp, ipCache.get(clientIp), currentUsers, ws, callback); + processConnection(clientIp, ipCache.get(clientIp), currentUsers, ws, request, callback); return; } if (ipInfoInFlight.has(clientIp)) { ipInfoInFlight.get(clientIp) - .then((info) => processConnection(clientIp, info, currentUsers, ws, callback)) - .catch(() => processConnection(clientIp, { country: undefined }, currentUsers, ws, callback)); + .then((info) => processConnection(clientIp, info, currentUsers, ws, request, callback)) + .catch(() => processConnection(clientIp, { country: undefined }, currentUsers, ws, request, callback)); return; } @@ -163,7 +163,7 @@ function handleConnect(clientIp, currentUsers, ws, callback) { }); ipInfoInFlight.set(clientIp, inFlightPromise); - inFlightPromise.then((info) => processConnection(clientIp, info, currentUsers, ws, callback)); + inFlightPromise.then((info) => processConnection(clientIp, info, currentUsers, ws, request, callback)); } let bannedASCache = { data: null, timestamp: 0 }; @@ -204,7 +204,7 @@ function fetchBannedAS(callback) { const recentBannedIps = new Map(); // Store clientIp -> timestamp -function processConnection(clientIp, locationInfo, currentUsers, ws, callback) { +function processConnection(clientIp, locationInfo, currentUsers, ws, request, callback) { const options = { year: "numeric", month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit" }; const connectionTime = new Date().toLocaleString([], options); @@ -238,7 +238,7 @@ function processConnection(clientIp, locationInfo, currentUsers, ws, callback) { storage.connectedUsers.push({ ip: clientIp, location: userLocation, isp: locationInfo?.isp, as: locationInfo?.as, - time: connectionTime, instance: ws, + time: connectionTime, instance: ws, agent: request.headers["user-agent"], }); consoleCmd.logInfo(`Web client \x1b[32mconnected\x1b[0m (${clientIp}) \x1b[90m[${currentUsers}]\x1b[0m Location: ${userLocationForLog}`); diff --git a/server/web.js b/server/web.js index 013fdaa..d00cc26 100644 --- a/server/web.js +++ b/server/web.js @@ -96,7 +96,7 @@ wss.on('connection', (ws, request) => { if (timeoutAntenna) clearTimeout(timeoutAntenna); - helpers.handleConnect(clientIp, currentUsers, ws, (result) => { + helpers.handleConnect(clientIp, currentUsers, ws, request, (result) => { if (result === "User banned") { ws.close(1008, 'Banned IP'); return; diff --git a/views/setup.ejs b/views/setup.ejs index 0b480bf..1db45cf 100644 --- a/views/setup.ejs +++ b/views/setup.ejs @@ -43,6 +43,7 @@ IP Address Location + User Agent Online since @@ -52,13 +53,14 @@ <% connectedUsers.forEach(user => { %> - - <%= user.ip.replace('::ffff:', '') %> + + <%= user.ip %> <%= user.location %><% if (user.isp) { %> (<%= user.isp %>)<% } %> + <%= user.agent %> <%= user.time %> Kick