pull/1372/head^2 4.10
2dust 2021-02-03 16:46:43 +08:00
parent 6084173257
commit 23b0f154f3
12 changed files with 426 additions and 314 deletions

View File

@ -1501,6 +1501,12 @@ namespace v2rayN.Forms
/// </summary> /// </summary>
private void RefreshRoutingsMenu() private void RefreshRoutingsMenu()
{ {
menuRoutings.Visible = config.enableRoutingAdvanced;
if (!config.enableRoutingAdvanced)
{
return;
}
menuRoutings.DropDownItems.Clear(); menuRoutings.DropDownItems.Clear();
List<ToolStripMenuItem> lst = new List<ToolStripMenuItem>(); List<ToolStripMenuItem> lst = new List<ToolStripMenuItem>();

View File

@ -32,9 +32,10 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RoutingSettingForm)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(RoutingSettingForm));
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
this.labRoutingTips = new System.Windows.Forms.Label();
this.btnOK = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.labRoutingTips = new System.Windows.Forms.Label(); this.chkenableRoutingAdvanced = new System.Windows.Forms.CheckBox();
this.linkLabelRoutingDoc = new System.Windows.Forms.LinkLabel(); this.linkLabelRoutingDoc = new System.Windows.Forms.LinkLabel();
this.cmbdomainStrategy = new System.Windows.Forms.ComboBox(); this.cmbdomainStrategy = new System.Windows.Forms.ComboBox();
this.cmsLv = new System.Windows.Forms.ContextMenuStrip(this.components); this.cmsLv = new System.Windows.Forms.ContextMenuStrip(this.components);
@ -96,10 +97,17 @@
// panel2 // panel2
// //
resources.ApplyResources(this.panel2, "panel2"); resources.ApplyResources(this.panel2, "panel2");
this.panel2.Controls.Add(this.labRoutingTips);
this.panel2.Controls.Add(this.btnClose); this.panel2.Controls.Add(this.btnClose);
this.panel2.Controls.Add(this.btnOK); this.panel2.Controls.Add(this.btnOK);
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
// //
// labRoutingTips
//
resources.ApplyResources(this.labRoutingTips, "labRoutingTips");
this.labRoutingTips.ForeColor = System.Drawing.Color.Brown;
this.labRoutingTips.Name = "labRoutingTips";
//
// btnOK // btnOK
// //
resources.ApplyResources(this.btnOK, "btnOK"); resources.ApplyResources(this.btnOK, "btnOK");
@ -110,16 +118,17 @@
// panel1 // panel1
// //
resources.ApplyResources(this.panel1, "panel1"); resources.ApplyResources(this.panel1, "panel1");
this.panel1.Controls.Add(this.labRoutingTips); this.panel1.Controls.Add(this.chkenableRoutingAdvanced);
this.panel1.Controls.Add(this.linkLabelRoutingDoc); this.panel1.Controls.Add(this.linkLabelRoutingDoc);
this.panel1.Controls.Add(this.cmbdomainStrategy); this.panel1.Controls.Add(this.cmbdomainStrategy);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
// //
// labRoutingTips // chkenableRoutingAdvanced
// //
resources.ApplyResources(this.labRoutingTips, "labRoutingTips"); resources.ApplyResources(this.chkenableRoutingAdvanced, "chkenableRoutingAdvanced");
this.labRoutingTips.ForeColor = System.Drawing.Color.Brown; this.chkenableRoutingAdvanced.Name = "chkenableRoutingAdvanced";
this.labRoutingTips.Name = "labRoutingTips"; this.chkenableRoutingAdvanced.UseVisualStyleBackColor = true;
this.chkenableRoutingAdvanced.CheckedChanged += new System.EventHandler(this.chkenableRoutingAdvanced_CheckedChanged_1);
// //
// linkLabelRoutingDoc // linkLabelRoutingDoc
// //
@ -415,5 +424,6 @@
private System.Windows.Forms.TabPage tabPageRuleList; private System.Windows.Forms.TabPage tabPageRuleList;
private Base.ListViewFlickerFree lvRoutings; private Base.ListViewFlickerFree lvRoutings;
private System.Windows.Forms.Label labRoutingTips; private System.Windows.Forms.Label labRoutingTips;
private System.Windows.Forms.CheckBox chkenableRoutingAdvanced;
} }
} }

View File

@ -21,6 +21,7 @@ namespace v2rayN.Forms
ConfigHandler.InitBuiltinRouting(ref config); ConfigHandler.InitBuiltinRouting(ref config);
cmbdomainStrategy.Text = config.domainStrategy; cmbdomainStrategy.Text = config.domainStrategy;
chkenableRoutingAdvanced.Checked = config.enableRoutingAdvanced;
if (config.routings == null) if (config.routings == null)
{ {
@ -30,24 +31,25 @@ namespace v2rayN.Forms
RefreshRoutingsView(); RefreshRoutingsView();
BindingLockedData(); BindingLockedData();
InitUI();
} }
private void tabNormal_Selecting(object sender, TabControlCancelEventArgs e) private void tabNormal_Selecting(object sender, TabControlCancelEventArgs e)
{ {
if (tabNormal.SelectedTab == tabPageRuleList) //if (tabNormal.SelectedTab == tabPageRuleList)
{ //{
MenuItem1.Enabled = true; // MenuItem1.Enabled = true;
} //}
else //else
{ //{
MenuItem1.Enabled = false; // MenuItem1.Enabled = false;
} //}
} }
private void btnOK_Click(object sender, EventArgs e) private void btnOK_Click(object sender, EventArgs e)
{ {
config.domainStrategy = cmbdomainStrategy.Text; config.domainStrategy = cmbdomainStrategy.Text;
config.enableRoutingAdvanced = chkenableRoutingAdvanced.Checked;
EndBindingLockedData(); EndBindingLockedData();
if (ConfigHandler.SaveRouting(ref config) == 0) if (ConfigHandler.SaveRouting(ref config) == 0)
@ -64,6 +66,31 @@ namespace v2rayN.Forms
{ {
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;
} }
private void chkenableRoutingAdvanced_CheckedChanged_1(object sender, EventArgs e)
{
InitUI();
}
private void InitUI()
{
if (chkenableRoutingAdvanced.Checked)
{
this.tabPageProxy.Parent = null;
this.tabPageDirect.Parent = null;
this.tabPageBlock.Parent = null;
this.tabPageRuleList.Parent = tabNormal;
MenuItem1.Enabled = true;
}
else
{
this.tabPageProxy.Parent = tabNormal;
this.tabPageDirect.Parent = tabNormal;
this.tabPageBlock.Parent = tabNormal;
this.tabPageRuleList.Parent = null;
MenuItem1.Enabled = false;
}
}
#region locked #region locked
@ -94,6 +121,7 @@ namespace v2rayN.Forms
lockedItem.rules[2].domain = Utils.String2List(txtBlockDomain.Text.TrimEx()); lockedItem.rules[2].domain = Utils.String2List(txtBlockDomain.Text.TrimEx());
lockedItem.rules[2].ip = Utils.String2List(txtBlockIp.Text.TrimEx()); lockedItem.rules[2].ip = Utils.String2List(txtBlockIp.Text.TrimEx());
} }
} }
#endregion #endregion
@ -136,7 +164,7 @@ namespace v2rayN.Forms
{ {
def = "√"; def = "√";
} }
ListViewItem lvItem = new ListViewItem(def); ListViewItem lvItem = new ListViewItem(def);
Utils.AddSubItem(lvItem, "remarks", item.remarks); Utils.AddSubItem(lvItem, "remarks", item.remarks);
Utils.AddSubItem(lvItem, "count", item.rules.Count.ToString()); Utils.AddSubItem(lvItem, "count", item.rules.Count.ToString());
@ -260,5 +288,6 @@ namespace v2rayN.Forms
#endregion #endregion
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -117,25 +117,37 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnClose.Location" type="System.Drawing.Point, System.Drawing">
<value>691, 17</value>
</data>
<data name="btnClose.Text" xml:space="preserve"> <data name="btnClose.Text" xml:space="preserve">
<value>取消(&amp;C)</value> <value>取消(&amp;C)</value>
</data> </data>
<data name="btnOK.Text" xml:space="preserve">
<value>确定(&amp;O)</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="panel2.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 545</value>
</data>
<data name="panel2.Size" type="System.Drawing.Size, System.Drawing">
<value>817, 60</value>
</data>
<data name="labRoutingTips.Size" type="System.Drawing.Size, System.Drawing"> <data name="labRoutingTips.Size" type="System.Drawing.Size, System.Drawing">
<value>518, 16</value> <value>518, 16</value>
</data> </data>
<data name="labRoutingTips.Text" xml:space="preserve"> <data name="labRoutingTips.Text" xml:space="preserve">
<value>*设置的路由规则,用逗号(,)分隔;正则中的逗号用&lt;COMMA&gt;替代</value> <value>*设置的路由规则,用逗号(,)分隔;正则中的逗号用&lt;COMMA&gt;替代</value>
</data> </data>
<data name="btnOK.Location" type="System.Drawing.Point, System.Drawing">
<value>598, 17</value>
</data>
<data name="btnOK.Text" xml:space="preserve">
<value>确定(&amp;O)</value>
</data>
<data name="panel2.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 545</value>
</data>
<data name="panel2.Size" type="System.Drawing.Size, System.Drawing">
<value>817, 60</value>
</data>
<data name="chkenableRoutingAdvanced.Size" type="System.Drawing.Size, System.Drawing">
<value>120, 16</value>
</data>
<data name="chkenableRoutingAdvanced.Text" xml:space="preserve">
<value>启用路由高级功能</value>
</data>
<data name="linkLabelRoutingDoc.Size" type="System.Drawing.Size, System.Drawing"> <data name="linkLabelRoutingDoc.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 12</value> <value>77, 12</value>
</data> </data>
@ -268,7 +280,7 @@
<value>809, 443</value> <value>809, 443</value>
</data> </data>
<data name="tabPageRuleList.Text" xml:space="preserve"> <data name="tabPageRuleList.Text" xml:space="preserve">
<value> 4.预定义规则集列表</value> <value> 预定义规则集列表</value>
</data> </data>
<data name="tabNormal.Size" type="System.Drawing.Size, System.Drawing"> <data name="tabNormal.Size" type="System.Drawing.Size, System.Drawing">
<value>817, 469</value> <value>817, 469</value>

View File

@ -1,4 +1,6 @@
 
using System.Collections.Generic;
namespace v2rayN namespace v2rayN
{ {
class Global class Global
@ -190,6 +192,8 @@ namespace v2rayN
public const string IEProxyExceptions = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*"; public const string IEProxyExceptions = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*";
public const string RoutingRuleComma = "<COMMA>"; public const string RoutingRuleComma = "<COMMA>";
public static readonly IEnumerable<string> ssSecuritys = new HashSet<string> { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" };
#endregion #endregion
#region 全局变量 #region 全局变量

View File

@ -528,8 +528,7 @@ namespace v2rayN.Handler
vmessItem.id = vmessItem.id.TrimEx(); vmessItem.id = vmessItem.id.TrimEx();
vmessItem.security = vmessItem.security.TrimEx(); vmessItem.security = vmessItem.security.TrimEx();
var securitys = new HashSet<string>() { "aes-256-gcm", "aes-128-gcm", "chacha20-poly1305", "chacha20-ietf-poly1305", "none", "plain" }; if (!Global.ssSecuritys.Contains(vmessItem.security))
if (!securitys.Contains(vmessItem.security))
{ {
return -1; return -1;
} }

View File

@ -190,19 +190,32 @@ namespace v2rayN.Handler
{ {
v2rayConfig.routing.domainStrategy = config.domainStrategy; v2rayConfig.routing.domainStrategy = config.domainStrategy;
var lockedItem = ConfigHandler.GetLockedRoutingItem(ref config); if (config.enableRoutingAdvanced)
if (lockedItem != null)
{ {
foreach (var item in lockedItem.rules) if (config.routings != null && config.routingIndex < config.routings.Count)
{ {
routingUserRule(item, ref v2rayConfig); foreach (var item in config.routings[config.routingIndex].rules)
{
routingUserRule(item, ref v2rayConfig);
}
} }
} }
if (config.routings != null && config.routingIndex < config.routings.Count) else
{ {
foreach (var item in config.routings[config.routingIndex].rules) var lockedItem = ConfigHandler.GetLockedRoutingItem(ref config);
if (lockedItem != null)
{ {
routingUserRule(item, ref v2rayConfig); foreach (var item in lockedItem.rules)
{
routingUserRule(item, ref v2rayConfig);
}
//Extra to bypass the mainland
string result = Utils.GetEmbedText(Global.CustomRoutingFileName + "white");
var lstRules = Utils.FromJson<List<RulesItem>>(result);
foreach (var item in lstRules)
{
routingUserRule(item, ref v2rayConfig);
}
} }
} }
} }
@ -378,7 +391,15 @@ namespace v2rayN.Handler
serversItem.address = config.address(); serversItem.address = config.address();
serversItem.port = config.port(); serversItem.port = config.port();
serversItem.password = config.id(); serversItem.password = config.id();
serversItem.method = config.security(); if (Global.ssSecuritys.Contains(config.security()))
{
serversItem.method = config.security();
}
else
{
serversItem.method = "none";
}
serversItem.ota = false; serversItem.ota = false;
serversItem.level = 1; serversItem.level = 1;

View File

@ -169,7 +169,11 @@ namespace v2rayN.Mode
{ {
get; set; get; set;
} }
public bool enableRoutingAdvanced
{
get; set;
}
public ECoreType coreType public ECoreType coreType
{ {
get; set; get; set;

View File

@ -32,4 +32,4 @@ using System.Runtime.InteropServices;
// 方法是按如下所示使用“*”: // 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")] //[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")] //[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("4.9")] [assembly: AssemblyFileVersion("4.10")]

View File

@ -8,8 +8,8 @@
{ {
"outboundTag": "direct", "outboundTag": "direct",
"domain": [ "domain": [
"domain:example.com", "domain:example-example.com",
"domain:example2.com" "domain:example-example2.com"
] ]
}, },
{ {

View File

@ -2,8 +2,8 @@
{ {
"outboundTag": "direct", "outboundTag": "direct",
"domain": [ "domain": [
"domain:example.com", "domain:example-example.com",
"domain:example2.com" "domain:example-example2.com"
] ]
}, },
{ {