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

Added support for changing the RDP port.

This commit is contained in:
Ylian Saint-Hilaire
2020-03-21 19:34:06 -07:00
parent e57fdc8aed
commit c236c7ccb8
8 changed files with 2082 additions and 2 deletions

View File

@@ -40,7 +40,10 @@
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.SuspendLayout();
//
// devicePictureBox
@@ -76,6 +79,7 @@
// rdpButton
//
this.rdpButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.rdpButton.ContextMenuStrip = this.rdpContextMenuStrip;
this.rdpButton.Location = new System.Drawing.Point(375, 6);
this.rdpButton.Name = "rdpButton";
this.rdpButton.Size = new System.Drawing.Size(58, 47);
@@ -152,6 +156,20 @@
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);
@@ -169,6 +187,7 @@
this.Name = "DeviceUserControl";
this.Size = new System.Drawing.Size(441, 60);
((System.ComponentModel.ISupportInitialize)(this.devicePictureBox)).EndInit();
this.rdpContextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
@@ -185,5 +204,7 @@
private System.Windows.Forms.Button httpButton;
private System.Windows.Forms.Button scpButton;
private System.Windows.Forms.Button sshButton;
private System.Windows.Forms.ContextMenuStrip rdpContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem setRDPPortToolStripMenuItem;
}
}

View File

@@ -77,5 +77,17 @@ namespace MeshCentralRouter
if (node.rdpport != 0) { rdpport = node.rdpport; }
parent.QuickMap(1, rdpport, 3, node); // RDP
}
private void setRDPPortToolStripMenuItem_Click(object sender, System.EventArgs e)
{
int rdpport = 3389;
if (node.rdpport != 0) { rdpport = node.rdpport; }
rdpPortForm form = new rdpPortForm();
form.rdpPort = node.rdpport;
if ((form.ShowDialog(this) == DialogResult.OK) && (rdpport != form.rdpPort))
{
parent.meshcentral.setRdpPort(node, form.rdpPort);
}
}
}
}

View File

@@ -117,6 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="rdpContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>313, 17</value>
</metadata>
<metadata name="deviceImageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
@@ -125,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3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sBGAFjARgBYwEYAWMBewFv
Af8Bf/8AfwAB3gF7ATkBZwFaAWsBWgFrAVoBawEYAWMBGAFjARgBYwE5AWcB3gF7Af8Bf8oAAd4BewG9

View File

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

View File

@@ -157,6 +157,15 @@ namespace MeshCentralRouter
}
}
public void setRdpPort(NodeClass node, int port)
{
if (wc != null)
{
if (debug) { File.AppendAllText("debug.log", "SetRdpPort\r\n"); }
wc.WriteStringWebSocket("{\"action\":\"changedevice\",\"nodeid\":\"" + node.nodeid + "\",\"rdpport\":" + port + "}");
}
}
public void processServerData(string data)
{
if (debug) { File.AppendAllText("debug.log", "ServerData-" + data + "\r\n"); }
@@ -246,6 +255,7 @@ namespace MeshCentralRouter
n.name = (string)node["name"];
if (node.ContainsKey("conn")) { n.conn = (int)node["conn"]; }
n.icon = (int)node["icon"];
if (node.ContainsKey("rdpport")) { n.rdpport = (int)node["rdpport"]; }
nodes[n.nodeid] = n;
}
if (onNodesChanged != null) onNodesChanged();

157
rdpPortForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,157 @@
namespace MeshCentralRouter
{
partial class rdpPortForm
{
/// <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(rdpPortForm));
this.cancelButton = new System.Windows.Forms.Button();
this.okButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.numericUpDown1 = new System.Windows.Forms.NumericUpDown();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).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, 98);
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, 98);
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);
//
// label1
//
this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.label1.Location = new System.Drawing.Point(12, 9);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(275, 30);
this.label1.TabIndex = 2;
this.label1.Text = "Enter the RDP port of the remote computer, the default RDP port is 3389.";
//
// 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.numericUpDown1);
this.groupBox1.Location = new System.Drawing.Point(12, 42);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(275, 50);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Settings";
//
// 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 = "RDP Port";
//
// numericUpDown1
//
this.numericUpDown1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.numericUpDown1.Location = new System.Drawing.Point(149, 19);
this.numericUpDown1.Maximum = new decimal(new int[] {
65535,
0,
0,
0});
this.numericUpDown1.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDown1.Name = "numericUpDown1";
this.numericUpDown1.Size = new System.Drawing.Size(120, 20);
this.numericUpDown1.TabIndex = 0;
this.numericUpDown1.Value = new decimal(new int[] {
3389,
0,
0,
0});
this.numericUpDown1.ValueChanged += new System.EventHandler(this.numericUpDown1_ValueChanged);
this.numericUpDown1.KeyUp += new System.Windows.Forms.KeyEventHandler(this.numericUpDown1_KeyUp);
//
// rdpPortForm
//
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, 133);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label1);
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 = "rdpPortForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "RDP Port";
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDown1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button cancelButton;
private System.Windows.Forms.Button okButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.NumericUpDown numericUpDown1;
}
}

53
rdpPortForm.cs Normal file
View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MeshCentralRouter
{
public partial class rdpPortForm : Form
{
public rdpPortForm()
{
InitializeComponent();
}
public int originalRdpPort;
public int rdpPort
{
get { return (int)numericUpDown1.Value; }
set { numericUpDown1.Value = originalRdpPort = 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 = (numericUpDown1.Value > 0) && (numericUpDown1.Value < 65536) && (numericUpDown1.Value != originalRdpPort);
}
private void numericUpDown1_KeyUp(object sender, KeyEventArgs e)
{
updateInfo();
}
}
}

1815
rdpPortForm.resx Normal file

File diff suppressed because it is too large Load Diff