mirror of
https://github.com/netchx/netch.git
synced 2026-03-18 18:13:21 +08:00
:sparkles:添加白名单模式(可代理全局进程)
This commit is contained in:
@@ -111,7 +111,13 @@ namespace Netch.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
var processes = "NTT.exe,";
|
||||
var processes = "";
|
||||
|
||||
//开启进程白名单模式
|
||||
if (!Global.Settings.ProcessBypassMode)
|
||||
{
|
||||
processes += "NTT.exe,";
|
||||
}
|
||||
|
||||
foreach (var proc in mode.Rule)
|
||||
{
|
||||
@@ -164,10 +170,24 @@ namespace Netch.Controllers
|
||||
}
|
||||
Instance.StartInfo.FileName = "bin\\Redirector.exe";
|
||||
|
||||
//开启进程白名单模式
|
||||
if (Global.Settings.ProcessBypassMode)
|
||||
{
|
||||
processes += ",Shadowsocks.exe";
|
||||
processes += ",ShadowsocksR.exe";
|
||||
processes += ",Privoxy.exe";
|
||||
processes += ",simple-obfs.exe";
|
||||
processes += ",v2ray.exe,v2ctl.exe,v2ray-plugin.exe";
|
||||
fallback += " -bypass true ";
|
||||
}
|
||||
else
|
||||
{
|
||||
fallback += " -bypass false";
|
||||
}
|
||||
|
||||
if (server.Type != "Socks5")
|
||||
{
|
||||
fallback = $"-r 127.0.0.1:{Global.Settings.Socks5LocalPort} -p \"{processes}\"";
|
||||
fallback += $"-r 127.0.0.1:{Global.Settings.Socks5LocalPort} -p \"{processes}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -178,7 +198,7 @@ namespace Netch.Controllers
|
||||
return false;
|
||||
}
|
||||
|
||||
fallback = $"-r {result}:{server.Port} -p \"{processes}\"";
|
||||
fallback += $"-r {result}:{server.Port} -p \"{processes}\"";
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(server.Username) && !string.IsNullOrWhiteSpace(server.Password))
|
||||
{
|
||||
@@ -187,6 +207,11 @@ namespace Netch.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
Utils.Logging.Info($"{fallback}");
|
||||
|
||||
if (File.Exists("logging\\redirector.log"))
|
||||
File.Delete("logging\\redirector.log");
|
||||
|
||||
Instance.StartInfo.Arguments = fallback;
|
||||
Instance.OutputDataReceived += OnOutputDataReceived;
|
||||
Instance.ErrorDataReceived += OnOutputDataReceived;
|
||||
|
||||
14
Netch/Forms/SettingForm.Designer.cs
generated
14
Netch/Forms/SettingForm.Designer.cs
generated
@@ -63,6 +63,7 @@
|
||||
this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ExitWhenClosedCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.BypassModeCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.PortGroupBox.SuspendLayout();
|
||||
this.TUNTAPGroupBox.SuspendLayout();
|
||||
this.BehaviorGroupBox.SuspendLayout();
|
||||
@@ -259,6 +260,7 @@
|
||||
//
|
||||
// BehaviorGroupBox
|
||||
//
|
||||
this.BehaviorGroupBox.Controls.Add(this.BypassModeCheckBox);
|
||||
this.BehaviorGroupBox.Controls.Add(this.Redirector2checkBox);
|
||||
this.BehaviorGroupBox.Controls.Add(this.label3);
|
||||
this.BehaviorGroupBox.Controls.Add(this.STUN_ServerPortTextBox);
|
||||
@@ -414,6 +416,17 @@
|
||||
this.ExitWhenClosedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.ExitWhenClosedCheckBox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// BypassModeCheckBox
|
||||
//
|
||||
this.BypassModeCheckBox.AutoSize = true;
|
||||
this.BypassModeCheckBox.Location = new System.Drawing.Point(237, 266);
|
||||
this.BypassModeCheckBox.Name = "BypassModeCheckBox";
|
||||
this.BypassModeCheckBox.Size = new System.Drawing.Size(135, 21);
|
||||
this.BypassModeCheckBox.TabIndex = 14;
|
||||
this.BypassModeCheckBox.Text = "进程代理白名单模式";
|
||||
this.BypassModeCheckBox.UseVisualStyleBackColor = true;
|
||||
this.BypassModeCheckBox.CheckedChanged += new System.EventHandler(this.BypassModeCheckBox_CheckedChanged);
|
||||
//
|
||||
// SettingForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
@@ -480,5 +493,6 @@
|
||||
private System.Windows.Forms.CheckBox TUNTAPProxyDNSCheckBox;
|
||||
private System.Windows.Forms.CheckBox Redirector2checkBox;
|
||||
private System.Windows.Forms.Label label3;
|
||||
private System.Windows.Forms.CheckBox BypassModeCheckBox;
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,7 @@ namespace Netch.Forms
|
||||
MinimizeWhenStartedCheckBox.Checked = Global.Settings.MinimizeWhenStarted;
|
||||
RunAtStartup.Checked = Global.Settings.RunAtStartup;
|
||||
Redirector2checkBox.Checked = Global.Settings.UseRedirector2;
|
||||
BypassModeCheckBox.Checked = Global.Settings.ProcessBypassMode;
|
||||
|
||||
Socks5PortTextBox.Text = Global.Settings.Socks5LocalPort.ToString();
|
||||
HTTPPortTextBox.Text = Global.Settings.HTTPLocalPort.ToString();
|
||||
@@ -146,6 +147,7 @@ namespace Netch.Forms
|
||||
Global.Settings.MinimizeWhenStarted = MinimizeWhenStartedCheckBox.Checked;
|
||||
Global.Settings.RunAtStartup = RunAtStartup.Checked;
|
||||
Global.Settings.UseRedirector2 = Redirector2checkBox.Checked;
|
||||
Global.Settings.ProcessBypassMode = BypassModeCheckBox.Checked;
|
||||
|
||||
// 开机自启判断
|
||||
TaskSchedulerClass scheduler = new TaskSchedulerClass();
|
||||
@@ -331,5 +333,18 @@ namespace Netch.Forms
|
||||
Close();
|
||||
}
|
||||
|
||||
private void BypassModeCheckBox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (BypassModeCheckBox.Checked)
|
||||
{
|
||||
Redirector2checkBox.Checked = false;
|
||||
Redirector2checkBox.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Redirector2checkBox.Enabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,5 +158,9 @@ namespace Netch.Models
|
||||
/// 是否切换为2号核心
|
||||
/// </summary>
|
||||
public bool UseRedirector2 = false;
|
||||
/// <summary>
|
||||
/// 是否启用进程代理白名单模式
|
||||
/// </summary>
|
||||
public bool ProcessBypassMode = false;
|
||||
}
|
||||
}
|
||||
|
||||
2
binaries
2
binaries
Submodule binaries updated: a07de644a8...a26274a834
Reference in New Issue
Block a user