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 => { ... })
21 lines
No EOL
833 B
C#
21 lines
No EOL
833 B
C#
using System.Net;
|
|
using LANCommander.SDK.Interceptors;
|
|
using LANCommander.SDK.Models;
|
|
|
|
namespace LANCommander.Server.Services.Interceptors;
|
|
|
|
public class BeaconMessageInterceptor(SettingsProvider<Settings.Settings> settingsProvider) : IBeaconMessageInterceptor
|
|
{
|
|
public async Task<BeaconMessage> ExecuteAsync(BeaconMessage message, IPEndPoint interfaceEndPoint)
|
|
{
|
|
if (String.IsNullOrWhiteSpace(message.Address))
|
|
{
|
|
if (settingsProvider.CurrentValue.Server.Http.UseSSL)
|
|
message.Address = $"https://{interfaceEndPoint.Address.ToString()}:{settingsProvider.CurrentValue.Server.Http.SSLPort}";
|
|
else
|
|
message.Address = $"http://{interfaceEndPoint.Address.ToString()}:{settingsProvider.CurrentValue.Server.Http.Port}";
|
|
}
|
|
|
|
return message;
|
|
}
|
|
} |