-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathProgram.cs
More file actions
75 lines (66 loc) · 2.21 KB
/
Program.cs
File metadata and controls
75 lines (66 loc) · 2.21 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
using PRMasterServer.Data;
using PRMasterServer.Servers;
using System;
using System.Globalization;
using System.Net;
using System.Threading;
namespace PRMasterServer
{
class Program
{
private static readonly object _lock = new object();
static void Main(string[] args)
{
Action<string, string> log = (category, message) => {
lock (_lock) {
Log(String.Format("[{0}] {1}", category, message));
}
};
Action<string, string> logError = (category, message) => {
lock (_lock) {
LogError(String.Format("[{0}] {1}", category, message));
}
};
IPAddress bind = IPAddress.Any;
if (args.Length >= 1) {
for (int i = 0; i < args.Length; i++) {
if (args[i].Equals("+bind")) {
if ((i >= args.Length - 1) || !IPAddress.TryParse(args[i + 1], out bind)) {
LogError("+bind value must be a valid IP Address to bind to!");
}
} else if (args[i].Equals("+db")) {
if ((i >= args.Length - 1)) {
LogError("+db value must be a path to the database");
} else {
LoginDatabase.Initialize(args[i + 1], log, logError);
}
}
}
}
if (!LoginDatabase.IsInitialized()) {
LogError("Error initializing database, please confirm parameter +db is valid");
LogError("Press any key to continue");
Console.ReadKey();
return;
}
CDKeyServer cdKeyServer = new CDKeyServer(bind, 29910, log, logError);
ServerListReport serverListReport = new ServerListReport(bind, 27900, log, logError);
ServerListRetrieve serverListRetrieve = new ServerListRetrieve(bind, 28910, serverListReport, log, logError);
LoginServer loginServer = new LoginServer(bind, 29900, 29901, log, logError);
while (true) {
Thread.Sleep(1000);
}
}
private static void Log(string message)
{
Console.WriteLine(String.Format("[{0}] {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), message));
}
private static void LogError(string message)
{
ConsoleColor c = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.WriteLine(String.Format("[{0}] {1}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture), message));
Console.ForegroundColor = c;
}
}
}