revert code from sending non needed IP info
This commit is contained in:
@ -14,35 +14,21 @@ function startDockerStatsInterval(ws, client, user, docker) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
// Send initial stats immediately
|
||||||
|
(async () => {
|
||||||
try {
|
try {
|
||||||
const initialStats = await getContainerStats(docker, user);
|
const initialStats = await getContainerStats(docker, user);
|
||||||
// Get container info to retrieve IP address
|
|
||||||
const container = docker.getContainer(user);
|
|
||||||
const containerInfo = await container.inspect();
|
|
||||||
const ipAddress = containerInfo.NetworkSettings.Networks?.minecraft_network?.IPAddress || 'N/A';
|
|
||||||
|
|
||||||
if (ws.readyState === ws.OPEN) {
|
if (ws.readyState === ws.OPEN) {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({ type: 'docker', data: { ...initialStats, user } }));
|
||||||
type: 'docker',
|
|
||||||
data: {
|
|
||||||
...initialStats,
|
|
||||||
user,
|
|
||||||
ipAddress
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error sending initial docker stats for ${user}:`, error.message);
|
console.error(`Error sending initial docker stats for ${user}:`, error.message);
|
||||||
if (ws.readyState === ws.OPEN) {
|
if (ws.readyState === ws.OPEN) {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({ type: 'docker', error: `Failed to fetch initial stats: ${error.message}` }));
|
||||||
type: 'docker',
|
|
||||||
error: `Failed to fetch initial stats: ${error.message}`
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
// Start interval for periodic stats
|
|
||||||
// Start interval for periodic stats
|
// Start interval for periodic stats
|
||||||
const intervalId = setInterval(async () => {
|
const intervalId = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
@ -61,20 +47,11 @@ function startDockerStatsInterval(ws, client, user, docker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const stats = await getContainerStats(docker, user);
|
const stats = await getContainerStats(docker, user);
|
||||||
const ipAddress = inspect.NetworkSettings.Networks?.minecraft_network?.IPAddress || 'N/A';
|
|
||||||
|
|
||||||
if (stats.error) {
|
if (stats.error) {
|
||||||
console.error(`Error fetching stats for ${user}: ${stats.error}`);
|
console.error(`Error fetching stats for ${user}: ${stats.error}`);
|
||||||
ws.send(JSON.stringify({ type: 'docker', error: stats.error }));
|
ws.send(JSON.stringify({ type: 'docker', error: stats.error }));
|
||||||
} else {
|
} else {
|
||||||
ws.send(JSON.stringify({
|
ws.send(JSON.stringify({ type: 'docker', data: { ...stats, user } }));
|
||||||
type: 'docker',
|
|
||||||
data: {
|
|
||||||
...stats,
|
|
||||||
user,
|
|
||||||
ipAddress
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error in docker stats interval for ${user}:`, error.message);
|
console.error(`Error in docker stats interval for ${user}:`, error.message);
|
||||||
|
Reference in New Issue
Block a user