From d09b5adc3370fab5a7a092dd61f6e0b4e2889098 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Sat, 27 Mar 2021 23:29:10 +0800 Subject: [PATCH] Drop proxy client routing --- Netch/Constants.cs | 2 - Netch/Forms/MainForm.Designer.cs | 12 +-- Netch/Forms/MainForm.cs | 30 +------- Netch/Forms/MainForm.resx | 74 +------------------ Netch/Forms/Mode/Process.cs | 1 - Netch/Forms/SettingForm.Designer.cs | 27 +------ Netch/Forms/SettingForm.cs | 2 - Netch/Models/Mode.cs | 16 +--- Netch/Models/Setting.cs | 5 -- Netch/Servers/Shadowsocks/SSController.cs | 3 - Netch/Servers/ShadowsocksR/SSRController.cs | 3 - Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs | 15 ---- 12 files changed, 6 insertions(+), 184 deletions(-) diff --git a/Netch/Constants.cs b/Netch/Constants.cs index 1981cfdf..6bdfa5dd 100644 --- a/Netch/Constants.cs +++ b/Netch/Constants.cs @@ -3,8 +3,6 @@ public static class Constants { public const string EOF = "\r\n"; - public const string UserACL = "data\\user.acl"; - public const string BuiltinACL = "bin\\default.acl"; public static class Parameter { diff --git a/Netch/Forms/MainForm.Designer.cs b/Netch/Forms/MainForm.Designer.cs index f92028f5..4d4cce8a 100644 --- a/Netch/Forms/MainForm.Designer.cs +++ b/Netch/Forms/MainForm.Designer.cs @@ -84,7 +84,6 @@ this.ProfileTable = new System.Windows.Forms.TableLayoutPanel(); this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.ButtomControlContainerControl = new System.Windows.Forms.ContainerControl(); - this.UpdateACLToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MenuStrip.SuspendLayout(); this.ConfigurationGroupBox.SuspendLayout(); this.configLayoutPanel.SuspendLayout(); @@ -192,7 +191,6 @@ this.OptionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.OpenDirectoryToolStripMenuItem, this.CleanDNSCacheToolStripMenuItem, - this.UpdateACLToolStripMenuItem, this.UninstallServiceToolStripMenuItem, this.removeNetchFirewallRulesToolStripMenuItem}); this.OptionsToolStripMenuItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); @@ -679,13 +677,6 @@ this.ButtomControlContainerControl.TabStop = false; this.ButtomControlContainerControl.Text = "groupBox1"; // - // UpdateACLToolStripMenuItem - // - this.UpdateACLToolStripMenuItem.Name = "UpdateACLToolStripMenuItem"; - this.UpdateACLToolStripMenuItem.Size = new System.Drawing.Size(243, 22); - this.UpdateACLToolStripMenuItem.Text = "Update ACL"; - this.UpdateACLToolStripMenuItem.Click += new System.EventHandler(this.updateACLToolStripMenuItem_Click); - // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -696,7 +687,7 @@ this.Controls.Add(this.MenuStrip); this.Controls.Add(this.StatusStrip); this.Controls.Add(this.flowLayoutPanel1); - this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.MaximizeBox = false; @@ -791,6 +782,5 @@ private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; private System.Windows.Forms.ContainerControl ButtomControlContainerControl; - private System.Windows.Forms.ToolStripMenuItem UpdateACLToolStripMenuItem; } } \ No newline at end of file diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index 8639646f..2fa5d93e 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -365,33 +365,6 @@ namespace Netch.Forms } } - private void updateACLToolStripMenuItem_Click(object sender, EventArgs e) - { - UpdateACL(); - } - - private async void UpdateACL() - { - Enabled = false; - StatusText(i18N.TranslateFormat("Updating {0}", "ACL")); - try - { - var req = WebUtil.CreateRequest(Global.Settings.ACL); - await WebUtil.DownloadFileAsync(req, Path.Combine(Global.NetchDir, Constants.UserACL)); - NotifyTip(i18N.Translate("ACL updated successfully")); - } - catch (Exception e) - { - NotifyTip(i18N.Translate("ACL update failed") + "\n" + e.Message, info: false); - Logging.Error("更新 ACL 失败!" + e); - } - finally - { - StatusText(); - Enabled = true; - } - } - private async void UninstallServiceToolStripMenuItem_Click(object sender, EventArgs e) { Enabled = false; @@ -981,8 +954,7 @@ namespace Netch.Forms EditServerPictureBox.Enabled = DeleteModePictureBox.Enabled = DeleteServerPictureBox.Enabled = enabled; // 启动需要禁用的控件 - UninstallServiceToolStripMenuItem.Enabled = - UpdateACLToolStripMenuItem.Enabled = UpdateServersFromSubscribeLinksToolStripMenuItem.Enabled = enabled; + UninstallServiceToolStripMenuItem.Enabled = UpdateServersFromSubscribeLinksToolStripMenuItem.Enabled = enabled; } _state = value; diff --git a/Netch/Forms/MainForm.resx b/Netch/Forms/MainForm.resx index bc26c702..f298a7be 100644 --- a/Netch/Forms/MainForm.resx +++ b/Netch/Forms/MainForm.resx @@ -1,64 +1,4 @@ - - - + @@ -117,16 +57,4 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - - - 130, 17 - - - 246, 17 - - - 359, 17 - \ No newline at end of file diff --git a/Netch/Forms/Mode/Process.cs b/Netch/Forms/Mode/Process.cs index 0359e62d..7d8a3afe 100644 --- a/Netch/Forms/Mode/Process.cs +++ b/Netch/Forms/Mode/Process.cs @@ -135,7 +135,6 @@ namespace Netch.Forms.Mode var mode = new Models.Mode(fullName) { - BypassChina = false, Type = 0, Remark = RemarkTextBox.Text }; diff --git a/Netch/Forms/SettingForm.Designer.cs b/Netch/Forms/SettingForm.Designer.cs index d111e99d..79f4684a 100644 --- a/Netch/Forms/SettingForm.Designer.cs +++ b/Netch/Forms/SettingForm.Designer.cs @@ -53,8 +53,6 @@ namespace Netch.Forms this.StartedPingIntervalTextBox = new System.Windows.Forms.TextBox(); this.STUNServerLabel = new System.Windows.Forms.Label(); this.STUN_ServerComboBox = new System.Windows.Forms.ComboBox(); - this.AclLabel = new System.Windows.Forms.Label(); - this.AclAddrTextBox = new System.Windows.Forms.TextBox(); this.LanguageLabel = new System.Windows.Forms.Label(); this.LanguageComboBox = new System.Windows.Forms.ComboBox(); this.NFTabPage = new System.Windows.Forms.TabPage(); @@ -161,8 +159,6 @@ namespace Netch.Forms this.GeneralTabPage.Controls.Add(this.StartedPingIntervalTextBox); this.GeneralTabPage.Controls.Add(this.STUNServerLabel); this.GeneralTabPage.Controls.Add(this.STUN_ServerComboBox); - this.GeneralTabPage.Controls.Add(this.AclLabel); - this.GeneralTabPage.Controls.Add(this.AclAddrTextBox); this.GeneralTabPage.Controls.Add(this.LanguageLabel); this.GeneralTabPage.Controls.Add(this.LanguageComboBox); this.GeneralTabPage.Location = new System.Drawing.Point(4, 29); @@ -359,27 +355,10 @@ namespace Netch.Forms this.STUN_ServerComboBox.Size = new System.Drawing.Size(314, 25); this.STUN_ServerComboBox.TabIndex = 12; // - // AclLabel - // - this.AclLabel.AutoSize = true; - this.AclLabel.Location = new System.Drawing.Point(12, 248); - this.AclLabel.Name = "AclLabel"; - this.AclLabel.Size = new System.Drawing.Size(78, 17); - this.AclLabel.TabIndex = 13; - this.AclLabel.Text = "Custom ACL"; - // - // AclAddrTextBox - // - this.AclAddrTextBox.Location = new System.Drawing.Point(120, 245); - this.AclAddrTextBox.Name = "AclAddrTextBox"; - this.AclAddrTextBox.Size = new System.Drawing.Size(314, 23); - this.AclAddrTextBox.TabIndex = 14; - this.AclAddrTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - // // LanguageLabel // this.LanguageLabel.AutoSize = true; - this.LanguageLabel.Location = new System.Drawing.Point(12, 277); + this.LanguageLabel.Location = new System.Drawing.Point(17, 254); this.LanguageLabel.Name = "LanguageLabel"; this.LanguageLabel.Size = new System.Drawing.Size(65, 17); this.LanguageLabel.TabIndex = 15; @@ -389,7 +368,7 @@ namespace Netch.Forms // this.LanguageComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.LanguageComboBox.FormattingEnabled = true; - this.LanguageComboBox.Location = new System.Drawing.Point(120, 274); + this.LanguageComboBox.Location = new System.Drawing.Point(120, 251); this.LanguageComboBox.Name = "LanguageComboBox"; this.LanguageComboBox.Size = new System.Drawing.Size(121, 25); this.LanguageComboBox.TabIndex = 16; @@ -1084,8 +1063,6 @@ namespace Netch.Forms private System.Windows.Forms.CheckBox ExitWhenClosedCheckBox; private System.Windows.Forms.Label LanguageLabel; private System.Windows.Forms.ComboBox LanguageComboBox; - private System.Windows.Forms.TextBox AclAddrTextBox; - private System.Windows.Forms.Label AclLabel; private System.Windows.Forms.Label DetectionTickLabel; private System.Windows.Forms.TextBox DetectionTickTextBox; private System.Windows.Forms.Label StartedPingLabel; diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs index 17643cb2..118d68d0 100644 --- a/Netch/Forms/SettingForm.cs +++ b/Netch/Forms/SettingForm.cs @@ -98,8 +98,6 @@ namespace Netch.Forms Global.Settings.STUN_Server + ":" + Global.Settings.STUN_Server_Port, stuns); - BindTextBox(AclAddrTextBox, s => true, s => Global.Settings.ACL = s, Global.Settings.ACL); - BindListComboBox(LanguageComboBox, o => Global.Settings.Language = o.ToString(), i18N.GetTranslateList(), Global.Settings.Language); #endregion diff --git a/Netch/Models/Mode.cs b/Netch/Models/Mode.cs index 6bc7b70a..28d207c0 100644 --- a/Netch/Models/Mode.cs +++ b/Netch/Models/Mode.cs @@ -37,9 +37,6 @@ namespace Netch.Models Type = typeResult ? type : 0; if (!ModeHelper.ModeTypes.Contains(Type)) throw new NotSupportedException($"not support mode \"[{Type}]{Remark}\"."); - - var bypassChinaResult = int.TryParse(split.ElementAtOrDefault(2), out var bypassChina); - BypassChina = this.ClientRouting() && bypassChinaResult && bypassChina == 1; } /// @@ -47,11 +44,6 @@ namespace Netch.Models /// public List Rule => _lazyRule.Value; - /// - /// 绕过中国(0. 不绕过 1. 绕过) - /// - public bool BypassChina { get; set; } - /// /// 备注 /// @@ -162,7 +154,7 @@ namespace Netch.Models /// 模式文件字符串 public string ToFileString() { - return $"# {Remark}, {Type}, {(BypassChina ? 1 : 0)}{Constants.EOF}{string.Join(Constants.EOF, Rule)}"; + return $"# {Remark}, {Type}{Constants.EOF}{string.Join(Constants.EOF, Rule)}"; } } @@ -173,11 +165,5 @@ namespace Netch.Models { return mode.Type is 0 or 2; } - - /// Socks5 分流是否能被有效实施 - public static bool ClientRouting(this Mode mode) - { - return mode.Type is not (1 or 2); - } } } \ No newline at end of file diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs index 469dfaa7..de8adaea 100644 --- a/Netch/Models/Setting.cs +++ b/Netch/Models/Setting.cs @@ -90,11 +90,6 @@ namespace Netch.Models /// public List Server { get; set; } = new(); - /// - /// ACL规则 - /// - public string ACL { get; set; } = "https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/banAD.acl"; - public AioDNSConfig AioDNS { get; set; } = new(); /// diff --git a/Netch/Servers/Shadowsocks/SSController.cs b/Netch/Servers/Shadowsocks/SSController.cs index ebd75ec3..765eb3c0 100644 --- a/Netch/Servers/Shadowsocks/SSController.cs +++ b/Netch/Servers/Shadowsocks/SSController.cs @@ -37,9 +37,6 @@ namespace Netch.Servers.Shadowsocks plugin_opts = server.PluginOption }; - if (mode.BypassChina) - command.acl = $"{Path.GetFullPath(File.Exists(Constants.UserACL) ? Constants.UserACL : Constants.BuiltinACL)}"; - StartInstanceAuto(command.ToString()); } diff --git a/Netch/Servers/ShadowsocksR/SSRController.cs b/Netch/Servers/ShadowsocksR/SSRController.cs index 75c03a0d..5724b8f8 100644 --- a/Netch/Servers/ShadowsocksR/SSRController.cs +++ b/Netch/Servers/ShadowsocksR/SSRController.cs @@ -40,9 +40,6 @@ namespace Netch.Servers.ShadowsocksR u = true }; - if (mode.BypassChina) - command.acl = $"{Path.GetFullPath(File.Exists(Constants.UserACL) ? Constants.UserACL : Constants.BuiltinACL)}"; - StartInstanceAuto(command.ToString()); } diff --git a/Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs b/Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs index b9d7f8aa..9818a0d4 100644 --- a/Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs +++ b/Netch/Servers/V2ray/Utils/V2rayConfigUtils.cs @@ -65,21 +65,6 @@ namespace Netch.Servers.V2ray.Utils outboundTag = "block" }; - if (mode.BypassChina) - switch (mode.Type) - { - case 0: - directRuleObject.ip.Add("geoip:cn"); - break; - case 1: - case 2: - // directRuleObject.ip.Add("geoip:cn"); - break; - default: - directRuleObject.domain.Add("geosite:cn"); - break; - } - if (mode.Type is 0 or 1 or 2) blockRuleObject.ip.Add("geoip:private");