mirror of
https://github.com/netchx/netch.git
synced 2026-03-28 18:59:46 +08:00
更新 Controller类
改善错误输出
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
using Netch.Models;
|
||||
using Netch.Utils;
|
||||
|
||||
@@ -9,15 +8,15 @@ namespace Netch.Controllers
|
||||
{
|
||||
public SSRController()
|
||||
{
|
||||
MainFile = "ShadowsocksR";
|
||||
InitCheck();
|
||||
Name = "ShadowsocksR";
|
||||
MainFile = "ShadowsocksR.exe";
|
||||
StartedKeywords("listening at");
|
||||
StoppedKeywords("Invalid config path","usage");
|
||||
}
|
||||
|
||||
public override bool Start(Server server, Mode mode)
|
||||
{
|
||||
if (!Ready) return false;
|
||||
|
||||
Instance = GetProcess("bin\\ShadowsocksR.exe");
|
||||
Instance = GetProcess();
|
||||
Instance.OutputDataReceived += OnOutputDataReceived;
|
||||
Instance.ErrorDataReceived += OnOutputDataReceived;
|
||||
|
||||
@@ -66,19 +65,6 @@ namespace Netch.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnOutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if (!Write(e.Data)) return;
|
||||
if (State == State.Starting)
|
||||
{
|
||||
if (Instance.HasExited)
|
||||
State = State.Stopped;
|
||||
else if (e.Data.Contains("listening at"))
|
||||
State = State.Started;
|
||||
else if (e.Data.Contains("Invalid config path") || e.Data.Contains("usage")) State = State.Stopped;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Stop()
|
||||
{
|
||||
StopInstance();
|
||||
|
||||
Reference in New Issue
Block a user