feat: remove v2ray config file when exit

This commit is contained in:
ChsBuffer
2020-10-12 21:56:53 +08:00
parent 3f1b21c4e5
commit 18b905ed0c
3 changed files with 11 additions and 20 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -283,6 +284,10 @@ namespace Netch.Forms
}
Configuration.Save();
if (File.Exists("data\\last.json"))
File.Delete("data\\last.json");
State = State.Terminating;
}

View File

@@ -1,6 +1,7 @@
using System.IO;
using Netch.Controllers;
using Netch.Models;
using Netch.Servers.VMess.Utils;
namespace Netch.Servers.VLESS
{
@@ -15,17 +16,8 @@ namespace Netch.Servers.VLESS
public bool Start(Server s, Mode mode)
{
var server = (VLESS) s;
File.WriteAllText("data\\last.json", VMess.Utils.V2rayConfigUtils.GenerateClientConfig(server, mode));
if (StartInstanceAuto("-config ..\\data\\last.json"))
{
if (File.Exists("data\\last.json")) File.Delete("data\\last.json");
return true;
}
return false;
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
return StartInstanceAuto("-config ..\\data\\last.json");
}
public override void Stop()

View File

@@ -1,6 +1,7 @@
using System.IO;
using Netch.Controllers;
using Netch.Models;
using Netch.Servers.VMess.Utils;
namespace Netch.Servers.VMess
{
@@ -20,15 +21,8 @@ namespace Netch.Servers.VMess
public bool Start(Server s, Mode mode)
{
File.WriteAllText("data\\last.json", Utils.V2rayConfigUtils.GenerateClientConfig(s, mode));
if (StartInstanceAuto("-config ..\\data\\last.json"))
{
if (File.Exists("data\\last.json")) File.Delete("data\\last.json");
return true;
}
return false;
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
return StartInstanceAuto("-config ..\\data\\last.json");
}
public override void Stop()