diff --git a/.github/workflows/pull-web-client.yml b/.github/workflows/pull-web-client.yml index ef7b105c..8ccdc2dc 100644 --- a/.github/workflows/pull-web-client.yml +++ b/.github/workflows/pull-web-client.yml @@ -8,6 +8,7 @@ on: type: string required: true destination-branch: + description: 'Destination branch for the pull-request' type: choice options: - develop diff --git a/MacroDeck.Server/Controllers/WebSocketController.cs b/MacroDeck.Server/Controllers/WebSocketController.cs index 137720b1..8ee7d242 100644 --- a/MacroDeck.Server/Controllers/WebSocketController.cs +++ b/MacroDeck.Server/Controllers/WebSocketController.cs @@ -5,18 +5,13 @@ namespace MacroDeck.Server.Controllers; public class WebSocketController : ControllerBase { - - public WebSocketController() - { - } - [Route("/")] [HttpGet] public async Task Get() { if (!HttpContext.WebSockets.IsWebSocketRequest) { - return Redirect("client"); + return Redirect("client/?auto-connect=true"); } using var webSocket = await HttpContext.WebSockets.AcceptWebSocketAsync(); diff --git a/MacroDeck.Server/MacroDeckServerHelper.cs b/MacroDeck.Server/MacroDeckServerHelper.cs index f0f87539..eefac47a 100644 --- a/MacroDeck.Server/MacroDeckServerHelper.cs +++ b/MacroDeck.Server/MacroDeckServerHelper.cs @@ -1,6 +1,7 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Hosting; using System.Security.Cryptography.X509Certificates; +using Microsoft.AspNetCore.Server.Kestrel.Core; namespace MacroDeck.Server; @@ -8,12 +9,16 @@ public static class MacroDeckServerHelper { private static IHost? _host; + internal static bool UseHttps { get; private set; } + public static async Task Setup(int port, bool enableSsl, string? certificatePath, string? certificatePassword) { if (_host is not null) { await _host.StopAsync(); } + + UseHttps = enableSsl && !string.IsNullOrWhiteSpace(certificatePath); _host = Host.CreateDefaultBuilder() .ConfigureWebHostDefaults(hostBuilder => @@ -21,11 +26,12 @@ public static async Task Setup(int port, bool enableSsl, string? certificatePath hostBuilder.UseStartup(); hostBuilder.ConfigureKestrel(options => { - if (enableSsl && !string.IsNullOrWhiteSpace(certificatePath)) + if (UseHttps) { options.ListenAnyIP(port, listenOptions => { listenOptions.UseHttps(new X509Certificate2(certificatePath, certificatePassword)); + listenOptions.Protocols = HttpProtocols.Http1; }); } else { diff --git a/MacroDeck.Server/Startup.cs b/MacroDeck.Server/Startup.cs index 4f413de8..668d7dfa 100644 --- a/MacroDeck.Server/Startup.cs +++ b/MacroDeck.Server/Startup.cs @@ -15,6 +15,10 @@ public void ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseCors("AllowAny"); + if (MacroDeckServerHelper.UseHttps) + { + app.UseHttpsRedirection(); + } app.UseFileServer(); app.UseWebSockets(new WebSocketOptions { diff --git a/MacroDeck.Setup/Macro Deck.iss b/MacroDeck.Setup/Macro Deck.iss index 561a922a..d2d80dff 100644 --- a/MacroDeck.Setup/Macro Deck.iss +++ b/MacroDeck.Setup/Macro Deck.iss @@ -93,7 +93,7 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ ; VC++ redistributable runtime. Extracted by VC2018RedistNeedsInstall(), if needed. Source: ".\Redist\VC_redist.x64.exe"; DestDir: {tmp}; Flags: dontcopy Source: ".\Android Debug Bridge\*"; DestDir: "{app}\Android Debug Bridge\"; Flags: ignoreversion -Source: "{#ApplicationDirectory}\*"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#ApplicationDirectory}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] diff --git a/MacroDeck.sln b/MacroDeck.sln index e2e52241..1bbcc047 100644 --- a/MacroDeck.sln +++ b/MacroDeck.sln @@ -9,8 +9,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MacroDeck.Tests", "MacroDec EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{A87511C0-A46B-40E0-A47A-81AEE2097F5D}" ProjectSection(SolutionItems) = preProject - .github\workflows\build-installer.yml = .github\workflows\build-installer.yml .github\workflows\tests.yml = .github\workflows\tests.yml + .github\workflows\build-push-windows.yml = .github\workflows\build-push-windows.yml + .github\workflows\ci.yml = .github\workflows\ci.yml + .github\workflows\create-release.yml = .github\workflows\create-release.yml + .github\workflows\release-created.yml = .github\workflows\release-created.yml + .github\workflows\pull-web-client.yml = .github\workflows\pull-web-client.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MacroDeck.Setup", "MacroDeck.Setup", "{8C1FC7A7-364F-4CE5-B59D-9A7EFC88CFDC}" diff --git a/MacroDeck/MacroDeck.csproj b/MacroDeck/MacroDeck.csproj index 5343a46f..88878ec9 100644 --- a/MacroDeck/MacroDeck.csproj +++ b/MacroDeck/MacroDeck.csproj @@ -34,6 +34,9 @@ Never + + Always + @@ -308,9 +311,6 @@ PublicSettingsSingleFileGenerator Settings.Designer.cs - - Always -