Added built-in IPX relay for DOSBox

dhcp-server
Pat Hartl 2023-09-08 22:26:28 -05:00
parent 6483bea96b
commit 329c147419
5 changed files with 105 additions and 0 deletions

View File

@ -32,6 +32,7 @@
<PackageReference Include="Hangfire.Core" Version="1.8.5" />
<PackageReference Include="Hangfire.InMemory" Version="0.5.1" />
<PackageReference Include="IGDB" Version="2.3.2" />
<PackageReference Include="IPXRelayDotNet" Version="1.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.10" />

View File

@ -16,6 +16,7 @@
public LANCommanderTheme Theme { get; set; } = LANCommanderTheme.Light;
public LANCommanderAuthenticationSettings Authentication { get; set; } = new LANCommanderAuthenticationSettings();
public LANCommanderIPXRelaySettings IPXRelay { get; set; } = new LANCommanderIPXRelaySettings();
}
public class LANCommanderAuthenticationSettings
@ -29,4 +30,11 @@
public bool PasswordRequireDigit { get; set; } = true;
public int PasswordRequiredLength { get; set; } = 8;
}
public class LANCommanderIPXRelaySettings
{
public bool Enabled { get; set; } = false;
public int Port { get; set; } = 213;
public bool Logging { get; set; } = false;
}
}

View File

@ -0,0 +1,53 @@
@page "/Settings/IPXRelay"
@using LANCommander.Models;
@layout SettingsLayout
@inject SettingService SettingService
@inject IPXRelayService IPXRelayService
@inject IMessageService MessageService
@attribute [Authorize(Roles = "Administrator")]
<PageHeader Title="IPX Relay" />
<div style="padding: 0 24px;">
<Form Model="Settings" Layout="@FormLayout.Vertical">
<FormItem Label="Enable">
<Switch @bind-Checked="context.IPXRelay.Enabled" />
</FormItem>
<FormItem Label="Port">
<AntDesign.InputNumber @bind-Value="Settings.IPXRelay.Port" Max="65535" />
</FormItem>
<FormItem Label="Logging">
<Switch @bind-Checked="context.IPXRelay.Logging" />
</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!");
IPXRelayService.Init();
}
catch
{
MessageService.Error("An unknown error occurred.");
}
}
}

View File

@ -8,6 +8,7 @@
<MenuItem RouterLink="/Settings/General">General</MenuItem>
<MenuItem RouterLink="/Settings/Users">Users</MenuItem>
<MenuItem RouterLink="/Settings/Authentication">Authentication</MenuItem>
<MenuItem RouterLink="/Settings/IPXRelay">IPX Relay</MenuItem>
<MenuItem RouterLink="/Settings/Tools" RouterMatch="@NavLinkMatch.Prefix">Tools</MenuItem>
</Menu>
</Sider>

View File

@ -0,0 +1,42 @@
using IPXRelayDotNet;
namespace LANCommander.Services
{
public class IPXRelayService : BaseService
{
private IPXRelay Relay;
public IPXRelayService()
{
if (Relay == null)
Relay = new IPXRelay();
Init();
}
public void Init()
{
var settings = SettingService.GetSettings();
if (Relay != null)
Stop();
if (Relay == null)
Relay = new IPXRelay(settings.IPXRelay.Port);
if (!settings.IPXRelay.Logging)
Relay.DisableLogging();
if (settings.IPXRelay.Enabled)
Relay.StartAsync();
}
public void Stop()
{
if (Relay != null)
Relay.Dispose();
Relay = null;
}
}
}