Browse Source

Enable system agent advanced settings

pull/2295/head
2dust 3 years ago
parent
commit
6259539c87
  1. 3
      v2rayN/v2rayN/Forms/MainMsgControl.resx
  2. 49
      v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs
  3. 4
      v2rayN/v2rayN/Forms/OptionSettingForm.cs
  4. 2622
      v2rayN/v2rayN/Forms/OptionSettingForm.resx
  5. 3
      v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx
  6. 48
      v2rayN/v2rayN/Handler/SysProxyHandle.cs
  7. 1
      v2rayN/v2rayN/Mode/Config.cs

3
v2rayN/v2rayN/Forms/MainMsgControl.resx

@ -375,9 +375,6 @@
<metadata name="ssMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>131, 18</value>
</metadata>
<metadata name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>zh-Hans</value>
</metadata>
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>

49
v2rayN/v2rayN/Forms/OptionSettingForm.Designer.cs generated

@ -104,6 +104,7 @@
this.panel2 = new System.Windows.Forms.Panel();
this.btnOK = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.chkEnableSystemProxyAdvanced = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
@ -118,34 +119,33 @@
//
// btnClose
//
resources.ApplyResources(this.btnClose, "btnClose");
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
resources.ApplyResources(this.btnClose, "btnClose");
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);
this.tabControl1.Controls.Add(this.tabPageCoreType);
this.tabControl1.Controls.Add(this.tabPage3);
resources.ApplyResources(this.tabControl1, "tabControl1");
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
//
// tabPage1
//
resources.ApplyResources(this.tabPage1, "tabPage1");
this.tabPage1.Controls.Add(this.groupBox1);
resources.ApplyResources(this.tabPage1, "tabPage1");
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.label4);
this.groupBox1.Controls.Add(this.txtpass);
@ -162,6 +162,7 @@
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;
//
@ -211,8 +212,8 @@
//
// cmbprotocol
//
resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
this.cmbprotocol.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
resources.ApplyResources(this.cmbprotocol, "cmbprotocol");
this.cmbprotocol.FormattingEnabled = true;
this.cmbprotocol.Items.AddRange(new object[] {
resources.GetString("cmbprotocol.Items"),
@ -238,7 +239,6 @@
//
// cmbloglevel
//
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbloglevel.FormattingEnabled = true;
this.cmbloglevel.Items.AddRange(new object[] {
@ -247,6 +247,7 @@
resources.GetString("cmbloglevel.Items2"),
resources.GetString("cmbloglevel.Items3"),
resources.GetString("cmbloglevel.Items4")});
resources.ApplyResources(this.cmbloglevel, "cmbloglevel");
this.cmbloglevel.Name = "cmbloglevel";
//
// label5
@ -266,10 +267,10 @@
//
// tabPage2
//
resources.ApplyResources(this.tabPage2, "tabPage2");
this.tabPage2.Controls.Add(this.linkDnsObjectDoc);
this.tabPage2.Controls.Add(this.txtremoteDNS);
this.tabPage2.Controls.Add(this.label14);
resources.ApplyResources(this.tabPage2, "tabPage2");
this.tabPage2.Name = "tabPage2";
this.tabPage2.UseVisualStyleBackColor = true;
//
@ -292,7 +293,6 @@
//
// tabPage6
//
resources.ApplyResources(this.tabPage6, "tabPage6");
this.tabPage6.Controls.Add(this.chkKcpcongestion);
this.tabPage6.Controls.Add(this.txtKcpwriteBufferSize);
this.tabPage6.Controls.Add(this.label10);
@ -306,6 +306,7 @@
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;
//
@ -377,7 +378,6 @@
//
// tabPage7
//
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Controls.Add(this.txttrayMenuServersLimit);
this.tabPage7.Controls.Add(this.label17);
this.tabPage7.Controls.Add(this.txtautoUpdateSubInterval);
@ -393,6 +393,7 @@
this.tabPage7.Controls.Add(this.lbFreshrate);
this.tabPage7.Controls.Add(this.chkEnableStatistics);
this.tabPage7.Controls.Add(this.chkAutoRun);
resources.ApplyResources(this.tabPage7, "tabPage7");
this.tabPage7.Name = "tabPage7";
this.tabPage7.UseVisualStyleBackColor = true;
//
@ -459,9 +460,9 @@
//
// 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
@ -483,7 +484,6 @@
//
// tabPageCoreType
//
resources.ApplyResources(this.tabPageCoreType, "tabPageCoreType");
this.tabPageCoreType.Controls.Add(this.cmbCoreType6);
this.tabPageCoreType.Controls.Add(this.labCoreType6);
this.tabPageCoreType.Controls.Add(this.cmbCoreType5);
@ -496,14 +496,15 @@
this.tabPageCoreType.Controls.Add(this.labCoreType2);
this.tabPageCoreType.Controls.Add(this.cmbCoreType1);
this.tabPageCoreType.Controls.Add(this.labCoreType1);
resources.ApplyResources(this.tabPageCoreType, "tabPageCoreType");
this.tabPageCoreType.Name = "tabPageCoreType";
this.tabPageCoreType.UseVisualStyleBackColor = true;
//
// cmbCoreType6
//
resources.ApplyResources(this.cmbCoreType6, "cmbCoreType6");
this.cmbCoreType6.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCoreType6.FormattingEnabled = true;
resources.ApplyResources(this.cmbCoreType6, "cmbCoreType6");
this.cmbCoreType6.Name = "cmbCoreType6";
//
// labCoreType6
@ -513,9 +514,9 @@
//
// cmbCoreType5
//
resources.ApplyResources(this.cmbCoreType5, "cmbCoreType5");
this.cmbCoreType5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCoreType5.FormattingEnabled = true;
resources.ApplyResources(this.cmbCoreType5, "cmbCoreType5");
this.cmbCoreType5.Name = "cmbCoreType5";
//
// labCoreType5
@ -525,9 +526,9 @@
//
// cmbCoreType4
//
resources.ApplyResources(this.cmbCoreType4, "cmbCoreType4");
this.cmbCoreType4.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCoreType4.FormattingEnabled = true;
resources.ApplyResources(this.cmbCoreType4, "cmbCoreType4");
this.cmbCoreType4.Name = "cmbCoreType4";
//
// labCoreType4
@ -537,9 +538,9 @@
//
// cmbCoreType3
//
resources.ApplyResources(this.cmbCoreType3, "cmbCoreType3");
this.cmbCoreType3.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCoreType3.FormattingEnabled = true;
resources.ApplyResources(this.cmbCoreType3, "cmbCoreType3");
this.cmbCoreType3.Name = "cmbCoreType3";
//
// labCoreType3
@ -549,9 +550,9 @@
//
// cmbCoreType2
//
resources.ApplyResources(this.cmbCoreType2, "cmbCoreType2");
this.cmbCoreType2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCoreType2.FormattingEnabled = true;
resources.ApplyResources(this.cmbCoreType2, "cmbCoreType2");
this.cmbCoreType2.Name = "cmbCoreType2";
//
// labCoreType2
@ -561,9 +562,9 @@
//
// cmbCoreType1
//
resources.ApplyResources(this.cmbCoreType1, "cmbCoreType1");
this.cmbCoreType1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbCoreType1.FormattingEnabled = true;
resources.ApplyResources(this.cmbCoreType1, "cmbCoreType1");
this.cmbCoreType1.Name = "cmbCoreType1";
//
// labCoreType1
@ -573,17 +574,18 @@
//
// tabPage3
//
resources.ApplyResources(this.tabPage3, "tabPage3");
this.tabPage3.Controls.Add(this.groupBox2);
resources.ApplyResources(this.tabPage3, "tabPage3");
this.tabPage3.Name = "tabPage3";
this.tabPage3.UseVisualStyleBackColor = true;
//
// groupBox2
//
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Controls.Add(this.chkEnableSystemProxyAdvanced);
this.groupBox2.Controls.Add(this.label13);
this.groupBox2.Controls.Add(this.label12);
this.groupBox2.Controls.Add(this.txtsystemProxyExceptions);
resources.ApplyResources(this.groupBox2, "groupBox2");
this.groupBox2.Name = "groupBox2";
this.groupBox2.TabStop = false;
//
@ -604,9 +606,9 @@
//
// 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
@ -621,6 +623,12 @@
resources.ApplyResources(this.panel1, "panel1");
this.panel1.Name = "panel1";
//
// chkEnableSystemProxyAdvanced
//
resources.ApplyResources(this.chkEnableSystemProxyAdvanced, "chkEnableSystemProxyAdvanced");
this.chkEnableSystemProxyAdvanced.Name = "chkEnableSystemProxyAdvanced";
this.chkEnableSystemProxyAdvanced.UseVisualStyleBackColor = true;
//
// OptionSettingForm
//
resources.ApplyResources(this, "$this");
@ -729,5 +737,6 @@
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txttrayMenuServersLimit;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.CheckBox chkEnableSystemProxyAdvanced;
}
}

4
v2rayN/v2rayN/Forms/OptionSettingForm.cs

@ -58,6 +58,8 @@ namespace v2rayN.Forms
chkdefAllowInsecure.Checked = config.defAllowInsecure;
txtsystemProxyExceptions.Text = config.systemProxyExceptions;
chkEnableSystemProxyAdvanced.Checked = config.enableSystemProxyAdvanced;
}
@ -253,6 +255,8 @@ namespace v2rayN.Forms
config.systemProxyExceptions = txtsystemProxyExceptions.Text.TrimEx();
config.enableSystemProxyAdvanced = chkEnableSystemProxyAdvanced.Checked;
return 0;
}

2622
v2rayN/v2rayN/Forms/OptionSettingForm.resx

File diff suppressed because it is too large Load Diff

3
v2rayN/v2rayN/Forms/OptionSettingForm.zh-Hans.resx

@ -373,4 +373,7 @@
<data name="$this.Text" xml:space="preserve">
<value>参数设置</value>
</data>
<data name="chkEnableSystemProxyAdvanced.Text" xml:space="preserve">
<value>开启系统代理高级设置 (http/https/ftp/socks)</value>
</data>
</root>

48
v2rayN/v2rayN/Handler/SysProxyHandle.cs

@ -60,6 +60,7 @@ namespace v2rayN.Handler
try
{
int port = config.GetLocalPort(Global.InboundHttp);
int portSocks = config.GetLocalPort(Global.InboundSocks);
if (port <= 0)
{
return false;
@ -67,7 +68,17 @@ namespace v2rayN.Handler
if (type == ESysProxyType.ForcedChange)
{
var strExceptions = $"{config.constItem.defIEProxyExceptions};{config.systemProxyExceptions}";
SetIEProxy(true, $"{Global.Loopback}:{port}", strExceptions);
var strProxy = string.Empty;
if (config.enableSystemProxyAdvanced)
{
strProxy = string.Format("http={0}:{1};https={0}:{1};ftp={0}:{1};socks={0}:{2}", Global.Loopback, port, portSocks);
}
else
{
strProxy = $"{Global.Loopback}:{port}";
}
SetIEProxy(true, strProxy, strExceptions);
}
else if (type == ESysProxyType.ForcedClear)
{
@ -96,41 +107,6 @@ namespace v2rayN.Handler
}
}
public static void SetIEProxy(bool enable, bool global, string strProxy)
{
//Read();
//if (!_userSettings.UserSettingsRecorded)
//{
// // record user settings
// ExecSysproxy("query");
// //ParseQueryStr(_queryStr);
//}
string arguments;
if (enable)
{
arguments = global
? $"global {strProxy} {Global.IEProxyExceptions}"
: $"pac {strProxy}";
}
else
{
// restore user settings
string flags = _userSettings.Flags;
string proxy_server = _userSettings.ProxyServer ?? "-";
string bypass_list = _userSettings.BypassList ?? "-";
string pac_url = _userSettings.PacUrl ?? "-";
arguments = $"set {flags} {proxy_server} {bypass_list} {pac_url}";
// have to get new settings
_userSettings.UserSettingsRecorded = false;
}
//Save();
ExecSysproxy(arguments);
}
public static void SetIEProxy(bool global, string strProxy, string strExceptions)
{

1
v2rayN/v2rayN/Mode/Config.cs

@ -124,6 +124,7 @@ namespace v2rayN.Mode
{
get; set;
}
public bool enableSystemProxyAdvanced { get; set; }
public int autoUpdateInterval { get; set; } = 0;

Loading…
Cancel
Save