You've already forked fm-dx-webserver
mirror of
https://github.com/KubaPro010/fm-dx-webserver.git
synced 2026-02-27 14:33:52 +01:00
bugfixes, accessibility settings
This commit is contained in:
@@ -160,6 +160,7 @@ router.get('/logout', (req, res) => {
|
||||
router.get('/kick', (req, res) => {
|
||||
const ipAddress = req.query.ip; // Extract the IP address parameter from the query string
|
||||
// Terminate the WebSocket connection for the specified IP address
|
||||
console.log(ipAddress);
|
||||
if(req.session.isAdminAuthenticated) {
|
||||
helpers.kickClient(ipAddress);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ function resolveDataBuffer(data, wss) {
|
||||
function kickClient(ipAddress) {
|
||||
// Find the entry in connectedClients associated with the provided IP address
|
||||
const targetClient = storage.connectedUsers.find(client => client.ip === ipAddress);
|
||||
console.log(storage.connectedUsers);
|
||||
if (targetClient && targetClient.instance) {
|
||||
// Send a termination message to the client
|
||||
targetClient.instance.send('KICK');
|
||||
|
||||
@@ -259,7 +259,7 @@ wss.on('connection', (ws, request) => {
|
||||
logInfo(`Web client \x1b[32mconnected\x1b[0m (${clientIp}) \x1b[90m[${currentUsers}]\x1b[0m`);
|
||||
} else {
|
||||
const userLocation = `${locationInfo.city}, ${locationInfo.region}, ${locationInfo.country}`;
|
||||
const userData = { ip: clientIp, location: userLocation, time: connectionTime };
|
||||
const userData = { ip: clientIp, location: userLocation, time: connectionTime, instance: ws };
|
||||
storage.connectedUsers.push(userData);
|
||||
logInfo(`Web client \x1b[32mconnected\x1b[0m (${clientIp}) \x1b[90m[${currentUsers}]\x1b[0m Location: ${locationInfo.city}, ${locationInfo.region}, ${locationInfo.country}`);
|
||||
}
|
||||
@@ -338,6 +338,10 @@ wss.on('connection', (ws, request) => {
|
||||
storage.connectedUsers.splice(index, 1); // Remove the user's data from storage.connectedUsers array
|
||||
}
|
||||
|
||||
if(currentUsers === 0) {
|
||||
storage.connectedUsers = [];
|
||||
}
|
||||
|
||||
if (currentUsers === 0 && serverConfig.enableDefaultFreq === true && serverConfig.autoShutdown !== true && serverConfig.xdrd.wirelessConnection === true) {
|
||||
setTimeout(function() {
|
||||
if(currentUsers === 0) {
|
||||
|
||||
Reference in New Issue
Block a user