diff --git a/MelonVPNCore/DaemonSocketServer.cs b/MelonVPNCore/DaemonSocketServer.cs index bd59923..8289d98 100644 --- a/MelonVPNCore/DaemonSocketServer.cs +++ b/MelonVPNCore/DaemonSocketServer.cs @@ -26,17 +26,18 @@ namespace MelonVPNCore public static void StartServer() { + if (File.Exists(daemonConfigPath)) config = DaemonConfig.FromJson(File.ReadAllText(daemonConfigPath)); + else config = new DaemonConfig(); + IPHostEntry host = Dns.GetHostEntry("localhost"); IPAddress ipAddress = host.AddressList[0]; IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 22035); - if (File.Exists(daemonConfigPath)) config = DaemonConfig.FromJson(File.ReadAllText(daemonConfigPath)); - else config = new DaemonConfig(); - try { Socket listener = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); listener.Bind(localEndPoint); + listener.Listen(32); string lastClientUpdate = Messages.EOF; @@ -63,12 +64,14 @@ namespace MelonVPNCore else if (data == Messages.RestartOnMsg) { shouldRestart = true; + config.ShouldRestart = true; SaveConfig(); Client.SendDataMessage(DataMessage.RestartOn, true); } else if (data == Messages.RestartOffMsg) { shouldRestart = false; + config.ShouldRestart = false; SaveConfig(); Client.SendDataMessage(DataMessage.RestartOff, true); } diff --git a/MelonVPNCore/Json.cs b/MelonVPNCore/Json.cs index 43ab1e2..6ffa0b0 100644 --- a/MelonVPNCore/Json.cs +++ b/MelonVPNCore/Json.cs @@ -75,6 +75,6 @@ namespace MelonVPNCore public DaemonConfig() => Type = "DaemonConfig"; [JsonProperty("restart")] - public string ShouldRestart { get; set; } + public bool ShouldRestart { get; set; } } }