diff --git a/Application/Game/Server/GetDataQuery.cs b/Application/Game/Server/GetDataQuery.cs index 2fbe74b..84b2e8d 100644 --- a/Application/Game/Server/GetDataQuery.cs +++ b/Application/Game/Server/GetDataQuery.cs @@ -4,7 +4,7 @@ using MediatR; namespace Application.Game.Server; -public record GetDataQuery(string Host) : IRequest; +public record GetDataQuery(string Host, string Scheme) : IRequest; public class GetDataQueryHandler : IRequestHandler { @@ -23,9 +23,8 @@ public class GetDataQueryHandler : IRequestHandler { return Task.FromResult(response); } - - var host = request.Host; - var urlBase = $"http://{host}/events/"; + + var urlBase = $"{request.Scheme}://{request.Host}/events/"; var dataString = new StringBuilder(); var events = eventManagerService.GetEvents(); var count = 0; diff --git a/Infrastructure/Common/CertificateService.cs b/Infrastructure/Common/CertificateService.cs index a547911..55244a3 100644 --- a/Infrastructure/Common/CertificateService.cs +++ b/Infrastructure/Common/CertificateService.cs @@ -289,7 +289,14 @@ public class CertificateService { logger.LogInformation("Certificate CN={CommonName} found!", commonName); - return result.First(); + var cert = result.First(); + var extensions = cert.Extensions; + if (extensions.Select(extension => extension.Oid).Any(oid => oid?.Value == OidLookup.ServerAuthentication.Value)) + { + return cert; + } + logger.LogInformation("Certificate CN={CommonName} does not include server authentication!", commonName); + return null; } store.Close(); diff --git a/MainServer/.gitignore b/MainServer/.gitignore index de92be8..ca7f8b0 100644 --- a/MainServer/.gitignore +++ b/MainServer/.gitignore @@ -439,4 +439,4 @@ FodyWeavers.xsd /db/card.db3 Certificates wwwroot/events/ -Database/* +Database/card*.db3 diff --git a/MainServer/Controllers/Game/ServerController.cs b/MainServer/Controllers/Game/ServerController.cs index bb4bdb5..8757b9f 100644 --- a/MainServer/Controllers/Game/ServerController.cs +++ b/MainServer/Controllers/Game/ServerController.cs @@ -35,7 +35,7 @@ public class ServerController : BaseController [HttpGet("data.php")] public async Task> GetData() { - var query = new GetDataQuery(Request.Host.Value); + var query = new GetDataQuery(Request.Host.Value, Request.Scheme); return Ok(await Mediator.Send(query)); } } \ No newline at end of file diff --git a/MainServer/Database/music.db3 b/MainServer/Database/music.db3 new file mode 100644 index 0000000..2067cc6 Binary files /dev/null and b/MainServer/Database/music.db3 differ diff --git a/MainServer/Database/music471.db3 b/MainServer/Database/music471.db3 new file mode 100644 index 0000000..ac72003 Binary files /dev/null and b/MainServer/Database/music471.db3 differ diff --git a/MainServer/Database/music471omni.db3 b/MainServer/Database/music471omni.db3 new file mode 100644 index 0000000..a2eaa50 Binary files /dev/null and b/MainServer/Database/music471omni.db3 differ diff --git a/MainServer/Database/music4MAX.db3 b/MainServer/Database/music4MAX.db3 new file mode 100644 index 0000000..ae22243 Binary files /dev/null and b/MainServer/Database/music4MAX.db3 differ diff --git a/MainServer/Database/music4MAX465.db3 b/MainServer/Database/music4MAX465.db3 new file mode 100644 index 0000000..39e6a3d Binary files /dev/null and b/MainServer/Database/music4MAX465.db3 differ diff --git a/MainServer/MainServer.csproj b/MainServer/MainServer.csproj index b0f561c..db3c256 100644 --- a/MainServer/MainServer.csproj +++ b/MainServer/MainServer.csproj @@ -10,40 +10,71 @@ - - + + - all - runtime; build; native; contentfiles; analyzers; buildtransitive + all + runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + - - - - - - - - - - + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + + + PreserveNewest + true + - + - - + + + diff --git a/MainServer/Program.cs b/MainServer/Program.cs index d493464..1cc9870 100644 --- a/MainServer/Program.cs +++ b/MainServer/Program.cs @@ -6,6 +6,7 @@ using Infrastructure; using Infrastructure.Common; using Infrastructure.Persistence; using MainServer.Filters; +using Microsoft.AspNetCore.StaticFiles; using Microsoft.EntityFrameworkCore; using Serilog; using Serilog.Extensions.Logging; @@ -92,8 +93,16 @@ try app.UseSwaggerUI(); } - // app.UseExceptionHandler(); - app.UseStaticFiles(); + // Add content type for .cmp and .evt files as static files with unknown file extensions return 404 by default + // See https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-7.0#fileextensioncontenttypeprovider + // ReSharper disable once UseObjectOrCollectionInitializer + var provider = new FileExtensionContentTypeProvider(); + provider.Mappings[".cmp"] = "text/plain"; + provider.Mappings[".evt"] = "text/plain"; + app.UseStaticFiles(new StaticFileOptions + { + ContentTypeProvider = provider + }); app.MapControllers();