mirror of https://github.com/2dust/v2rayN
user pac rules
parent
f8517a316b
commit
cf04c64fee
|
@ -91,6 +91,10 @@
|
|||
this.txturlGFWList = new System.Windows.Forms.TextBox();
|
||||
this.label13 = new System.Windows.Forms.Label();
|
||||
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.btnOK = new System.Windows.Forms.Button();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
|
@ -107,36 +111,40 @@
|
|||
this.panel3.SuspendLayout();
|
||||
this.tabPage6.SuspendLayout();
|
||||
this.tabPage7.SuspendLayout();
|
||||
this.tabPage9.SuspendLayout();
|
||||
this.panel4.SuspendLayout();
|
||||
this.panel2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
resources.ApplyResources(this.btnClose, "btnClose");
|
||||
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.UseVisualStyleBackColor = true;
|
||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
resources.ApplyResources(this.tabControl1, "tabControl1");
|
||||
this.tabControl1.Controls.Add(this.tabPage1);
|
||||
this.tabControl1.Controls.Add(this.tabPage2);
|
||||
this.tabControl1.Controls.Add(this.tabPage6);
|
||||
this.tabControl1.Controls.Add(this.tabPage7);
|
||||
resources.ApplyResources(this.tabControl1, "tabControl1");
|
||||
this.tabControl1.Controls.Add(this.tabPage9);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
this.tabPage1.Controls.Add(this.groupBox1);
|
||||
resources.ApplyResources(this.tabPage1, "tabPage1");
|
||||
this.tabPage1.Controls.Add(this.groupBox1);
|
||||
this.tabPage1.Name = "tabPage1";
|
||||
this.tabPage1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
resources.ApplyResources(this.groupBox1, "groupBox1");
|
||||
this.groupBox1.Controls.Add(this.label16);
|
||||
this.groupBox1.Controls.Add(this.cmblistenerType);
|
||||
this.groupBox1.Controls.Add(this.chksniffingEnabled2);
|
||||
|
@ -157,7 +165,6 @@
|
|||
this.groupBox1.Controls.Add(this.label5);
|
||||
this.groupBox1.Controls.Add(this.txtlocalPort);
|
||||
this.groupBox1.Controls.Add(this.label2);
|
||||
resources.ApplyResources(this.groupBox1, "groupBox1");
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.TabStop = false;
|
||||
//
|
||||
|
@ -168,6 +175,7 @@
|
|||
//
|
||||
// cmblistenerType
|
||||
//
|
||||
resources.ApplyResources(this.cmblistenerType, "cmblistenerType");
|
||||
this.cmblistenerType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmblistenerType.FormattingEnabled = true;
|
||||
this.cmblistenerType.Items.AddRange(new object[] {
|
||||
|
@ -176,7 +184,6 @@
|
|||
resources.GetString("cmblistenerType.Items2"),
|
||||
resources.GetString("cmblistenerType.Items3"),
|
||||
resources.GetString("cmblistenerType.Items4")});
|
||||
resources.ApplyResources(this.cmblistenerType, "cmblistenerType");
|
||||
this.cmblistenerType.Name = "cmblistenerType";
|
||||
//
|
||||
// chksniffingEnabled2
|
||||
|
@ -222,12 +229,12 @@
|
|||
//
|
||||
// cmbprotocol2
|
||||
//
|
||||
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
|
||||
this.cmbprotocol2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbprotocol2.FormattingEnabled = true;
|
||||
this.cmbprotocol2.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbprotocol2.Items"),
|
||||
resources.GetString("cmbprotocol2.Items1")});
|
||||
resources.ApplyResources(this.cmbprotocol2, "cmbprotocol2");
|
||||
this.cmbprotocol2.Name = "cmbprotocol2";
|
||||
//
|
||||
// label3
|
||||
|
@ -242,8 +249,8 @@
|
|||
//
|
||||
// cmbprotocol
|
||||
//
|
||||
this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
|
||||
this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbprotocol.FormattingEnabled = true;
|
||||
this.cmbprotocol.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbprotocol.Items"),
|
||||
|
@ -269,6 +276,7 @@
|
|||
//
|
||||
// cmbloglevel
|
||||
//
|
||||
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
|
||||
this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbloglevel.FormattingEnabled = true;
|
||||
this.cmbloglevel.Items.AddRange(new object[] {
|
||||
|
@ -277,7 +285,6 @@
|
|||
resources.GetString("cmbloglevel.Items2"),
|
||||
resources.GetString("cmbloglevel.Items3"),
|
||||
resources.GetString("cmbloglevel.Items4")});
|
||||
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
|
||||
this.cmbloglevel.Name = "cmbloglevel";
|
||||
//
|
||||
// label5
|
||||
|
@ -297,33 +304,33 @@
|
|||
//
|
||||
// tabPage2
|
||||
//
|
||||
this.tabPage2.Controls.Add(this.groupBox2);
|
||||
resources.ApplyResources(this.tabPage2, "tabPage2");
|
||||
this.tabPage2.Controls.Add(this.groupBox2);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
resources.ApplyResources(this.groupBox2, "groupBox2");
|
||||
this.groupBox2.Controls.Add(this.tabControl2);
|
||||
this.groupBox2.Controls.Add(this.panel3);
|
||||
resources.ApplyResources(this.groupBox2, "groupBox2");
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.TabStop = false;
|
||||
//
|
||||
// tabControl2
|
||||
//
|
||||
resources.ApplyResources(this.tabControl2, "tabControl2");
|
||||
this.tabControl2.Controls.Add(this.tabPage3);
|
||||
this.tabControl2.Controls.Add(this.tabPage4);
|
||||
this.tabControl2.Controls.Add(this.tabPage5);
|
||||
this.tabControl2.Controls.Add(this.tabPage8);
|
||||
resources.ApplyResources(this.tabControl2, "tabControl2");
|
||||
this.tabControl2.Name = "tabControl2";
|
||||
this.tabControl2.SelectedIndex = 0;
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
this.tabPage3.Controls.Add(this.txtUseragent);
|
||||
resources.ApplyResources(this.tabPage3, "tabPage3");
|
||||
this.tabPage3.Controls.Add(this.txtUseragent);
|
||||
this.tabPage3.Name = "tabPage3";
|
||||
this.tabPage3.UseVisualStyleBackColor = true;
|
||||
//
|
||||
|
@ -334,8 +341,8 @@
|
|||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.Controls.Add(this.txtUserdirect);
|
||||
resources.ApplyResources(this.tabPage4, "tabPage4");
|
||||
this.tabPage4.Controls.Add(this.txtUserdirect);
|
||||
this.tabPage4.Name = "tabPage4";
|
||||
this.tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
|
@ -346,8 +353,8 @@
|
|||
//
|
||||
// tabPage5
|
||||
//
|
||||
this.tabPage5.Controls.Add(this.txtUserblock);
|
||||
resources.ApplyResources(this.tabPage5, "tabPage5");
|
||||
this.tabPage5.Controls.Add(this.txtUserblock);
|
||||
this.tabPage5.Name = "tabPage5";
|
||||
this.tabPage5.UseVisualStyleBackColor = true;
|
||||
//
|
||||
|
@ -358,13 +365,14 @@
|
|||
//
|
||||
// tabPage8
|
||||
//
|
||||
this.tabPage8.Controls.Add(this.cmbroutingMode);
|
||||
resources.ApplyResources(this.tabPage8, "tabPage8");
|
||||
this.tabPage8.Controls.Add(this.cmbroutingMode);
|
||||
this.tabPage8.Name = "tabPage8";
|
||||
this.tabPage8.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cmbroutingMode
|
||||
//
|
||||
resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode");
|
||||
this.cmbroutingMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbroutingMode.FormattingEnabled = true;
|
||||
this.cmbroutingMode.Items.AddRange(new object[] {
|
||||
|
@ -372,16 +380,15 @@
|
|||
resources.GetString("cmbroutingMode.Items1"),
|
||||
resources.GetString("cmbroutingMode.Items2"),
|
||||
resources.GetString("cmbroutingMode.Items3")});
|
||||
resources.ApplyResources(this.cmbroutingMode, "cmbroutingMode");
|
||||
this.cmbroutingMode.Name = "cmbroutingMode";
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
resources.ApplyResources(this.panel3, "panel3");
|
||||
this.panel3.Controls.Add(this.btnSetDefRountingRule);
|
||||
this.panel3.Controls.Add(this.labRoutingTips);
|
||||
this.panel3.Controls.Add(this.cmbdomainStrategy);
|
||||
this.panel3.Controls.Add(this.label15);
|
||||
resources.ApplyResources(this.panel3, "panel3");
|
||||
this.panel3.Name = "panel3";
|
||||
//
|
||||
// btnSetDefRountingRule
|
||||
|
@ -393,19 +400,19 @@
|
|||
//
|
||||
// labRoutingTips
|
||||
//
|
||||
this.labRoutingTips.ForeColor = System.Drawing.Color.Brown;
|
||||
resources.ApplyResources(this.labRoutingTips, "labRoutingTips");
|
||||
this.labRoutingTips.ForeColor = System.Drawing.Color.Brown;
|
||||
this.labRoutingTips.Name = "labRoutingTips";
|
||||
//
|
||||
// cmbdomainStrategy
|
||||
//
|
||||
resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy");
|
||||
this.cmbdomainStrategy.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbdomainStrategy.FormattingEnabled = true;
|
||||
this.cmbdomainStrategy.Items.AddRange(new object[] {
|
||||
resources.GetString("cmbdomainStrategy.Items"),
|
||||
resources.GetString("cmbdomainStrategy.Items1"),
|
||||
resources.GetString("cmbdomainStrategy.Items2")});
|
||||
resources.ApplyResources(this.cmbdomainStrategy, "cmbdomainStrategy");
|
||||
this.cmbdomainStrategy.Name = "cmbdomainStrategy";
|
||||
//
|
||||
// label15
|
||||
|
@ -415,6 +422,7 @@
|
|||
//
|
||||
// tabPage6
|
||||
//
|
||||
resources.ApplyResources(this.tabPage6, "tabPage6");
|
||||
this.tabPage6.Controls.Add(this.chkKcpcongestion);
|
||||
this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize);
|
||||
this.tabPage6.Controls.Add(this.label10);
|
||||
|
@ -428,7 +436,6 @@
|
|||
this.tabPage6.Controls.Add(this.label7);
|
||||
this.tabPage6.Controls.Add(this.txtKcpmtu);
|
||||
this.tabPage6.Controls.Add(this.label6);
|
||||
resources.ApplyResources(this.tabPage6, "tabPage6");
|
||||
this.tabPage6.Name = "tabPage6";
|
||||
this.tabPage6.UseVisualStyleBackColor = true;
|
||||
//
|
||||
|
@ -500,6 +507,7 @@
|
|||
//
|
||||
// tabPage7
|
||||
//
|
||||
resources.ApplyResources(this.tabPage7, "tabPage7");
|
||||
this.tabPage7.Controls.Add(this.cbFreshrate);
|
||||
this.tabPage7.Controls.Add(this.lbFreshrate);
|
||||
this.tabPage7.Controls.Add(this.chkEnableStatistics);
|
||||
|
@ -507,15 +515,14 @@
|
|||
this.tabPage7.Controls.Add(this.txturlGFWList);
|
||||
this.tabPage7.Controls.Add(this.label13);
|
||||
this.tabPage7.Controls.Add(this.chkAutoRun);
|
||||
resources.ApplyResources(this.tabPage7, "tabPage7");
|
||||
this.tabPage7.Name = "tabPage7";
|
||||
this.tabPage7.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbFreshrate
|
||||
//
|
||||
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
|
||||
this.cbFreshrate.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cbFreshrate.FormattingEnabled = true;
|
||||
resources.ApplyResources(this.cbFreshrate, "cbFreshrate");
|
||||
this.cbFreshrate.Name = "cbFreshrate";
|
||||
//
|
||||
// lbFreshrate
|
||||
|
@ -551,11 +558,36 @@
|
|||
this.chkAutoRun.Name = "chkAutoRun";
|
||||
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
|
||||
//
|
||||
resources.ApplyResources(this.panel2, "panel2");
|
||||
this.panel2.Controls.Add(this.btnClose);
|
||||
this.panel2.Controls.Add(this.btnOK);
|
||||
resources.ApplyResources(this.panel2, "panel2");
|
||||
this.panel2.Name = "panel2";
|
||||
//
|
||||
// btnOK
|
||||
|
@ -601,6 +633,9 @@
|
|||
this.tabPage6.PerformLayout();
|
||||
this.tabPage7.ResumeLayout(false);
|
||||
this.tabPage7.PerformLayout();
|
||||
this.tabPage9.ResumeLayout(false);
|
||||
this.tabPage9.PerformLayout();
|
||||
this.panel4.ResumeLayout(false);
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
|
@ -673,5 +708,9 @@
|
|||
private System.Windows.Forms.Label label16;
|
||||
private System.Windows.Forms.ComboBox cmblistenerType;
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,8 @@ namespace v2rayN.Forms
|
|||
InitKCP();
|
||||
|
||||
InitGUI();
|
||||
|
||||
InitUserPAC();
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
if (SaveBase() != 0)
|
||||
|
@ -164,6 +171,11 @@ namespace v2rayN.Forms
|
|||
return;
|
||||
}
|
||||
|
||||
if (SaveUserPAC() != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ConfigHandler.SaveConfig(ref config) == 0)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
|
@ -250,7 +262,7 @@ namespace v2rayN.Forms
|
|||
|
||||
//remoteDNS
|
||||
config.remoteDNS = txtremoteDNS.Text.TrimEx();
|
||||
|
||||
|
||||
config.listenerType = cmblistenerType.SelectedIndex;
|
||||
return 0;
|
||||
}
|
||||
|
@ -344,6 +356,15 @@ namespace v2rayN.Forms
|
|||
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)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -123,6 +123,21 @@
|
|||
<data name="tabPage1.Text" xml:space="preserve">
|
||||
<value> Core:基础设置 </value>
|
||||
</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" />
|
||||
<data name="label16.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>53, 12</value>
|
||||
|
@ -214,9 +229,6 @@
|
|||
<data name="label2.Text" xml:space="preserve">
|
||||
<value>本地监听端口</value>
|
||||
</data>
|
||||
<data name="tabPage2.Text" xml:space="preserve">
|
||||
<value> Core:路由设置 </value>
|
||||
</data>
|
||||
<data name="tabControl2.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>3, 89</value>
|
||||
</data>
|
||||
|
@ -315,24 +327,12 @@
|
|||
<data name="label15.Text" xml:space="preserve">
|
||||
<value>域名策略</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="lbFreshrate.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>77, 12</value>
|
||||
</data>
|
||||
<data name="lbFreshrate.Text" xml:space="preserve">
|
||||
<value>统计刷新频率</value>
|
||||
</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">
|
||||
<value>384, 16</value>
|
||||
</data>
|
||||
|
|
|
@ -131,6 +131,10 @@ namespace v2rayN.Handler
|
|||
{
|
||||
config.subItem = new List<SubItem>();
|
||||
}
|
||||
if (config.userPacRule == null)
|
||||
{
|
||||
config.userPacRule = new List<string>();
|
||||
}
|
||||
|
||||
if (config == null
|
||||
|| config.index < 0
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -17,6 +17,7 @@ namespace v2rayN.HttpProxyHandler
|
|||
private static int pacPort = 0;
|
||||
private static HttpWebServer server;
|
||||
private static HttpWebServerB serverB;
|
||||
private static Config _config;
|
||||
|
||||
public static bool IsRunning
|
||||
{
|
||||
|
@ -28,6 +29,7 @@ namespace v2rayN.HttpProxyHandler
|
|||
|
||||
public static void Init(Config config)
|
||||
{
|
||||
_config = config;
|
||||
Global.pacPort = config.GetLocalPort("pac");
|
||||
|
||||
if (InitServer("*"))
|
||||
|
@ -161,7 +163,6 @@ namespace v2rayN.HttpProxyHandler
|
|||
//}
|
||||
}
|
||||
|
||||
|
||||
private static string GetPacList(string address)
|
||||
{
|
||||
var port = Global.httpPort;
|
||||
|
@ -182,6 +183,18 @@ namespace v2rayN.HttpProxyHandler
|
|||
}
|
||||
var pac = File.ReadAllText(strPacfile, Encoding.UTF8);
|
||||
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;
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -169,6 +169,11 @@ namespace v2rayN.Mode
|
|||
get; set;
|
||||
}
|
||||
|
||||
public List<string> userPacRule
|
||||
{
|
||||
get; set;
|
||||
}
|
||||
|
||||
#region 函数
|
||||
|
||||
public string address()
|
||||
|
|
|
@ -230,7 +230,6 @@
|
|||
</Compile>
|
||||
<Compile Include="Global.cs" />
|
||||
<Compile Include="Handler\QRCodeHelper.cs" />
|
||||
<Compile Include="Handler\RoutingRuleHandler.cs" />
|
||||
<Compile Include="Mode\VmessQRCode.cs" />
|
||||
<Compile Include="Mode\V2rayTcpRequest.cs" />
|
||||
<Compile Include="Handler\ConfigHandler.cs" />
|
||||
|
|
Loading…
Reference in New Issue