1
0
mirror of https://github.com/Ylianst/MeshCentralRouter synced 2025-12-06 00:13:33 +00:00

Added alternative port support in device tab.

This commit is contained in:
Ylian Saint-Hilaire
2020-03-22 14:29:07 -07:00
parent 6c076f3777
commit 6840b9018b
7 changed files with 2071 additions and 18 deletions

View File

@@ -34,16 +34,19 @@
this.deviceNameLabel = new System.Windows.Forms.Label();
this.deviceStatusLabel = new System.Windows.Forms.Label();
this.rdpButton = new System.Windows.Forms.Button();
this.rdpContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.setRDPPortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.deviceImageList = new System.Windows.Forms.ImageList(this.components);
this.disabledDeviceImageList = new System.Windows.Forms.ImageList(this.components);
this.httpsButton = new System.Windows.Forms.Button();
this.altPortContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.httpButton = new System.Windows.Forms.Button();
this.scpButton = new System.Windows.Forms.Button();
this.sshButton = new System.Windows.Forms.Button();
this.rdpContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.setRDPPortToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.devicePictureBox)).BeginInit();
this.rdpContextMenuStrip.SuspendLayout();
this.altPortContextMenuStrip.SuspendLayout();
this.SuspendLayout();
//
// devicePictureBox
@@ -88,6 +91,20 @@
this.rdpButton.UseVisualStyleBackColor = true;
this.rdpButton.Click += new System.EventHandler(this.rdpButton_Click);
//
// rdpContextMenuStrip
//
this.rdpContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.setRDPPortToolStripMenuItem});
this.rdpContextMenuStrip.Name = "rdpContextMenuStrip";
this.rdpContextMenuStrip.Size = new System.Drawing.Size(150, 26);
//
// setRDPPortToolStripMenuItem
//
this.setRDPPortToolStripMenuItem.Name = "setRDPPortToolStripMenuItem";
this.setRDPPortToolStripMenuItem.Size = new System.Drawing.Size(149, 22);
this.setRDPPortToolStripMenuItem.Text = "Set RDP port...";
this.setRDPPortToolStripMenuItem.Click += new System.EventHandler(this.setRDPPortToolStripMenuItem_Click);
//
// deviceImageList
//
this.deviceImageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("deviceImageList.ImageStream")));
@@ -115,6 +132,7 @@
// httpsButton
//
this.httpsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.httpsButton.ContextMenuStrip = this.altPortContextMenuStrip;
this.httpsButton.Location = new System.Drawing.Point(311, 6);
this.httpsButton.Name = "httpsButton";
this.httpsButton.Size = new System.Drawing.Size(58, 23);
@@ -123,9 +141,24 @@
this.httpsButton.UseVisualStyleBackColor = true;
this.httpsButton.Click += new System.EventHandler(this.httpsButton_Click);
//
// altPortContextMenuStrip
//
this.altPortContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1});
this.altPortContextMenuStrip.Name = "rdpContextMenuStrip";
this.altPortContextMenuStrip.Size = new System.Drawing.Size(179, 48);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(178, 22);
this.toolStripMenuItem1.Text = "Use Alternate Port...";
this.toolStripMenuItem1.Click += new System.EventHandler(this.toolStripMenuItem1_Click);
//
// httpButton
//
this.httpButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.httpButton.ContextMenuStrip = this.altPortContextMenuStrip;
this.httpButton.Location = new System.Drawing.Point(311, 30);
this.httpButton.Name = "httpButton";
this.httpButton.Size = new System.Drawing.Size(58, 23);
@@ -137,6 +170,7 @@
// scpButton
//
this.scpButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.scpButton.ContextMenuStrip = this.altPortContextMenuStrip;
this.scpButton.Location = new System.Drawing.Point(375, 30);
this.scpButton.Name = "scpButton";
this.scpButton.Size = new System.Drawing.Size(58, 23);
@@ -148,6 +182,7 @@
// sshButton
//
this.sshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.sshButton.ContextMenuStrip = this.altPortContextMenuStrip;
this.sshButton.Location = new System.Drawing.Point(375, 6);
this.sshButton.Name = "sshButton";
this.sshButton.Size = new System.Drawing.Size(58, 23);
@@ -156,20 +191,6 @@
this.sshButton.UseVisualStyleBackColor = true;
this.sshButton.Click += new System.EventHandler(this.sshButton_Click);
//
// rdpContextMenuStrip
//
this.rdpContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.setRDPPortToolStripMenuItem});
this.rdpContextMenuStrip.Name = "rdpContextMenuStrip";
this.rdpContextMenuStrip.Size = new System.Drawing.Size(153, 48);
//
// setRDPPortToolStripMenuItem
//
this.setRDPPortToolStripMenuItem.Name = "setRDPPortToolStripMenuItem";
this.setRDPPortToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.setRDPPortToolStripMenuItem.Text = "Set RDP port...";
this.setRDPPortToolStripMenuItem.Click += new System.EventHandler(this.setRDPPortToolStripMenuItem_Click);
//
// DeviceUserControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -188,6 +209,7 @@
this.Size = new System.Drawing.Size(441, 60);
((System.ComponentModel.ISupportInitialize)(this.devicePictureBox)).EndInit();
this.rdpContextMenuStrip.ResumeLayout(false);
this.altPortContextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -206,5 +228,7 @@
private System.Windows.Forms.Button sshButton;
private System.Windows.Forms.ContextMenuStrip rdpContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem setRDPPortToolStripMenuItem;
private System.Windows.Forms.ContextMenuStrip altPortContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
}
}

View File

@@ -89,5 +89,19 @@ namespace MeshCentralRouter
parent.meshcentral.setRdpPort(node, form.rdpPort);
}
}
private void toolStripMenuItem1_Click(object sender, System.EventArgs e)
{
int port = 0, appid = 0;
if (altPortContextMenuStrip.SourceControl == httpButton) { appid = 1; port = 80; } // HTTP
if (altPortContextMenuStrip.SourceControl == httpsButton) { appid = 2; port = 443; } // HTTPS
if (altPortContextMenuStrip.SourceControl == scpButton) { appid = 5; port = 22; } // SCP
if (altPortContextMenuStrip.SourceControl == sshButton) { appid = 4; port = 22; } // SSH
if (appid == 0) return;
altPortForm form = new altPortForm();
form.altPort = port;
if ((form.ShowDialog(this) == DialogResult.OK)) { parent.QuickMap(1, form.altPort, appid, node); }
}
}
}

View File

@@ -128,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAC+
fQAAAk1TRnQBSQFMAgEBBwEAATgBAAE4AQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI
fQAAAk1TRnQBSQFMAgEBBwEAAUgBAAFIAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI
AwABZAMAAQEBAAEQBQABQAGc/wD/AP8A/wD/AP8A/wD/ANIAAf8BfwH/AX//AI0AATgBXwGzAUYB3gF7
/wCJAAF6AWsBiQERAYkBDQHtASUBmwFvAf8Bf/8AgwABewFvAfABOQEwATIBqgEZAYkBDQGpAREB1QFO
Af8Bf/8AfwABvQF3ARABPgF0AU4BlAFOAXMBSgGpARUBqQERAYkBDQEOASoBnAFzAf8Bf8oAAd4BewG9
@@ -675,7 +675,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA8
fgAAAk1TRnQBSQFMAgEBBwEAAUABAAFAAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI
fgAAAk1TRnQBSQFMAgEBBwEAAVABAAFQAQABMgEAATIBAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAHI
AwABZAMAAQEBAAEQBQABQAGc/wD/AP8A/wD/AP8A/wD/ANIAAf8BfwH/AX//AI0AAb0BdwF7AW8B/wF/
/wCJAAG9AXcBGAFjARgBYwE5AWcB3gF7Af8Bf/8AgwAB3gF7ATkBZwFaAWsBGAFjARgBYwEYAWMBewFv
Af8Bf/8AfwAB3gF7ATkBZwFaAWsBWgFrAVoBawEYAWMBGAFjARgBYwE5AWcB3gF7Af8Bf8oAAd4BewG9
@@ -1216,4 +1216,7 @@
AT8H/wMADf8B/gMACP8DAA7/AgABDwj/AwAO/wH8AT8J/wMAGf8DAAs=
</value>
</data>
<metadata name="altPortContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>468, 17</value>
</metadata>
</root>

View File

@@ -133,6 +133,12 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="altPortForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="altPortForm.Designer.cs">
<DependentUpon>altPortForm.cs</DependentUpon>
</Compile>
<Compile Include="rdpPortForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -179,6 +185,9 @@
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="altPortForm.resx">
<DependentUpon>altPortForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="rdpPortForm.resx">
<DependentUpon>rdpPortForm.cs</DependentUpon>
</EmbeddedResource>

144
altPortForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,144 @@
namespace MeshCentralRouter
{
partial class altPortForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(altPortForm));
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.portNumericUpDown = new System.Windows.Forms.NumericUpDown();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.portNumericUpDown)).BeginInit();
this.SuspendLayout();
//
// cancelButton
//
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancelButton.Location = new System.Drawing.Point(212, 66);
this.cancelButton.Name = "cancelButton";
this.cancelButton.Size = new System.Drawing.Size(75, 23);
this.cancelButton.TabIndex = 0;
this.cancelButton.Text = "Cancel";
this.cancelButton.UseVisualStyleBackColor = true;
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
// okButton
//
this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.okButton.Location = new System.Drawing.Point(131, 66);
this.okButton.Name = "okButton";
this.okButton.Size = new System.Drawing.Size(75, 23);
this.okButton.TabIndex = 1;
this.okButton.Text = "OK";
this.okButton.UseVisualStyleBackColor = true;
this.okButton.Click += new System.EventHandler(this.okButton_Click);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.portNumericUpDown);
this.groupBox1.Location = new System.Drawing.Point(12, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(275, 48);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection";
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label2.Location = new System.Drawing.Point(6, 21);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(137, 18);
this.label2.TabIndex = 3;
this.label2.Text = "Alternative Port";
//
// portNumericUpDown
//
this.portNumericUpDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.portNumericUpDown.Location = new System.Drawing.Point(149, 19);
this.portNumericUpDown.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.portNumericUpDown.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.portNumericUpDown.Name = "portNumericUpDown";
this.portNumericUpDown.Size = new System.Drawing.Size(120, 20);
this.portNumericUpDown.TabIndex = 0;
this.portNumericUpDown.Value = new decimal(new int[] {
3389,
0,
0,
0});
this.portNumericUpDown.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
this.portNumericUpDown.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown1_KeyUp);
//
// altPortForm
//
this.AcceptButton = this.okButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.cancelButton;
this.ClientSize = new System.Drawing.Size(299, 101);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.okButton);
this.Controls.Add(this.cancelButton);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "altPortForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Alternative Port";
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.portNumericUpDown)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown portNumericUpDown;
}
}

44
altPortForm.cs Normal file
View File

@@ -0,0 +1,44 @@
using System;
using System.Windows.Forms;
namespace MeshCentralRouter
{
public partial class altPortForm : Form
{
public altPortForm()
{
InitializeComponent();
}
public int altPort
{
get { return (int)portNumericUpDown.Value; }
set { portNumericUpDown.Value = value; updateInfo(); }
}
private void okButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
}
private void cancelButton_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
updateInfo();
}
public void updateInfo()
{
okButton.Enabled = (portNumericUpDown.Value > 0) && (portNumericUpDown.Value < 65536);
}
private void numericUpDown1_KeyUp(object sender, KeyEventArgs e)
{
updateInfo();
}
}
}

1815
altPortForm.resx Normal file

File diff suppressed because it is too large Load Diff