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

Different attempt at the RDP/Putty fix.

This commit is contained in:
Ylian Saint-Hilaire
2021-02-03 11:29:44 -08:00
parent 101af85ebe
commit 63f651081f
5 changed files with 68 additions and 51 deletions

View File

@@ -18,7 +18,16 @@ namespace MeshCentralRouter
public int getProtocol() { return (int)(tcpRadioButton.Checked?1:2); }
public int getLocalPort() { return (int)localNumericUpDown.Value; }
public int getRemotePort() { return (int)remoteNumericUpDown.Value; }
public int getAppId() { return (int)appComboBox.SelectedIndex; }
public int getAppId() {
int x = (int)appComboBox.SelectedIndex;
if (x == 0) { return 0; } // Custom
if (x == 1) { return 1; } // HTTP
if (x == 2) { return 2; } // HTTPS
if (x == 3) { return 4; } // PuTTY
if (x == 4) { return 3; } // RDP
if (x == 5) { return 5; } // WinSCP
return x;
}
public NodeClass getNode() { return (NodeClass)nodeComboBox.SelectedItem; }
public void setNode(NodeClass node) { selectedNode = node; }
@@ -103,11 +112,11 @@ namespace MeshCentralRouter
private void appComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (appComboBox.SelectedIndex == 1) { remoteNumericUpDown.Value = 80; }
if (appComboBox.SelectedIndex == 2) { remoteNumericUpDown.Value = 443; }
if (appComboBox.SelectedIndex == 3) { remoteNumericUpDown.Value = 22; }
if (appComboBox.SelectedIndex == 4) { remoteNumericUpDown.Value = 3389; }
if (appComboBox.SelectedIndex == 5) { remoteNumericUpDown.Value = 22; }
if (appComboBox.SelectedIndex == 1) { remoteNumericUpDown.Value = 80; } // HTTP
if (appComboBox.SelectedIndex == 2) { remoteNumericUpDown.Value = 443; } // HTTPS
if (appComboBox.SelectedIndex == 3) { remoteNumericUpDown.Value = 22; } // SSH
if (appComboBox.SelectedIndex == 4) { remoteNumericUpDown.Value = 3389; } // RDP
if (appComboBox.SelectedIndex == 5) { remoteNumericUpDown.Value = 22; } // SCP
}
private void cancelButton_Click(object sender, EventArgs e)

View File

@@ -21,7 +21,16 @@ namespace MeshCentralRouter
public int getLocalPort() { return (int)localNumericUpDown.Value; }
public int getRemotePort() { return (int)remoteNumericUpDown.Value; }
public string getRemoteIP() { return remoteIpTextBox.Text; }
public int getAppId() { return (int)appComboBox.SelectedIndex; }
public int getAppId() {
int x = (int)appComboBox.SelectedIndex;
if (x == 0) { return 0; } // Custom
if (x == 1) { return 1; } // HTTP
if (x == 2) { return 2; } // HTTPS
if (x == 3) { return 4; } // PuTTY
if (x == 4) { return 3; } // RDP
if (x == 5) { return 5; } // WinSCP
return x;
}
public NodeClass getNode() { return (NodeClass)nodeComboBox.SelectedItem; }
public void setNode(NodeClass node) { selectedNode = node; }
@@ -107,8 +116,8 @@ namespace MeshCentralRouter
{
if (appComboBox.SelectedIndex == 1) { remoteNumericUpDown.Value = 80; }
if (appComboBox.SelectedIndex == 2) { remoteNumericUpDown.Value = 443; }
if (appComboBox.SelectedIndex == 3) { remoteNumericUpDown.Value = 22; }
if (appComboBox.SelectedIndex == 4) { remoteNumericUpDown.Value = 3389; }
if (appComboBox.SelectedIndex == 3) { remoteNumericUpDown.Value = 3389; }
if (appComboBox.SelectedIndex == 4) { remoteNumericUpDown.Value = 22; }
if (appComboBox.SelectedIndex == 5) { remoteNumericUpDown.Value = 22; }
}

View File

@@ -1337,7 +1337,7 @@ namespace MeshCentralRouter
map.protocol = protocol; // 1 = TCP, 2 = UDP
map.localPort = 0; // Any
map.remotePort = port; // HTTP
map.appId = appId; // 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = PuTTY, 4 = RDP, 5 = WinSCP
map.appId = appId; // 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
map.node = node;
if (authLoginUrl != null) { map.host = authLoginUrl.Host + ":" + ((authLoginUrl.Port > 0) ? authLoginUrl.Port : 443); } else { map.host = serverNameComboBox.Text; }
map.authCookie = meshcentral.authCookie;
@@ -1608,16 +1608,6 @@ namespace MeshCentralRouter
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
QuickMap(1, 443, 2, node); // HTTPS
}
private void sshToolStripMenuItem_Click(object sender, EventArgs e)
{
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
QuickMap(1, 22, 3, node); // Putty
}
private void rdpToolStripMenuItem_Click(object sender, EventArgs e)
{
if (devicesListView.SelectedItems.Count != 1) { return; }
@@ -1626,7 +1616,16 @@ namespace MeshCentralRouter
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
int rdpport = 3389;
if (node.rdpport != 0) { rdpport = node.rdpport; }
QuickMap(1, rdpport, 4, node); // RDP
QuickMap(1, rdpport, 3, node); // RDP
}
private void sshToolStripMenuItem_Click(object sender, EventArgs e)
{
if (devicesListView.SelectedItems.Count != 1) { return; }
ListViewItem selecteditem = devicesListView.SelectedItems[0];
NodeClass node = (NodeClass)selecteditem.Tag;
if ((node.conn & 1) == 0) { return; } // Agent not connected on this device
QuickMap(1, 22, 4, node); // Putty
}
private void scpToolStripMenuItem_Click(object sender, EventArgs e)

View File

@@ -95,8 +95,8 @@ namespace MeshCentralRouter
} else {
if (appId == 1) { statemsg = "HTTP: " + statemsg; }
else if (appId == 2) { statemsg = "HTTPS: " + statemsg; }
else if (appId == 3) { statemsg = "PuTTY: " + statemsg; }
else if (appId == 4) { statemsg = "RDP: " + statemsg; }
else if (appId == 3) { statemsg = "RDP: " + statemsg; }
else if (appId == 4) { statemsg = "PuTTY: " + statemsg; }
else if (appId == 5) { statemsg = "WinSCP: " + statemsg; }
else { statemsg = "TCP: " + statemsg; }
}
@@ -111,6 +111,33 @@ namespace MeshCentralRouter
if (appId == 1) { System.Diagnostics.Process.Start("http://localhost:" + mapper.localport); }
if (appId == 2) { System.Diagnostics.Process.Start("https://localhost:" + mapper.localport); }
if (appId == 3)
{
System.Diagnostics.Process proc = null;
string cmd = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System) + "\\mstsc.exe";
string tfile = Path.Combine(Path.GetTempPath(), "MeshRdpFile.rdp");
string[] f = null;
try { if (File.Exists(tfile)) f = File.ReadAllLines(tfile); } catch (Exception) { }
if (f != null)
{
List<string> f2 = new List<string>();
foreach (string fx in f) { if (!fx.StartsWith("full address")) f2.Add(fx); }
f2.Add(string.Format("full address:s:127.0.0.1:{0}", mapper.localport));
File.WriteAllLines(tfile, f2.ToArray());
}
else
{
File.WriteAllText(tfile, string.Format("full address:s:127.0.0.1:{0}", mapper.localport));
}
string args = "/edit:\"" + tfile + "\"";
// Launch the process
try { proc = System.Diagnostics.Process.Start(cmd, args); }
catch (System.ComponentModel.Win32Exception) { }
// Setup auto-exit
if ((autoexit == true) && (parent.autoExitProc == null)) { parent.autoExitProc = proc; parent.SetAutoClose(); autoExitTimer.Enabled = true; }
}
if (appId == 4)
{
string puttyPath = loadFromRegistry("PuttyPath");
if ((shift == false) && (File.Exists(puttyPath)))
@@ -147,33 +174,6 @@ namespace MeshCentralRouter
}
}
}
if (appId == 4)
{
System.Diagnostics.Process proc = null;
string cmd = System.Environment.GetFolderPath(System.Environment.SpecialFolder.System) + "\\mstsc.exe";
string tfile = Path.Combine(Path.GetTempPath(), "MeshRdpFile.rdp");
string[] f = null;
try { if (File.Exists(tfile)) f = File.ReadAllLines(tfile); } catch (Exception) { }
if (f != null)
{
List<string> f2 = new List<string>();
foreach (string fx in f) { if (!fx.StartsWith("full address")) f2.Add(fx); }
f2.Add(string.Format("full address:s:127.0.0.1:{0}", mapper.localport));
File.WriteAllLines(tfile, f2.ToArray());
}
else
{
File.WriteAllText(tfile, string.Format("full address:s:127.0.0.1:{0}", mapper.localport));
}
string args = "/edit:\"" + tfile + "\"";
// Launch the process
try { proc = System.Diagnostics.Process.Start(cmd, args); }
catch (System.ComponentModel.Win32Exception) { }
// Setup auto-exit
if ((autoexit == true) && (parent.autoExitProc == null)) { parent.autoExitProc = proc; parent.SetAutoClose(); autoExitTimer.Enabled = true; }
}
if (appId == 5)
{
string winScpPath = loadFromRegistry("WinSCPPath");

View File

@@ -31,6 +31,6 @@ using System.Runtime.InteropServices;
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.2.*")]
[assembly: AssemblyVersion("1.3.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]