diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs index b97517d0f7..6b99878466 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Prometheus; @@ -28,9 +29,9 @@ namespace Tgstation.Server.Host.Components.Watchdog sealed class PosixWatchdog : AdvancedWatchdog { /// - /// The for the . + /// The of for the . /// - readonly GeneralConfiguration generalConfiguration; + readonly IOptionsMonitor generalConfigurationOptions; /// /// Initializes a new instance of the class. @@ -48,10 +49,10 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The for the . /// The pointing to the game directory for the .. /// The for the . + /// The value of . /// The for the . /// The for the . /// The for the . - /// The value of . /// The autostart value for the . public PosixWatchdog( IChatManager chat, @@ -67,10 +68,10 @@ namespace Tgstation.Server.Host.Components.Watchdog IMetricFactory metricFactory, IIOManager gameIOManager, IFilesystemLinkFactory linkFactory, + IOptionsMonitor generalConfigurationOptions, ILogger logger, DreamDaemonLaunchParameters initialLaunchParameters, Api.Models.Instance instance, - GeneralConfiguration generalConfiguration, bool autoStart) : base( chat, @@ -91,7 +92,7 @@ namespace Tgstation.Server.Host.Components.Watchdog instance, autoStart) { - this.generalConfiguration = generalConfiguration ?? throw new ArgumentNullException(nameof(generalConfiguration)); + this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); } /// @@ -100,6 +101,12 @@ namespace Tgstation.Server.Host.Components.Watchdog /// protected override SwappableDmbProvider CreateSwappableDmbProvider(IDmbProvider dmbProvider) - => new HardLinkDmbProvider(dmbProvider, GameIOManager, LinkFactory, Logger, generalConfiguration, ActiveLaunchParameters.SecurityLevel!.Value); + => new HardLinkDmbProvider( + dmbProvider, + GameIOManager, + LinkFactory, + Logger, + generalConfigurationOptions.CurrentValue, + ActiveLaunchParameters.SecurityLevel!.Value); } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs index 23539d34ac..19f7344089 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs @@ -34,14 +34,14 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The for the . /// The for the . /// The for the . - /// The for for the . + /// The of for the . public PosixWatchdogFactory( IServerControl serverControl, ILoggerFactory loggerFactory, IJobManager jobManager, IAsyncDelayer asyncDelayer, IFilesystemLinkFactory linkFactory, - IOptions generalConfigurationOptions) + IOptionsMonitor generalConfigurationOptions) : base( serverControl, loggerFactory, @@ -79,10 +79,10 @@ namespace Tgstation.Server.Host.Components.Watchdog metricFactory, gameIOManager, LinkFactory, + GeneralConfigurationOptions, LoggerFactory.CreateLogger(), settings, instance, - GeneralConfiguration, settings.AutoStart ?? throw new ArgumentNullException(nameof(settings))); } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs index d052001900..c2fd1c981e 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs @@ -43,9 +43,9 @@ namespace Tgstation.Server.Host.Components.Watchdog protected IAsyncDelayer AsyncDelayer { get; } /// - /// The for the . + /// The of for the . /// - protected GeneralConfiguration GeneralConfiguration { get; } + protected IOptionsMonitor GeneralConfigurationOptions { get; } /// /// Initializes a new instance of the class. @@ -54,19 +54,19 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The value of . /// The value of . /// The value of . - /// The containing the value of . + /// The containing the value of . public WatchdogFactory( IServerControl serverControl, ILoggerFactory loggerFactory, IJobManager jobManager, IAsyncDelayer asyncDelayer, - IOptions generalConfigurationOptions) + IOptionsMonitor generalConfigurationOptions) { ServerControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory)); JobManager = jobManager ?? throw new ArgumentNullException(nameof(jobManager)); AsyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); - GeneralConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); + GeneralConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); } /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs index 5639219021..7f41d39ef7 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs @@ -37,14 +37,14 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The for the . /// The for the . /// The value of . - /// The for for the . + /// The for for the . public WindowsWatchdogFactory( IServerControl serverControl, ILoggerFactory loggerFactory, IJobManager jobManager, IAsyncDelayer asyncDelayer, IFilesystemLinkFactory symlinkFactory, - IOptions generalConfigurationOptions) + IOptionsMonitor generalConfigurationOptions) : base( serverControl, loggerFactory, diff --git a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs index b886f40feb..1b9b20f198 100644 --- a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs +++ b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs @@ -21,7 +21,6 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.System; -using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Controllers @@ -54,14 +53,9 @@ namespace Tgstation.Server.Host.Controllers readonly IPlatformIdentifier platformIdentifier; /// - /// The for the . + /// The for the . /// - readonly IFileTransferTicketProvider fileTransferService; - - /// - /// The for the . - /// - readonly FileLoggingConfiguration fileLoggingConfiguration; + readonly IOptions fileLoggingConfigurationOptions; /// /// Initializes a new instance of the class. @@ -74,8 +68,7 @@ namespace Tgstation.Server.Host.Controllers /// The value of . /// The value of . /// The value of . - /// The value of . - /// The containing value of . + /// The containing value of . public AdministrationController( IDatabaseContext databaseContext, IAuthenticationContext authenticationContext, @@ -85,7 +78,6 @@ namespace Tgstation.Server.Host.Controllers IAssemblyInformationProvider assemblyInformationProvider, IIOManager ioManager, IPlatformIdentifier platformIdentifier, - IFileTransferTicketProvider fileTransferService, IOptions fileLoggingConfigurationOptions) : base( databaseContext, @@ -98,8 +90,7 @@ namespace Tgstation.Server.Host.Controllers this.assemblyInformationProvider = assemblyInformationProvider ?? throw new ArgumentNullException(nameof(assemblyInformationProvider)); this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier)); - this.fileTransferService = fileTransferService ?? throw new ArgumentNullException(nameof(fileTransferService)); - fileLoggingConfiguration = fileLoggingConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(fileLoggingConfigurationOptions)); + this.fileLoggingConfigurationOptions = fileLoggingConfigurationOptions ?? throw new ArgumentNullException(nameof(fileLoggingConfigurationOptions)); } /// @@ -185,7 +176,7 @@ namespace Tgstation.Server.Host.Controllers => Paginated( async () => { - var path = fileLoggingConfiguration.GetFullLogDirectory(ioManager, assemblyInformationProvider, platformIdentifier); + var path = fileLoggingConfigurationOptions.Value.GetFullLogDirectory(ioManager, assemblyInformationProvider, platformIdentifier); try { var files = await ioManager.GetFiles(path, cancellationToken); diff --git a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs index d7dd5c092a..148f5bbc7b 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs @@ -65,14 +65,14 @@ namespace Tgstation.Server.Host.Controllers readonly IRestAuthorityInvoker loginAuthority; /// - /// The for the . + /// The of for the . /// - readonly GeneralConfiguration generalConfiguration; + readonly IOptionsSnapshot generalConfigurationOptions; /// - /// The for the . + /// The of for the . /// - readonly SecurityConfiguration securityConfiguration; + readonly IOptionsSnapshot securityConfigurationOptions; /// /// Initializes a new instance of the class. @@ -84,8 +84,8 @@ namespace Tgstation.Server.Host.Controllers /// The value of . /// The value of . /// The value of . - /// The containing the value of . - /// The containing the value of . + /// The value of . + /// The value of . /// The for the . /// The for the . /// The value of . @@ -97,7 +97,7 @@ namespace Tgstation.Server.Host.Controllers IPlatformIdentifier platformIdentifier, ISwarmService swarmService, IServerControl serverControl, - IOptions generalConfigurationOptions, + IOptionsSnapshot generalConfigurationOptions, IOptionsSnapshot securityConfigurationOptions, ILogger logger, IApiHeadersProvider apiHeadersProvider, @@ -114,8 +114,8 @@ namespace Tgstation.Server.Host.Controllers this.oAuthProviders = oAuthProviders ?? throw new ArgumentNullException(nameof(oAuthProviders)); this.swarmService = swarmService ?? throw new ArgumentNullException(nameof(swarmService)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); - generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); - securityConfiguration = securityConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(securityConfigurationOptions)); + this.generalConfigurationOptions = generalConfigurationOptions ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); + this.securityConfigurationOptions = securityConfigurationOptions ?? throw new ArgumentNullException(nameof(securityConfigurationOptions)); this.loginAuthority = loginAuthority ?? throw new ArgumentNullException(nameof(loginAuthority)); } @@ -157,20 +157,20 @@ namespace Tgstation.Server.Host.Controllers Version = assemblyInformationProvider.Version, ApiVersion = ApiHeaders.Version, DMApiVersion = DMApiConstants.InteropVersion, - MinimumPasswordLength = generalConfiguration.MinimumPasswordLength, - InstanceLimit = generalConfiguration.InstanceLimit, - UserLimit = generalConfiguration.UserLimit, - UserGroupLimit = generalConfiguration.UserGroupLimit, - ValidInstancePaths = generalConfiguration.ValidInstancePaths, + MinimumPasswordLength = generalConfigurationOptions.Value.MinimumPasswordLength, + InstanceLimit = generalConfigurationOptions.Value.InstanceLimit, + UserLimit = generalConfigurationOptions.Value.UserLimit, + UserGroupLimit = generalConfigurationOptions.Value.UserGroupLimit, + ValidInstancePaths = generalConfigurationOptions.Value.ValidInstancePaths, WindowsHost = platformIdentifier.IsWindows, SwarmServers = swarmService .GetSwarmServers() ?.Select(swarmServerInfo => new SwarmServerResponse(swarmServerInfo)) .ToList(), OAuthProviderInfos = oAuthProviders.ProviderInfos(), - OidcProviderInfos = securityConfiguration.OidcProviderInfos().ToList(), + OidcProviderInfos = securityConfigurationOptions.Value.OidcProviderInfos().ToList(), UpdateInProgress = serverControl.UpdateInProgress, - OidcStrictMode = securityConfiguration.OidcStrictMode, + OidcStrictMode = securityConfigurationOptions.Value.OidcStrictMode, }); } diff --git a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs index ec763dd955..2a89fcd33f 100644 --- a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs +++ b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs @@ -45,29 +45,29 @@ namespace Tgstation.Server.Host.Controllers /// readonly IWebHostEnvironment hostEnvironment; + /// + /// The for the . + /// + readonly IOptionsSnapshot controlPanelConfigurationOptions; + /// /// The for the . /// readonly ILogger logger; - /// - /// The for the . - /// - readonly ControlPanelConfiguration controlPanelConfiguration; - /// /// Initializes a new instance of the class. /// /// The value of . - /// The containing the value of . + /// The value of . /// The value of . public ControlPanelController( IWebHostEnvironment hostEnvironment, - IOptions controlPanelConfigurationOptions, + IOptionsSnapshot controlPanelConfigurationOptions, ILogger logger) { this.hostEnvironment = hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment)); - controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions)); + this.controlPanelConfigurationOptions = controlPanelConfigurationOptions ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); } @@ -79,13 +79,13 @@ namespace Tgstation.Server.Host.Controllers [HttpGet] public IActionResult GetChannelJson() { - if (!controlPanelConfiguration.Enable) + if (!controlPanelConfigurationOptions.Value.Enable) { logger.LogDebug("Not serving channel.json as control panel is disabled."); return NotFound(); } - var controlPanelChannel = controlPanelConfiguration.Channel; + var controlPanelChannel = controlPanelConfigurationOptions.Value.Channel; logger.LogTrace("Generating channel.json for channel \"{channel}\"...", controlPanelChannel); if (controlPanelChannel == "local") @@ -102,7 +102,7 @@ namespace Tgstation.Server.Host.Controllers { FormatVersion = 1, Channel = controlPanelChannel, - controlPanelConfiguration.PublicPath, + controlPanelConfigurationOptions.Value.PublicPath, }); } @@ -132,7 +132,7 @@ namespace Tgstation.Server.Host.Controllers [HttpGet] public IActionResult Get([FromRoute] string appRoute) { - if (!controlPanelConfiguration.Enable) + if (!controlPanelConfigurationOptions.Value.Enable) { logger.LogDebug("Not serving static files as control panel is disabled."); return NotFound();