whitelist fixes, grpc stream fixes

This commit is contained in:
Stanley Dimant
2022-10-20 23:08:46 +02:00
parent e3e07fe117
commit 8164d737bf
5 changed files with 29 additions and 12 deletions

View File

@@ -176,7 +176,13 @@ public class SecretKeyAuthenticationHandler
this.metrics = metrics;
var config = configuration.GetRequiredSection("MareSynchronos");
_failedAttemptsForTempBan = config.GetValue<int>("FailedAuthForTempBan", 5);
logger.LogInformation("FailedAuthForTempBan: {num}", _failedAttemptsForTempBan);
_tempBanMinutes = config.GetValue<int>("TempBanDurationInMinutes", 30);
_whitelistedIps = config.GetValue<List<string>>("WhitelistedIps", new List<string>());
logger.LogInformation("TempBanMinutes: {num}", _tempBanMinutes);
_whitelistedIps = config.GetSection("WhitelistedIps").Get<List<string>>();
foreach (var ip in _whitelistedIps)
{
logger.LogInformation("Whitelisted IP: " + ip);
}
}
}

View File

@@ -72,7 +72,7 @@ internal class IdentityService : IdentificationService.IdentificationServiceBase
_handler.RegisterServerForQueue(server.ServerId);
_logger.LogInformation("Registered Server " + server.ServerId + " input stream");
while (await requestStream.MoveNext().ConfigureAwait(false))
while (await requestStream.MoveNext(context.CancellationToken).ConfigureAwait(false))
{
var cur = requestStream.Current.IdentChange;
if (cur == null) throw new System.Exception("Expected client ident change");

View File

@@ -44,11 +44,11 @@ public class Startup
MetricsAPI.GaugeUsersRegistered
}));
services.AddTransient(_ => Configuration);
services.AddSingleton<SecretKeyAuthenticationHandler>();
services.AddSingleton<DiscordBotServices>();
services.AddSingleton<IdentityHandler>();
services.AddSingleton<CleanupService>();
services.AddTransient(_ => Configuration);
services.AddHostedService(provider => provider.GetService<CleanupService>());
services.AddHostedService<DiscordBot>();
services.AddGrpc();