wabbajack/Wabbajack.Server/Program.cs

39 lines
1.4 KiB
C#
Raw Normal View History

2021-10-23 16:51:17 +00:00
using System.Linq;
2020-05-09 13:04:38 +00:00
using System.Net;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.Server;
public class Program
2020-05-09 13:04:38 +00:00
{
2021-10-23 16:51:17 +00:00
public static void Main(string[] args)
{
var testMode = args.Contains("TESTMODE");
CreateHostBuilder(args, testMode).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args, bool testMode)
2020-05-09 13:04:38 +00:00
{
2021-10-23 16:51:17 +00:00
return Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
.UseKestrel(options =>
{
options.Listen(IPAddress.Any, testMode ? 8080 : 80);
if (!testMode)
options.Listen(IPAddress.Any, 443, listenOptions =>
2020-05-09 13:04:38 +00:00
{
2021-10-23 16:51:17 +00:00
using var store = new X509Store(StoreName.My);
store.Open(OpenFlags.ReadOnly);
var cert = store.Certificates.Find(X509FindType.FindBySubjectName,
"build.wabbajack.org", true)[0];
listenOptions.UseHttps(cert);
});
options.Limits.MaxRequestBodySize = null;
});
});
2020-05-09 13:04:38 +00:00
}
2021-10-23 16:51:17 +00:00
}