Settings for the server are now combined with the settings from the SDK. This introduces a large breaking change and a migration should be created. This refactor utilizes .NET Configuration and the Options pattern. This will allow for the overriding of any setting using envionment variables. It also means that Settings.yml can be used to override any .NET configuration. A SettingsProvider implementation was created, and any updating of settings was changed from SettingsService.SaveSettings() to SettingsProvider.Update(s => { ... })
61 lines
1.8 KiB
Text
61 lines
1.8 KiB
Text
@page "/Settings/IPXRelay"
|
|
@using LANCommander.Server.Settings
|
|
@using Microsoft.Extensions.Options
|
|
@inject IPXRelayService IPXRelayService
|
|
@inject IMessageService MessageService
|
|
@inject ILogger<IPXRelay> Logger
|
|
@inject IOptions<Settings> Settings
|
|
@inject SettingsProvider<Settings> SettingsProvider
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
|
|
|
<PageHeader Title="IPX Relay" />
|
|
|
|
<PageContent>
|
|
<Form Model="Settings.Value" Layout="@FormLayout.Vertical">
|
|
<FormItem Label="Enable">
|
|
<Switch @bind-Checked="context.Server.IPXRelay.Enabled" />
|
|
</FormItem>
|
|
|
|
<FormItem Label="Host">
|
|
<Text Type="@TextElementType.Secondary">Use this to customize the host that is broadcasted to clients.</Text>
|
|
<Input @bind-Value="context.Server.IPXRelay.Host" />
|
|
</FormItem>
|
|
|
|
<FormItem Label="Port">
|
|
<AntDesign.InputNumber @bind-Value="context.Server.IPXRelay.Port" Max="65535" />
|
|
</FormItem>
|
|
|
|
<FormItem Label="Logging">
|
|
<Switch @bind-Checked="context.Server.IPXRelay.Logging" />
|
|
</FormItem>
|
|
|
|
<FormItem>
|
|
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
|
|
</FormItem>
|
|
</Form>
|
|
</PageContent>
|
|
|
|
@code {
|
|
|
|
async Task Save()
|
|
{
|
|
try
|
|
{
|
|
SettingsProvider.Update(s =>
|
|
{
|
|
s.Server.IPXRelay = Settings.Value.Server.IPXRelay;
|
|
});
|
|
|
|
MessageService.Success("Settings saved!");
|
|
|
|
await IPXRelayService.StopAsync();
|
|
|
|
IPXRelayService.Init(Logger);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageService.Error("An unknown error occurred.");
|
|
Logger.LogError(ex, "An unknown error occurred.");
|
|
}
|
|
}
|
|
}
|