Files
netch/Netch/Controllers/DNSController.cs
ChsBuffer 79c4a9d203 - Migrate to xjasonlyu/tun2socks
- Fix Starting Controller misc UI block
- Fix didn't stop Controller when starting Controller
2021-11-10 22:44:01 +08:00

33 lines
981 B
C#

using System.IO;
using System.Threading.Tasks;
using Netch.Interfaces;
using Netch.Models;
using static Netch.Interops.AioDNS;
namespace Netch.Controllers
{
public class DNSController : IController
{
public string Name => "DNS Service";
public async Task StartAsync(string listenAddress)
{
var aioDnsConfig = Global.Settings.AioDNS;
Dial(NameList.TYPE_REST, "");
Dial(NameList.TYPE_LIST, Path.GetFullPath(Constants.AioDnsRuleFile));
// TODO remove ListenPort setting
Dial(NameList.TYPE_LISN, $"{listenAddress}:{aioDnsConfig.ListenPort}");
Dial(NameList.TYPE_CDNS, $"{aioDnsConfig.ChinaDNS}");
Dial(NameList.TYPE_ODNS, $"{aioDnsConfig.OtherDNS}");
if (!await InitAsync())
throw new MessageException("AioDNS start failed.");
}
public async Task StopAsync()
{
await FreeAsync();
}
}
}