Fix restarting status stating online.

This commit is contained in:
Captain ALM 2021-03-19 18:51:50 +00:00
parent b59d2727f3
commit 499d86bed3

View File

@ -12,6 +12,7 @@ namespace MelonVPNCore
private static Process currentVpnProcess = null;
private static bool shouldBeRunning = false;
private static bool shouldRestart = false;
private static bool isRestarting = false;
private static int startingTime = 3000;
private static int restartDelay = 250;
@ -63,11 +64,20 @@ namespace MelonVPNCore
{
Console.WriteLine("Status requested");
if (isProcessOnline(currentVpnProcess) || shouldBeRunning)
{
if (isRestarting)
{
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
{
Console.WriteLine("Sending response: offline");
@ -190,6 +200,7 @@ namespace MelonVPNCore
currentVpnProcess = null;
Thread.Sleep(restartDelay);
bool imonline = false;
isRestarting = true;
while (shouldRestart && shouldBeRunning)
{
Console.WriteLine("Sending restarting reply");
@ -209,6 +220,7 @@ namespace MelonVPNCore
Thread.Sleep(restartDelay);
}
}
isRestarting = false;
if (! imonline)
{
shouldBeRunning = false;