Skip to content

Commit

Permalink
fix multiple rdp connections and individual devices rdp #100
Browse files Browse the repository at this point in the history
  • Loading branch information
si458 committed Sep 12, 2024
1 parent f24b120 commit a99a01d
Showing 1 changed file with 4 additions and 40 deletions.
44 changes: 4 additions & 40 deletions src/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ private void searchTextBox_KeyPress(object sender, KeyPressEventArgs e)
public void QuickMap(int protocol, int port, int appId, NodeClass node)
{
NodeClass tmpNode = node;
if (node.mesh.relayid != null)
if (node.mesh != null && node.mesh.relayid != null)
{
if (!meshcentral.nodes.ContainsKey(node.mesh.relayid))
return;
Expand All @@ -1759,7 +1759,8 @@ public void QuickMap(int protocol, int port, int appId, NodeClass node)
if (c.GetType() == typeof(MapUserControl))
{
MapUserControl cc = (MapUserControl)c;
if ((cc.remoteIP == node.host) && (cc.protocol == protocol) && (cc.remotePort == port) && (cc.appId == appId) && (cc.node == tmpNode))
if ((cc.protocol == protocol) && (cc.remotePort == port) && (cc.appId == appId) &&
(cc.node == tmpNode || cc.node == node) && (tmpNode == node || cc.remoteIP == node.host))
{
// Found a match
cc.appButton_Click(this, null);
Expand All @@ -1773,7 +1774,7 @@ public void QuickMap(int protocol, int port, int appId, NodeClass node)
map.xdebug = debug;
map.inaddrany = false; // Loopback only
map.protocol = protocol; // 1 = TCP, 2 = UDP
if (node.mesh.relayid != null)
if (node.mesh != null && node.mesh.relayid != null)
{
map.name = node.name;
map.remoteIP = node.host;
Expand All @@ -1794,43 +1795,6 @@ public void QuickMap(int protocol, int port, int appId, NodeClass node)
map.appButton_Click(this, null);
}

public void QuickMap(int protocol, int port, string appIdStr, NodeClass node)
{
// See if we already have the right port mapping
foreach (Control c in mapPanel.Controls)
{
if (c.GetType() == typeof(MapUserControl))
{
MapUserControl cc = (MapUserControl)c;
if ((cc.protocol == protocol) && (cc.remotePort == port) && (cc.appIdStr == appIdStr) && (cc.node == node))
{
// Found a match
cc.appButton_Click(this, null);
return;
}
}
}

// Add a new port map
MapUserControl map = new MapUserControl();
map.xdebug = debug;
map.inaddrany = false; // Loopback only
map.protocol = protocol; // 1 = TCP, 2 = UDP
map.localPort = 0; // Any
map.remotePort = port; // HTTP
map.appId = 0; // 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP
map.appIdStr = appIdStr;
map.node = node;
if (authLoginUrl != null) { map.host = authLoginUrl.Host + ":" + ((authLoginUrl.Port > 0) ? authLoginUrl.Port : 443) + authLoginUrl.AbsolutePath.Replace("/control.ashx", ""); } else { map.host = serverNameComboBox.Text; }
map.certhash = meshcentral.wshash;
map.parent = this;
map.Dock = DockStyle.Top;
map.Start();
mapPanel.Controls.Add(map);
noMapLabel.Visible = false;
map.appButton_Click(this, null);
}

private void emailTokenButton_Click(object sender, EventArgs e)
{
if (MessageBox.Show(this, Translate.T(Properties.Resources.SendTokenEmail), Translate.T(Properties.Resources.TwoFactorAuthentication), MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
Expand Down

0 comments on commit a99a01d

Please sign in to comment.