Add authentication and improve server side configuration

This commit is contained in:
Stone_Red
2025-12-23 14:53:44 +01:00
parent 5819432c36
commit 55f26b3a92
14 changed files with 292 additions and 34 deletions
@@ -1,22 +1,24 @@
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Options;
using RemoteExec.Server.Configuration;
using RemoteExec.Server.Hubs;
namespace RemoteExec.Server.Services;
public class MetricsBroadcastService(IHubContext<RemoteExecutionHub> hubContext, ILogger<MetricsBroadcastService> logger) : BackgroundService
public class MetricsBroadcastService(IHubContext<RemoteExecutionHub> hubContext, ILogger<MetricsBroadcastService> logger, IOptions<MetricsConfiguration> metricsOptions) : BackgroundService
{
private readonly TimeSpan _broadcastInterval = TimeSpan.FromMilliseconds(500);
private readonly TimeSpan broadcastInterval = TimeSpan.FromMilliseconds(metricsOptions.Value.BroadcastIntervalMs);
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
logger.LogInformation("Metrics broadcast service started");
logger.LogInformation("Metrics broadcast service started with interval {Interval}ms", broadcastInterval.TotalMilliseconds);
while (!stoppingToken.IsCancellationRequested)
{
try
{
await Task.Delay(_broadcastInterval, stoppingToken);
await Task.Delay(broadcastInterval, stoppingToken);
await RemoteExecutionHub.BroadcastMetricsAsync(hubContext);
}