Web panel (like txAdmin) on the game port: login/roles/users, players, kick/ban/op, bans, live console, world reset/backups/restore, settings editor, save ZIP upload/download, start/stop/restart; in-process restart loop; tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,18 @@ public sealed class ServerConfig
|
||||
/// <summary>Admins (SteamID64): dürfen im Spiel mit /admin Spieler kicken und bannen.</summary>
|
||||
public List<string> Admins { get; set; } = new();
|
||||
|
||||
// ---------------------------------------------------------------- Web-Panel (wie txAdmin)
|
||||
/// <summary>Web-Panel einschalten.</summary>
|
||||
public bool PanelEnabled { get; set; } = true;
|
||||
/// <summary>0 = derselbe Port wie der Gameserver (Browser und Spiel werden automatisch unterschieden), sonst eigener Port.</summary>
|
||||
public int PanelPort { get; set; } = 0;
|
||||
/// <summary>Nur bei eigenem PanelPort: Adresse, auf der gelauscht wird ("0.0.0.0" = alle, "127.0.0.1" = nur lokal, z.B. hinter einem Proxy).</summary>
|
||||
public string PanelBindAddress { get; set; } = "0.0.0.0";
|
||||
/// <summary>Hinter einem Reverse-Proxy: X-Forwarded-For/-Proto/-Prefix übernehmen (echte IP, HTTPS, Unterpfad).</summary>
|
||||
public bool PanelTrustProxy { get; set; } = false;
|
||||
/// <summary>Unterpfad, unter dem das Panel läuft, z.B. "/panel" (leer = direkt unter /).</summary>
|
||||
public string PanelBasePath { get; set; } = "";
|
||||
|
||||
static readonly JsonSerializerOptions Options = new() { WriteIndented = true };
|
||||
|
||||
public static ServerConfig LoadOrCreate(string path, out bool created)
|
||||
@@ -58,9 +70,14 @@ public sealed class ServerConfig
|
||||
/// MSCO_PUBLIC_ADDRESS, MSCO_STEAM_WEB_API_KEY (die Master-Adresse ist fest, siehe MasterServer)
|
||||
/// </summary>
|
||||
/// <returns>Namen der gesetzten Umgebungsvariablen (fürs Log, damit klar ist, woher ein Wert kommt).</returns>
|
||||
/// <summary>Per Umgebungsvariable gesetzte Einstellungen (nicht in server.json gespeichert).</summary>
|
||||
[System.Text.Json.Serialization.JsonIgnore]
|
||||
public List<string> EnvironmentOverrides { get; private set; } = new();
|
||||
|
||||
public List<string> ApplyEnvironment()
|
||||
{
|
||||
var used = new List<string>();
|
||||
EnvironmentOverrides = used;
|
||||
string Take(string name, string current)
|
||||
{
|
||||
string value = Env(name);
|
||||
@@ -78,6 +95,11 @@ public sealed class ServerConfig
|
||||
if (int.TryParse(Env("MSCO_MAX_PLAYERS"), out int max)) { MaxPlayers = max; used.Add("MSCO_MAX_PLAYERS"); }
|
||||
if (bool.TryParse(Env("MSCO_PUBLIC"), out bool isPublic)) { Public = isPublic; used.Add("MSCO_PUBLIC"); }
|
||||
if (bool.TryParse(Env("MSCO_REQUIRE_STEAM"), out bool requireSteam)) { RequireSteam = requireSteam; used.Add("MSCO_REQUIRE_STEAM"); }
|
||||
if (bool.TryParse(Env("MSCO_PANEL_ENABLED"), out bool panel)) { PanelEnabled = panel; used.Add("MSCO_PANEL_ENABLED"); }
|
||||
if (int.TryParse(Env("MSCO_PANEL_PORT"), out int panelPort)) { PanelPort = panelPort; used.Add("MSCO_PANEL_PORT"); }
|
||||
if (bool.TryParse(Env("MSCO_PANEL_TRUST_PROXY"), out bool trustProxy)) { PanelTrustProxy = trustProxy; used.Add("MSCO_PANEL_TRUST_PROXY"); }
|
||||
PanelBindAddress = Take("MSCO_PANEL_BIND", PanelBindAddress);
|
||||
PanelBasePath = Take("MSCO_PANEL_BASE_PATH", PanelBasePath);
|
||||
return used;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user