From ebaa8c5b0ce26bdf4a4be30955cbaad689e8c900 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sat, 7 Oct 2023 12:22:45 -0700 Subject: [PATCH] Reverted bad change to web socket client. --- src/MainForm.Designer.cs | 3 +- src/MainForm.resx | 568 +++++++++++++-------------------------- src/WebSocketClient.cs | 26 +- 3 files changed, 206 insertions(+), 391 deletions(-) diff --git a/src/MainForm.Designer.cs b/src/MainForm.Designer.cs index e24117f..1c8fcd4 100644 --- a/src/MainForm.Designer.cs +++ b/src/MainForm.Designer.cs @@ -679,8 +679,7 @@ private void InitializeComponent() this.rdpToolStripMenuItem, this.sshToolStripMenuItem, this.scpToolStripMenuItem, - this.wolToolStripMenuItem, - }); + this.wolToolStripMenuItem}); this.devicesContextMenuStrip.Name = "devicesContextMenuStrip"; resources.ApplyResources(this.devicesContextMenuStrip, "devicesContextMenuStrip"); this.devicesContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.devicesContextMenuStrip_Opening); diff --git a/src/MainForm.resx b/src/MainForm.resx index 7ce76db..c4635b2 100644 --- a/src/MainForm.resx +++ b/src/MainForm.resx @@ -129,13 +129,10 @@ - 13, 355 - - - 4, 4, 4, 4 + 10, 286 - 127, 28 + 95, 23 @@ -166,13 +163,10 @@ NoControl - 148, 355 - - - 4, 4, 4, 4 + 111, 286 - 127, 28 + 95, 23 104 @@ -208,13 +202,10 @@ NoControl - 321, 277 - - - 4, 0, 4, 0 + 241, 225 - 114, 17 + 88, 13 19 @@ -244,13 +235,10 @@ NoControl - 317, 217 - - - 4, 0, 4, 0 + 238, 176 - 69, 17 + 53, 13 18 @@ -277,13 +265,10 @@ NoControl - 317, 166 - - - 4, 0, 4, 0 + 238, 135 - 73, 17 + 55, 13 17 @@ -310,13 +295,10 @@ NoControl - 317, 113 - - - 4, 0, 4, 0 + 238, 92 - 50, 17 + 38, 13 16 @@ -340,16 +322,13 @@ Top, Left, Right - 321, 236 - - - 4, 4, 4, 4 + 241, 192 - 287, 22 + 214, 20 102 @@ -373,13 +352,10 @@ meshcentral.com - 321, 135 - - - 4, 4, 4, 4 + 241, 110 - 287, 24 + 214, 21 100 @@ -400,13 +376,10 @@ Top, Left, Right - 321, 186 - - - 4, 4, 4, 4 + 241, 151 - 287, 22 + 214, 20 101 @@ -430,13 +403,10 @@ NoControl - 235, 323 - - - 4, 0, 4, 0 + 174, 260 - 404, 16 + 303, 13 103 @@ -469,13 +439,10 @@ NoControl - 4, 323 - - - 4, 0, 4, 0 + 3, 260 - 47, 17 + 37, 13 11 @@ -502,13 +469,10 @@ NoControl - 499, 355 - - - 4, 4, 4, 4 + 372, 286 - 127, 28 + 95, 23 105 @@ -535,13 +499,10 @@ NoControl - 0, 345 - - - 4, 4, 4, 4 + 0, 278 - 640, 49 + 478, 40 StretchImage @@ -568,13 +529,10 @@ NoControl - 16, 11 - - - 4, 0, 4, 0 + 12, 9 - 608, 69 + 454, 56 6 @@ -601,13 +559,10 @@ NoControl - 20, 84 - - - 4, 4, 4, 4 + 15, 68 - 292, 212 + 217, 170 Zoom @@ -631,13 +586,10 @@ Fill - 4, 4 - - - 4, 4, 4, 4 + 3, 3 - 640, 392 + 478, 316 6 @@ -655,16 +607,13 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 648, 400 + 484, 322 0 @@ -688,13 +637,10 @@ NoControl - 320, 216 - - - 4, 4, 4, 4 + 240, 176 - 127, 28 + 95, 23 207 @@ -724,13 +670,10 @@ NoControl - 321, 272 - - - 4, 4, 4, 4 + 241, 221 - 170, 21 + 131, 17 204 @@ -757,13 +700,10 @@ NoControl - 321, 180 - - - 4, 4, 4, 4 + 241, 146 - 127, 28 + 95, 23 202 @@ -790,13 +730,10 @@ NoControl - 456, 180 - - - 4, 4, 4, 4 + 342, 146 - 127, 28 + 95, 23 203 @@ -826,13 +763,10 @@ NoControl - 317, 186 - - - 4, 0, 4, 0 + 238, 151 - 73, 17 + 55, 13 21 @@ -862,13 +796,10 @@ NoControl - 317, 128 - - - 4, 0, 4, 0 + 238, 104 - 48, 17 + 38, 13 19 @@ -892,13 +823,10 @@ Top, Left, Right - 321, 148 - - - 4, 4, 4, 4 + 241, 120 - 287, 22 + 214, 20 201 @@ -922,13 +850,10 @@ NoControl - 20, 84 - - - 4, 4, 4, 4 + 15, 68 - 292, 212 + 217, 170 Zoom @@ -955,13 +880,10 @@ NoControl - 363, 355 - - - 4, 4, 4, 4 + 270, 286 - 127, 28 + 95, 23 205 @@ -988,13 +910,10 @@ NoControl - 499, 355 - - - 4, 4, 4, 4 + 372, 286 - 127, 28 + 95, 23 206 @@ -1021,13 +940,10 @@ NoControl - 0, 345 - - - 4, 4, 4, 4 + 0, 278 - 640, 49 + 478, 40 StretchImage @@ -1054,13 +970,10 @@ NoControl - 16, 11 - - - 4, 0, 4, 0 + 12, 9 - 608, 69 + 454, 56 6 @@ -1084,13 +997,10 @@ Fill - 4, 4 - - - 4, 4, 4, 4 + 3, 3 - 640, 392 + 478, 316 7 @@ -1108,16 +1018,13 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 648, 400 + 484, 322 1 @@ -1147,13 +1054,10 @@ NoControl - 277, 319 - - - 4, 4, 4, 4 + 208, 256 - 190, 21 + 145, 17 302 @@ -1177,10 +1081,7 @@ Top, Bottom, Left, Right - 20, 101 - - - 4, 4, 4, 4 + 15, 82 True @@ -1189,7 +1090,7 @@ Vertical - 602, 202 + 450, 162 25 @@ -1213,13 +1114,10 @@ NoControl - 19, 313 - - - 4, 4, 4, 4 + 14, 251 - 251, 28 + 188, 23 301 @@ -1249,13 +1147,10 @@ NoControl - 11, 7 - - - 4, 0, 4, 0 + 8, 6 - 627, 27 + 468, 22 23 @@ -1285,13 +1180,10 @@ NoControl - 16, 42 - - - 4, 0, 4, 0 + 12, 34 - 608, 55 + 454, 45 22 @@ -1318,13 +1210,10 @@ NoControl - 371, 362 - - - 4, 4, 4, 4 + 276, 291 - 127, 28 + 95, 23 303 @@ -1351,13 +1240,10 @@ NoControl - 507, 362 - - - 4, 4, 4, 4 + 378, 291 - 127, 28 + 95, 23 304 @@ -1384,13 +1270,10 @@ NoControl - 0, 351 - - - 4, 4, 4, 4 + 0, 282 - 648, 49 + 484, 40 StretchImage @@ -1416,11 +1299,8 @@ 0, 0 - - 4, 4, 4, 4 - - 648, 400 + 484, 322 8 @@ -1438,13 +1318,10 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 648, 400 + 484, 322 2 @@ -1474,49 +1351,49 @@ 613, 17 - 218, 26 + 185, 22 Show &Group Names - 218, 26 + 185, 22 Show &Offline Devices - 215, 6 + 182, 6 - 218, 26 + 185, 22 Sort by &Name - 218, 26 + 185, 22 Sort by G&roup - 215, 6 + 182, 6 - 218, 26 + 185, 22 S&ettings... - 218, 26 + 185, 22 &Custom Apps... - 219, 172 + 186, 148 mainContextMenuStrip @@ -1531,13 +1408,10 @@ NoControl - 608, 2 - - - 4, 0, 4, 0 + 454, 2 - 31, 31 + 25, 25 403 @@ -1561,13 +1435,10 @@ Top, Right - 411, 6 - - - 4, 4, 4, 4 + 306, 5 - 193, 22 + 146, 20 402 @@ -1603,13 +1474,10 @@ NoControl - 8, 226 - - - 4, 4, 4, 4 + 6, 180 - 224, 43 + 168, 35 405 @@ -1651,88 +1519,88 @@ Segoe UI, 9pt, style=Bold - 198, 24 + 170, 22 Add &Map... - 198, 24 + 170, 22 Add &Relay Map... - 195, 6 + 167, 6 - 204, 26 + 171, 22 Ask Consent + Bar - 204, 26 + 171, 22 Ask Consent - 204, 26 + 171, 22 Privacy Bar - 198, 24 + 170, 22 Remote Desktop... - 198, 24 + 170, 22 Remote Files... - - 198, 24 - - - Wake Up... - - 198, 24 + 170, 22 HTTP - 198, 24 + 170, 22 HTTPS - 198, 24 + 170, 22 RDP - 198, 24 + 170, 22 SSH - 198, 24 + 170, 22 SCP + + 170, 22 + + + Wake Up... + - 199, 226 + 171, 230 devicesContextMenuStrip @@ -1748,7 +1616,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADg - HQAAAk1TRnQBSQFMAgEBEAEAASgBAQEoAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA + HQAAAk1TRnQBSQFMAgEBEAEAATABAQEwAQEBEAEAARABAAT/ARkBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABUAMAAQEBAAEYBgABPP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AJYAA/0D+AP3A/sD/yEAA/0D+gP5 A/wD/xgAAfoB+wH6A/4qAAP9A/8tAAP7A88D1QPbA88D1AO+A9QYAAP8A90D4APjA90D4APUA+MSAAP8 AZEBjwF9AU4BaAEhAfQB9QH0JAAD/gPRA8YD+ioAAcYCxwHPAtAB2ALZA90DywPBA68DmgP3FQAD2APd @@ -1879,13 +1747,10 @@ - 13, 5 - - - 4, 4, 4, 4 + 10, 4 - 593, 258 + 446, 210 404 @@ -1897,7 +1762,7 @@ devicesListView - MeshCentralRouter.ListViewExtended, MeshCentralRouter, Version=1.8.8332.12419, Culture=neutral, PublicKeyToken=null + MeshCentralRouter.ListViewExtended, MeshCentralRouter, Version=1.8.8680.22147, Culture=neutral, PublicKeyToken=null devicesPanel @@ -1915,13 +1780,10 @@ NoControl - 3, 108 - - - 4, 0, 4, 0 + 2, 88 - 490, 64 + 362, 52 5 @@ -1957,13 +1819,10 @@ NoControl - 3, 108 - - - 4, 0, 4, 0 + 2, 88 - 490, 64 + 362, 52 4 @@ -1989,11 +1848,8 @@ 0, 0 - - 4, 4, 4, 4 - - 628, 305 + 470, 248 50 @@ -2011,16 +1867,13 @@ 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 632, 315 + 470, 250 0 @@ -2047,13 +1900,10 @@ NoControl - 5, 221 - - - 4, 4, 4, 4 + 4, 182 - 224, 43 + 168, 35 55 @@ -2092,13 +1942,10 @@ NoControl - 8, 97 - - - 4, 0, 4, 0 + 6, 79 - 586, 64 + 436, 52 4 @@ -2126,11 +1973,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 628, 268 + 472, 221 49 @@ -2154,13 +1998,10 @@ Click "Add" to get started. NoControl - 1, 275 - - - 4, 4, 4, 4 + 1, 226 - 27, 25 + 20, 20 54 @@ -2184,13 +2025,10 @@ Click "Add" to get started. NoControl - 320, 275 - - - 4, 4, 4, 4 + 240, 226 - 27, 25 + 20, 20 5 @@ -2217,13 +2055,10 @@ Click "Add" to get started. NoControl - 496, 271 - - - 4, 4, 4, 4 + 372, 223 - 133, 28 + 100, 23 50 @@ -2253,13 +2088,10 @@ Click "Add" to get started. NoControl - 355, 271 - - - 4, 4, 4, 4 + 266, 223 - 133, 28 + 100, 23 52 @@ -2280,16 +2112,13 @@ Click "Add" to get started. 5 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 4, 4, 4, 4 + 3, 3, 3, 3 - 632, 315 + 472, 253 1 @@ -2310,13 +2139,10 @@ Click "Add" to get started. 1 - 4, 4 - - - 4, 4, 4, 4 + 3, 3 - 640, 347 + 478, 279 401 @@ -2340,13 +2166,10 @@ Click "Add" to get started. NoControl - 13, 362 - - - 4, 4, 4, 4 + 10, 291 - 145, 28 + 109, 23 406 @@ -2376,13 +2199,10 @@ Click "Add" to get started. NoControl - 371, 362 - - - 4, 4, 4, 4 + 276, 291 - 127, 28 + 95, 23 407 @@ -2409,13 +2229,10 @@ Click "Add" to get started. NoControl - 507, 362 - - - 4, 4, 4, 4 + 378, 291 - 127, 28 + 95, 23 408 @@ -2442,13 +2259,10 @@ Click "Add" to get started. NoControl - 0, 351 - - - 4, 4, 4, 4 + 0, 282 - 648, 49 + 484, 40 StretchImage @@ -2474,11 +2288,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 648, 400 + 484, 322 8 @@ -2496,13 +2307,10 @@ Click "Add" to get started. 0 - 4, 28 - - - 4, 4, 4, 4 + 4, 25 - 648, 400 + 484, 322 4 @@ -2532,7 +2340,7 @@ Click "Add" to get started. 0, 0, 0, 0 - 656, 432 + 492, 351 8 @@ -2556,13 +2364,10 @@ Click "Add" to get started. Fill - 0, 80 - - - 4, 4, 4, 4 + 0, 65 - 656, 432 + 492, 351 9 @@ -2588,11 +2393,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 656, 80 + 492, 65 Zoom @@ -2618,11 +2420,8 @@ Click "Add" to get started. 0, 0 - - 4, 4, 4, 4 - - 656, 512 + 492, 416 8 @@ -2652,22 +2451,22 @@ Click "Add" to get started. 418, 17 - 123, 24 + 112, 22 &Open... - 120, 6 + 109, 6 - 123, 24 + 112, 22 E&xit - 124, 58 + 113, 54 trayIconContextMenuStrip @@ -4379,34 +4178,34 @@ Click "Add" to get started. 905, 17 - 193, 24 + 168, 22 &Open Mappings... - 193, 24 + 168, 22 &Save Mappings... - 190, 6 + 165, 6 - 193, 24 + 168, 22 S&ettings... - 193, 24 + 168, 22 &Custom Apps... - 194, 106 + 169, 98 mappingsContextMenuStrip @@ -4436,10 +4235,10 @@ Click "Add" to get started. True - 8, 16 + 6, 13 - 656, 512 + 492, 416 @@ -6135,9 +5934,6 @@ Click "Add" to get started. AADAPwAAwD8AAMA/AADAPwAA - - 4, 4, 4, 4 - MeshCentral Router @@ -6249,12 +6045,6 @@ Click "Add" to get started. System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - wolToolStripMenuItem - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - httpToolStripMenuItem @@ -6285,6 +6075,12 @@ Click "Add" to get started. System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + wolToolStripMenuItem + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + devicesImageList diff --git a/src/WebSocketClient.cs b/src/WebSocketClient.cs index 4abffe3..6c0eb0d 100644 --- a/src/WebSocketClient.cs +++ b/src/WebSocketClient.cs @@ -209,9 +209,30 @@ public bool Start(Uri url, string tlsCertFingerprint, string tlsCertFingerprint2 else { // Use C# coded websockets - Uri proxyUri = Win32Api.GetProxy(url); + Uri proxyUri = null; Log("Websocket Start, URL=" + ((url == null) ? "(NULL)" : url.ToString())); + // Check if we need to use a HTTP proxy (Auto-proxy way) + try + { + RegistryKey registryKey = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); + Object x = registryKey.GetValue("AutoConfigURL", null); + if ((x != null) && (x.GetType() == typeof(string))) + { + string proxyStr = GetProxyForUrlUsingPac("http" + ((url.Port == 80) ? "" : "s") + "://" + url.Host + ":" + url.Port, x.ToString()); + if (proxyStr != null) { proxyUri = new Uri("http://" + proxyStr); } + } + } + catch (Exception) { proxyUri = null; } + + // Check if we need to use a HTTP proxy (Normal way) + if (proxyUri == null) + { + var proxy = System.Net.HttpWebRequest.GetSystemWebProxy(); + proxyUri = proxy.GetProxy(url); + if ((url.Host.ToLower() == proxyUri.Host.ToLower()) && (url.Port == proxyUri.Port)) { proxyUri = null; } + } + if (proxyUri != null) { // Proxy in use @@ -267,8 +288,7 @@ private void OnConnectSink(IAsyncResult ar) { // Send proxy connection request wsrawstream = wsclient.GetStream(); - Uri proxyUri = Win32Api.GetProxy(url); - string userCreds = proxyUri.UserInfo; + string basicAuth = ""; if (proxyUri?.UserInfo != null) {