From f2a5141b422d4cc0956d15a99f75c2125001a32a Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Fri, 31 May 2019 14:48:13 -0700 Subject: [PATCH] Agent URL to clipboard, Terminal scroll back. --- meshagent.js | 4 -- package.json | 2 +- public/scripts/amt-desktop-0.0.2.js | 2 +- public/scripts/amt-terminal-0.0.2.js | 78 ++++++++++++++++++---------- public/styles/style.css | 5 +- views/default-min.handlebars | 2 +- views/default.handlebars | 28 ++++++++-- views/messenger-min.handlebars | 2 +- webserver.js | 1 - 9 files changed, 84 insertions(+), 40 deletions(-) diff --git a/meshagent.js b/meshagent.js index a1eb33de..6c6e8df1 100644 --- a/meshagent.js +++ b/meshagent.js @@ -477,10 +477,6 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { } obj.close(0); }); - ws._socket._parent.on('close', function (req) { - parent.agentStats.agentTcpClose++; - //if (obj.nodeid != null) { parent.parent.debug(1, 'Agent TCP disconnect ' + obj.nodeid + ' (' + obj.remoteaddrport + ')'); } - }); // Start authenticate the mesh agent by sending a auth nonce & server TLS cert hash. // Send 384 bits SHA384 hash of TLS cert public key + 384 bits nonce diff --git a/package.json b/package.json index abb065e1..157ff7e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.5-r", + "version": "0.3.5-s", "keywords": [ "Remote Management", "Intel AMT", diff --git a/public/scripts/amt-desktop-0.0.2.js b/public/scripts/amt-desktop-0.0.2.js index 8eb26534..ff7d390f 100644 --- a/public/scripts/amt-desktop-0.0.2.js +++ b/public/scripts/amt-desktop-0.0.2.js @@ -737,7 +737,7 @@ var CreateAmtRemoteDesktop = function (divid, scrolldiv) { if (k == 192) kk = 96; // ` if (k == 219) kk = 91; // [ if (k == 220) kk = 92; // \ - if (k == 221) kk = 93; // ]t + if (k == 221) kk = 93; // ] if (k == 222) kk = 39; // ' //console.log('Key' + d + ": " + k + " = " + kk); obj.sendkey(kk, d); diff --git a/public/scripts/amt-terminal-0.0.2.js b/public/scripts/amt-terminal-0.0.2.js index 0f71cd55..2e9b0b10 100644 --- a/public/scripts/amt-terminal-0.0.2.js +++ b/public/scripts/amt-terminal-0.0.2.js @@ -45,6 +45,7 @@ var CreateAmtRemoteTerminal = function (divid) { var _cursorVisible = true; var _scrollRegion = [0, 24]; var _altKeypadMode = false; + var scrollBackBuffer = []; obj.Start = function () { } @@ -251,6 +252,7 @@ var CreateAmtRemoteTerminal = function (divid) { obj.TermClear((_TermCurrentBColor << 12) + (_TermCurrentFColor << 6)); // Erase entire screen _termx = 0; _termy = 0; + scrollBackBuffer = []; } else if (argslen == 0 || argslen == 1 && args[0] == 0) // Erase cursor down { @@ -526,6 +528,7 @@ var CreateAmtRemoteTerminal = function (divid) { _termy++; if (_termy > _scrollRegion[1]) { // Move everything up one line + obj.recordLineTobackBuffer(0); _TermMoveUp(1); _termy = _scrollRegion[1]; } @@ -544,7 +547,6 @@ var CreateAmtRemoteTerminal = function (divid) { _termx++; break; } - } function _TermDrawChar(c) { @@ -559,6 +561,7 @@ var CreateAmtRemoteTerminal = function (divid) { _scratt[y][x] = TermColor; } } + scrollBackBuffer = []; } obj.TermResetScreen = function () { @@ -695,36 +698,57 @@ var CreateAmtRemoteTerminal = function (divid) { return false; } - obj.TermDraw = function() { - var c, buf = '', closetag = '', newat, oldat = 1, x1, x2; - for (var y = 0; y < obj.height; ++y) { - for (var x = 0; x < obj.width; ++x) { - newat = _scratt[y][x]; - if (_termx == x && _termy == y && _cursorVisible) { newat |= _VTREVERSE; } // If this is the cursor location, reverse the color. - if (newat != oldat) { - buf += closetag; - closetag = ''; - x1 = 6; x2 = 12; - if (newat & _VTREVERSE) { x1 = 12; x2 = 6; } - buf += ''; - closetag = "" + closetag; - oldat = newat; - } + obj.recordLineTobackBuffer = function(y) { + var closetag = '', buf = ''; + var r = obj.TermDrawLine(buf, y, closetag); + buf = r[0]; + closetag = r[1]; + scrollBackBuffer.push(buf + closetag + '
'); + if (scrollBackBuffer.length > 800) { scrollBackBuffer = scrollBackBuffer.slice(0, 800); } + } - c = _tscreen[y][x]; - switch (c) { - case '&': buf += '&'; break; - case '<': buf += '<'; break; - case '>': buf += '>'; break; - case ' ': buf += ' '; break; - default: buf += c; break; - } + obj.TermDrawLine = function (buf, y, closetag) { + var newat, c, oldat = 1, x1, x2; + for (var x = 0; x < obj.width; ++x) { + newat = _scratt[y][x]; + if (_termx == x && _termy == y && _cursorVisible) { newat |= _VTREVERSE; } // If this is the cursor location, reverse the color. + if (newat != oldat) { + buf += closetag; + closetag = ''; + x1 = 6; x2 = 12; + if (newat & _VTREVERSE) { x1 = 12; x2 = 6; } + buf += ''; + closetag = "" + closetag; + oldat = newat; } + + c = _tscreen[y][x]; + switch (c) { + case '&': buf += '&'; break; + case '<': buf += '<'; break; + case '>': buf += '>'; break; + case ' ': buf += ' '; break; + default: buf += c; break; + } + } + return [buf, closetag]; + } + + obj.TermDraw = function() { + var closetag = '', buf = ''; + for (var y = 0; y < obj.height; ++y) { + var r = obj.TermDrawLine(buf, y, closetag); + buf = r[0]; + closetag = r[1]; if (y != (obj.height - 1)) buf += '
'; } - obj.DivElement.innerHTML = "" + buf + closetag + ""; + + var backbuffer = ''; + for (var i in scrollBackBuffer) { backbuffer += scrollBackBuffer[i]; } + obj.DivElement.innerHTML = "" + backbuffer + buf + closetag + ""; + obj.DivElement.scrollTop = obj.DivElement.scrollHeight; } obj.TermInit = function () { obj.TermResetScreen(); } diff --git a/public/styles/style.css b/public/styles/style.css index fd44482b..492da359 100644 --- a/public/styles/style.css +++ b/public/styles/style.css @@ -2140,11 +2140,14 @@ a { #termarea3x { background: black; text-align: center; - height: 500px; + height: 450px; position: relative; } #Term { + height: 450px; + max-height: 450px; + overflow-y: scroll; background: black; margin: 0; padding: 0; diff --git a/views/default-min.handlebars b/views/default-min.handlebars index e6a4b6fb..278b9cc5 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default.handlebars b/views/default.handlebars index e6df758e..b9c5a317 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -488,6 +488,8 @@ + + @@ -2706,8 +2708,8 @@ x += "
To add a new computer to device group \"" + EscapeHtml(mesh.name) + "\", download the mesh agent and install it the computer to manage. This agent has server and mesh information embedded within it.

"; //x += addHtmlValue('Mesh Agent', 'Windows (.exe)'); //x += addHtmlValue('Mesh Agent', 'Windows x64 (.exe)'); - x += addHtmlValue('Mesh Agent', 'Windows (.exe)'); - x += addHtmlValue('Mesh Agent', 'Windows x64 (.exe)'); + x += addHtmlValue('Mesh Agent', 'Windows (.exe) Windows x64 (.exe) ' + EscapeHtml(mesh.name) + ' settings (.msh)'); } x += "
"; @@ -2773,6 +2775,14 @@ addAgentToMeshClick(); } + function copyAgentUrl(url) { + 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); + navigator.clipboard.writeText("http://" + servername + portStr + domainUrl + url + Q('aginsType').value); + } + function fileDownload(path, name, appendFlag) { var xdr = null, flag = ''; if (appendFlag == 1) { @@ -4778,10 +4788,22 @@ } } else if (ks == 6) { // WIN+R if (desktop.contype == 2) { - desktop.m.sendkey([[0xffe7, 1], [0x72, 1], [0x72, 0], [0xffe7, 0]]); // Intel AMT: Meta-left down, 'l' press, 'l' release, Meta-left release + desktop.m.sendkey([[0xffe7,1],[0x72,1],[0x72,0],[0xffe7,0]]); // Intel AMT: Meta-left down, 'r' press, 'r' release, Meta-left release } else { desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 0x5B], [desktop.m.KeyAction.DOWN, 82], [desktop.m.KeyAction.UP, 82], [desktop.m.KeyAction.EXUP, 0x5B]]); // MeshAgent: L-Winkey press, 'R' press, 'R' release, L-Winkey release } + } else if (ks == 7) { // ALT-F4 + if (desktop.contype == 2) { + desktop.m.sendkey([[0xffe9,1],[0xffc1,1],[0xffc1,0],[0xffe9,0]]); // Intel AMT: Alt down, 'F4' press, 'F4' release, Alt release + } else { + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 18], [desktop.m.KeyAction.DOWN, 115], [desktop.m.KeyAction.UP, 115], [desktop.m.KeyAction.EXUP, 18]]); // MeshAgent: Alt press, 'F4' press, 'F4' release, Alt release + } + } else if (ks == 8) { // CTRL-W + if (desktop.contype == 2) { + desktop.m.sendkey([[0xffe3,1],[0x77,1],[0x77,0],[0xffe3,0]]); // Intel AMT: Ctrl down, 'w' press, 'w' release, Ctrl release + } else { + desktop.m.SendKeyMsgKC([[desktop.m.KeyAction.EXDOWN, 17], [desktop.m.KeyAction.DOWN, 87], [desktop.m.KeyAction.UP, 87], [desktop.m.KeyAction.EXUP, 17]]); // MeshAgent: Ctrl press, 'W' press, 'W' release, Ctrl release + } } } diff --git a/views/messenger-min.handlebars b/views/messenger-min.handlebars index 59fe7827..78cb64b9 100644 --- a/views/messenger-min.handlebars +++ b/views/messenger-min.handlebars @@ -1 +1 @@ - MeshMessenger
MeshMessenger
\ No newline at end of file + MeshMessenger
MeshMessenger
\ No newline at end of file diff --git a/webserver.js b/webserver.js index a1ff556a..79fa4363 100644 --- a/webserver.js +++ b/webserver.js @@ -242,7 +242,6 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) { obj.agentStats = { createMeshAgentCount: 0, agentClose: 0, - agentTcpClose: 0, agentBinaryUpdate: 0, coreIsStableCount: 0, verifiedAgentConnectionCount: 0,