-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
77 lines (64 loc) · 2.69 KB
/
Program.cs
File metadata and controls
77 lines (64 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Threading;
namespace SmartChain.Web
{
public class Program
{
public static string client_version = "1";
public static ManualResetEvent shutdown_Event = new ManualResetEvent(false);
public static int language { get; set; } = 1;
public static JArray listen_urls = new JArray();
public static int listen_port = 80;
public static void Main(string[] args)
{
IConfigurationRoot config;
config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables()
.Build();
// route all unhandled exceptions to the logger
AppDomain currentDomain = AppDomain.CurrentDomain;
BuildWebHost(args, config).RunAsync();
// setup logging
shutdown_Event.Reset();
shutdown_Event.WaitOne();
}
private static void OpenBrowser(string ip)
{
System.Diagnostics.Process.Start("cmd", "/C start " + ip);
}
public static IWebHost BuildWebHost(string[] args, IConfiguration config) =>
WebHost.CreateDefaultBuilder(args)
// swithc to easy turn off kestral to enable chrome debugging
#if !DEBUG
.UseKestrel(
options =>
{
options.AddServerHeader = false;
// if SSL is to be used, make sure we listen on SSL port 443 and use our SSL cert.
foreach (JObject listen in listen_urls)
{
if ((bool)listen["SSL"] && useSSL)
options.Listen(IPAddress.Parse(listen["listen_url"].ToString()), (int)listen["listen_port"], listenOptions => { listenOptions.UseHttps(cert); });
else
options.Listen(IPAddress.Parse(listen["listen_url"].ToString()), (int)listen["listen_port"]);
}
}
)
#endif
// set the port non-ssl requests will be forwarded to, if we are using SSL
.UseSetting("https_port", "443")
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
// not used due to kestral setting listen urls/ports
//.UseElectron(args)
.UseStartup<Startup>()
//.UseSetting("https_port", "8080")
.Build();
}
}