diff --git a/src/MainForm.cs b/src/MainForm.cs index 6bf6978..88f44c3 100644 --- a/src/MainForm.cs +++ b/src/MainForm.cs @@ -526,7 +526,10 @@ namespace MeshCentralRouter private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { +// ignore close-to-tray on debug-builds +#if !DEBUG if ((notifyIcon.Visible == true) && (currentPanel == 4) && (forceExit == false)) { e.Cancel = true; Visible = false; } +#endif Settings.SetRegValue("Location", Location.X + "," + Location.Y); } @@ -1709,13 +1712,22 @@ namespace MeshCentralRouter public void QuickMap(int protocol, int port, int appId, NodeClass node) { + NodeClass tmpNode = node; + if (node.mesh.relayid != null) + { + if (!meshcentral.nodes.ContainsKey(node.mesh.relayid)) + return; + + tmpNode = meshcentral.nodes[node.mesh.relayid]; + } + // 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.appId == appId) && (cc.node == node)) + if ((cc.remoteIP == node.host) && (cc.protocol == protocol) && (cc.remotePort == port) && (cc.appId == appId) && (cc.node == tmpNode)) { // Found a match cc.appButton_Click(this, null); @@ -1729,11 +1741,17 @@ namespace MeshCentralRouter map.xdebug = debug; map.inaddrany = false; // Loopback only map.protocol = protocol; // 1 = TCP, 2 = UDP + if (node.mesh.relayid != null) + { + map.name = node.name; + map.remoteIP = node.host; + } + map.localPort = 0; // Any map.remotePort = port; // HTTP map.appId = appId; // 0 = Custom, 1 = HTTP, 2 = HTTPS, 3 = RDP, 4 = PuTTY, 5 = WinSCP map.appIdStr = null; - map.node = node; + map.node = tmpNode; 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; diff --git a/src/MeshCentralServer.cs b/src/MeshCentralServer.cs index 3306841..779979b 100644 --- a/src/MeshCentralServer.cs +++ b/src/MeshCentralServer.cs @@ -494,6 +494,7 @@ namespace MeshCentralRouter m.meshid = (string)mesh["_id"]; m.name = (string)mesh["name"]; if (mesh.ContainsKey("desc")) { m.desc = (string)mesh["desc"]; } + if (mesh.ContainsKey("relayid")) { m.relayid = (string)mesh["relayid"]; } m.rights = 0; m.links = new Dictionary(); @@ -602,6 +603,7 @@ namespace MeshCentralRouter } n.name = (string)node["name"]; n.meshid = meshid; + if (node.ContainsKey("host")) { n.host = (string)node["host"]; } if (node.ContainsKey("mtype")) { diff --git a/src/MeshMapper.cs b/src/MeshMapper.cs index 25f7640..91ed516 100644 --- a/src/MeshMapper.cs +++ b/src/MeshMapper.cs @@ -167,7 +167,7 @@ namespace MeshCentralRouter TcpClient client = null; try { - client = listener.EndAcceptTcpClient(ar); + client = listener?.EndAcceptTcpClient(ar); } catch (Exception) { exit = true; } @@ -179,7 +179,7 @@ namespace MeshCentralRouter try { - listener.BeginAcceptTcpClient(new AsyncCallback(AcceptTcpClientSink), null); + listener?.BeginAcceptTcpClient(new AsyncCallback(AcceptTcpClientSink), null); } catch (Exception) { exit = true; } } diff --git a/src/NodeClass.cs b/src/NodeClass.cs index 98579ed..c084352 100644 --- a/src/NodeClass.cs +++ b/src/NodeClass.cs @@ -25,6 +25,7 @@ namespace MeshCentralRouter public int icon; public string nodeid; public string meshid; + public string host; public int agentid; public int agentcaps; public int conn; @@ -60,6 +61,7 @@ namespace MeshCentralRouter public string name; public string meshid; public string desc; + public string relayid; public int type; public ulong rights; public Dictionary links;