Allow customization of the address that gets broadcast by the beacon
parent
fd3f6c24b1
commit
8c61a7e3b5
|
@ -40,7 +40,10 @@ namespace LANCommander.PlaynitePlugin.Views
|
||||||
{
|
{
|
||||||
var beacon = beacons.First();
|
var beacon = beacons.First();
|
||||||
|
|
||||||
Context.ServerAddress = $"http://{beacon.Address.Address}:{beacon.Address.Port}";
|
if (!String.IsNullOrWhiteSpace(beacon.Data) && Uri.TryCreate(beacon.Data, UriKind.Absolute, out var beaconUri))
|
||||||
|
Context.ServerAddress = beaconUri.ToString();
|
||||||
|
else
|
||||||
|
Context.ServerAddress = $"http://{beacon.Address.Address}:{beacon.Address.Port}";
|
||||||
|
|
||||||
this.ServerAddress.Text = Context.ServerAddress;
|
this.ServerAddress.Text = Context.ServerAddress;
|
||||||
|
|
||||||
|
|
|
@ -9,18 +9,24 @@
|
||||||
public class LANCommanderSettings
|
public class LANCommanderSettings
|
||||||
{
|
{
|
||||||
public int Port { get; set; } = 1337;
|
public int Port { get; set; } = 1337;
|
||||||
public bool Beacon { get; set; } = true;
|
|
||||||
public string DatabaseConnectionString { get; set; } = "Data Source=LANCommander.db;Cache=Shared";
|
public string DatabaseConnectionString { get; set; } = "Data Source=LANCommander.db;Cache=Shared";
|
||||||
public string IGDBClientId { get; set; } = "";
|
public string IGDBClientId { get; set; } = "";
|
||||||
public string IGDBClientSecret { get; set; } = "";
|
public string IGDBClientSecret { get; set; } = "";
|
||||||
public LANCommanderTheme Theme { get; set; } = LANCommanderTheme.Light;
|
public LANCommanderTheme Theme { get; set; } = LANCommanderTheme.Light;
|
||||||
|
|
||||||
|
public LANCommanderBeaconSettings Beacon { get; set; } = new LANCommanderBeaconSettings();
|
||||||
public LANCommanderAuthenticationSettings Authentication { get; set; } = new LANCommanderAuthenticationSettings();
|
public LANCommanderAuthenticationSettings Authentication { get; set; } = new LANCommanderAuthenticationSettings();
|
||||||
public LANCommanderUserSaveSettings UserSaves { get; set; } = new LANCommanderUserSaveSettings();
|
public LANCommanderUserSaveSettings UserSaves { get; set; } = new LANCommanderUserSaveSettings();
|
||||||
public LANCommanderArchiveSettings Archives { get; set; } = new LANCommanderArchiveSettings();
|
public LANCommanderArchiveSettings Archives { get; set; } = new LANCommanderArchiveSettings();
|
||||||
public LANCommanderIPXRelaySettings IPXRelay { get; set; } = new LANCommanderIPXRelaySettings();
|
public LANCommanderIPXRelaySettings IPXRelay { get; set; } = new LANCommanderIPXRelaySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class LANCommanderBeaconSettings
|
||||||
|
{
|
||||||
|
public bool Enabled { get; set; } = true;
|
||||||
|
public string Address { get; set; } = "";
|
||||||
|
}
|
||||||
|
|
||||||
public class LANCommanderAuthenticationSettings
|
public class LANCommanderAuthenticationSettings
|
||||||
{
|
{
|
||||||
public bool RequireApproval { get; set; } = false;
|
public bool RequireApproval { get; set; } = false;
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
@page "/Settings/Beacon"
|
||||||
|
@using LANCommander.Models;
|
||||||
|
@layout SettingsLayout
|
||||||
|
@inject SettingService SettingService
|
||||||
|
@inject IPXRelayService IPXRelayService
|
||||||
|
@inject IMessageService MessageService
|
||||||
|
@attribute [Authorize(Roles = "Administrator")]
|
||||||
|
|
||||||
|
<PageHeader Title="Beacon" />
|
||||||
|
|
||||||
|
<div style="padding: 0 24px;">
|
||||||
|
<Form Model="Settings" Layout="@FormLayout.Vertical">
|
||||||
|
<FormItem Label="Enable">
|
||||||
|
<Text Type="@TextElementType.Secondary">Enabling the beacon will allow clients on the same network to auto-discover the LANCommander address.</Text>
|
||||||
|
<Switch @bind-Checked="context.Beacon.Enabled" />
|
||||||
|
</FormItem>
|
||||||
|
|
||||||
|
<FormItem Label="Address">
|
||||||
|
<Text Type="@TextElementType.Secondary">Use this to customize the address that is broadcasted to clients. Default: http://<Server IP>:@context.Port</Text>
|
||||||
|
<Input @bind-Value="Settings.Beacon.Address" />
|
||||||
|
</FormItem>
|
||||||
|
|
||||||
|
<FormItem>
|
||||||
|
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
|
||||||
|
</FormItem>
|
||||||
|
</Form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
LANCommanderSettings Settings;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
Settings = SettingService.GetSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Save()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SettingService.SaveSettings(Settings);
|
||||||
|
MessageService.Success("Settings saved!");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageService.Error("An unknown error occurred.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,12 +12,6 @@
|
||||||
|
|
||||||
<div style="padding: 0 24px;">
|
<div style="padding: 0 24px;">
|
||||||
<Form Model="Settings" Layout="@FormLayout.Vertical">
|
<Form Model="Settings" Layout="@FormLayout.Vertical">
|
||||||
<FormItem Label="Beacon">
|
|
||||||
<Switch @bind-Checked="context.Beacon" />
|
|
||||||
</FormItem>
|
|
||||||
|
|
||||||
<Text Type="@TextElementType.Secondary">Enabling the beacon will allow clients on the same network to auto-discover the LANCommander address.</Text>
|
|
||||||
|
|
||||||
<FormItem Label="Theme">
|
<FormItem Label="Theme">
|
||||||
<Select @bind-Value="context.Theme" TItem="LANCommanderTheme" TItemValue="LANCommanderTheme" DataSource="Enum.GetValues<LANCommanderTheme>()">
|
<Select @bind-Value="context.Theme" TItem="LANCommanderTheme" TItemValue="LANCommanderTheme" DataSource="Enum.GetValues<LANCommanderTheme>()">
|
||||||
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
|
<LabelTemplate Context="Value">@Value.GetDisplayName()</LabelTemplate>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<MenuItem RouterLink="/Settings/UserSaves">User Saves</MenuItem>
|
<MenuItem RouterLink="/Settings/UserSaves">User Saves</MenuItem>
|
||||||
<MenuItem RouterLink="/Settings/Archives">Archives</MenuItem>
|
<MenuItem RouterLink="/Settings/Archives">Archives</MenuItem>
|
||||||
<MenuItem RouterLink="/Settings/IPXRelay">IPX Relay</MenuItem>
|
<MenuItem RouterLink="/Settings/IPXRelay">IPX Relay</MenuItem>
|
||||||
|
<MenuItem RouterLink="/Settings/Beacon">Beacon</MenuItem>
|
||||||
<MenuItem RouterLink="/Settings/Tools" RouterMatch="@NavLinkMatch.Prefix">Tools</MenuItem>
|
<MenuItem RouterLink="/Settings/Tools" RouterMatch="@NavLinkMatch.Prefix">Tools</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
</Sider>
|
</Sider>
|
||||||
|
|
|
@ -146,7 +146,7 @@ namespace LANCommander
|
||||||
builder.Services.AddSingleton<ServerProcessService>();
|
builder.Services.AddSingleton<ServerProcessService>();
|
||||||
builder.Services.AddSingleton<IPXRelayService>();
|
builder.Services.AddSingleton<IPXRelayService>();
|
||||||
|
|
||||||
if (settings.Beacon)
|
if (settings.Beacon?.Enabled ?? false)
|
||||||
{
|
{
|
||||||
Logger.Debug("The beacons have been lit! LANCommander calls for players!");
|
Logger.Debug("The beacons have been lit! LANCommander calls for players!");
|
||||||
builder.Services.AddHostedService<BeaconService>();
|
builder.Services.AddHostedService<BeaconService>();
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace LANCommander.Services
|
||||||
|
|
||||||
public Task StartAsync(CancellationToken cancellationToken)
|
public Task StartAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
Beacon.BeaconData = "Acknowledged HQ";
|
Beacon.BeaconData = Settings.Beacon?.Address;
|
||||||
Beacon.Start();
|
Beacon.Start();
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
Loading…
Reference in New Issue