diff --git a/Netch/Controllers/DNSController.cs b/Netch/Controllers/DNSController.cs index 902f0845..f73cdeb0 100644 --- a/Netch/Controllers/DNSController.cs +++ b/Netch/Controllers/DNSController.cs @@ -25,7 +25,6 @@ namespace Netch.Controllers 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}")); aiodns_dial((int) NameList.TYPE_ODNS, Encoding.UTF8.GetBytes($"{Global.Settings.AioDNS.OtherDNS}")); - aiodns_dial((int) NameList.TYPE_METH, Encoding.UTF8.GetBytes(Global.Settings.AioDNS.Protocol)); if (!aiodns_init()) throw new Exception("AioDNS start failed"); @@ -42,14 +41,13 @@ namespace Netch.Controllers [DllImport("aiodns.bin", CallingConvention = CallingConvention.Cdecl)] public static extern void aiodns_free(); - private enum NameList + public enum NameList { TYPE_REST, TYPE_ADDR, TYPE_LIST, TYPE_CDNS, - TYPE_ODNS, - TYPE_METH + TYPE_ODNS } #endregion diff --git a/Netch/Controllers/TUNController.cs b/Netch/Controllers/TUNController.cs index f5cfb0a1..33512c9b 100644 --- a/Netch/Controllers/TUNController.cs +++ b/Netch/Controllers/TUNController.cs @@ -133,11 +133,7 @@ namespace Netch.Controllers { var tasks = new[] { - Task.Run(() => - { - Free(); - // _tunInterop.Unload(); - }), + Task.Run(Free), Task.Run(ClearRouteTable), Task.Run(DNSController.Stop) }; @@ -266,7 +262,9 @@ namespace Netch.Controllers { case Action.Create: result = NativeMethods.CreateRoute((int) AddressFamily.InterNetwork, ip, cidr, gateway, index, metric); - ipList.Add(ipNetwork); + if (result && record) + ipList.Add(ipNetwork); + break; case Action.Delete: result = NativeMethods.DeleteRoute((int) AddressFamily.InterNetwork, ip, cidr, gateway, index, metric); @@ -277,7 +275,9 @@ namespace Netch.Controllers Logging.Debug($"{action}Route(\"{ip}\", {cidr}, \"{gateway}\", {index}, {metric})"); if (!result) + { Logging.Warning($"Failed to invoke {action}Route(\"{ip}\", {cidr}, \"{gateway}\", {index}, {metric})"); + } return result; }