mirror of
https://github.com/netchx/netch.git
synced 2026-03-14 17:43:18 +08:00
Update aiodns
This commit is contained in:
@@ -1,47 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Netch.Controllers.Other.DNS
|
||||
{
|
||||
public class AioDNSController : Interface.IController
|
||||
{
|
||||
private enum NameList : int
|
||||
private Tools.Guard Guard = new()
|
||||
{
|
||||
TYPE_REST,
|
||||
TYPE_ADDR,
|
||||
TYPE_LIST,
|
||||
TYPE_CDNS,
|
||||
TYPE_ODNS
|
||||
}
|
||||
|
||||
private static class Methods
|
||||
StartInfo = new ProcessStartInfo()
|
||||
{
|
||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool aiodns_dial(NameList name, string value);
|
||||
|
||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern bool aiodns_init();
|
||||
|
||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void aiodns_free();
|
||||
}
|
||||
FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin\\aiodns.exe"),
|
||||
WorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"),
|
||||
CreateNoWindow = true,
|
||||
UseShellExecute = false,
|
||||
WindowStyle = ProcessWindowStyle.Hidden
|
||||
},
|
||||
JudgmentStarted = new List<string>()
|
||||
{
|
||||
"Started"
|
||||
},
|
||||
JudgmentStopped = new List<string>()
|
||||
{
|
||||
"[aiodns][main]"
|
||||
},
|
||||
AutoRestart = true
|
||||
};
|
||||
|
||||
public bool Create(Models.Server.Server s, Models.Mode.Mode m)
|
||||
{
|
||||
Global.Logger.Info(String.Format("{0:x} aiodns.bin", Utils.FileHelper.Checksum("Bin\\aiodns.bin")));
|
||||
Global.Logger.Info(String.Format("{0:x} aiodns.exe", Utils.FileHelper.Checksum("bin\\aiodns.exe")));
|
||||
|
||||
Methods.aiodns_dial(NameList.TYPE_REST, "");
|
||||
Methods.aiodns_dial(NameList.TYPE_ADDR, ":53");
|
||||
Methods.aiodns_dial(NameList.TYPE_LIST, "Bin\\aiodns.conf");
|
||||
Methods.aiodns_dial(NameList.TYPE_CDNS, Global.Config.AioDNS.ChinaDNS);
|
||||
Methods.aiodns_dial(NameList.TYPE_ODNS, Global.Config.AioDNS.OtherDNS);
|
||||
|
||||
return Methods.aiodns_init();
|
||||
this.Guard.StartInfo.Arguments = String.Format("-c {} -l {} -cdns {} -odns {}", ".\\aiodns.conf", ":53", Global.Config.AioDNS.ChinaDNS, Global.Config.AioDNS.OtherDNS);
|
||||
return this.Guard.Create();
|
||||
}
|
||||
|
||||
public bool Delete()
|
||||
{
|
||||
Methods.aiodns_free();
|
||||
this.Guard.Delete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user