-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProxy.cs
61 lines (52 loc) · 1.72 KB
/
Proxy.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
using System;
namespace KeePassNatMsgProxy
{
public class Proxy
{
private const string EnableLog = "/log";
private static LogWriter _log;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<optimization>")]
public static int Main(string[] args)
{
ProxyBase proxy = null;
var enableLog = args.Length == 1 && EnableLog.Equals(args[0], StringComparison.OrdinalIgnoreCase);
if (enableLog)
{
_log = new LogWriter();
}
// check if we're running under Mono
var t = Type.GetType("Mono.Runtime");
try
{
if (t == null)
{
// not Mono, assume Windows
proxy = new PipeProxy();
}
else
{
if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX)
{
proxy = new UnixSocketProxy();
}
}
if (proxy != null)
{
proxy.Log = _log;
proxy.Run();
}
else
{
_log?.Write($"Unable to create proxy. Platform: {Environment.OSVersion.Platform}");
}
}
catch (Exception ex)
{
_log?.Write($"{nameof(KeePassNatMsgProxy)} Error: {ex}");
}
_log?.Close();
// Set exit code of application
return 0;
}
}
}