Cap consumed-item reports per player (max 20/min); test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-27 16:31:54 +02:00
co-authored by Claude Opus 5.5
parent eac0ac046b
commit 9444ffa109
2 changed files with 8 additions and 0 deletions
+6
View File
@@ -30,6 +30,8 @@ public sealed class GameServer
/// <summary>SteamID von Steam bestätigt (Ticket per Web API geprüft). Nur dann gibt es Admin-Rechte.</summary>
public bool SteamVerified;
public bool IsAdmin;
public DateTime DestroyWindowStart;
public int DestroyCount;
/// <summary>
/// Ab wann die Position des Spielers gespeichert wird: erst nachdem er seinen Weltzustand (mit seiner letzten
/// Position) bekommen und sich dorthin gesetzt hat - sonst überschreibt der Startpunkt des Spielstands
@@ -79,6 +81,7 @@ public sealed class GameServer
const int KeepSaveBackups = 5;
/// <summary>So lange auf den hochgeladenen Spielstand warten, danach bekommen Wartende den gespeicherten.</summary>
public double SaveUploadTimeoutSeconds { get; set; } = 15;
const int MaxDestroyPerMinute = 20;
/// <summary>Ohne Master-Server (nur für automatische Tests): keine Heartbeats, keine Serverliste.</summary>
readonly bool offline;
@@ -410,6 +413,9 @@ public sealed class GameServer
break;
case MsgType.ObjDestroy:
if (m.Payload.Length != 4) return;
// Niemand isst/verbraucht 20 Dinge pro Minute - mehr ist ein Fehler (z.B. Szene entladen) oder Absicht
if (DateTime.UtcNow - c.DestroyWindowStart > TimeSpan.FromMinutes(1)) { c.DestroyWindowStart = DateTime.UtcNow; c.DestroyCount = 0; }
if (++c.DestroyCount > MaxDestroyPerMinute) return;
world.AddDestroyed(BitConverter.ToInt32(m.Payload, 0));
break;
case MsgType.Chat: