mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-07-30 16:59:15 +02:00
Compare commits
4
Commits
67d70eef43
...
7bd28794d6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bd28794d6
|
||
|
|
302d73854f
|
||
|
|
baf277210d
|
||
|
|
848877d452
|
+11
-11
@@ -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,10 +238,10 @@ 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}`);
|
||||
consoleCmd.logInfo(`Web client \x1b[32mconnected\x1b[0m (${clientIp}) \x1b[90m[${currentUsers}]\x1b[0m Location: ${userLocationForLog} | User Agent: ${request.headers["user-agent"]}`);
|
||||
|
||||
callback("User allowed");
|
||||
});
|
||||
|
||||
+2
-2
@@ -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;
|
||||
@@ -252,7 +252,7 @@ pluginsWss.on('connection', (ws, request) => {
|
||||
|
||||
ws.on('message', message => {
|
||||
// Anti-spam
|
||||
const msg2 = helpers.antispamProtection(message, clientIp, ws, userCommands, lastWarn, userCommandHistory, '10', 'data_plugins');
|
||||
const msg2 = helpers.antispamProtection(message, clientIp, ws, userCommands, lastWarn, userCommandHistory, '10', 'data_plugins', 1024 * 1024 * 2);
|
||||
if(!msg2) return;
|
||||
|
||||
try {
|
||||
|
||||
+5
-3
@@ -13,7 +13,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<div id="toast-container"></div>
|
||||
<div id="wrapper" class="setup-wrapper admin-wrapper">
|
||||
<div id="wrapper" class="panel-full">
|
||||
<div class="m-0 no-bg">
|
||||
<h2>Dashboard</h2>
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<tr>
|
||||
<th>IP Address</th>
|
||||
<th>Location</th>
|
||||
<th>User Agent</th>
|
||||
<th>Online since</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -52,13 +53,14 @@
|
||||
<% connectedUsers.forEach(user => { %>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="https://ipinfo.io/<%= user.ip.replace('::ffff:', '') %>" target="_blank">
|
||||
<%= user.ip.replace('::ffff:', '') %>
|
||||
<a href="https://ipinfo.io/<%= user.ip %>" target="_blank">
|
||||
<%= user.ip %>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<%= user.location %><% if (user.isp) { %> (<%= user.isp %>)<% } %>
|
||||
</td>
|
||||
<td><%= user.agent %></td>
|
||||
<td><%= user.time %></td>
|
||||
<td><a href="./kick?ip=<%= user.ip %>">Kick</a></td>
|
||||
</tr>
|
||||
|
||||
+7
-7
@@ -101,15 +101,15 @@ li.active {
|
||||
height: 100%;
|
||||
z-index: 1000; /* Ensure it's above other content */
|
||||
transition: margin-left 0.3s ease; /* Smooth transition */
|
||||
}
|
||||
|
||||
.admin-wrapper {
|
||||
transition: margin-left 0.3s ease, width 0.3s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.admin-wrapper > .panel-full > .panel-full {
|
||||
.admin-wrapper {
|
||||
transition: margin-left 0.3s ease, width 0.3s ease;
|
||||
}
|
||||
|
||||
.admin-wrapper > .panel-full > .panel-full {
|
||||
min-height: 100vh;
|
||||
}
|
||||
}
|
||||
|
||||
#map {
|
||||
height:400px;
|
||||
|
||||
Reference in New Issue
Block a user