From f5c6632a9243090356ee78ad865339ad499daab5 Mon Sep 17 00:00:00 2001 From: Amazing_DM Date: Thu, 6 Feb 2020 13:14:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Tap-Driver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Amazing_DM --- Netch/Netch.csproj | 2 +- Netch/Resources/zh-CN | 1 + Netch/Utils/Configuration.cs | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Netch/Netch.csproj b/Netch/Netch.csproj index e836d149..13e1bdfb 100644 --- a/Netch/Netch.csproj +++ b/Netch/Netch.csproj @@ -68,7 +68,7 @@ - + \ No newline at end of file diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN index e8a83b00..016c48aa 100644 --- a/Netch/Resources/zh-CN +++ b/Netch/Resources/zh-CN @@ -128,6 +128,7 @@ "Global Bypass IPs": "全局直连 IP", "Port value illegal. Try again.": "端口值非法。请重试。", "Check update when opened": "打开软件时检查更新", + "TUN/TAP driver is not detected. Is it installed now?": "未检测到TUN/TAP驱动,是否现在安装?", "Profile": "配置名", "Profiles": "配置", diff --git a/Netch/Utils/Configuration.cs b/Netch/Utils/Configuration.cs index 2319e8d4..ce322dc7 100644 --- a/Netch/Utils/Configuration.cs +++ b/Netch/Utils/Configuration.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Net; using System.Net.NetworkInformation; @@ -145,8 +146,20 @@ namespace Netch.Utils Global.TUNTAP.ComponentID = TUNTAP.GetComponentID(); if (string.IsNullOrEmpty(Global.TUNTAP.ComponentID)) { - MessageBox.Show(i18N.Translate("Please install TAP-Windows and create an TUN/TAP adapter manually"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); - return false; + if (MessageBox.Show(i18N.Translate("TUN/TAP driver is not detected. Is it installed now?"), i18N.Translate("Information"), MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) + { + //安装Tap Driver + Process installProcess = new Process(); + installProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; + installProcess.StartInfo.FileName = Path.Combine("bin/tap-driver", "install.bat"); + installProcess.Start(); + installProcess.WaitForExit(); + installProcess.Close(); + + Global.TUNTAP.ComponentID = TUNTAP.GetComponentID(); + } + //MessageBox.Show(i18N.Translate("Please install TAP-Windows and create an TUN/TAP adapter manually"), i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); + // return false; } var name = TUNTAP.GetName(Global.TUNTAP.ComponentID);