Fix saving and reading daemon config
This commit is contained in:
parent
b05cce4fd7
commit
ec0c46a3a8
@ -12,7 +12,6 @@ namespace MelonVPNCore
|
|||||||
{
|
{
|
||||||
private static Process currentVpnProcess;
|
private static Process currentVpnProcess;
|
||||||
private static bool shouldBeRunning;
|
private static bool shouldBeRunning;
|
||||||
private static bool shouldRestart;
|
|
||||||
private static bool isRestarting;
|
private static bool isRestarting;
|
||||||
private const int startingTime = 3000;
|
private const int startingTime = 3000;
|
||||||
private const int restartDelay = 250;
|
private const int restartDelay = 250;
|
||||||
@ -63,14 +62,14 @@ namespace MelonVPNCore
|
|||||||
}
|
}
|
||||||
else if (data == Messages.RestartOnMsg)
|
else if (data == Messages.RestartOnMsg)
|
||||||
{
|
{
|
||||||
shouldRestart = true;
|
Console.WriteLine("Updated shouldRestart to true");
|
||||||
config.ShouldRestart = true;
|
config.ShouldRestart = true;
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
Client.SendDataMessage(DataMessage.RestartOn, true);
|
Client.SendDataMessage(DataMessage.RestartOn, true);
|
||||||
}
|
}
|
||||||
else if (data == Messages.RestartOffMsg)
|
else if (data == Messages.RestartOffMsg)
|
||||||
{
|
{
|
||||||
shouldRestart = false;
|
Console.WriteLine("Updated shouldRestart to false");
|
||||||
config.ShouldRestart = false;
|
config.ShouldRestart = false;
|
||||||
SaveConfig();
|
SaveConfig();
|
||||||
Client.SendDataMessage(DataMessage.RestartOff, true);
|
Client.SendDataMessage(DataMessage.RestartOff, true);
|
||||||
@ -99,7 +98,7 @@ namespace MelonVPNCore
|
|||||||
Client.SendDataMessage(DataMessage.Offline, true);
|
Client.SendDataMessage(DataMessage.Offline, true);
|
||||||
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
Client.SendCustomMessage(Messages.ClientListEmptyMsg, true);
|
||||||
}
|
}
|
||||||
Client.SendDataMessage((shouldRestart) ? DataMessage.RestartOn : DataMessage.RestartOff);
|
Client.SendDataMessage(config.ShouldRestart ? DataMessage.RestartOn : DataMessage.RestartOff);
|
||||||
}
|
}
|
||||||
else if (data == Messages.StartMsg)
|
else if (data == Messages.StartMsg)
|
||||||
{
|
{
|
||||||
@ -198,7 +197,7 @@ namespace MelonVPNCore
|
|||||||
Thread.Sleep(restartDelay);
|
Thread.Sleep(restartDelay);
|
||||||
bool imonline = false;
|
bool imonline = false;
|
||||||
isRestarting = true;
|
isRestarting = true;
|
||||||
while (shouldRestart && shouldBeRunning)
|
while (config.ShouldRestart && shouldBeRunning)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Sending restarting reply");
|
Console.WriteLine("Sending restarting reply");
|
||||||
Client.SendDataMessage(DataMessage.Restarting, true);
|
Client.SendDataMessage(DataMessage.Restarting, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user