From 91a41f842d989ebb180ced1277d15c3a908a39a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sch=C3=B6n?= Date: Thu, 16 Mar 2023 15:35:52 +0100 Subject: [PATCH 1/4] fix: remote file transfer path jumps back to root after transfer of a file (issue #51) --- src/FileViewer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/FileViewer.cs b/src/FileViewer.cs index e0c2dcf..d0f4aba 100644 --- a/src/FileViewer.cs +++ b/src/FileViewer.cs @@ -1413,7 +1413,8 @@ namespace MeshCentralRouter transferStatusForm.transferCompleted(); } - remoteFolder = strDownloadRel; // Zurücksetzen + if (downloadActive) + remoteFolder = strDownloadRel; // Zurücksetzen remoteRefresh(); } From 05949d9be1aaccf77c5f8a9f449067f54523b182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sch=C3=B6n?= Date: Thu, 16 Mar 2023 20:24:43 +0100 Subject: [PATCH 2/4] added 'Remote Files' button to KVMViewer --- src/KVMViewer.Designer.cs | 11 +++ src/KVMViewer.cs | 15 ++++ src/KVMViewer.resx | 167 +++++++++++++++++++------------------- 3 files changed, 108 insertions(+), 85 deletions(-) diff --git a/src/KVMViewer.Designer.cs b/src/KVMViewer.Designer.cs index cee1679..fa60aa0 100644 --- a/src/KVMViewer.Designer.cs +++ b/src/KVMViewer.Designer.cs @@ -51,6 +51,7 @@ namespace MeshCentralRouter this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.updateTimer = new System.Windows.Forms.Timer(this.components); this.topPanel = new System.Windows.Forms.Panel(); + this.openRemoteFilesButton = new System.Windows.Forms.Button(); this.extraButtonsPanel = new System.Windows.Forms.Panel(); this.splitButton = new System.Windows.Forms.Button(); this.clipOutboundButton = new System.Windows.Forms.Button(); @@ -104,6 +105,7 @@ namespace MeshCentralRouter // topPanel // this.topPanel.BackColor = System.Drawing.SystemColors.Control; + this.topPanel.Controls.Add(this.openRemoteFilesButton); this.topPanel.Controls.Add(this.extraButtonsPanel); this.topPanel.Controls.Add(this.splitButton); this.topPanel.Controls.Add(this.clipOutboundButton); @@ -116,6 +118,14 @@ namespace MeshCentralRouter resources.ApplyResources(this.topPanel, "topPanel"); this.topPanel.Name = "topPanel"; // + // openRemoteFilesButton + // + resources.ApplyResources(this.openRemoteFilesButton, "openRemoteFilesButton"); + this.openRemoteFilesButton.Name = "openRemoteFilesButton"; + this.openRemoteFilesButton.TabStop = false; + this.openRemoteFilesButton.UseVisualStyleBackColor = true; + this.openRemoteFilesButton.Click += new System.EventHandler(this.openRemoteFilesButton_Click); + // // extraButtonsPanel // resources.ApplyResources(this.extraButtonsPanel, "extraButtonsPanel"); @@ -298,6 +308,7 @@ namespace MeshCentralRouter private Button splitButton; private Panel extraButtonsPanel; private ImageList displaySelectorImageList; + private Button openRemoteFilesButton; } } diff --git a/src/KVMViewer.cs b/src/KVMViewer.cs index 920f39e..0888c5b 100644 --- a/src/KVMViewer.cs +++ b/src/KVMViewer.cs @@ -397,6 +397,7 @@ namespace MeshCentralRouter } cadButton.Enabled = (state == 3); + openRemoteFilesButton.Enabled = (state == 3 && (node.agentcaps & 4) != 0); if ((kvmControl.AutoSendClipboard) && ((server.features2 & 0x1000) == 0)) // 0x1000 Clipboard Set { clipInboundButton.Visible = false; @@ -755,6 +756,20 @@ namespace MeshCentralRouter } } + private void openRemoteFilesButton_Click(object sender, EventArgs e) + { + if ((node.conn & 1) == 0) { return; } // Agent not connected on this device + if (node.fileViewer == null) + { + node.fileViewer = new FileViewer(server, node); + node.fileViewer.Show(); + node.fileViewer.MenuItemConnect_Click(null, null); + } + else + { + node.fileViewer.Focus(); + } + } } } diff --git a/src/KVMViewer.resx b/src/KVMViewer.resx index d23caf2..0131993 100644 --- a/src/KVMViewer.resx +++ b/src/KVMViewer.resx @@ -122,7 +122,7 @@ - 1372, 20 + 1029, 17 --- @@ -131,7 +131,7 @@ MiddleLeft - 16, 20 + 13, 17 v @@ -141,14 +141,10 @@ False - 0, 897 - - - - 1, 0, 19, 0 + 0, 727 - 1392, 25 + 1044, 22 9 @@ -171,14 +167,48 @@ 154, 17 + + False + + + 192, 3 + + + + 2, 2, 2, 2 + + + 89, 26 + + + 2 + + + Remote Files + + + openRemoteFilesButton + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + topPanel + + + 0 + Top, Left, Right - 383, 4 + 380, 2 + + + 2, 2, 2, 2 - 658, 32 + 401, 27 10 @@ -193,7 +223,7 @@ topPanel - 0 + 1 Top, Right @@ -202,13 +232,10 @@ NoControl - 1048, 4 - - - 4, 4, 4, 4 + 786, 3 - 119, 32 + 89, 26 8 @@ -229,7 +256,7 @@ topPanel - 1 + 2 Top, Right @@ -241,16 +268,13 @@ NoControl - 1175, 4 - - - 4, 4, 4, 4 + 881, 3 - 40, 32 + 30, 26 - 3 + 4 clipOutboundButton @@ -262,7 +286,7 @@ topPanel - 2 + 3 Top, Right @@ -274,16 +298,13 @@ NoControl - 1223, 4 - - - 4, 4, 4, 4 + 917, 3 - 40, 32 + 30, 26 - 4 + 5 399, 17 @@ -301,7 +322,7 @@ topPanel - 3 + 4 Top, Right @@ -310,13 +331,10 @@ NoControl - 1319, 4 - - - 4, 4, 4, 4 + 989, 3 - 69, 32 + 52, 26 7 @@ -334,22 +352,19 @@ topPanel - 4 + 5 NoControl - 257, 4 - - - 4, 4, 4, 4 + 286, 3 - 119, 32 + 89, 26 - 2 + 3 Settings @@ -364,7 +379,7 @@ topPanel - 5 + 6 Top, Right @@ -373,13 +388,10 @@ NoControl - 1271, 4 - - - 4, 4, 4, 4 + 953, 3 - 40, 32 + 30, 26 6 @@ -394,7 +406,7 @@ topPanel - 6 + 7 False @@ -403,13 +415,10 @@ NoControl - 131, 4 - - - 4, 4, 4, 4 + 98, 3 - 119, 32 + 89, 26 1 @@ -427,31 +436,31 @@ topPanel - 7 + 8 518, 17 - 198, 24 + 171, 22 Ask Consent + Bar - 198, 24 + 171, 22 Ask Consent - 198, 24 + 171, 22 Privacy Bar - 199, 76 + 172, 70 consentContextMenuStrip @@ -463,13 +472,10 @@ NoControl - 4, 4 - - - 4, 4, 4, 4 + 3, 3 - 119, 32 + 89, 26 0 @@ -487,7 +493,7 @@ topPanel - 8 + 9 Top @@ -495,11 +501,8 @@ 0, 0 - - 4, 4, 4, 4 - - 1392, 39 + 1044, 32 11 @@ -529,13 +532,10 @@ NoControl - 16, 73 - - - 4, 0, 4, 0 + 12, 59 - 86, 31 + 70, 25 12 @@ -565,13 +565,10 @@ Fill - 0, 39 - - - 4, 4, 4, 4 + 0, 32 - 1392, 858 + 1044, 695 10 @@ -580,7 +577,7 @@ resizeKvmControl - MeshCentralRouter.KVMResizeControl, MeshCentralRouter, Version=1.8.8096.29519, Culture=neutral, PublicKeyToken=null + MeshCentralRouter.KVMResizeControl, MeshCentralRouter, Version=1.8.8475.33354, Culture=neutral, PublicKeyToken=null $this @@ -596,7 +593,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADs - DgAAAk1TRnQBSQFMAgEBBAEAARABAAEQAQABEAEAARABAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFA + DgAAAk1TRnQBSQFMAgEBBAEAATABAAEwAQABEAEAARABAAT/AREBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABIAMAAQEBAAEQBgABEP8A/wD/AP8A/wD/AP8A/wAiAAH3AV4BpQEUAaUBFAGlARQBpQEUAaUBFAGl ARQB9wFeEAAB9wFeAaUBFAGlARQBpQEUAaUBFAGlARQBpQEUAfcBXhAAAfcBXgGlARQBpQEUAaUBFAGl ARQBpQEUAaUBFAH3AV4QAAH3AV4BpQEUAaUBFAGlARQBpQEUAaUBFAGlARQB9wFeEAAB3gF7ARgBYwFr @@ -666,10 +663,10 @@ True - 8, 16 + 6, 13 - 1392, 922 + 1044, 749 @@ -1097,7 +1094,7 @@ - 3, 2, 3, 2 + 2, 2, 2, 2 CenterScreen From bbdc101d8baae8d15830eda8a8f5ec1127f94e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sch=C3=B6n?= Date: Fri, 17 Mar 2023 22:59:00 +0100 Subject: [PATCH 3/4] fix: devices in "no agent devices relayed thru agent"-groups not accessible --- src/MainForm.cs | 22 ++++++++++++++++++++-- src/MeshCentralServer.cs | 2 ++ src/MeshMapper.cs | 4 ++-- src/NodeClass.cs | 2 ++ 4 files changed, 26 insertions(+), 4 deletions(-) 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; From 4aadc7e98effd03bc63d4403d825772fb5e93f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sch=C3=B6n?= Date: Fri, 17 Mar 2023 22:59:26 +0100 Subject: [PATCH 4/4] fix: double remote keyboard input (space, divide, multiply, subtract, add & decimal) --- src/KVMControl.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/KVMControl.cs b/src/KVMControl.cs index f5e7793..e456d8c 100644 --- a/src/KVMControl.cs +++ b/src/KVMControl.cs @@ -568,13 +568,24 @@ namespace MeshCentralRouter if (c >= 32) { SendUnicodeKey(c, 0); } } + private static readonly Keys[] ignoreKeys = { + // 0-9 (KeyCode: 48-57) + Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8, Keys.D9, + // NumPad 0-9 (KeyCode: 96-105) + Keys.NumPad0, Keys.NumPad1, Keys.NumPad2, Keys.NumPad3, Keys.NumPad4, Keys.NumPad5, Keys.NumPad6, Keys.NumPad7, Keys.NumPad8, Keys.NumPad9, + // Special-Keys + Keys.Space, Keys.Divide, Keys.Multiply, Keys.Subtract, Keys.Add, Keys.Decimal, + // Oem-Keys + Keys.Oem1, Keys.Oem2, Keys.Oem3, Keys.Oem4, Keys.Oem5, Keys.Oem6, Keys.Oem7, Keys.Oem8, Keys.Oem102, Keys.OemSemicolon, Keys.Oemplus, Keys.Oemcomma, + Keys.OemMinus, Keys.OemPeriod, Keys.OemQuestion, Keys.Oemtilde, Keys.OemOpenBrackets, Keys.OemPipe, Keys.OemCloseBrackets, Keys.OemQuotes + }; private void SendKey(KeyEventArgs e, byte action) { //if (state != ConnectState.Connected) return; if (remoteKeyboardMap == true) { SendKey((byte)e.KeyCode, action); return; } // Use old key system that uses the remote keyboard mapping. string keycode = e.KeyCode.ToString(); - if ((action == 0) && (e.Control == false) && (e.Alt == false) && (((e.KeyValue >= 48) && (e.KeyValue <= 57))|| ((e.KeyValue >= 96) && (e.KeyValue <= 105)) || (keycode.Length == 1) || (keycode.StartsWith("Oem") == true))) return; + if ((action == 0) && (e.Control == false) && (e.Alt == false) && (Array.IndexOf(ignoreKeys, e.KeyCode) > -1 || (keycode.Length == 1))) return; if ((e.Control == true) || (e.Alt == true)) { killNextKeyPress = DateTime.Now.Ticks; } SendKey((byte)e.KeyCode, action); e.Handled = true;