From 591a4be34da2f2c17b2e9d5bbd5f0ac2a33cbd3c Mon Sep 17 00:00:00 2001 From: anonymous Date: Tue, 7 Jan 2020 23:29:46 +0800 Subject: [PATCH] Enhance tun/tap interface metric and fix dns server bug --- Netch/Controllers/TUNTAPController.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Netch/Controllers/TUNTAPController.cs b/Netch/Controllers/TUNTAPController.cs index 7cd6465f..36a390dc 100644 --- a/Netch/Controllers/TUNTAPController.cs +++ b/Netch/Controllers/TUNTAPController.cs @@ -100,6 +100,19 @@ namespace Netch.Controllers if (SavedMode.Type == 2) // 处理仅规则内走直连 { + // 将TAP网卡权重放到最高 + Instance = new Process() + { + StartInfo = + { + FileName = String.Format("netsh"), + Arguments = String.Format("interface ip set interface {0} metric=0",Global.TUNTAP.Index), + WindowStyle = ProcessWindowStyle.Hidden, + UseShellExecute = true, + CreateNoWindow = true + } + }; + Instance.Start(); // 创建默认路由 if (!NativeMethods.CreateRoute("0.0.0.0", 0, Global.Settings.TUNTAP.Gateway, Global.TUNTAP.Index, 10)) { @@ -336,7 +349,8 @@ namespace Netch.Controllers Instance.Kill(); } - pDNSController.Stop(); + //pDNSController.Stop(); + //修复点击停止按钮后再启动,DNS服务没监听的BUG ClearBypass(); } catch (Exception e)