Logging für REST Abfragen aus dem Palworld Server etnfernt
All checks were successful
Deploy GSM / deploy (push) Successful in 24s

This commit is contained in:
2026-01-12 03:07:23 +01:00
parent 4bfb870fbb
commit 51b95240f2
4 changed files with 39 additions and 15 deletions

View File

@@ -4,6 +4,24 @@ const rconConnections = new Map();
const playerCache = new Map();
const CACHE_TTL = 30000; // 30 seconds
// Palworld REST API helper
async function getPalworldPlayers(server) {
const port = server.restApiPort || 8212;
const url = `http://${server.host}:${port}/v1/api/players`;
const auth = Buffer.from(`admin:${server.rconPassword}`).toString('base64');
const response = await fetch(url, {
headers: { 'Authorization': `Basic ${auth}` },
signal: AbortSignal.timeout(5000)
});
if (!response.ok) {
throw new Error(`REST API error: ${response.status}`);
}
return await response.json();
}
async function getConnection(server) {
const key = `${server.host}:${server.rconPort}`;
@@ -88,10 +106,9 @@ export async function getPlayers(server) {
const lines = response.split('\n').filter(l => l.trim() && !l.includes('listusers'));
result = { online: lines.length, max: null };
} else if (server.type === 'palworld') {
const response = await sendRconCommand(server, 'ShowPlayers');
// Format: "name,playeruid,steamid\nPlayer1,123,765...\nPlayer2,456,765..."
const lines = response.split('\n').filter(l => l.trim() && !l.toLowerCase().startsWith('name,'));
result = { online: lines.length, max: null };
// Use REST API instead of RCON for Palworld
const data = await getPalworldPlayers(server);
result = { online: data.players?.length || 0, max: null };
}
playerCache.set(cacheKey, { data: result, time: Date.now() });
@@ -151,15 +168,9 @@ export async function getPlayerList(server) {
const lines = response.split('\n').filter(l => l.trim() && !l.includes('listusers'));
players = lines.map(l => l.trim()).filter(p => p);
} else if (server.type === 'palworld') {
const response = await sendRconCommand(server, 'ShowPlayers');
// Format: "name,playeruid,steamid\nPlayer1,123,765...\nPlayer2,456,765..."
const lines = response.split('\n').filter(l => l.trim() && !l.toLowerCase().startsWith('name,'));
for (const line of lines) {
const parts = line.split(',');
if (parts.length >= 1 && parts[0].trim()) {
players.push(parts[0].trim());
}
}
// Use REST API instead of RCON for Palworld
const data = await getPalworldPlayers(server);
players = (data.players || []).map(p => p.name);
}
const result = { players };

View File

@@ -192,7 +192,12 @@ export async function getConsoleLog(server, lines = 50) {
const result = await ssh.execCommand(`/usr/local/bin/docker-logs-tz ${server.containerName} ${lines}`);
return result.stdout || result.stderr;
} else if (server.runtime === 'systemd') {
const result = await ssh.execCommand(`tail -n ${lines} ${server.workDir}/logs/VRisingServer.log 2>/dev/null || journalctl -u ${server.serviceName} -n ${lines} --no-pager`);
let cmd = `tail -n ${lines} ${server.workDir}/logs/VRisingServer.log 2>/dev/null || journalctl -u ${server.serviceName} -n ${lines} --no-pager`;
// Filter out REST API spam for Palworld
if (server.type === 'palworld') {
cmd = `journalctl -u ${server.serviceName} -n ${lines * 2} --no-pager | grep -v "REST accessed endpoint" | tail -n ${lines}`;
}
const result = await ssh.execCommand(cmd);
return result.stdout || result.stderr;
} else if (server.runtime === 'pm2') {
const nvmPrefix = "source ~/.nvm/nvm.sh && ";