diff --git a/MelonVPNClient/gtk-gui/gui.stetic b/MelonVPNClient/gtk-gui/gui.stetic
index eefdfbd..d430d8e 100644
--- a/MelonVPNClient/gtk-gui/gui.stetic
+++ b/MelonVPNClient/gtk-gui/gui.stetic
@@ -4,9 +4,8 @@
..
-
-
+
diff --git a/MelonVPNCore/DaemonSocketServer.cs b/MelonVPNCore/DaemonSocketServer.cs
index 698dc5c..942e8b4 100644
--- a/MelonVPNCore/DaemonSocketServer.cs
+++ b/MelonVPNCore/DaemonSocketServer.cs
@@ -44,7 +44,7 @@ namespace MelonVPNCore
if (data.IndexOf(Messages.EOF, StringComparison.CurrentCulture) > -1) break;
}
- if (data.StartsWith(Messages.ClientListStartMsg, StringComparison.CurrentCulture))
+ if (data.StartsWith(Messages.ClientListStartMsg, StringComparison.CurrentCulture) && shouldBeRunning)
{
lastClientUpdate = data;
Client.SendCustomMessage(lastClientUpdate, true);
@@ -91,6 +91,13 @@ namespace MelonVPNCore
{
Console.WriteLine("Sending online reply");
Client.SendDataMessage(DataMessage.Online, true);
+ currentVpnProcess.EnableRaisingEvents = true;
+ }
+ else
+ {
+ shouldBeRunning = false;
+ Client.SendDataMessage(DataMessage.Offline, true);
+ Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
}
}
catch (Exception e)
@@ -178,12 +185,12 @@ namespace MelonVPNCore
static void CurrentVpnProcess_Exited(object sender, EventArgs e)
{
- Client.SendDataMessage(DataMessage.Restarting, true);
Console.WriteLine("Restarting embedded process");
currentVpnProcess.Dispose();
currentVpnProcess = null;
Thread.Sleep(restartDelay);
- if (shouldRestart)
+ bool imonline = false;
+ while (shouldRestart && shouldBeRunning)
{
Console.WriteLine("Sending restarting reply");
Client.SendDataMessage(DataMessage.Restarting, true);
@@ -191,10 +198,21 @@ namespace MelonVPNCore
{
Console.WriteLine("Sending online reply");
Client.SendDataMessage(DataMessage.Online, true);
+ currentVpnProcess.EnableRaisingEvents = true;
+ imonline = true;
+ break;
+ }
+ else
+ {
+ currentVpnProcess.Dispose();
+ currentVpnProcess = null;
+ Thread.Sleep(restartDelay);
}
}
- else
+ if (! imonline)
{
+ shouldBeRunning = false;
+ Console.WriteLine("Sending offline reply");
Client.SendDataMessage(DataMessage.Offline, true);
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
}
@@ -209,7 +227,7 @@ namespace MelonVPNCore
currentVpnProcess = new Process
{
StartInfo = new ProcessStartInfo("simple-vpn", "client /etc/melon-vpn/client.cfg"),
- EnableRaisingEvents = true
+ EnableRaisingEvents = false
};
currentVpnProcess.Exited += CurrentVpnProcess_Exited;
currentVpnProcess.Start();