增加一个全局生效的socks端口

This commit is contained in:
YohoYang 2022-10-21 00:02:16 +08:00
parent b3292729b0
commit 5f7feac85c
12 changed files with 1239 additions and 1156 deletions

View file

@ -106,6 +106,12 @@ namespace v2rayN.Forms
sb.Append($"[{Global.InboundHttp}:{config.GetLocalPort(Global.InboundHttp2)}]");
}
if (config.inbound[0].addGlobalProxyPort)
{
sb.Append($" {ResUI.LabLocalGlobal}:");
sb.Append($"[{Global.InboundSocks}:{config.GetLocalPort(Global.InboundSocksG)}]");
}
SetToolSslInfo("inbound", sb.ToString());
}

View file

@ -70,6 +70,7 @@
this.txtKcpmtu = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.tabPage7 = new System.Windows.Forms.TabPage();
this.chkEnableCheckPreReleaseUpdate = new System.Windows.Forms.CheckBox();
this.numStatisticsFreshRate = new System.Windows.Forms.NumericUpDown();
this.txttrayMenuServersLimit = new System.Windows.Forms.TextBox();
this.label17 = new System.Windows.Forms.Label();
@ -108,7 +109,7 @@
this.panel2 = new System.Windows.Forms.Panel();
this.btnOK = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.chkEnableCheckPreReleaseUpdate = new System.Windows.Forms.CheckBox();
this.chkaddGlobalProxyPort = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
@ -151,6 +152,7 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.chkaddGlobalProxyPort);
this.groupBox1.Controls.Add(this.label16);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.txtpass);
@ -422,6 +424,12 @@
this.tabPage7.Name = "tabPage7";
this.tabPage7.UseVisualStyleBackColor = true;
//
// chkEnableCheckPreReleaseUpdate
//
resources.ApplyResources(this.chkEnableCheckPreReleaseUpdate, "chkEnableCheckPreReleaseUpdate");
this.chkEnableCheckPreReleaseUpdate.Name = "chkEnableCheckPreReleaseUpdate";
this.chkEnableCheckPreReleaseUpdate.UseVisualStyleBackColor = true;
//
// numStatisticsFreshRate
//
resources.ApplyResources(this.numStatisticsFreshRate, "numStatisticsFreshRate");
@ -658,11 +666,11 @@
resources.ApplyResources(this.panel1, "panel1");
this.panel1.Name = "panel1";
//
// chkEnableCheckPreReleaseUpdate
// chkaddGlobalProxyPort
//
resources.ApplyResources(this.chkEnableCheckPreReleaseUpdate, "chkEnableCheckPreReleaseUpdate");
this.chkEnableCheckPreReleaseUpdate.Name = "chkEnableCheckPreReleaseUpdate";
this.chkEnableCheckPreReleaseUpdate.UseVisualStyleBackColor = true;
resources.ApplyResources(this.chkaddGlobalProxyPort, "chkaddGlobalProxyPort");
this.chkaddGlobalProxyPort.Name = "chkaddGlobalProxyPort";
this.chkaddGlobalProxyPort.UseVisualStyleBackColor = true;
//
// OptionSettingForm
//
@ -778,5 +786,6 @@
private System.Windows.Forms.ComboBox cmbdomainStrategy4Freedom;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.CheckBox chkEnableCheckPreReleaseUpdate;
private System.Windows.Forms.CheckBox chkaddGlobalProxyPort;
}
}

View file

@ -49,6 +49,7 @@ namespace v2rayN.Forms
chkudpEnabled.Checked = config.inbound[0].udpEnabled;
chksniffingEnabled.Checked = config.inbound[0].sniffingEnabled;
chkAllowLANConn.Checked = config.inbound[0].allowLANConn;
chkaddGlobalProxyPort.Checked = config.inbound[0].addGlobalProxyPort;
txtuser.Text = config.inbound[0].user;
txtpass.Text = config.inbound[0].pass;
@ -183,6 +184,7 @@ namespace v2rayN.Forms
bool udpEnabled = chkudpEnabled.Checked;
bool sniffingEnabled = chksniffingEnabled.Checked;
bool allowLANConn = chkAllowLANConn.Checked;
bool addGlobalProxyPort = chkaddGlobalProxyPort.Checked;
if (Utils.IsNullOrEmpty(localPort) || !Utils.IsNumberic(localPort))
{
UI.Show(ResUI.FillLocalListeningPort);
@ -213,6 +215,7 @@ namespace v2rayN.Forms
config.inbound[0].udpEnabled = udpEnabled;
config.inbound[0].sniffingEnabled = sniffingEnabled;
config.inbound[0].allowLANConn = allowLANConn;
config.inbound[0].addGlobalProxyPort = addGlobalProxyPort;
config.inbound[0].user = txtuser.Text;
config.inbound[0].pass = txtpass.Text;

File diff suppressed because it is too large Load diff

View file

@ -163,8 +163,14 @@
<data name="chkAllowLANConn.Text" xml:space="preserve">
<value>允许来自局域网的连接</value>
</data>
<data name="chksniffingEnabled.Size" type="System.Drawing.Size, System.Drawing">
<value>96, 16</value>
<data name="chkAllowLANConn.Size" type="System.Drawing.Size, System.Drawing">
<value>144, 16</value>
</data>
<data name="chkaddGlobalProxyPort.Text" xml:space="preserve">
<value>增加一个本地全局socks端口</value>
</data>
<data name="chkaddGlobalProxyPort.Size" type="System.Drawing.Size, System.Drawing">
<value>144, 16</value>
</data>
<data name="chksniffingEnabled.Text" xml:space="preserve">
<value>开启流量探测</value>

View file

@ -120,6 +120,7 @@ namespace v2rayN
public const string InboundHttp = "http";
public const string InboundSocks2 = "socks2";
public const string InboundHttp2 = "http2";
public const string InboundSocksG = "socksG";
public const string Loopback = "127.0.0.1";
public const string InboundAPITagName = "api";
public const string InboundAPIProtocal = "dokodemo-door";

View file

@ -156,6 +156,12 @@ namespace v2rayN.Handler
inbound4.settings.accounts = new List<AccountsItem> { new AccountsItem() { user = config.inbound[0].user, pass = config.inbound[0].pass } };
}
}
if (config.inbound[0].addGlobalProxyPort)
{
Inbounds inbound5 = GetInbound(config.inbound[0], Global.InboundSocksG, 4, true);
v2rayConfig.inbounds.Add(inbound5);
}
}
catch (Exception ex)
{
@ -202,6 +208,17 @@ namespace v2rayN.Handler
v2rayConfig.routing.domainStrategy = config.domainStrategy;
v2rayConfig.routing.domainMatcher = Utils.IsNullOrEmpty(config.domainMatcher) ? null : config.domainMatcher;
if (config.inbound[0].addGlobalProxyPort)
{
var item = new RulesItem();
var inTag = new List<String>();
inTag.Add("socksG");
item.type = "field";
item.inboundTag = inTag;
item.outboundTag = "proxy";
v2rayConfig.routing.rules.Add(item);
}
if (config.enableRoutingAdvanced)
{
if (config.routings != null && config.routingIndex < config.routings.Count)

View file

@ -238,6 +238,10 @@ namespace v2rayN.Mode
{
return localPort + 3;
}
else if (protocol == Global.InboundSocksG)
{
return localPort + 4;
}
else if (protocol == "speedtest")
{
return localPort + 103;
@ -611,6 +615,8 @@ namespace v2rayN.Mode
public bool allowLANConn { get; set; }
public bool addGlobalProxyPort { get; set; }
public string user { get; set; }
public string pass { get; set; }

View file

@ -12,7 +12,7 @@ namespace v2rayN.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View file

@ -339,6 +339,17 @@ namespace v2rayN.Resx {
}
}
/// <summary>
/// 查找类似 Local 的本地化字符串。
/// </summary>
internal static string LabLocalGlobal
{
get
{
return ResourceManager.GetString("LabLocalGlobal", resourceCulture);
}
}
/// <summary>
/// 查找类似 Address 的本地化字符串。
/// </summary>

View file

@ -475,4 +475,7 @@
<data name="NetFrameworkRequirementsTip" xml:space="preserve">
<value>Normal use of this version requires .NET Framework 4.8</value>
</data>
<data name="LabLocalGlobal" xml:space="preserve">
<value>Global</value>
</data>
</root>

View file

@ -475,4 +475,7 @@
<data name="NetFrameworkRequirementsTip" xml:space="preserve">
<value>正常使用此版本需要.NET Framework 4.8,请更新后重启</value>
</data>
<data name="LabLocalGlobal" xml:space="preserve">
<value>全局</value>
</data>
</root>