This commit is contained in:
Amazing_DM
2020-04-01 14:37:29 +08:00
parent 2895989b13
commit c2f33ba15b
5 changed files with 50 additions and 6 deletions

View File

@@ -207,12 +207,11 @@ namespace Netch.Controllers
}
}
Utils.Logging.Info($"{fallback}");
if (File.Exists("logging\\redirector.log"))
File.Delete("logging\\redirector.log");
Instance.StartInfo.Arguments = fallback;
Instance.StartInfo.Arguments = fallback + $" -tcport {Global.Settings.RedirectorTCPPort}";
Utils.Logging.Info(Instance.StartInfo.Arguments);
Instance.OutputDataReceived += OnOutputDataReceived;
Instance.ErrorDataReceived += OnOutputDataReceived;
State = Models.State.Starting;

View File

@@ -68,6 +68,8 @@
this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox();
this.ExitWhenClosedCheckBox = new System.Windows.Forms.CheckBox();
this.RedirectorLabel = new System.Windows.Forms.Label();
this.RedirectorTextBox = new System.Windows.Forms.TextBox();
this.PortGroupBox.SuspendLayout();
this.TUNTAPGroupBox.SuspendLayout();
this.BehaviorGroupBox.SuspendLayout();
@@ -75,6 +77,8 @@
//
// PortGroupBox
//
this.PortGroupBox.Controls.Add(this.RedirectorLabel);
this.PortGroupBox.Controls.Add(this.RedirectorTextBox);
this.PortGroupBox.Controls.Add(this.AllowDevicesCheckBox);
this.PortGroupBox.Controls.Add(this.HTTPPortLabel);
this.PortGroupBox.Controls.Add(this.HTTPPortTextBox);
@@ -90,7 +94,7 @@
// AllowDevicesCheckBox
//
this.AllowDevicesCheckBox.AutoSize = true;
this.AllowDevicesCheckBox.Location = new System.Drawing.Point(120, 80);
this.AllowDevicesCheckBox.Location = new System.Drawing.Point(120, 109);
this.AllowDevicesCheckBox.Name = "AllowDevicesCheckBox";
this.AllowDevicesCheckBox.Size = new System.Drawing.Size(206, 21);
this.AllowDevicesCheckBox.TabIndex = 5;
@@ -471,6 +475,23 @@
this.ExitWhenClosedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
this.ExitWhenClosedCheckBox.UseVisualStyleBackColor = true;
//
// RedirectorLabel
//
this.RedirectorLabel.AutoSize = true;
this.RedirectorLabel.Location = new System.Drawing.Point(9, 83);
this.RedirectorLabel.Name = "RedirectorLabel";
this.RedirectorLabel.Size = new System.Drawing.Size(95, 17);
this.RedirectorLabel.TabIndex = 6;
this.RedirectorLabel.Text = "Redirector TCP";
//
// RedirectorTextBox
//
this.RedirectorTextBox.Location = new System.Drawing.Point(120, 80);
this.RedirectorTextBox.Name = "RedirectorTextBox";
this.RedirectorTextBox.Size = new System.Drawing.Size(294, 23);
this.RedirectorTextBox.TabIndex = 7;
this.RedirectorTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
//
// SettingForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@@ -542,5 +563,7 @@
private System.Windows.Forms.CheckBox EnableStartedTcping_CheckBox;
private System.Windows.Forms.Label DelayTestAfterStartup_Label;
private System.Windows.Forms.Label DetectionInterval_Label;
private System.Windows.Forms.Label RedirectorLabel;
private System.Windows.Forms.TextBox RedirectorTextBox;
}
}

View File

@@ -69,6 +69,7 @@ namespace Netch.Forms
Socks5PortTextBox.Text = Global.Settings.Socks5LocalPort.ToString();
HTTPPortTextBox.Text = Global.Settings.HTTPLocalPort.ToString();
RedirectorTextBox.Text = Global.Settings.RedirectorTCPPort.ToString();
TUNTAPAddressTextBox.Text = Global.Settings.TUNTAP.Address;
TUNTAPNetmaskTextBox.Text = Global.Settings.TUNTAP.Netmask;
@@ -238,6 +239,27 @@ namespace Netch.Forms
return;
}
try
{
var RedirectorPort = int.Parse(RedirectorTextBox.Text);
if (RedirectorPort > 0 && RedirectorPort < 65536)
{
Global.Settings.RedirectorTCPPort = RedirectorPort;
}
else
{
throw new FormatException();
}
}
catch (FormatException)
{
RedirectorTextBox.Text = Global.Settings.RedirectorTCPPort.ToString();
MessageBox.Show(Utils.i18N.Translate("Port value illegal. Try again."), Utils.i18N.Translate("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (AllowDevicesCheckBox.Checked)
{
Global.Settings.LocalAddress = "0.0.0.0";

View File

@@ -102,7 +102,7 @@ namespace Netch.Models
/// <summary>
/// Redirector TCP 占用端口
/// </summary>
//public int RedirectorTCPPort = 2800;
public int RedirectorTCPPort = 3901;
/// <summary>
/// HTTP 和 Socks5 本地代理地址