From f6a78bc34e27bffc016ca7a8650ce3ad35bf2d32 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Wed, 28 Oct 2020 14:46:40 -0700 Subject: [PATCH] Fixed server crash in AMT manager. --- amt/amt-wsman-comm.js | 2 +- amtmanager.js | 4 +++- views/agentinvite.handlebars | 1 + views/default-mobile.handlebars | 1 + views/default.handlebars | 24 +++++++++++++++++++----- views/desktop.handlebars | 1 + views/download.handlebars | 1 + views/download2.handlebars | 1 + views/error404-mobile.handlebars | 1 + views/error404.handlebars | 1 + views/error4042.handlebars | 1 + views/invite.handlebars | 1 + views/login-mobile.handlebars | 1 + views/login.handlebars | 1 + views/login2.handlebars | 1 + views/message.handlebars | 1 + views/message2.handlebars | 1 + views/messenger.handlebars | 1 + views/mstsc.handlebars | 1 + views/player.handlebars | 1 + views/terms-mobile.handlebars | 1 + views/terms.handlebars | 1 + views/xterm.handlebars | 1 + 23 files changed, 43 insertions(+), 7 deletions(-) diff --git a/amt/amt-wsman-comm.js b/amt/amt-wsman-comm.js index c405f438..cf19b100 100644 --- a/amt/amt-wsman-comm.js +++ b/amt/amt-wsman-comm.js @@ -229,7 +229,7 @@ var CreateWsmanComm = function (host, port, user, pass, tls, tlsoptions, mpsConn // let's chain up the TLSSocket <-> SerialTunnel <-> CIRA APF (chnl) // Anything that needs to be forwarded by SerialTunnel will be encapsulated by chnl write - ser.forwardwrite = function (msg) { obj.cirasocket.write(msg); }; // TLS ---> CIRA + ser.forwardwrite = function (msg) { try { obj.cirasocket.write(msg); } catch (ex) { } }; // TLS ---> CIRA // When APF tunnel return something, update SerialTunnel buffer obj.cirasocket.onData = function (ciraconn, data) { if (data.length > 0) { try { ser.updateBuffer(Buffer.from(data, 'binary')); } catch (e) { } } }; // CIRA ---> TLS diff --git a/amtmanager.js b/amtmanager.js index 5019a59d..939bf2d6 100644 --- a/amtmanager.js +++ b/amtmanager.js @@ -877,7 +877,9 @@ module.exports.CreateAmtManager = function (parent) { const dev = stack.dev; if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request. if (status != 200) { dev.consoleMsg("Failed to add TLS certificate (" + status + ")."); removeAmtDevice(dev); return; } - var certInstanceId = responses.Body['CreatedCertificate']['ReferenceParameters']['SelectorSet']['Selector']['Value']; + var certInstanceId = null; + try { certInstanceId = responses.Body['CreatedCertificate']['ReferenceParameters']['SelectorSet']['Selector']['Value']; } catch (ex) { } + if (certInstanceId == null) { dev.consoleMsg("Failed to get TLS certificate identifier."); removeAmtDevice(dev); return; } // Set the TLS certificate dev.setTlsSecurityPendingCalls = 3; diff --git a/views/agentinvite.handlebars b/views/agentinvite.handlebars index 2f09a4df..9fff10ea 100644 --- a/views/agentinvite.handlebars +++ b/views/agentinvite.handlebars @@ -6,6 +6,7 @@ + diff --git a/views/default-mobile.handlebars b/views/default-mobile.handlebars index 25bb2cd7..041bfa94 100644 --- a/views/default-mobile.handlebars +++ b/views/default-mobile.handlebars @@ -6,6 +6,7 @@ + diff --git a/views/default.handlebars b/views/default.handlebars index c5371072..5e78feca 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -6,6 +6,7 @@ + @@ -2334,6 +2335,18 @@ var rdpurl = 'http://' + window.location.hostname + ':' + basicPort + domainUrl + 'clickonce/minirouter/MeshMiniRouter.application?WS=wss%3A%2F%2F' + window.location.hostname + '%2Fmeshrelay.ashx%3Fauth=' + message.cookie + '&CH={{{webcerthash}}}&AP=' + message.protocol + ((debugmode == 1) ? '' : '&HOL=1'); safeNewWindow(rdpurl, '_blank'); } + /* + var servername = serverinfo.name; + if ((servername.indexOf('.') == -1) || ((features & 2) != 0)) { servername = window.location.hostname; } // If the server name is not set or it's in LAN-only mode, use the URL hostname as server name. + var domainUrlNoSlash = domainUrl.substring(0, domainUrl.length - 1); + var portStr = (serverinfo.port == 443) ? '' : (':' + serverinfo.port); + var url = 'mcrouter://' + servername + portStr + domainUrl + 'control.ashx?c=' + authCookie + '&t=' + serverinfo.tlshash + '&l={{{lang}}}' + (urlargs.key?('&key=' + urlargs.key):''); + if (message.nodeid != null) { url += ('&n=' + message.nodeid); } + if (message.protocol != null) { url += ('&p=' + message.protocol); } + if (message.tcpport != null) { url += ('&tcpport=' + message.tcpport); } + console.log(url); + downloadFile(url, ''); + */ } else if (message.tag == 'novnc') { var vncurl = window.location.origin + domainUrl + 'novnc/vnc.html?ws=wss%3A%2F%2F' + window.location.host + encodeURIComponentEx(domainUrl) + 'meshrelay.ashx%3Fauth%3D' + message.cookie + '&show_dot=1' + (urlargs.key?('&key=' + urlargs.key):'') + '&l={{{lang}}}'; var node = getNodeFromId(message.nodeid); @@ -3996,9 +4009,9 @@ r += ' ' + "Add Agent" + ''; if ((features & 2) == 0) { r += ' ' + "Invite" + ''; } } - if (mesh.amt && (mesh.amt.type > 2)) { // ACM activation or Full Automatic - r += ' ' + "ACM" + ''; - } + //if (mesh.amt && (mesh.amt.type > 2)) { // ACM activation or Full Automatic + // r += ' ' + "ACM" + ''; + //} return r; } @@ -6522,7 +6535,7 @@ if (os == 16) { osn = "MeshCmd (macOS, 64bit)"; } if (os == 25) { osn = "MeshCmd (Linux ARM, 32bit)"; } QH('meshcmddownloadid', osn); - Q('meshcmddownloadid').onclick = function() { downloadFile('meshagents?meshcmd=' + os + (urlargs.key?('&key=' + urlargs.key):''), null, true); } + Q('meshcmddownloadid').onclick = function() { downloadFile('meshagents?meshcmd=' + os + (urlargs.key?('&key=' + urlargs.key):'')); } } function p10showiconselector() { @@ -13713,7 +13726,8 @@ var element = document.createElement('a'); element.setAttribute('href', link); element.setAttribute('rel', 'noreferrer noopener'); - if (navigator.userAgent.indexOf('Firefox') >= 0) { element.setAttribute('download', decodeURIComponent(name?name:'')); } else { element.setAttribute('target', 'fileDownloadFrame'); } + element.setAttribute('target', 'fileDownloadFrame'); + if (navigator.userAgent.indexOf('Firefox') >= 0) { element.setAttribute('download', decodeURIComponent(name?name:'')); } document.body.appendChild(element); element.click(); document.body.removeChild(element); diff --git a/views/desktop.handlebars b/views/desktop.handlebars index 6ff6f4df..1b431ffd 100644 --- a/views/desktop.handlebars +++ b/views/desktop.handlebars @@ -6,6 +6,7 @@ + diff --git a/views/download.handlebars b/views/download.handlebars index e965fa05..54d01e50 100644 --- a/views/download.handlebars +++ b/views/download.handlebars @@ -6,6 +6,7 @@ + {{{title1}}} - Download diff --git a/views/download2.handlebars b/views/download2.handlebars index 88955918..f9e0f5bd 100644 --- a/views/download2.handlebars +++ b/views/download2.handlebars @@ -6,6 +6,7 @@ + {{{title1}}} - Download diff --git a/views/error404-mobile.handlebars b/views/error404-mobile.handlebars index b102856f..def7cd34 100644 --- a/views/error404-mobile.handlebars +++ b/views/error404-mobile.handlebars @@ -6,6 +6,7 @@ + {{{title}}}