From ac3e39e9cdef45402ea0ea76b5b3935b04b55611 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Fri, 25 Dec 2020 22:44:44 +0800 Subject: [PATCH] Update AioDNS --- Netch/Controllers/DNSController.cs | 28 +++++++++++++++++++--------- Netch/Models/Setting.cs | 2 ++ binaries | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Netch/Controllers/DNSController.cs b/Netch/Controllers/DNSController.cs index a3a67d99..03125753 100644 --- a/Netch/Controllers/DNSController.cs +++ b/Netch/Controllers/DNSController.cs @@ -6,7 +6,6 @@ namespace Netch.Controllers { public class DNSController : IController { - public string Name { get; } = "DNS Service"; /// @@ -15,13 +14,14 @@ namespace Netch.Controllers /// public bool Start() { - if (!aiodns_dial(Encoding.UTF8.GetBytes(Path.GetFullPath(Global.Settings.AioDNS.RulePath)), - Encoding.UTF8.GetBytes($"{Global.Settings.AioDNS.ChinaDNS}:53"), - Encoding.UTF8.GetBytes($"{Global.Settings.AioDNS.OtherDNS}:53")) - ) - return false; - return - aiodns_init(); + aiodns_dial((int) NameList.TYPE_REST, null); + aiodns_dial((int) NameList.TYPE_ADDR, Encoding.UTF8.GetBytes($"{Global.Settings.LocalAddress}:53")); + aiodns_dial((int) NameList.TYPE_LIST, Encoding.UTF8.GetBytes(Path.GetFullPath(Global.Settings.AioDNS.RulePath))); + aiodns_dial((int) NameList.TYPE_CDNS, Encoding.UTF8.GetBytes($"{Global.Settings.AioDNS.ChinaDNS}:53")); + aiodns_dial((int) NameList.TYPE_ODNS, Encoding.UTF8.GetBytes($"{Global.Settings.AioDNS.OtherDNS}:53")); + aiodns_dial((int) NameList.TYPE_METH, Encoding.UTF8.GetBytes(Global.Settings.AioDNS.Protocol)); + + return aiodns_init(); } public void Stop() @@ -32,7 +32,7 @@ namespace Netch.Controllers #region NativeMethods [DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)] - public static extern bool aiodns_dial(byte[] chinacon, byte[] chinadns, byte[] otherdns); + public static extern bool aiodns_dial(int name, byte[] value); [DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)] public static extern bool aiodns_init(); @@ -40,6 +40,16 @@ namespace Netch.Controllers [DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)] public static extern void aiodns_free(); + enum NameList : int + { + TYPE_REST, + TYPE_ADDR, + TYPE_LIST, + TYPE_CDNS, + TYPE_ODNS, + TYPE_METH + } + #endregion } } \ No newline at end of file diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs index ad08da51..356b3f93 100644 --- a/Netch/Models/Setting.cs +++ b/Netch/Models/Setting.cs @@ -78,6 +78,8 @@ namespace Netch.Models public string ChinaDNS = "223.5.5.5"; public string OtherDNS = "1.1.1.1"; + + public string Protocol = "tcp"; } /// diff --git a/binaries b/binaries index ca3428f5..36742591 160000 --- a/binaries +++ b/binaries @@ -1 +1 @@ -Subproject commit ca3428f5a5802ac40fb0ca4ef2f826ae07079bab +Subproject commit 36742591aef7bc228dd2f159096d71ce6167cf73