Panel: warn before changing the game/panel port (needs a full program restart, Docker port mapping, how to undo) so nobody locks themselves out

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nico Meister
2026-09-29 19:26:31 +02:00
co-authored by Claude Opus 5.5
parent 1ff37065d0
commit ad2dac21ba
4 changed files with 58 additions and 4 deletions
+9 -2
View File
@@ -24,7 +24,9 @@ public static class ConfigEditor
panelBasePath = config.PanelBasePath,
licenseKeySet = !string.IsNullOrWhiteSpace(config.LicenseKey),
steamWebApiKeySet = !string.IsNullOrWhiteSpace(config.SteamWebApiKey),
environmentOverrides = config.EnvironmentOverrides
environmentOverrides = config.EnvironmentOverrides,
// In Docker muss ein anderer Port zusätzlich in docker-compose.yml freigegeben werden (Warnung im Panel)
inDocker = Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER") == "true"
};
/// <summary>Einstellungen ändern. Schlüssel (Lizenz, Steam Web API) nur als Owner; leer = unverändert.</summary>
@@ -69,6 +71,7 @@ public static class ConfigEditor
config.AutosaveSeconds = Number("autosaveSeconds", config.AutosaveSeconds, 10, 3600);
int before = changed.Count;
int oldPort = config.Port, oldPanelPort = config.PanelPort;
config.Port = Number("port", config.Port, 1, 65535);
config.PanelEnabled = Flag("panelEnabled", config.PanelEnabled);
config.PanelPort = Number("panelPort", config.PanelPort, 0, 65535);
@@ -76,6 +79,8 @@ public static class ConfigEditor
config.PanelTrustProxy = Flag("panelTrustProxy", config.PanelTrustProxy);
config.PanelBasePath = Text("panelBasePath", config.PanelBasePath, 60);
if (changed.Count > before) restartNeeded = true;
// Ports gehören dem Programm, nicht dem Gameserver: "Restart" im Panel reicht dafür nicht
bool portChanged = config.Port != oldPort || config.PanelPort != oldPanelPort;
foreach (string secret in new[] { "licenseKey", "steamWebApiKey" })
{
@@ -93,7 +98,9 @@ public static class ConfigEditor
catch (Exception e) { return "Could not save server.json: " + e.Message; }
GameServer.Log($"Settings changed by {by}: {string.Join(", ", changed)}");
var overridden = changed.Where(c => config.EnvironmentOverrides.Any(e => e.Replace("_", "").Contains(c.ToUpperInvariant().Replace("ISPUBLIC", "PUBLIC")))).ToList();
return "Settings saved" + (restartNeeded ? " - some changes need a restart" : "") +
return "Settings saved" +
(portChanged ? " - the new port only applies after the whole program restarts (docker compose restart); in Docker publish it in docker-compose.yml first"
: restartNeeded ? " - some changes need a restart" : "") +
(overridden.Count > 0 ? " (note: " + string.Join(", ", overridden) + " is also set by an environment variable, which wins on restart)" : "");
}
}