make the version name match the actual name for FTP deployment

fix rare issue with summing session scores
copy font to expected wwwroot dir in debug mode so we get pretty icons when developing
upgrade some packages

pretty much reworked the entire server web config to support better validation and stuff.. not really a small fix

finish web configuration changes (I think)

finish up configuration changes and update shared library nuget
This commit is contained in:
RaidMax
2020-01-17 17:31:53 -06:00
parent 3a1cfba251
commit 697a752be0
38 changed files with 531 additions and 200 deletions

View File

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
@ -13,32 +13,39 @@ namespace WebfrontCore.Middleware
/// </summary>
internal sealed class IPWhitelist
{
private readonly List<byte[]> whitelistedIps;
private readonly RequestDelegate nextRequest;
private readonly byte[][] _whitelistedIps;
private readonly RequestDelegate _nextRequest;
private readonly ILogger _logger;
/// <summary>
/// constructor
/// </summary>
/// <param name="nextRequest"></param>
/// <param name="logger"></param>
/// <param name="whitelistedIps">list of textual ip addresses</param>
public IPWhitelist(RequestDelegate nextRequest, ILogger<IPWhitelist> logger, List<string> whitelistedIps)
public IPWhitelist(RequestDelegate nextRequest, ILogger logger, string[] whitelistedIps)
{
this.whitelistedIps = whitelistedIps.Select(_ip => System.Net.IPAddress.Parse(_ip).GetAddressBytes()).ToList();
this.nextRequest = nextRequest;
_whitelistedIps = whitelistedIps.Select(_ip => System.Net.IPAddress.Parse(_ip).GetAddressBytes()).ToArray();
_nextRequest = nextRequest;
_logger = logger;
}
public async Task Invoke(HttpContext context)
{
bool isAlllowed = whitelistedIps.Any(_ip => _ip.SequenceEqual(context.Connection.RemoteIpAddress.GetAddressBytes()));
bool isAlllowed = true;
if (_whitelistedIps.Length > 0)
{
isAlllowed = _whitelistedIps.Any(_ip => _ip.SequenceEqual(context.Connection.RemoteIpAddress.GetAddressBytes()));
}
if (isAlllowed)
{
await nextRequest.Invoke(context);
await _nextRequest.Invoke(context);
}
else
{
_logger.WriteInfo($"Blocking HTTP request from {context.Connection.RemoteIpAddress.ToString()}");
context.Abort();
}
}