1、增加一个tunnel端口。2、跳过v3.8.6.6对配置文件读写优化。
This commit is contained in:
wisdomwei201804 2020-02-17 16:09:47 +08:00
parent f1efc46a56
commit 353ade281a
5 changed files with 125 additions and 59 deletions

View File

@ -47,14 +47,17 @@
this.label_lanport = new System.Windows.Forms.Label();
this.label_remoteport = new System.Windows.Forms.Label();
this.label_tunnels = new System.Windows.Forms.Label();
this.textBox_lanHttps = new System.Windows.Forms.TextBox();
this.textBox_lanHttp = new System.Windows.Forms.TextBox();
this.textBox_subDomain = new System.Windows.Forms.TextBox();
this.label_lanHttps = new System.Windows.Forms.Label();
this.label_lanHttp = new System.Windows.Forms.Label();
this.label_subDomain = new System.Windows.Forms.Label();
this.button_cancel = new System.Windows.Forms.Button();
this.button_save = new System.Windows.Forms.Button();
this.label_lanHttps = new System.Windows.Forms.Label();
this.textBox_lanHttps = new System.Windows.Forms.TextBox();
this.textBox_lanPort4 = new System.Windows.Forms.TextBox();
this.textBox_remotePort4 = new System.Windows.Forms.TextBox();
this.label_tunnel4 = new System.Windows.Forms.Label();
this.groupBox_AuthToken.SuspendLayout();
this.groupBox_Ngrokserver.SuspendLayout();
this.groupBox_Url.SuspendLayout();
@ -65,7 +68,7 @@
this.groupBox_AuthToken.Controls.Add(this.textBox_AuthToken);
this.groupBox_AuthToken.Location = new System.Drawing.Point(6, 12);
this.groupBox_AuthToken.Name = "groupBox_AuthToken";
this.groupBox_AuthToken.Size = new System.Drawing.Size(273, 50);
this.groupBox_AuthToken.Size = new System.Drawing.Size(242, 50);
this.groupBox_AuthToken.TabIndex = 0;
this.groupBox_AuthToken.TabStop = false;
this.groupBox_AuthToken.Text = "认证令牌";
@ -74,7 +77,7 @@
//
this.textBox_AuthToken.Location = new System.Drawing.Point(11, 21);
this.textBox_AuthToken.Name = "textBox_AuthToken";
this.textBox_AuthToken.Size = new System.Drawing.Size(250, 21);
this.textBox_AuthToken.Size = new System.Drawing.Size(219, 21);
this.textBox_AuthToken.TabIndex = 0;
//
// groupBox_Ngrokserver
@ -83,7 +86,7 @@
this.groupBox_Ngrokserver.Controls.Add(this.label_NgrokDomain);
this.groupBox_Ngrokserver.Location = new System.Drawing.Point(6, 68);
this.groupBox_Ngrokserver.Name = "groupBox_Ngrokserver";
this.groupBox_Ngrokserver.Size = new System.Drawing.Size(273, 48);
this.groupBox_Ngrokserver.Size = new System.Drawing.Size(242, 48);
this.groupBox_Ngrokserver.TabIndex = 1;
this.groupBox_Ngrokserver.TabStop = false;
this.groupBox_Ngrokserver.Text = "服务端Ngrokd";
@ -92,8 +95,8 @@
//
this.textBox_serverAddr.Location = new System.Drawing.Point(50, 18);
this.textBox_serverAddr.Name = "textBox_serverAddr";
this.textBox_serverAddr.Size = new System.Drawing.Size(211, 21);
this.textBox_serverAddr.TabIndex = 5;
this.textBox_serverAddr.Size = new System.Drawing.Size(180, 21);
this.textBox_serverAddr.TabIndex = 1;
//
// label_NgrokDomain
//
@ -106,6 +109,9 @@
//
// groupBox_Url
//
this.groupBox_Url.Controls.Add(this.textBox_lanPort4);
this.groupBox_Url.Controls.Add(this.textBox_remotePort4);
this.groupBox_Url.Controls.Add(this.label_tunnel4);
this.groupBox_Url.Controls.Add(this.textBox_lanPort3);
this.groupBox_Url.Controls.Add(this.textBox_remotePort3);
this.groupBox_Url.Controls.Add(this.label_tunnel3);
@ -126,24 +132,24 @@
this.groupBox_Url.Controls.Add(this.label_subDomain);
this.groupBox_Url.Location = new System.Drawing.Point(6, 123);
this.groupBox_Url.Name = "groupBox_Url";
this.groupBox_Url.Size = new System.Drawing.Size(273, 170);
this.groupBox_Url.Size = new System.Drawing.Size(242, 197);
this.groupBox_Url.TabIndex = 2;
this.groupBox_Url.TabStop = false;
this.groupBox_Url.Text = "内网端Ngrok";
//
// textBox_lanPort3
//
this.textBox_lanPort3.Location = new System.Drawing.Point(191, 140);
this.textBox_lanPort3.Location = new System.Drawing.Point(171, 140);
this.textBox_lanPort3.Name = "textBox_lanPort3";
this.textBox_lanPort3.Size = new System.Drawing.Size(50, 21);
this.textBox_lanPort3.TabIndex = 19;
this.textBox_lanPort3.TabIndex = 17;
//
// textBox_remotePort3
//
this.textBox_remotePort3.Location = new System.Drawing.Point(96, 140);
this.textBox_remotePort3.Location = new System.Drawing.Point(87, 140);
this.textBox_remotePort3.Name = "textBox_remotePort3";
this.textBox_remotePort3.Size = new System.Drawing.Size(50, 21);
this.textBox_remotePort3.TabIndex = 18;
this.textBox_remotePort3.TabIndex = 16;
//
// label_tunnel3
//
@ -151,7 +157,7 @@
this.label_tunnel3.Location = new System.Drawing.Point(17, 142);
this.label_tunnel3.Name = "label_tunnel3";
this.label_tunnel3.Size = new System.Drawing.Size(53, 12);
this.label_tunnel3.TabIndex = 17;
this.label_tunnel3.TabIndex = 15;
this.label_tunnel3.Text = "Tunnel3:";
//
// label_tunnel2
@ -160,7 +166,7 @@
this.label_tunnel2.Location = new System.Drawing.Point(17, 115);
this.label_tunnel2.Name = "label_tunnel2";
this.label_tunnel2.Size = new System.Drawing.Size(53, 12);
this.label_tunnel2.TabIndex = 16;
this.label_tunnel2.TabIndex = 12;
this.label_tunnel2.Text = "Tunnel2:";
//
// label_tunnel1
@ -169,33 +175,33 @@
this.label_tunnel1.Location = new System.Drawing.Point(17, 88);
this.label_tunnel1.Name = "label_tunnel1";
this.label_tunnel1.Size = new System.Drawing.Size(53, 12);
this.label_tunnel1.TabIndex = 15;
this.label_tunnel1.TabIndex = 9;
this.label_tunnel1.Text = "Tunnel1:";
//
// textBox_lanPort2
//
this.textBox_lanPort2.Location = new System.Drawing.Point(191, 112);
this.textBox_lanPort2.Location = new System.Drawing.Point(171, 112);
this.textBox_lanPort2.Name = "textBox_lanPort2";
this.textBox_lanPort2.Size = new System.Drawing.Size(50, 21);
this.textBox_lanPort2.TabIndex = 14;
//
// textBox_remotePort2
//
this.textBox_remotePort2.Location = new System.Drawing.Point(96, 112);
this.textBox_remotePort2.Location = new System.Drawing.Point(87, 112);
this.textBox_remotePort2.Name = "textBox_remotePort2";
this.textBox_remotePort2.Size = new System.Drawing.Size(50, 21);
this.textBox_remotePort2.TabIndex = 13;
//
// textBox_lanPort1
//
this.textBox_lanPort1.Location = new System.Drawing.Point(191, 85);
this.textBox_lanPort1.Location = new System.Drawing.Point(171, 85);
this.textBox_lanPort1.Name = "textBox_lanPort1";
this.textBox_lanPort1.Size = new System.Drawing.Size(50, 21);
this.textBox_lanPort1.TabIndex = 11;
//
// textBox_remotePort1
//
this.textBox_remotePort1.Location = new System.Drawing.Point(96, 85);
this.textBox_remotePort1.Location = new System.Drawing.Point(87, 85);
this.textBox_remotePort1.Name = "textBox_remotePort1";
this.textBox_remotePort1.Size = new System.Drawing.Size(50, 21);
this.textBox_remotePort1.TabIndex = 10;
@ -203,16 +209,16 @@
// label_lanport
//
this.label_lanport.AutoSize = true;
this.label_lanport.Location = new System.Drawing.Point(178, 65);
this.label_lanport.Location = new System.Drawing.Point(169, 65);
this.label_lanport.Name = "label_lanport";
this.label_lanport.Size = new System.Drawing.Size(77, 12);
this.label_lanport.Size = new System.Drawing.Size(53, 12);
this.label_lanport.TabIndex = 8;
this.label_lanport.Text = "内网服务端口";
this.label_lanport.Text = "内网端口";
//
// label_remoteport
//
this.label_remoteport.AutoSize = true;
this.label_remoteport.Location = new System.Drawing.Point(96, 65);
this.label_remoteport.Location = new System.Drawing.Point(87, 65);
this.label_remoteport.Name = "label_remoteport";
this.label_remoteport.Size = new System.Drawing.Size(53, 12);
this.label_remoteport.TabIndex = 7;
@ -227,9 +233,16 @@
this.label_tunnels.TabIndex = 6;
this.label_tunnels.Text = "TCP穿透服务";
//
// textBox_lanHttps
//
this.textBox_lanHttps.Location = new System.Drawing.Point(171, 37);
this.textBox_lanHttps.Name = "textBox_lanHttps";
this.textBox_lanHttps.Size = new System.Drawing.Size(50, 21);
this.textBox_lanHttps.TabIndex = 5;
//
// textBox_lanHttp
//
this.textBox_lanHttp.Location = new System.Drawing.Point(96, 37);
this.textBox_lanHttp.Location = new System.Drawing.Point(87, 37);
this.textBox_lanHttp.Name = "textBox_lanHttp";
this.textBox_lanHttp.Size = new System.Drawing.Size(50, 21);
this.textBox_lanHttp.TabIndex = 4;
@ -241,14 +254,23 @@
this.textBox_subDomain.Size = new System.Drawing.Size(50, 21);
this.textBox_subDomain.TabIndex = 3;
//
// label_lanHttps
//
this.label_lanHttps.AutoSize = true;
this.label_lanHttps.Location = new System.Drawing.Point(167, 17);
this.label_lanHttps.Name = "label_lanHttps";
this.label_lanHttps.Size = new System.Drawing.Size(59, 12);
this.label_lanHttps.TabIndex = 2;
this.label_lanHttps.Text = "https端口";
//
// label_lanHttp
//
this.label_lanHttp.AutoSize = true;
this.label_lanHttp.Location = new System.Drawing.Point(80, 18);
this.label_lanHttp.Location = new System.Drawing.Point(87, 18);
this.label_lanHttp.Name = "label_lanHttp";
this.label_lanHttp.Size = new System.Drawing.Size(77, 12);
this.label_lanHttp.Size = new System.Drawing.Size(53, 12);
this.label_lanHttp.TabIndex = 1;
this.label_lanHttp.Text = "http服务端口";
this.label_lanHttp.Text = "http端口";
//
// label_subDomain
//
@ -261,52 +283,63 @@
//
// button_cancel
//
this.button_cancel.Location = new System.Drawing.Point(40, 299);
this.button_cancel.Location = new System.Drawing.Point(33, 324);
this.button_cancel.Name = "button_cancel";
this.button_cancel.Size = new System.Drawing.Size(80, 23);
this.button_cancel.TabIndex = 3;
this.button_cancel.TabIndex = 4;
this.button_cancel.Text = "取消";
this.button_cancel.UseVisualStyleBackColor = true;
this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
//
// button_save
//
this.button_save.Location = new System.Drawing.Point(156, 299);
this.button_save.Location = new System.Drawing.Point(145, 324);
this.button_save.Name = "button_save";
this.button_save.Size = new System.Drawing.Size(80, 23);
this.button_save.TabIndex = 4;
this.button_save.TabIndex = 3;
this.button_save.Text = "保存";
this.button_save.UseVisualStyleBackColor = true;
this.button_save.Click += new System.EventHandler(this.button_save_Click);
//
// label_lanHttps
// textBox_lanPort4
//
this.label_lanHttps.AutoSize = true;
this.label_lanHttps.Location = new System.Drawing.Point(172, 18);
this.label_lanHttps.Name = "label_lanHttps";
this.label_lanHttps.Size = new System.Drawing.Size(83, 12);
this.label_lanHttps.TabIndex = 1;
this.label_lanHttps.Text = "https服务端口";
this.textBox_lanPort4.Location = new System.Drawing.Point(171, 166);
this.textBox_lanPort4.Name = "textBox_lanPort4";
this.textBox_lanPort4.Size = new System.Drawing.Size(50, 21);
this.textBox_lanPort4.TabIndex = 20;
//
// textBox_lanHttps
// textBox_remotePort4
//
this.textBox_lanHttps.Location = new System.Drawing.Point(191, 37);
this.textBox_lanHttps.Name = "textBox_lanHttps";
this.textBox_lanHttps.Size = new System.Drawing.Size(50, 21);
this.textBox_lanHttps.TabIndex = 4;
this.textBox_remotePort4.Location = new System.Drawing.Point(87, 166);
this.textBox_remotePort4.Name = "textBox_remotePort4";
this.textBox_remotePort4.Size = new System.Drawing.Size(50, 21);
this.textBox_remotePort4.TabIndex = 19;
//
// label_tunnel4
//
this.label_tunnel4.AutoSize = true;
this.label_tunnel4.Location = new System.Drawing.Point(17, 169);
this.label_tunnel4.Name = "label_tunnel4";
this.label_tunnel4.Size = new System.Drawing.Size(53, 12);
this.label_tunnel4.TabIndex = 18;
this.label_tunnel4.Text = "Tunnel4:";
//
// Form_ngrok
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 330);
this.ClientSize = new System.Drawing.Size(254, 351);
this.Controls.Add(this.button_save);
this.Controls.Add(this.button_cancel);
this.Controls.Add(this.groupBox_Url);
this.Controls.Add(this.groupBox_Ngrokserver);
this.Controls.Add(this.groupBox_AuthToken);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form_ngrok";
this.Tag = "";
this.Text = "Ngrok设置";
this.Shown += new System.EventHandler(this.Form_ngrok_Shown);
this.groupBox_AuthToken.ResumeLayout(false);
@ -347,5 +380,8 @@
private System.Windows.Forms.Label label_tunnel1;
private System.Windows.Forms.TextBox textBox_lanHttps;
private System.Windows.Forms.Label label_lanHttps;
private System.Windows.Forms.TextBox textBox_lanPort4;
private System.Windows.Forms.TextBox textBox_remotePort4;
private System.Windows.Forms.Label label_tunnel4;
}
}

View File

@ -56,7 +56,14 @@ namespace net.nutcore.aliddns
int.TryParse(textBox_lanPort3.Text, out lanport3);
textBox_lanPort3.Text = lanport3.ToString();
ngrok.Save(token, server_addr, subdomain, lanhttp, lanhttps, remoteport1, lanport1, remoteport2, lanport2, remoteport3, lanport3, true, true);
var remoteport4 = 10099;
int.TryParse(textBox_remotePort4.Text, out remoteport4);
textBox_remotePort4.Text = remoteport4.ToString();
var lanport4 = 9000;
int.TryParse(textBox_lanPort4.Text, out lanport4);
textBox_lanPort4.Text = lanport4.ToString();
ngrok.Save(token, server_addr, subdomain, lanhttp, lanhttps, remoteport1, lanport1, remoteport2, lanport2, remoteport3, lanport3, remoteport4, lanport4, false, true, true);
this.Close();
this.Dispose();
}
@ -83,10 +90,12 @@ namespace net.nutcore.aliddns
textBox_lanPort2.Text = config.tunnels.tcp2.proto.tcp.ToString();
textBox_remotePort3.Text = config.tunnels.tcp3.remote_port.ToString();
textBox_lanPort3.Text = config.tunnels.tcp3.proto.tcp.ToString();
textBox_remotePort4.Text = config.tunnels.tcp4.remote_port.ToString();
textBox_lanPort4.Text = config.tunnels.tcp4.proto.tcp.ToString();
}
catch (Exception error)
catch (Exception)
{
MessageBox.Show("设置文件ngrok.cfg读取出错错误信息\n" + error);
MessageBox.Show("配置文件ngrok.cfg读取出错请修改文件内容或者格式也可以删除错误文件自动生成新文件。","警告",MessageBoxButtons.OK,MessageBoxIcon.Error);
this.Dispose();
}

View File

@ -13,10 +13,10 @@ namespace net.nutcore.aliddns
internal class NgrokHelper
{
private static readonly string NgrokExecutable = "ngrok.exe";
private static readonly string NgrokYaml = "ngrok.cfg";
private static readonly string NgrokYamlConfig = "ngrok.cfg";
public static readonly string CurrentDirectory = Path.GetDirectoryName(Application.ExecutablePath);
public static readonly string FileNgrokExecutable = Path.Combine(CurrentDirectory, NgrokExecutable);
public static readonly string FileConfig = Path.Combine(CurrentDirectory, NgrokYaml);
public static readonly string FileConfig = Path.Combine(CurrentDirectory, NgrokYamlConfig);
private static string LocalHost = "localhost:4040";
public class Config
@ -29,6 +29,7 @@ namespace net.nutcore.aliddns
public string log_format { get; set; }
public string log { get; set; }
public string web_addr { get; set; }
public bool trust_host_root_certs { get; set; }
public bool run_website { get; set; }
public bool run_tcp { get; set; }
public Tunnel tunnels { get; set; }
@ -41,6 +42,7 @@ namespace net.nutcore.aliddns
public Protocol tcp1 { get; set; }
public Protocol tcp2 { get; set; }
public Protocol tcp3 { get; set; }
public Protocol tcp4 { get; set; }
}
public class Protocol
@ -84,13 +86,14 @@ namespace net.nutcore.aliddns
log_format = "logfmt",
log = "ngrok.log",
web_addr = LocalHost,
trust_host_root_certs = false,
run_website = true,
run_tcp = true,
tunnels = new Tunnel
{
website_http = new Protocol
{
subdomain = "www",
subdomain = "subdomain",
proto = new Proto
{
http = 80
@ -99,7 +102,7 @@ namespace net.nutcore.aliddns
},
website_https = new Protocol
{
subdomain = "www",
subdomain = "subdomain",
proto = new Proto
{
https = 443
@ -107,7 +110,7 @@ namespace net.nutcore.aliddns
},
tcp1 = new Protocol
{
remote_port = 2221,
remote_port = 10001,
proto = new Proto
{
tcp = 21
@ -115,7 +118,7 @@ namespace net.nutcore.aliddns
},
tcp2 = new Protocol
{
remote_port = 2222,
remote_port = 10002,
proto = new Proto
{
tcp = 22
@ -123,11 +126,19 @@ namespace net.nutcore.aliddns
},
tcp3 = new Protocol
{
remote_port = 33890,
remote_port = 10003,
proto = new Proto
{
tcp = 3389
}
},
tcp4 = new Protocol
{
remote_port = 10099,
proto = new Proto
{
tcp = 9000
}
}
}
};
@ -169,7 +180,7 @@ namespace net.nutcore.aliddns
return config;
}
public void Save(string token, string server_addr, string subdomain, int http, int https, int remoteport1, int lanport1, int remoteport2, int lanport2, int remoteport3, int lanport3, bool run_website, bool run_tcp)
public void Save(string token, string server_addr, string subdomain, int http, int https, int remoteport1, int lanport1, int remoteport2, int lanport2, int remoteport3, int lanport3, int remoteport4, int lanport4, bool root_certs, bool run_website, bool run_tcp)
{
var config = Load();
config.authtoken = token;
@ -184,6 +195,9 @@ namespace net.nutcore.aliddns
config.tunnels.tcp2.proto.tcp = lanport2;
config.tunnels.tcp3.remote_port = remoteport3;
config.tunnels.tcp3.proto.tcp = lanport3;
config.tunnels.tcp4.remote_port = remoteport4;
config.tunnels.tcp4.proto.tcp = lanport4;
config.trust_host_root_certs = root_certs;
config.run_website = run_website;
config.run_tcp = run_tcp;
@ -199,7 +213,7 @@ namespace net.nutcore.aliddns
exec.FileName = NgrokExecutable;
exec.CreateNoWindow = true;
exec.UseShellExecute = false;
exec.Arguments = $"-config \"{NgrokYaml}\" start ";
exec.Arguments = $"-config \"{NgrokYamlConfig}\" start ";
switch (code)
{
@ -219,9 +233,13 @@ namespace net.nutcore.aliddns
exec.Arguments += "website_http website_https tcp1 tcp2";
break;
default:
case 5:
exec.Arguments += "website_http website_https tcp1 tcp2 tcp3";
break;
default:
exec.Arguments += "website_http website_https tcp1 tcp2 tcp3 tcp5";
break;
}
try

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.8.6.5")]
[assembly: AssemblyFileVersion("3.8.6.5")]
[assembly: AssemblyVersion("3.8.6.7")]
[assembly: AssemblyFileVersion("3.8.6.7")]

View File

@ -1,3 +1,6 @@
v3.8.6.7
1、增加一个tunnel端口。2、跳过v3.8.6.6对配置文件读写优化。
v3.8.6.5
1、增加ngrok https穿透。