Files
netch/Netch/Servers/V2ray/V2rayController.cs
Connection Refused 5803b94ae9 Update NativeMethods
2021-04-02 02:40:13 +08:00

41 lines
1.3 KiB
C#

using Netch.Controllers;
using Netch.Models;
using Netch.Servers.V2ray.Utils;
using System.Collections.Generic;
using System.IO;
namespace Netch.Servers.V2ray
{
public class V2rayController : Guard, IServerController
{
public override string MainFile { get; protected set; } = "xray.exe";
protected override IEnumerable<string> StartedKeywords { get; set; } = new[] { "started" };
protected override IEnumerable<string> StoppedKeywords { get; set; } = new[] { "config file not readable", "failed to" };
public override string Name { get; } = "Xray";
public ushort? Socks5LocalPort { get; set; }
public string? LocalAddress { get; set; }
public virtual void Start(in Server s, in Mode mode)
{
File.WriteAllText("data\\last.json", V2rayConfigUtils.GenerateClientConfig(s, mode));
StartInstanceAuto("-config ..\\data\\last.json");
}
public override void Stop()
{
StopInstance();
}
protected override void InitInstance(string argument)
{
base.InitInstance(argument);
if (!Global.Settings.V2RayConfig.XrayCone)
Instance!.StartInfo.Environment["XRAY_CONE_DISABLED"] = "true";
}
}
}