2023-09-08 22:26:28 -05:00
|
|
|
|
using IPXRelayDotNet;
|
2024-10-07 18:04:26 -05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2023-09-08 22:26:28 -05:00
|
|
|
|
|
2024-08-04 18:44:33 -05:00
|
|
|
|
namespace LANCommander.Server.Services
|
2023-09-08 22:26:28 -05:00
|
|
|
|
{
|
|
|
|
|
|
public class IPXRelayService : BaseService
|
|
|
|
|
|
{
|
|
|
|
|
|
private IPXRelay Relay;
|
|
|
|
|
|
|
2024-08-28 20:33:59 -05:00
|
|
|
|
public IPXRelayService(ILogger<IPXRelayService> logger) : base(logger)
|
2023-09-08 22:26:28 -05:00
|
|
|
|
{
|
|
|
|
|
|
if (Relay == null)
|
|
|
|
|
|
Relay = new IPXRelay();
|
|
|
|
|
|
|
|
|
|
|
|
Init();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Relay != null)
|
|
|
|
|
|
Stop();
|
|
|
|
|
|
|
|
|
|
|
|
if (Relay == null)
|
2024-08-28 20:44:14 -05:00
|
|
|
|
Relay = new IPXRelay(Settings.IPXRelay.Port);
|
2023-09-08 22:26:28 -05:00
|
|
|
|
|
2024-08-28 20:44:14 -05:00
|
|
|
|
if (!Settings.IPXRelay.Logging)
|
2023-09-08 22:26:28 -05:00
|
|
|
|
Relay.DisableLogging();
|
|
|
|
|
|
|
2024-08-28 20:44:14 -05:00
|
|
|
|
if (Settings.IPXRelay.Enabled)
|
2023-09-08 22:26:28 -05:00
|
|
|
|
Relay.StartAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Relay != null)
|
|
|
|
|
|
Relay.Dispose();
|
|
|
|
|
|
|
|
|
|
|
|
Relay = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|