Add more json settings fields for daemon.

This commit is contained in:
Captain ALM 2021-03-26 09:02:05 +00:00
parent b488b29d45
commit 20c88c027c
2 changed files with 11 additions and 5 deletions

View File

@ -13,8 +13,8 @@ namespace MelonVPNCore
private static Process currentVpnProcess;
private static bool shouldBeRunning;
private static bool isRestarting;
private const int startingTime = 3000;
private const int restartDelay = 250;
private const int dstartingTime = 3000;
private const int drestartDelay = 250;
private static DaemonConfig config;
public const string daemonConfigPath = "/etc/melon-vpn/daemon.cfg";
@ -194,7 +194,7 @@ namespace MelonVPNCore
Console.WriteLine("Restarting embedded process");
currentVpnProcess.Dispose();
currentVpnProcess = null;
Thread.Sleep(restartDelay);
Thread.Sleep((config.restartDelay < drestartDelay) ? drestartDelay : config.restartDelay);
bool imonline = false;
isRestarting = true;
while (config.ShouldRestart && shouldBeRunning)
@ -213,7 +213,7 @@ namespace MelonVPNCore
{
currentVpnProcess.Dispose();
currentVpnProcess = null;
Thread.Sleep(restartDelay);
Thread.Sleep((config.restartDelay < drestartDelay) ? drestartDelay : config.restartDelay);
}
}
isRestarting = false;
@ -239,7 +239,7 @@ namespace MelonVPNCore
};
currentVpnProcess.Exited += CurrentVpnProcess_Exited;
currentVpnProcess.Start();
Thread.Sleep(startingTime);
Thread.Sleep((config.StartingTime < dstartingTime) ? dstartingTime : config.StartingTime);
return !currentVpnProcess.HasExited;
}
catch (Exception e)

View File

@ -76,5 +76,11 @@ namespace MelonVPNCore
[JsonProperty("restart")]
public bool ShouldRestart { get; set; }
[JsonProperty("starting_time")]
public int StartingTime { get; set; }
[JsonProperty("restart_delay")]
public int restartDelay { get; set; }
}
}