瀏覽代碼

Increased kestrel default limits and added option to change the moonlight defaults

Marcel Baumgartner 1 年之前
父節點
當前提交
0234a8e179
共有 2 個文件被更改,包括 21 次插入1 次删除
  1. 9 0
      Moonlight/Core/Configuration/CoreConfiguration.cs
  2. 12 1
      Moonlight/Core/CoreFeature.cs

+ 9 - 0
Moonlight/Core/Configuration/CoreConfiguration.cs

@@ -39,6 +39,15 @@ public class CoreConfiguration
         [Description("Specifies the location of the key .pem file to load")]
         [Description("Specifies the location of the key .pem file to load")]
         [JsonProperty("KeyPath")]
         [JsonProperty("KeyPath")]
         public string KeyPath { get; set; } = "";
         public string KeyPath { get; set; } = "";
+
+        [Description("Specifies the file upload limit per http request in megabytes")]
+        [JsonProperty("UploadLimit")]
+        public int UploadLimit { get; set; } = 100;
+
+        [Description(
+            "Specifies the maximum message size moonlight can receive via the websocket connection in kilobytes")]
+        [JsonProperty("MessageSizeLimit")]
+        public int MessageSizeLimit { get; set; } = 1024;
     }
     }
     
     
     public class DatabaseData
     public class DatabaseData

+ 12 - 1
Moonlight/Core/CoreFeature.cs

@@ -64,15 +64,26 @@ public class CoreFeature : MoonlightFeature
         
         
         // Add external services and blazor/asp.net stuff
         // Add external services and blazor/asp.net stuff
         builder.Services.AddRazorPages();
         builder.Services.AddRazorPages();
-        builder.Services.AddServerSideBlazor();
         builder.Services.AddHttpContextAccessor();
         builder.Services.AddHttpContextAccessor();
         builder.Services.AddControllers();
         builder.Services.AddControllers();
         builder.Services.AddBlazorTable();
         builder.Services.AddBlazorTable();
+        
+        // Configure blazor pipeline in detail
+        builder.Services.AddServerSideBlazor().AddHubOptions(options =>
+        {
+            options.MaximumReceiveMessageSize = ByteSizeValue.FromKiloBytes(config.Http.MessageSizeLimit).Bytes;
+        });
 
 
         // Setup authentication if required
         // Setup authentication if required
         if (config.Authentication.UseDefaultAuthentication)
         if (config.Authentication.UseDefaultAuthentication)
             builder.Services.AddScoped<IAuthenticationProvider, DefaultAuthenticationProvider>();
             builder.Services.AddScoped<IAuthenticationProvider, DefaultAuthenticationProvider>();
         
         
+        // Setup http upload limit
+        context.Builder.WebHost.ConfigureKestrel(options =>
+        {
+            options.Limits.MaxRequestBodySize = ByteSizeValue.FromMegaBytes(config.Http.UploadLimit).Bytes;
+        });
+        
         // Assets
         // Assets
         
         
         // - Javascript
         // - Javascript