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;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Netch.Controllers.Other.DNS
|
namespace Netch.Controllers.Other.DNS
|
||||||
{
|
{
|
||||||
public class AioDNSController : Interface.IController
|
public class AioDNSController : Interface.IController
|
||||||
{
|
{
|
||||||
private enum NameList : int
|
private Tools.Guard Guard = new()
|
||||||
{
|
{
|
||||||
TYPE_REST,
|
StartInfo = new ProcessStartInfo()
|
||||||
TYPE_ADDR,
|
{
|
||||||
TYPE_LIST,
|
FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin\\aiodns.exe"),
|
||||||
TYPE_CDNS,
|
WorkingDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"),
|
||||||
TYPE_ODNS
|
CreateNoWindow = true,
|
||||||
}
|
UseShellExecute = false,
|
||||||
|
WindowStyle = ProcessWindowStyle.Hidden
|
||||||
private static class Methods
|
},
|
||||||
{
|
JudgmentStarted = new List<string>()
|
||||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
{
|
||||||
public static extern bool aiodns_dial(NameList name, string value);
|
"Started"
|
||||||
|
},
|
||||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
JudgmentStopped = new List<string>()
|
||||||
public static extern bool aiodns_init();
|
{
|
||||||
|
"[aiodns][main]"
|
||||||
[DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)]
|
},
|
||||||
public static extern void aiodns_free();
|
AutoRestart = true
|
||||||
}
|
};
|
||||||
|
|
||||||
public bool Create(Models.Server.Server s, Models.Mode.Mode m)
|
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, "");
|
this.Guard.StartInfo.Arguments = String.Format("-c {} -l {} -cdns {} -odns {}", ".\\aiodns.conf", ":53", Global.Config.AioDNS.ChinaDNS, Global.Config.AioDNS.OtherDNS);
|
||||||
Methods.aiodns_dial(NameList.TYPE_ADDR, ":53");
|
return this.Guard.Create();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Delete()
|
public bool Delete()
|
||||||
{
|
{
|
||||||
Methods.aiodns_free();
|
this.Guard.Delete();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user