user pac rules

pull/354/head
2dust 2019-12-11 13:36:05 +08:00
parent f8517a316b
commit cf04c64fee
9 changed files with 1907 additions and 1766 deletions

View File

@ -91,6 +91,10 @@
this.txturlGFWList = new System.Windows.Forms.TextBox(); this.txturlGFWList = new System.Windows.Forms.TextBox();
this.label13 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label();
this.chkAutoRun = new System.Windows.Forms.CheckBox(); this.chkAutoRun = new System.Windows.Forms.CheckBox();
this.tabPage9 = new System.Windows.Forms.TabPage();
this.txtuserPacRule = new System.Windows.Forms.TextBox();
this.panel4 = new System.Windows.Forms.Panel();
this.label4 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel(); this.panel2 = new System.Windows.Forms.Panel();
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();
@ -107,36 +111,40 @@
this.panel3.SuspendLayout(); this.panel3.SuspendLayout();
this.tabPage6.SuspendLayout(); this.tabPage6.SuspendLayout();
this.tabPage7.SuspendLayout(); this.tabPage7.SuspendLayout();
this.tabPage9.SuspendLayout();
this.panel4.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnClose // btnClose
// //
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.btnClose, "btnClose"); resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Name = "btnClose"; this.btnClose.Name = "btnClose";
this.btnClose.UseVisualStyleBackColor = true; this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click); this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
// //
// tabControl1 // tabControl1
// //
resources.ApplyResources(this.tabControl1, "tabControl1");
this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2); this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage6); this.tabControl1.Controls.Add(this.tabPage6);
this.tabControl1.Controls.Add(this.tabPage7); this.tabControl1.Controls.Add(this.tabPage7);
resources.ApplyResources(this.tabControl1, "tabControl1"); this.tabControl1.Controls.Add(this.tabPage9);
this.tabControl1.Name = "tabControl1"; this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0; this.tabControl1.SelectedIndex = 0;
// //
// tabPage1 // tabPage1
// //
this.tabPage1.Controls.Add(this.groupBox1);
resources.ApplyResources(this.tabPage1, "tabPage1"); resources.ApplyResources(this.tabPage1, "tabPage1");
this.tabPage1.Controls.Add(this.groupBox1);
this.tabPage1.Name = "tabPage1"; this.tabPage1.Name = "tabPage1";
this.tabPage1.UseVisualStyleBackColor = true; this.tabPage1.UseVisualStyleBackColor = true;
// //
// groupBox1 // groupBox1
// //
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Controls.Add(this.label16); this.groupBox1.Controls.Add(this.label16);
this.groupBox1.Controls.Add(this.cmblistenerType); this.groupBox1.Controls.Add(this.cmblistenerType);
this.groupBox1.Controls.Add(this.chksniffingEnabled2); this.groupBox1.Controls.Add(this.chksniffingEnabled2);
@ -157,7 +165,6 @@
this.groupBox1.Controls.Add(this.label5); this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.txtlocalPort); this.groupBox1.Controls.Add(this.txtlocalPort);
this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label2);
resources.ApplyResources(this.groupBox1, "groupBox1");
this.groupBox1.Name = "groupBox1"; this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
// //
@ -168,6 +175,7 @@
// //
// cmblistenerType // cmblistenerType
// //
resources.ApplyResources(this.cmblistenerType, "cmblistenerType");
this.cmblistenerType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmblistenerType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmblistenerType.FormattingEnabled = true; this.cmblistenerType.FormattingEnabled = true;
this.cmblistenerType.Items.AddRange(new object[] { this.cmblistenerType.Items.AddRange(new object[] {
@ -176,7 +184,6 @@
resources.GetString("cmblistenerType.Items2"), resources.GetString("cmblistenerType.Items2"),
resources.GetString("cmblistenerType.Items3"), resources.GetString("cmblistenerType.Items3"),
resources.GetString("cmblistenerType.Items4")}); resources.GetString("cmblistenerType.Items4")});
resources.ApplyResources(this.cmblistenerType, "cmblistenerType");
this.cmblistenerType.Name = "cmblistenerType"; this.cmblistenerType.Name = "cmblistenerType";
// //
// chksniffingEnabled2 // chksniffingEnabled2
@ -222,12 +229,12 @@
// //
// cmbprotocol2 // cmbprotocol2
// //
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
this.cmbprotocol2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbprotocol2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbprotocol2.FormattingEnabled = true; this.cmbprotocol2.FormattingEnabled = true;
this.cmbprotocol2.Items.AddRange(new object[] { this.cmbprotocol2.Items.AddRange(new object[] {
resources.GetString("cmbprotocol2.Items"), resources.GetString("cmbprotocol2.Items"),
resources.GetString("cmbprotocol2.Items1")}); resources.GetString("cmbprotocol2.Items1")});
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
this.cmbprotocol2.Name = "cmbprotocol2"; this.cmbprotocol2.Name = "cmbprotocol2";
// //
// label3 // label3
@ -242,8 +249,8 @@
// //
// cmbprotocol // cmbprotocol
// //
this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.cmbprotocol, "cmbprotocol"); resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbprotocol.FormattingEnabled = true; this.cmbprotocol.FormattingEnabled = true;
this.cmbprotocol.Items.AddRange(new object[] { this.cmbprotocol.Items.AddRange(new object[] {
resources.GetString("cmbprotocol.Items"), resources.GetString("cmbprotocol.Items"),
@ -269,6 +276,7 @@
// //
// cmbloglevel // cmbloglevel
// //
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbloglevel.FormattingEnabled = true; this.cmbloglevel.FormattingEnabled = true;
this.cmbloglevel.Items.AddRange(new object[] { this.cmbloglevel.Items.AddRange(new object[] {
@ -277,7 +285,6 @@
resources.GetString("cmbloglevel.Items2"), resources.GetString("cmbloglevel.Items2"),
resources.GetString("cmbloglevel.Items3"), resources.GetString("cmbloglevel.Items3"),
resources.GetString("cmbloglevel.Items4")}); resources.GetString("cmbloglevel.Items4")});
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.Name = "cmbloglevel"; this.cmbloglevel.Name = "cmbloglevel";
// //
// label5 // label5
@ -297,33 +304,33 @@
// //
// tabPage2 // tabPage2
// //
this.tabPage2.Controls.Add(this.groupBox2);
resources.ApplyResources(this.tabPage2, "tabPage2"); resources.ApplyResources(this.tabPage2, "tabPage2");
this.tabPage2.Controls.Add(this.groupBox2);
this.tabPage2.Name = "tabPage2"; this.tabPage2.Name = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true; this.tabPage2.UseVisualStyleBackColor = true;
// //
// groupBox2 // groupBox2
// //
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Controls.Add(this.tabControl2); this.groupBox2.Controls.Add(this.tabControl2);
this.groupBox2.Controls.Add(this.panel3); this.groupBox2.Controls.Add(this.panel3);
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Name = "groupBox2"; this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false; this.groupBox2.TabStop = false;
// //
// tabControl2 // tabControl2
// //
resources.ApplyResources(this.tabControl2, "tabControl2");
this.tabControl2.Controls.Add(this.tabPage3); this.tabControl2.Controls.Add(this.tabPage3);
this.tabControl2.Controls.Add(this.tabPage4); this.tabControl2.Controls.Add(this.tabPage4);
this.tabControl2.Controls.Add(this.tabPage5); this.tabControl2.Controls.Add(this.tabPage5);
this.tabControl2.Controls.Add(this.tabPage8); this.tabControl2.Controls.Add(this.tabPage8);
resources.ApplyResources(this.tabControl2, "tabControl2");
this.tabControl2.Name = "tabControl2"; this.tabControl2.Name = "tabControl2";
this.tabControl2.SelectedIndex = 0; this.tabControl2.SelectedIndex = 0;
// //
// tabPage3 // tabPage3
// //
this.tabPage3.Controls.Add(this.txtUseragent);
resources.ApplyResources(this.tabPage3, "tabPage3"); resources.ApplyResources(this.tabPage3, "tabPage3");
this.tabPage3.Controls.Add(this.txtUseragent);
this.tabPage3.Name = "tabPage3"; this.tabPage3.Name = "tabPage3";
this.tabPage3.UseVisualStyleBackColor = true; this.tabPage3.UseVisualStyleBackColor = true;
// //
@ -334,8 +341,8 @@
// //
// tabPage4 // tabPage4
// //
this.tabPage4.Controls.Add(this.txtUserdirect);
resources.ApplyResources(this.tabPage4, "tabPage4"); resources.ApplyResources(this.tabPage4, "tabPage4");
this.tabPage4.Controls.Add(this.txtUserdirect);
this.tabPage4.Name = "tabPage4"; this.tabPage4.Name = "tabPage4";
this.tabPage4.UseVisualStyleBackColor = true; this.tabPage4.UseVisualStyleBackColor = true;
// //
@ -346,8 +353,8 @@
// //
// tabPage5 // tabPage5
// //
this.tabPage5.Controls.Add(this.txtUserblock);
resources.ApplyResources(this.tabPage5, "tabPage5"); resources.ApplyResources(this.tabPage5, "tabPage5");
this.tabPage5.Controls.Add(this.txtUserblock);
this.tabPage5.Name = "tabPage5"; this.tabPage5.Name = "tabPage5";
this.tabPage5.UseVisualStyleBackColor = true; this.tabPage5.UseVisualStyleBackColor = true;
// //
@ -358,13 +365,14 @@
// //
// tabPage8 // tabPage8
// //
this.tabPage8.Controls.Add(this.cmbroutingMode);
resources.ApplyResources(this.tabPage8, "tabPage8"); resources.ApplyResources(this.tabPage8, "tabPage8");
this.tabPage8.Controls.Add(this.cmbroutingMode);
this.tabPage8.Name = "tabPage8"; this.tabPage8.Name = "tabPage8";
this.tabPage8.UseVisualStyleBackColor = true; this.tabPage8.UseVisualStyleBackColor = true;
// //
// cmbroutingMode // cmbroutingMode
// //
resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode");
this.cmbroutingMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbroutingMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbroutingMode.FormattingEnabled = true; this.cmbroutingMode.FormattingEnabled = true;
this.cmbroutingMode.Items.AddRange(new object[] { this.cmbroutingMode.Items.AddRange(new object[] {
@ -372,16 +380,15 @@
resources.GetString("cmbroutingMode.Items1"), resources.GetString("cmbroutingMode.Items1"),
resources.GetString("cmbroutingMode.Items2"), resources.GetString("cmbroutingMode.Items2"),
resources.GetString("cmbroutingMode.Items3")}); resources.GetString("cmbroutingMode.Items3")});
resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode");
this.cmbroutingMode.Name = "cmbroutingMode"; this.cmbroutingMode.Name = "cmbroutingMode";
// //
// panel3 // panel3
// //
resources.ApplyResources(this.panel3, "panel3");
this.panel3.Controls.Add(this.btnSetDefRountingRule); this.panel3.Controls.Add(this.btnSetDefRountingRule);
this.panel3.Controls.Add(this.labRoutingTips); this.panel3.Controls.Add(this.labRoutingTips);
this.panel3.Controls.Add(this.cmbdomainStrategy); this.panel3.Controls.Add(this.cmbdomainStrategy);
this.panel3.Controls.Add(this.label15); this.panel3.Controls.Add(this.label15);
resources.ApplyResources(this.panel3, "panel3");
this.panel3.Name = "panel3"; this.panel3.Name = "panel3";
// //
// btnSetDefRountingRule // btnSetDefRountingRule
@ -393,19 +400,19 @@
// //
// labRoutingTips // labRoutingTips
// //
this.labRoutingTips.ForeColor = System.Drawing.Color.Brown;
resources.ApplyResources(this.labRoutingTips, "labRoutingTips"); resources.ApplyResources(this.labRoutingTips, "labRoutingTips");
this.labRoutingTips.ForeColor = System.Drawing.Color.Brown;
this.labRoutingTips.Name = "labRoutingTips"; this.labRoutingTips.Name = "labRoutingTips";
// //
// cmbdomainStrategy // cmbdomainStrategy
// //
resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy");
this.cmbdomainStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cmbdomainStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbdomainStrategy.FormattingEnabled = true; this.cmbdomainStrategy.FormattingEnabled = true;
this.cmbdomainStrategy.Items.AddRange(new object[] { this.cmbdomainStrategy.Items.AddRange(new object[] {
resources.GetString("cmbdomainStrategy.Items"), resources.GetString("cmbdomainStrategy.Items"),
resources.GetString("cmbdomainStrategy.Items1"), resources.GetString("cmbdomainStrategy.Items1"),
resources.GetString("cmbdomainStrategy.Items2")}); resources.GetString("cmbdomainStrategy.Items2")});
resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy");
this.cmbdomainStrategy.Name = "cmbdomainStrategy"; this.cmbdomainStrategy.Name = "cmbdomainStrategy";
// //
// label15 // label15
@ -415,6 +422,7 @@
// //
// tabPage6 // tabPage6
// //
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Controls.Add(this.chkKcpcongestion); this.tabPage6.Controls.Add(this.chkKcpcongestion);
this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize); this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize);
this.tabPage6.Controls.Add(this.label10); this.tabPage6.Controls.Add(this.label10);
@ -428,7 +436,6 @@
this.tabPage6.Controls.Add(this.label7); this.tabPage6.Controls.Add(this.label7);
this.tabPage6.Controls.Add(this.txtKcpmtu); this.tabPage6.Controls.Add(this.txtKcpmtu);
this.tabPage6.Controls.Add(this.label6); this.tabPage6.Controls.Add(this.label6);
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Name = "tabPage6"; this.tabPage6.Name = "tabPage6";
this.tabPage6.UseVisualStyleBackColor = true; this.tabPage6.UseVisualStyleBackColor = true;
// //
@ -500,6 +507,7 @@
// //
// tabPage7 // tabPage7
// //
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Controls.Add(this.cbFreshrate); this.tabPage7.Controls.Add(this.cbFreshrate);
this.tabPage7.Controls.Add(this.lbFreshrate); this.tabPage7.Controls.Add(this.lbFreshrate);
this.tabPage7.Controls.Add(this.chkEnableStatistics); this.tabPage7.Controls.Add(this.chkEnableStatistics);
@ -507,15 +515,14 @@
this.tabPage7.Controls.Add(this.txturlGFWList); this.tabPage7.Controls.Add(this.txturlGFWList);
this.tabPage7.Controls.Add(this.label13); this.tabPage7.Controls.Add(this.label13);
this.tabPage7.Controls.Add(this.chkAutoRun); this.tabPage7.Controls.Add(this.chkAutoRun);
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Name = "tabPage7"; this.tabPage7.Name = "tabPage7";
this.tabPage7.UseVisualStyleBackColor = true; this.tabPage7.UseVisualStyleBackColor = true;
// //
// cbFreshrate // cbFreshrate
// //
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
this.cbFreshrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbFreshrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbFreshrate.FormattingEnabled = true; this.cbFreshrate.FormattingEnabled = true;
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
this.cbFreshrate.Name = "cbFreshrate"; this.cbFreshrate.Name = "cbFreshrate";
// //
// lbFreshrate // lbFreshrate
@ -551,11 +558,36 @@
this.chkAutoRun.Name = "chkAutoRun"; this.chkAutoRun.Name = "chkAutoRun";
this.chkAutoRun.UseVisualStyleBackColor = true; this.chkAutoRun.UseVisualStyleBackColor = true;
// //
// tabPage9
//
resources.ApplyResources(this.tabPage9, "tabPage9");
this.tabPage9.Controls.Add(this.txtuserPacRule);
this.tabPage9.Controls.Add(this.panel4);
this.tabPage9.Name = "tabPage9";
this.tabPage9.UseVisualStyleBackColor = true;
//
// txtuserPacRule
//
resources.ApplyResources(this.txtuserPacRule, "txtuserPacRule");
this.txtuserPacRule.Name = "txtuserPacRule";
//
// panel4
//
resources.ApplyResources(this.panel4, "panel4");
this.panel4.Controls.Add(this.label4);
this.panel4.Name = "panel4";
//
// label4
//
resources.ApplyResources(this.label4, "label4");
this.label4.ForeColor = System.Drawing.Color.Brown;
this.label4.Name = "label4";
//
// panel2 // panel2
// //
resources.ApplyResources(this.panel2, "panel2");
this.panel2.Controls.Add(this.btnClose); this.panel2.Controls.Add(this.btnClose);
this.panel2.Controls.Add(this.btnOK); this.panel2.Controls.Add(this.btnOK);
resources.ApplyResources(this.panel2, "panel2");
this.panel2.Name = "panel2"; this.panel2.Name = "panel2";
// //
// btnOK // btnOK
@ -601,6 +633,9 @@
this.tabPage6.PerformLayout(); this.tabPage6.PerformLayout();
this.tabPage7.ResumeLayout(false); this.tabPage7.ResumeLayout(false);
this.tabPage7.PerformLayout(); this.tabPage7.PerformLayout();
this.tabPage9.ResumeLayout(false);
this.tabPage9.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel2.ResumeLayout(false); this.panel2.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
@ -673,5 +708,9 @@
private System.Windows.Forms.Label label16; private System.Windows.Forms.Label label16;
private System.Windows.Forms.ComboBox cmblistenerType; private System.Windows.Forms.ComboBox cmblistenerType;
private System.Windows.Forms.TabPage tabPage8; private System.Windows.Forms.TabPage tabPage8;
private System.Windows.Forms.TabPage tabPage9;
private System.Windows.Forms.TextBox txtuserPacRule;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Label label4;
} }
} }

View File

@ -22,6 +22,8 @@ namespace v2rayN.Forms
InitKCP(); InitKCP();
InitGUI(); InitGUI();
InitUserPAC();
} }
/// <summary> /// <summary>
@ -142,6 +144,11 @@ namespace v2rayN.Forms
} }
private void InitUserPAC()
{
txtuserPacRule.Text = Utils.List2String(config.userPacRule, true);
}
private void btnOK_Click(object sender, EventArgs e) private void btnOK_Click(object sender, EventArgs e)
{ {
if (SaveBase() != 0) if (SaveBase() != 0)
@ -164,6 +171,11 @@ namespace v2rayN.Forms
return; return;
} }
if (SaveUserPAC() != 0)
{
return;
}
if (ConfigHandler.SaveConfig(ref config) == 0) if (ConfigHandler.SaveConfig(ref config) == 0)
{ {
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;
@ -250,7 +262,7 @@ namespace v2rayN.Forms
//remoteDNS //remoteDNS
config.remoteDNS = txtremoteDNS.Text.TrimEx(); config.remoteDNS = txtremoteDNS.Text.TrimEx();
config.listenerType = cmblistenerType.SelectedIndex; config.listenerType = cmblistenerType.SelectedIndex;
return 0; return 0;
} }
@ -344,6 +356,15 @@ namespace v2rayN.Forms
return 0; return 0;
} }
private int SaveUserPAC()
{
string userPacRule = txtuserPacRule.Text.TrimEx();
userPacRule = userPacRule.Replace("\"", "");
config.userPacRule = Utils.String2List(userPacRule);
return 0;
}
private void btnClose_Click(object sender, EventArgs e) private void btnClose_Click(object sender, EventArgs e)
{ {
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;

File diff suppressed because it is too large Load Diff

View File

@ -123,6 +123,21 @@
<data name="tabPage1.Text" xml:space="preserve"> <data name="tabPage1.Text" xml:space="preserve">
<value> Core:基础设置 </value> <value> Core:基础设置 </value>
</data> </data>
<data name="tabPage2.Text" xml:space="preserve">
<value> Core:路由设置 </value>
</data>
<data name="tabPage6.Text" xml:space="preserve">
<value> Core:KCP设置 </value>
</data>
<data name="tabPage7.Text" xml:space="preserve">
<value> v2rayN设置 </value>
</data>
<data name="label4.Text" xml:space="preserve">
<value>*设置用户PAC规则用逗号(,)隔开</value>
</data>
<data name="tabPage9.Text" xml:space="preserve">
<value> 用户PAC设置 </value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="label16.Size" type="System.Drawing.Size, System.Drawing"> <data name="label16.Size" type="System.Drawing.Size, System.Drawing">
<value>53, 12</value> <value>53, 12</value>
@ -214,9 +229,6 @@
<data name="label2.Text" xml:space="preserve"> <data name="label2.Text" xml:space="preserve">
<value>本地监听端口</value> <value>本地监听端口</value>
</data> </data>
<data name="tabPage2.Text" xml:space="preserve">
<value> Core:路由设置 </value>
</data>
<data name="tabControl2.Location" type="System.Drawing.Point, System.Drawing"> <data name="tabControl2.Location" type="System.Drawing.Point, System.Drawing">
<value>3, 89</value> <value>3, 89</value>
</data> </data>
@ -315,24 +327,12 @@
<data name="label15.Text" xml:space="preserve"> <data name="label15.Text" xml:space="preserve">
<value>域名策略</value> <value>域名策略</value>
</data> </data>
<data name="tabPage6.Text" xml:space="preserve">
<value> Core:KCP设置 </value>
</data>
<data name="tabPage7.Text" xml:space="preserve">
<value> v2rayN设置 </value>
</data>
<data name="lbFreshrate.Size" type="System.Drawing.Size, System.Drawing"> <data name="lbFreshrate.Size" type="System.Drawing.Size, System.Drawing">
<value>77, 12</value> <value>77, 12</value>
</data> </data>
<data name="lbFreshrate.Text" xml:space="preserve"> <data name="lbFreshrate.Text" xml:space="preserve">
<value>统计刷新频率</value> <value>统计刷新频率</value>
</data> </data>
<data name="lbCacheDays.Size" type="System.Drawing.Size, System.Drawing">
<value>305, 12</value>
</data>
<data name="lbCacheDays.Text" xml:space="preserve">
<value>缓存天数0-30 0关闭缓存单独每天的数据使用情况</value>
</data>
<data name="chkEnableStatistics.Size" type="System.Drawing.Size, System.Drawing"> <data name="chkEnableStatistics.Size" type="System.Drawing.Size, System.Drawing">
<value>384, 16</value> <value>384, 16</value>
</data> </data>

View File

@ -131,6 +131,10 @@ namespace v2rayN.Handler
{ {
config.subItem = new List<SubItem>(); config.subItem = new List<SubItem>();
} }
if (config.userPacRule == null)
{
config.userPacRule = new List<string>();
}
if (config == null if (config == null
|| config.index < 0 || config.index < 0

View File

@ -1,54 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace v2rayN.Handler
{
/// <summary>
/// 路由规则文件处理类
/// </summary>
class RoutingRuleHandler
{
/// <summary>
/// Parse Pac to v2ray rule
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public static List<string> ParsePac(string filePath)
{
string result = Utils.LoadResource(filePath);
if (Utils.IsNullOrEmpty(result))
{
return null;
}
//取得rule
string pattern = @"(?is)(?<=\[)(.*)(?=\])";
Regex rgx = new Regex(pattern);
result = rgx.Match(result).Value;
int index = result.IndexOf("];");
result = result.Substring(0, index);
if (Utils.IsNullOrEmpty(result))
{
return null;
}
string[] arrPac = result.Split(',');
List<string> lstPac = new List<string>();
foreach (string str in arrPac)
{
//处理有效值
if (Utils.IsNullOrEmpty(str)
|| str.Length <= 3)
{
continue;
}
string value = str.Replace("\",", "").Replace("\"", "").Replace(",", "").Replace(Environment.NewLine, "").Replace(" ", "");
lstPac.Add(value);
}
return lstPac;
}
}
}

View File

@ -17,6 +17,7 @@ namespace v2rayN.HttpProxyHandler
private static int pacPort = 0; private static int pacPort = 0;
private static HttpWebServer server; private static HttpWebServer server;
private static HttpWebServerB serverB; private static HttpWebServerB serverB;
private static Config _config;
public static bool IsRunning public static bool IsRunning
{ {
@ -28,6 +29,7 @@ namespace v2rayN.HttpProxyHandler
public static void Init(Config config) public static void Init(Config config)
{ {
_config = config;
Global.pacPort = config.GetLocalPort("pac"); Global.pacPort = config.GetLocalPort("pac");
if (InitServer("*")) if (InitServer("*"))
@ -161,7 +163,6 @@ namespace v2rayN.HttpProxyHandler
//} //}
} }
private static string GetPacList(string address) private static string GetPacList(string address)
{ {
var port = Global.httpPort; var port = Global.httpPort;
@ -182,6 +183,18 @@ namespace v2rayN.HttpProxyHandler
} }
var pac = File.ReadAllText(strPacfile, Encoding.UTF8); var pac = File.ReadAllText(strPacfile, Encoding.UTF8);
pac = pac.Replace("__PROXY__", proxy); pac = pac.Replace("__PROXY__", proxy);
if (_config.userPacRule.Count > 0)
{
var keyWords = "var rules = [";
if (pac.IndexOf(keyWords) >= 0)
{
var userPac = string.Join($"\",{Environment.NewLine}\"", _config.userPacRule.ToArray());
userPac = string.Format("\"{0}\",", userPac);
pac = pac.Replace(keyWords, keyWords + userPac);
}
}
return pac; return pac;
} }
catch catch

View File

@ -169,6 +169,11 @@ namespace v2rayN.Mode
get; set; get; set;
} }
public List<string> userPacRule
{
get; set;
}
#region 函数 #region 函数
public string address() public string address()

View File

@ -230,7 +230,6 @@
</Compile> </Compile>
<Compile Include="Global.cs" /> <Compile Include="Global.cs" />
<Compile Include="Handler\QRCodeHelper.cs" /> <Compile Include="Handler\QRCodeHelper.cs" />
<Compile Include="Handler\RoutingRuleHandler.cs" />
<Compile Include="Mode\VmessQRCode.cs" /> <Compile Include="Mode\VmessQRCode.cs" />
<Compile Include="Mode\V2rayTcpRequest.cs" /> <Compile Include="Mode\V2rayTcpRequest.cs" />
<Compile Include="Handler\ConfigHandler.cs" /> <Compile Include="Handler\ConfigHandler.cs" />