-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (48 loc) · 2.06 KB
/
Program.cs
File metadata and controls
59 lines (48 loc) · 2.06 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
using System.Net;
using System.Security.Cryptography.X509Certificates;
using Blaze2SDK;
using Blaze3SDK;
using NLog;
using NLog.Layouts;
using LogLevel = NLog.LogLevel;
namespace TheDirector;
internal class Program
{
public const string Name = "TheDirector 1.0";
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public static string PublicIp;
private static async Task Main(string[] args)
{
PublicIp = new HttpClient().GetStringAsync("https://checkip.amazonaws.com/").GetAwaiter().GetResult().Trim();
StartLogger();
var redirectorTaskSdk2 = StartRedirectorServerSdk2();
var redirectorTaskSdk3 = StartRedirectorServerSdk3();
Logger.Warn(Name + " started");
await Task.WhenAll(redirectorTaskSdk2, redirectorTaskSdk3);
}
private static void StartLogger()
{
var logLevel = LogLevel.Trace;
var layout = new SimpleLayout("[${longdate}][${callsite-filename:includeSourcePath=false}(${callsite-linenumber})][${level:uppercase=true}]: ${message:withexception=true}");
LogManager.Setup().LoadConfiguration(builder =>
{
builder.ForLogger().FilterMinLevel(logLevel)
.WriteToConsole(layout)
.WriteToFile("logs/server-${shortdate}.log", layout);
});
}
private static async Task StartRedirectorServerSdk2()
{
var redirector = Blaze2.CreateBlazeServer("RedirectorServer", new IPEndPoint(IPAddress.Any, 42100));
redirector.AddComponent<RedirectorComponent>();
await redirector.Start(-1).ConfigureAwait(false);
}
private static async Task StartRedirectorServerSdk3()
{
var certBytes = File.ReadAllBytes("gosredirector_mod.pfx");
X509Certificate cert = new X509Certificate2(certBytes, "123456");
var redirector = Blaze3.CreateBlazeServer("RedirectorServer", new IPEndPoint(IPAddress.Any, 42127), cert);
redirector.AddComponent<RedirectorComponent>();
await redirector.Start(-1).ConfigureAwait(false);
}
}