mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
45 lines
1.1 KiB
C#
45 lines
1.1 KiB
C#
using System;
|
|
using Netch.Utils;
|
|
|
|
namespace Netch.Controllers
|
|
{
|
|
public class DNSController : Controller
|
|
{
|
|
public DNSController()
|
|
{
|
|
Name = "DNS Service";
|
|
MainFile = "unbound.exe";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 启动DNS服务
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool Start()
|
|
{
|
|
Instance = GetProcess();
|
|
Instance.StartInfo.Arguments = "-c unbound-service.conf -v";
|
|
|
|
Instance.OutputDataReceived += OnOutputDataReceived;
|
|
Instance.ErrorDataReceived += OnOutputDataReceived;
|
|
|
|
try
|
|
{
|
|
Instance.Start();
|
|
Instance.BeginOutputReadLine();
|
|
Instance.BeginErrorReadLine();
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logging.Error("dns-unbound 进程出错:\n" + e);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public override void Stop()
|
|
{
|
|
StopInstance();
|
|
}
|
|
}
|
|
} |