-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from gardian12/master
bugfix for proxy crash and general optimizations added
- Loading branch information
Showing
9 changed files
with
303 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,67 @@ | ||
using System; | ||
using System.Windows.Forms; | ||
|
||
namespace KeePassNatMsgProxy | ||
{ | ||
class Proxy | ||
public class Proxy | ||
{ | ||
static void Main(string[] args) | ||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "<optimization>")] | ||
public static int Main(string[] args) | ||
{ | ||
// check if we're running under Mono | ||
var t = Type.GetType("Mono.Runtime"); | ||
|
||
if (t == null) | ||
if (args.Length == 0) | ||
{ | ||
// not Mono, assume Windows | ||
var proxy = new PipeProxy(); | ||
proxy.Run(); | ||
DialogResult result = MessageBox.Show("No arguments received.", nameof(KeePassNatMsgProxy) + " Info"); | ||
|
||
// Set exit code of application | ||
return 1; | ||
} | ||
else | ||
{ | ||
if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) | ||
string msg = ""; | ||
|
||
foreach (string item in args) | ||
{ | ||
msg = msg + "\n" + item; | ||
} | ||
|
||
#if DEBUG | ||
DialogResult result = MessageBox.Show("Attention: " + nameof(KeePassNatMsgProxy) + " runs in DEBUG mode.\n" + | ||
"\n" + | ||
"Arguments: " + msg, | ||
nameof(KeePassNatMsgProxy) + " Info"); | ||
#endif | ||
} | ||
|
||
|
||
// check if we're running under Mono | ||
var t = Type.GetType("Mono.Runtime"); | ||
|
||
try | ||
{ | ||
if (t == null) | ||
{ | ||
var proxy = new UnixSocketProxy(); | ||
// not Mono, assume Windows | ||
var proxy = new PipeProxy(); | ||
proxy.Run(); | ||
|
||
} | ||
else | ||
{ | ||
if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) | ||
{ | ||
var proxy = new UnixSocketProxy(); | ||
proxy.Run(); | ||
|
||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
DialogResult result = MessageBox.Show(ex.Message, nameof(KeePassNatMsgProxy) + " Error"); | ||
} | ||
|
||
// Set exit code of application | ||
return 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.