:sparkles:新增重装tap驱动功能

This commit is contained in:
Amazing_DM
2020-04-25 11:07:48 +08:00
parent 704def859a
commit 365d4b5ff5
6 changed files with 154 additions and 101 deletions

View File

@@ -51,6 +51,7 @@ namespace Netch.Forms
this.UninstallServiceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.CleanDNSCacheToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.UpdateACLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.updateACLWithProxyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AboutToolStripButton = new System.Windows.Forms.ToolStripButton();
this.VersionLabel = new System.Windows.Forms.ToolStripLabel();
this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -63,13 +64,7 @@ namespace Netch.Forms
this.ModeComboBox = new System.Windows.Forms.SearchComboBox();
this.ServerComboBox = new System.Windows.Forms.ComboBox();
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
this.EditPictureBox = new System.Windows.Forms.PictureBox();
this.CopyLinkPictureBox = new System.Windows.Forms.PictureBox();
this.DeletePictureBox = new System.Windows.Forms.PictureBox();
this.SpeedPictureBox = new System.Windows.Forms.PictureBox();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.EditModePictureBox = new System.Windows.Forms.PictureBox();
this.DeleteModePictureBox = new System.Windows.Forms.PictureBox();
this.StatusStrip = new System.Windows.Forms.StatusStrip();
this.StatusLabel = new System.Windows.Forms.ToolStripStatusLabel();
this.UsedBandwidthLabel = new System.Windows.Forms.ToolStripStatusLabel();
@@ -84,21 +79,27 @@ namespace Netch.Forms
this.SettingsButton = new System.Windows.Forms.Button();
this.ProfileGroupBox = new System.Windows.Forms.GroupBox();
this.ProfileTable = new System.Windows.Forms.TableLayoutPanel();
this.updateACLWithProxyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reinstallTapDriverToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.EditPictureBox = new System.Windows.Forms.PictureBox();
this.CopyLinkPictureBox = new System.Windows.Forms.PictureBox();
this.DeletePictureBox = new System.Windows.Forms.PictureBox();
this.SpeedPictureBox = new System.Windows.Forms.PictureBox();
this.EditModePictureBox = new System.Windows.Forms.PictureBox();
this.DeleteModePictureBox = new System.Windows.Forms.PictureBox();
this.MenuStrip.SuspendLayout();
this.ConfigurationGroupBox.SuspendLayout();
this.configLayoutPanel.SuspendLayout();
this.tableLayoutPanel2.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.StatusStrip.SuspendLayout();
this.NotifyMenu.SuspendLayout();
this.ProfileGroupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.EditPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.CopyLinkPictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.DeletePictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.SpeedPictureBox)).BeginInit();
this.tableLayoutPanel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.EditModePictureBox)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.DeleteModePictureBox)).BeginInit();
this.StatusStrip.SuspendLayout();
this.NotifyMenu.SuspendLayout();
this.ProfileGroupBox.SuspendLayout();
this.SuspendLayout();
//
// MenuStrip
@@ -223,7 +224,8 @@ namespace Netch.Forms
this.UninstallServiceToolStripMenuItem,
this.CleanDNSCacheToolStripMenuItem,
this.UpdateACLToolStripMenuItem,
this.updateACLWithProxyToolStripMenuItem});
this.updateACLWithProxyToolStripMenuItem,
this.reinstallTapDriverToolStripMenuItem});
this.OptionsToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.OptionsToolStripMenuItem.Name = "OptionsToolStripMenuItem";
this.OptionsToolStripMenuItem.Size = new System.Drawing.Size(66, 21);
@@ -264,6 +266,13 @@ namespace Netch.Forms
this.UpdateACLToolStripMenuItem.Text = "Update ACL";
this.UpdateACLToolStripMenuItem.Click += new System.EventHandler(this.updateACLToolStripMenuItem_Click);
//
// updateACLWithProxyToolStripMenuItem
//
this.updateACLWithProxyToolStripMenuItem.Name = "updateACLWithProxyToolStripMenuItem";
this.updateACLWithProxyToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
this.updateACLWithProxyToolStripMenuItem.Text = "Update ACL with proxy";
this.updateACLWithProxyToolStripMenuItem.Click += new System.EventHandler(this.updateACLWithProxyToolStripMenuItem_Click);
//
// AboutToolStripButton
//
this.AboutToolStripButton.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
@@ -410,50 +419,6 @@ namespace Netch.Forms
this.tableLayoutPanel2.Size = new System.Drawing.Size(94, 24);
this.tableLayoutPanel2.TabIndex = 12;
//
// EditPictureBox
//
this.EditPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("EditPictureBox.Image")));
this.EditPictureBox.Location = new System.Drawing.Point(3, 3);
this.EditPictureBox.Name = "EditPictureBox";
this.EditPictureBox.Size = new System.Drawing.Size(16, 16);
this.EditPictureBox.TabIndex = 7;
this.EditPictureBox.TabStop = false;
this.EditPictureBox.Click += new System.EventHandler(this.EditPictureBox_Click);
//
// CopyLinkPictureBox
//
this.CopyLinkPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.CopyLinkPictureBox.Image = global::Netch.Properties.Resources.CopyLink;
this.CopyLinkPictureBox.Location = new System.Drawing.Point(72, 3);
this.CopyLinkPictureBox.Name = "CopyLinkPictureBox";
this.CopyLinkPictureBox.Size = new System.Drawing.Size(18, 18);
this.CopyLinkPictureBox.TabIndex = 14;
this.CopyLinkPictureBox.TabStop = false;
this.CopyLinkPictureBox.Click += new System.EventHandler(this.CopyLinkPictureBox_Click);
//
// DeletePictureBox
//
this.DeletePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.DeletePictureBox.Image = ((System.Drawing.Image)(resources.GetObject("DeletePictureBox.Image")));
this.DeletePictureBox.Location = new System.Drawing.Point(26, 3);
this.DeletePictureBox.Name = "DeletePictureBox";
this.DeletePictureBox.Size = new System.Drawing.Size(16, 16);
this.DeletePictureBox.TabIndex = 8;
this.DeletePictureBox.TabStop = false;
this.DeletePictureBox.Click += new System.EventHandler(this.DeletePictureBox_Click);
//
// SpeedPictureBox
//
this.SpeedPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.SpeedPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("SpeedPictureBox.Image")));
this.SpeedPictureBox.Location = new System.Drawing.Point(49, 3);
this.SpeedPictureBox.Name = "SpeedPictureBox";
this.SpeedPictureBox.Size = new System.Drawing.Size(16, 16);
this.SpeedPictureBox.TabIndex = 9;
this.SpeedPictureBox.TabStop = false;
this.SpeedPictureBox.Click += new System.EventHandler(this.SpeedPictureBox_Click);
//
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 4;
@@ -470,30 +435,6 @@ namespace Netch.Forms
this.tableLayoutPanel3.Size = new System.Drawing.Size(94, 24);
this.tableLayoutPanel3.TabIndex = 13;
//
// EditModePictureBox
//
this.EditModePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditModePictureBox.ErrorImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Image = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.InitialImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Location = new System.Drawing.Point(3, 3);
this.EditModePictureBox.Name = "EditModePictureBox";
this.EditModePictureBox.Size = new System.Drawing.Size(16, 16);
this.EditModePictureBox.TabIndex = 12;
this.EditModePictureBox.TabStop = false;
this.EditModePictureBox.Click += new System.EventHandler(this.EditModePictureBox_Click);
//
// DeleteModePictureBox
//
this.DeleteModePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.DeleteModePictureBox.Image = global::Netch.Properties.Resources.delete;
this.DeleteModePictureBox.Location = new System.Drawing.Point(26, 3);
this.DeleteModePictureBox.Name = "DeleteModePictureBox";
this.DeleteModePictureBox.Size = new System.Drawing.Size(16, 16);
this.DeleteModePictureBox.TabIndex = 13;
this.DeleteModePictureBox.TabStop = false;
this.DeleteModePictureBox.Click += new System.EventHandler(this.DeleteModePictureBox_Click);
//
// StatusStrip
//
this.StatusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
@@ -622,12 +563,80 @@ namespace Netch.Forms
this.ProfileTable.Size = new System.Drawing.Size(599, 43);
this.ProfileTable.TabIndex = 0;
//
// updateACLWithProxyToolStripMenuItem
// reinstallTapDriverToolStripMenuItem
//
this.updateACLWithProxyToolStripMenuItem.Name = "updateACLWithProxyToolStripMenuItem";
this.updateACLWithProxyToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
this.updateACLWithProxyToolStripMenuItem.Text = "Update ACL with proxy";
this.updateACLWithProxyToolStripMenuItem.Click += new System.EventHandler(this.updateACLWithProxyToolStripMenuItem_Click);
this.reinstallTapDriverToolStripMenuItem.Name = "reinstallTapDriverToolStripMenuItem";
this.reinstallTapDriverToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
this.reinstallTapDriverToolStripMenuItem.Text = "Reinstall Tap driver";
this.reinstallTapDriverToolStripMenuItem.Click += new System.EventHandler(this.reinstallTapDriverToolStripMenuItem_Click);
//
// EditPictureBox
//
this.EditPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("EditPictureBox.Image")));
this.EditPictureBox.Location = new System.Drawing.Point(3, 3);
this.EditPictureBox.Name = "EditPictureBox";
this.EditPictureBox.Size = new System.Drawing.Size(16, 16);
this.EditPictureBox.TabIndex = 7;
this.EditPictureBox.TabStop = false;
this.EditPictureBox.Click += new System.EventHandler(this.EditPictureBox_Click);
//
// CopyLinkPictureBox
//
this.CopyLinkPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.CopyLinkPictureBox.Image = global::Netch.Properties.Resources.CopyLink;
this.CopyLinkPictureBox.Location = new System.Drawing.Point(72, 3);
this.CopyLinkPictureBox.Name = "CopyLinkPictureBox";
this.CopyLinkPictureBox.Size = new System.Drawing.Size(18, 18);
this.CopyLinkPictureBox.TabIndex = 14;
this.CopyLinkPictureBox.TabStop = false;
this.CopyLinkPictureBox.Click += new System.EventHandler(this.CopyLinkPictureBox_Click);
//
// DeletePictureBox
//
this.DeletePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.DeletePictureBox.Image = ((System.Drawing.Image)(resources.GetObject("DeletePictureBox.Image")));
this.DeletePictureBox.Location = new System.Drawing.Point(26, 3);
this.DeletePictureBox.Name = "DeletePictureBox";
this.DeletePictureBox.Size = new System.Drawing.Size(16, 16);
this.DeletePictureBox.TabIndex = 8;
this.DeletePictureBox.TabStop = false;
this.DeletePictureBox.Click += new System.EventHandler(this.DeletePictureBox_Click);
//
// SpeedPictureBox
//
this.SpeedPictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.SpeedPictureBox.Image = ((System.Drawing.Image)(resources.GetObject("SpeedPictureBox.Image")));
this.SpeedPictureBox.Location = new System.Drawing.Point(49, 3);
this.SpeedPictureBox.Name = "SpeedPictureBox";
this.SpeedPictureBox.Size = new System.Drawing.Size(16, 16);
this.SpeedPictureBox.TabIndex = 9;
this.SpeedPictureBox.TabStop = false;
this.SpeedPictureBox.Click += new System.EventHandler(this.SpeedPictureBox_Click);
//
// EditModePictureBox
//
this.EditModePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.EditModePictureBox.ErrorImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Image = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.InitialImage = global::Netch.Properties.Resources.edit;
this.EditModePictureBox.Location = new System.Drawing.Point(3, 3);
this.EditModePictureBox.Name = "EditModePictureBox";
this.EditModePictureBox.Size = new System.Drawing.Size(16, 16);
this.EditModePictureBox.TabIndex = 12;
this.EditModePictureBox.TabStop = false;
this.EditModePictureBox.Click += new System.EventHandler(this.EditModePictureBox_Click);
//
// DeleteModePictureBox
//
this.DeleteModePictureBox.Cursor = System.Windows.Forms.Cursors.Hand;
this.DeleteModePictureBox.Image = global::Netch.Properties.Resources.delete;
this.DeleteModePictureBox.Location = new System.Drawing.Point(26, 3);
this.DeleteModePictureBox.Name = "DeleteModePictureBox";
this.DeleteModePictureBox.Size = new System.Drawing.Size(16, 16);
this.DeleteModePictureBox.TabIndex = 13;
this.DeleteModePictureBox.TabStop = false;
this.DeleteModePictureBox.Click += new System.EventHandler(this.DeleteModePictureBox_Click);
//
// MainForm
//
@@ -656,18 +665,18 @@ namespace Netch.Forms
this.configLayoutPanel.ResumeLayout(false);
this.configLayoutPanel.PerformLayout();
this.tableLayoutPanel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.EditPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CopyLinkPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DeletePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SpeedPictureBox)).EndInit();
this.tableLayoutPanel3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.EditModePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DeleteModePictureBox)).EndInit();
this.StatusStrip.ResumeLayout(false);
this.StatusStrip.PerformLayout();
this.NotifyMenu.ResumeLayout(false);
this.ProfileGroupBox.ResumeLayout(false);
this.ProfileGroupBox.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.EditPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.CopyLinkPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DeletePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.SpeedPictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.EditModePictureBox)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.DeleteModePictureBox)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -728,5 +737,6 @@ namespace Netch.Forms
private System.Windows.Forms.ToolStripMenuItem UpdateACLToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem updateACLWithProxyToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem reinstallTapDriverToolStripMenuItem;
}
}

View File

@@ -1,4 +1,5 @@
using Netch.Controllers;
using Netch.Utils;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -332,6 +333,7 @@ namespace Netch.Forms
CleanDNSCacheToolStripMenuItem.Text = Utils.i18N.Translate(CleanDNSCacheToolStripMenuItem.Text);
UpdateACLToolStripMenuItem.Text = Utils.i18N.Translate(UpdateACLToolStripMenuItem.Text);
updateACLWithProxyToolStripMenuItem.Text = Utils.i18N.Translate(updateACLWithProxyToolStripMenuItem.Text);
reinstallTapDriverToolStripMenuItem.Text = Utils.i18N.Translate(reinstallTapDriverToolStripMenuItem.Text);
AboutToolStripButton.Text = Utils.i18N.Translate(AboutToolStripButton.Text);
ConfigurationGroupBox.Text = Utils.i18N.Translate(ConfigurationGroupBox.Text);
ServerLabel.Text = Utils.i18N.Translate(ServerLabel.Text);
@@ -801,6 +803,7 @@ namespace Netch.Forms
//关闭使用代理更新ACL
updateACLWithProxyToolStripMenuItem.Enabled = false;
UpdateServersFromSubscribeLinksToolStripMenuItem.Enabled = false;
reinstallTapDriverToolStripMenuItem.Enabled = false;
ControlButton.Text = "...";
StatusLabel.Text = $"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Starting")}";
@@ -949,6 +952,7 @@ namespace Netch.Forms
updateACLWithProxyToolStripMenuItem.Enabled = true;
UpdateServersFromSubscribeLinksToolStripMenuItem.Enabled = true;
reinstallTapDriverToolStripMenuItem.Enabled = true;
ControlButton.Text = Utils.i18N.Translate("Start");
StatusLabel.Text = $"{Utils.i18N.Translate("Status")}{Utils.i18N.Translate(": ")}{Utils.i18N.Translate("Stopped")}";
@@ -1419,5 +1423,23 @@ namespace Netch.Forms
}
});
}
private void reinstallTapDriverToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
Configuration.deltapall();
Configuration.addtap();
NotifyIcon.ShowBalloonTip(5,
UpdateChecker.Name, Utils.i18N.Translate("Reinstall Tap driver successfully"),
ToolTipIcon.Info);
}
catch
{
NotifyIcon.ShowBalloonTip(5,
UpdateChecker.Name, Utils.i18N.Translate("Reinstall Tap driver failed"),
ToolTipIcon.Error);
}
}
}
}

View File

@@ -108,7 +108,7 @@
</None>
</ItemGroup>
<Target Condition="'$(VisualStudioDir)' != ''" Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="@ECHO OFF&#xD;&#xA;RD /S /Q $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;MKDIR $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;COPY /Y $(SolutionDir)binaries\$(PlatformName)\* $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)binaries\* $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;MOVE /Y $(TargetDir)bin\nfapinet.dll $(TargetDir)nfapinet.dll &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)translations\i18n\* $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)modes\mode\*.txt $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)binaries\$(PlatformName)\tap-driver\* $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1" />
<Exec Command="@ECHO OFF&#xD;&#xA;RD /S /Q $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;RD /S /Q $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;MKDIR $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;&#xD;&#xA;COPY /Y $(SolutionDir)binaries\$(PlatformName)\* $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)binaries\* $(TargetDir)bin &gt; NUL 2&gt;&amp;1&#xD;&#xA;MOVE /Y $(TargetDir)bin\nfapinet.dll $(TargetDir)nfapinet.dll &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)translations\i18n\* $(TargetDir)i18n &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)modes\mode\*.txt $(TargetDir)mode &gt; NUL 2&gt;&amp;1&#xD;&#xA;MKDIR $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1&#xD;&#xA;COPY /Y $(SolutionDir)binaries\tap-driver\* $(TargetDir)bin\tap-driver &gt; NUL 2&gt;&amp;1" />
</Target>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project>

View File

@@ -92,6 +92,9 @@
"Update ACL with proxy": "使用代理更新 ACL 规则",
"ACL updated successfully": "ACL 更新成功",
"ACL update failed": "ACL更新失败",
"Reinstall Tap driver": "重新安装Tap驱动",
"Reinstall Tap driver successfully": "重装Tap驱动成功",
"Reinstall Tap driver failed": "重装Tap驱动失败",
"About": "关于",
"Telegram Channel": "Telegram 频道",

View File

@@ -163,16 +163,9 @@ namespace Netch.Utils
{
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();
addtap();
//给点时间不然立马安装完毕就查找适配器可能会导致找不到适配器ID
Thread.Sleep(1000);
Global.TUNTAP.ComponentID = TUNTAP.GetComponentID();
}
else
@@ -199,5 +192,30 @@ namespace Netch.Utils
Logging.Info("无法找到出口");
return false;
}
/// <summary>
/// 安装tap网卡
/// </summary>
public static void addtap()
{
//安装Tap Driver
Process installProcess = new Process();
installProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
installProcess.StartInfo.FileName = Path.Combine("bin/tap-driver", "addtap.bat");
installProcess.Start();
installProcess.WaitForExit();
installProcess.Close();
}
/// <summary>
/// 卸载tap网卡
/// </summary>
public static void deltapall()
{
Process installProcess = new Process();
installProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
installProcess.StartInfo.FileName = Path.Combine("bin/tap-driver", "deltapall.bat");
installProcess.Start();
installProcess.WaitForExit();
installProcess.Close();
}
}
}