Paralleles WebGUI mit Kestrel, Token-Sicherung und SSE-Logs implementiert
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -20,6 +20,8 @@ using PolyTrader.Modules.Supervisor;
|
||||
using PolyTraderSharp;
|
||||
using PolyTraderSharp.Models;
|
||||
using PolyTraderSharp.Services;
|
||||
using PolyTrader.Web.Configuration;
|
||||
using PolyTrader.Web.Hosting;
|
||||
|
||||
namespace PolyTrader.App.Avalonia
|
||||
{
|
||||
@@ -166,6 +168,22 @@ namespace PolyTrader.App.Avalonia
|
||||
return config["Database:MySqlConnectionString"] ?? string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lädt die WebUI-Konfiguration (Port, LocalOnly, AuthToken) aus den Konfigurationsdateien.
|
||||
/// </summary>
|
||||
internal static WebUiOptions LoadWebUiOptions()
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.SetBasePath(AppContext.BaseDirectory)
|
||||
.AddJsonFile("appsettings.json", optional: true)
|
||||
.AddJsonFile("appsettings.Local.json", optional: true)
|
||||
.Build();
|
||||
|
||||
var options = new WebUiOptions();
|
||||
config.GetSection(WebUiOptions.SectionName).Bind(options);
|
||||
return options;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Baut den Anwendungs-Host: Konfiguration, Master-Key, Persistenz, Core-Dienste und die
|
||||
/// aktiven Module. Kennt die Oberfläche nicht.
|
||||
@@ -235,6 +253,25 @@ namespace PolyTrader.App.Avalonia
|
||||
|
||||
var modules = allModules.Where(m => !disabled.Contains(m.Name)).ToList();
|
||||
|
||||
var webOptions = LoadWebUiOptions();
|
||||
if (!enforceLicense)
|
||||
{
|
||||
// Bei Konstruktionsprüfung (--smoke-ui) kein Kestrel starten
|
||||
webOptions.Enabled = false;
|
||||
}
|
||||
|
||||
if (webOptions.Enabled)
|
||||
{
|
||||
string bind = webOptions.LocalOnly ? "127.0.0.1 (nur lokal)" : "0.0.0.0 (Netzwerk/VPN)";
|
||||
logger.Info($"🌐 WebGUI aktiv auf Port {webOptions.Port} [{bind}].");
|
||||
if (string.IsNullOrWhiteSpace(webOptions.AuthToken))
|
||||
logger.Warning("⚠️ WebGUI: Kein Zugangs-Token gesetzt – Zugriff ist vollständig gesperrt.");
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Info("🌐 WebGUI deaktiviert (WebUi:Enabled = false).");
|
||||
}
|
||||
|
||||
return Host.CreateDefaultBuilder()
|
||||
.UseContentRoot(AppContext.BaseDirectory)
|
||||
.ConfigureAppConfiguration((_, config) =>
|
||||
@@ -242,6 +279,7 @@ namespace PolyTrader.App.Avalonia
|
||||
.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddSingleton(dcOptions);
|
||||
services.AddSingleton(webOptions);
|
||||
var databaseOptions = new DatabaseOptions
|
||||
{
|
||||
MySqlConnectionString = context.Configuration["Database:MySqlConnectionString"] ?? string.Empty
|
||||
@@ -306,6 +344,7 @@ namespace PolyTrader.App.Avalonia
|
||||
// Shell-Zustand (Fensterverwaltung). Auch im kopflosen Betrieb harmlos.
|
||||
services.AddSingleton<AvaloniaUiHost>();
|
||||
})
|
||||
.ConfigurePolyTraderWeb(webOptions)
|
||||
.Build();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user