This commit is contained in:
fallenwood 2022-12-07 11:22:33 +08:00
parent cdf35740d9
commit 7d853fc51b
7 changed files with 825 additions and 1401 deletions

View file

@ -100,10 +100,19 @@ namespace v2rayN.Forms
if (config.inbound[0].allowLANConn)
{
var inboudSocks2 = Global.InboundSocks2;
var inboudHttp2 = Global.InboundHttp2;
if (config.inbound[0].useSamePortForLocalAndLan)
{
inboudSocks2 = Global.InboundSocks;
inboudHttp2 = Global.InboundHttp;
}
sb.Append($" {ResUI.LabLAN}:");
sb.Append($"[{Global.InboundSocks}:{config.GetLocalPort(Global.InboundSocks2)}]");
sb.Append($"[{Global.InboundSocks}:{config.GetLocalPort(inboudSocks2)}]");
sb.Append(" | ");
sb.Append($"[{Global.InboundHttp}:{config.GetLocalPort(Global.InboundHttp2)}]");
sb.Append($"[{Global.InboundHttp}:{config.GetLocalPort(inboudHttp2)}]");
}
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.chkUseSamePortForLocalAndLan = new System.Windows.Forms.CheckBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.groupBox1.SuspendLayout();
@ -155,6 +156,7 @@
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.txtpass);
this.groupBox1.Controls.Add(this.txtuser);
this.groupBox1.Controls.Add(this.chkUseSamePortForLocalAndLan);
this.groupBox1.Controls.Add(this.chkdefAllowInsecure);
this.groupBox1.Controls.Add(this.chkAllowLANConn);
this.groupBox1.Controls.Add(this.chksniffingEnabled);
@ -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
// chkUseSamePortForLocalAndLan
//
resources.ApplyResources(this.chkEnableCheckPreReleaseUpdate, "chkEnableCheckPreReleaseUpdate");
this.chkEnableCheckPreReleaseUpdate.Name = "chkEnableCheckPreReleaseUpdate";
this.chkEnableCheckPreReleaseUpdate.UseVisualStyleBackColor = true;
resources.ApplyResources(this.chkUseSamePortForLocalAndLan, "chkUseSamePortForLocalAndLan");
this.chkUseSamePortForLocalAndLan.Name = "chkUseSamePortForLocalAndLan";
this.chkUseSamePortForLocalAndLan.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 chkUseSamePortForLocalAndLan;
}
}

View file

@ -53,7 +53,7 @@ namespace v2rayN.Forms
chkAllowLANConn.Checked = config.inbound[0].allowLANConn;
txtuser.Text = config.inbound[0].user;
txtpass.Text = config.inbound[0].pass;
chkUseSamePortForLocalAndLan.Checked = config.inbound[0].useSamePortForLocalAndLan;
}
//remoteDNS
@ -185,6 +185,7 @@ namespace v2rayN.Forms
bool udpEnabled = chkudpEnabled.Checked;
bool sniffingEnabled = chksniffingEnabled.Checked;
bool allowLANConn = chkAllowLANConn.Checked;
bool useSamePortForLocalAndLan = chkUseSamePortForLocalAndLan.Checked;
if (Utils.IsNullOrEmpty(localPort) || !Utils.IsNumberic(localPort))
{
UI.Show(ResUI.FillLocalListeningPort);
@ -215,6 +216,7 @@ namespace v2rayN.Forms
config.inbound[0].udpEnabled = udpEnabled;
config.inbound[0].sniffingEnabled = sniffingEnabled;
config.inbound[0].allowLANConn = allowLANConn;
config.inbound[0].useSamePortForLocalAndLan = useSamePortForLocalAndLan;
config.inbound[0].user = txtuser.Text;
config.inbound[0].pass = txtpass.Text;

File diff suppressed because it is too large Load diff

View file

@ -391,4 +391,7 @@
<data name="chkEnableCheckPreReleaseUpdate.Text" xml:space="preserve">
<value>检查Pre-Release更新(请谨慎启用)</value>
</data>
<data name="chkUseSamePortForLocalAndLan.Text" xml:space="preserve">
<value>为局域网和本地回环使用相通的端口</value>
</data>
</root>

View file

@ -138,22 +138,40 @@ namespace v2rayN.Handler
if (config.inbound[0].allowLANConn)
{
Inbounds inbound3 = GetInbound(config.inbound[0], Global.InboundSocks2, 2, true);
inbound3.listen = "0.0.0.0";
v2rayConfig.inbounds.Add(inbound3);
Inbounds inbound4 = GetInbound(config.inbound[0], Global.InboundHttp2, 3, false);
inbound4.listen = "0.0.0.0";
v2rayConfig.inbounds.Add(inbound4);
//auth
if (!Utils.IsNullOrEmpty(config.inbound[0].user) && !Utils.IsNullOrEmpty(config.inbound[0].pass))
if (config.inbound[0].useSamePortForLocalAndLan)
{
inbound3.settings.auth = "password";
inbound3.settings.accounts = new List<AccountsItem> { new AccountsItem() { user = config.inbound[0].user, pass = config.inbound[0].pass } };
inbound.listen = "0.0.0.0";
inbound2.listen = "0.0.0.0";
inbound4.settings.auth = "password";
inbound4.settings.accounts = new List<AccountsItem> { new AccountsItem() { user = config.inbound[0].user, pass = config.inbound[0].pass } };
//auth
if (!Utils.IsNullOrEmpty(config.inbound[0].user) && !Utils.IsNullOrEmpty(config.inbound[0].pass))
{
inbound.settings.auth = "password";
inbound.settings.accounts = new List<AccountsItem> { new AccountsItem() { user = config.inbound[0].user, pass = config.inbound[0].pass } };
inbound2.settings.auth = "password";
inbound2.settings.accounts = new List<AccountsItem> { new AccountsItem() { user = config.inbound[0].user, pass = config.inbound[0].pass } };
}
}
else
{
Inbounds inbound3 = GetInbound(config.inbound[0], Global.InboundSocks2, 2, true);
inbound3.listen = "0.0.0.0";
v2rayConfig.inbounds.Add(inbound3);
Inbounds inbound4 = GetInbound(config.inbound[0], Global.InboundHttp2, 3, false);
inbound4.listen = "0.0.0.0";
v2rayConfig.inbounds.Add(inbound4);
//auth
if (!Utils.IsNullOrEmpty(config.inbound[0].user) && !Utils.IsNullOrEmpty(config.inbound[0].pass))
{
inbound3.settings.auth = "password";
inbound3.settings.accounts = new List<AccountsItem> { new AccountsItem() { user = config.inbound[0].user, pass = config.inbound[0].pass } };
inbound4.settings.auth = "password";
inbound4.settings.accounts = new List<AccountsItem> { new AccountsItem() { user = config.inbound[0].user, pass = config.inbound[0].pass } };
}
}
}
}

View file

@ -615,6 +615,7 @@ namespace v2rayN.Mode
public string pass { get; set; }
public bool useSamePortForLocalAndLan { get; set; }
}
[Serializable]