Fix restarting status stating online.

This commit is contained in:
Captain ALM 2021-03-19 18:51:50 +00:00
parent b59d2727f3
commit 499d86bed3
1 changed files with 15 additions and 3 deletions

View File

@ -12,6 +12,7 @@ namespace MelonVPNCore
private static Process currentVpnProcess = null; private static Process currentVpnProcess = null;
private static bool shouldBeRunning = false; private static bool shouldBeRunning = false;
private static bool shouldRestart = false; private static bool shouldRestart = false;
private static bool isRestarting = false;
private static int startingTime = 3000; private static int startingTime = 3000;
private static int restartDelay = 250; private static int restartDelay = 250;
@ -64,9 +65,18 @@ namespace MelonVPNCore
Console.WriteLine("Status requested"); Console.WriteLine("Status requested");
if (isProcessOnline(currentVpnProcess) || shouldBeRunning) if (isProcessOnline(currentVpnProcess) || shouldBeRunning)
{ {
Console.WriteLine("Sending response: online"); if (isRestarting)
Client.SendDataMessage(DataMessage.Online, true); {
Client.SendCustomMessage(lastClientUpdate, true); Console.WriteLine("Sending response: restarting");
Client.SendDataMessage(DataMessage.Restarting, true);
Client.SendCustomMessage(lastClientUpdate, true);
}
else
{
Console.WriteLine("Sending response: online");
Client.SendDataMessage(DataMessage.Online, true);
Client.SendCustomMessage(lastClientUpdate, true);
}
} }
else else
{ {
@ -190,6 +200,7 @@ namespace MelonVPNCore
currentVpnProcess = null; currentVpnProcess = null;
Thread.Sleep(restartDelay); Thread.Sleep(restartDelay);
bool imonline = false; bool imonline = false;
isRestarting = true;
while (shouldRestart && shouldBeRunning) while (shouldRestart && shouldBeRunning)
{ {
Console.WriteLine("Sending restarting reply"); Console.WriteLine("Sending restarting reply");
@ -209,6 +220,7 @@ namespace MelonVPNCore
Thread.Sleep(restartDelay); Thread.Sleep(restartDelay);
} }
} }
isRestarting = false;
if (! imonline) if (! imonline)
{ {
shouldBeRunning = false; shouldBeRunning = false;