Agent URL to clipboard, Terminal scroll back.

This commit is contained in:
Ylian Saint-Hilaire 2019-05-31 14:48:13 -07:00
parent 7529dce77b
commit f378104c16
9 changed files with 84 additions and 40 deletions

View File

@ -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

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.3.5-r",
"version": "0.3.5-s",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -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);

View File

@ -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 += '<span style="color:#' + _TermColors[(newat >> x1) & 0x3F] + ';background-color:#' + _TermColors[(newat >> x2) & 0x3F];
if (newat & _VTUNDERLINE) buf += ';text-decoration:underline';
buf += ';">';
closetag = "</span>" + 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 + '<br>');
if (scrollBackBuffer.length > 800) { scrollBackBuffer = scrollBackBuffer.slice(0, 800); }
}
c = _tscreen[y][x];
switch (c) {
case '&': buf += '&amp;'; break;
case '<': buf += '&lt;'; break;
case '>': buf += '&gt;'; break;
case ' ': buf += '&nbsp;'; 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 += '<span style="color:#' + _TermColors[(newat >> x1) & 0x3F] + ';background-color:#' + _TermColors[(newat >> x2) & 0x3F];
if (newat & _VTUNDERLINE) buf += ';text-decoration:underline';
buf += ';">';
closetag = "</span>" + closetag;
oldat = newat;
}
c = _tscreen[y][x];
switch (c) {
case '&': buf += '&amp;'; break;
case '<': buf += '&lt;'; break;
case '>': buf += '&gt;'; break;
case ' ': buf += '&nbsp;'; 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 += '<br>';
}
obj.DivElement.innerHTML = "<font size='4'><b>" + buf + closetag + "</b></font>";
var backbuffer = '';
for (var i in scrollBackBuffer) { backbuffer += scrollBackBuffer[i]; }
obj.DivElement.innerHTML = "<font size='4'><b>" + backbuffer + buf + closetag + "</b></font>";
obj.DivElement.scrollTop = obj.DivElement.scrollHeight;
}
obj.TermInit = function () { obj.TermResetScreen(); }

View File

@ -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;

File diff suppressed because one or more lines are too long

View File

@ -488,6 +488,8 @@
<option value=3>Win+M</option>
<option value=4>Shift+Win+M</option>
<option value=6>Win+R</option>
<option value=7>Alt-F4</option>
<option value=8>Ctrl-W</option>
</select>
<input id="DeskWD" type=button value="Send" onkeypress="return false" onkeydown="return false" onclick="deskSendKeys()">
<input id="DeskClip" style="" type="button" value="Clipboard" onkeypress="return false" onkeydown="return false" onclick="showDeskClip()">
@ -2706,8 +2708,8 @@
x += "<div id=agins_windows>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.<br /><br />";
//x += addHtmlValue('Mesh Agent', '<a id=aginsw32lnk href="meshagents?id=3&meshid=' + meshid.split('/')[2] + '&installflags=0" rel="noreferrer noopener" target="_blank" title="32bit version of the MeshAgent">Windows (.exe)</a>');
//x += addHtmlValue('Mesh Agent', '<a id=aginsw64lnk href="meshagents?id=4&meshid=' + meshid.split('/')[2] + '&installflags=0" rel="noreferrer noopener" target="_blank" title="64bit version of the MeshAgent">Windows x64 (.exe)</a>');
x += addHtmlValue('Mesh Agent', '<a id=aginsw32lnk style=cursor:pointer onclick=fileDownload("meshagents?id=3&meshid=' + meshid.split('/')[2] + '&installflags=","MeshAgent-' + meshfilename + '.exe",1) title="32bit version of the MeshAgent">Windows (.exe)</a>');
x += addHtmlValue('Mesh Agent', '<a id=aginsw64lnk style=cursor:pointer onclick=fileDownload("meshagents?id=4&meshid=' + meshid.split('/')[2] + '&installflags=","MeshAgent-' + meshfilename + '.exe",1) title="64bit version of the MeshAgent">Windows x64 (.exe)</a>');
x += addHtmlValue('Mesh Agent', '<a id=aginsw32lnk style=cursor:pointer onclick=fileDownload("meshagents?id=3&meshid=' + meshid.split('/')[2] + '&installflags=","MeshAgent-' + meshfilename + '.exe",1) title="32bit version of the MeshAgent">Windows (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy 32bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=3&meshid=' + meshid.split('/')[2] + '&installflags=")>');
x += addHtmlValue('Mesh Agent', '<a id=aginsw64lnk style=cursor:pointer onclick=fileDownload("meshagents?id=4&meshid=' + meshid.split('/')[2] + '&installflags=","MeshAgent-' + meshfilename + '.exe",1) title="64bit version of the MeshAgent">Windows x64 (.exe)</a> <img src=images/link4.png height=10 width=10 title="Copy 64bit agent URL to clipboard" style=cursor:pointer onclick=copyAgentUrl("meshagents?id=4&meshid=' + meshid.split('/')[2] + '&installflags=")>');
if (debugmode > 0) { x += addHtmlValue('Settings File', '<a id=aginswmshlnk href="meshsettings?id=' + meshid.split('/')[2] + '&installflags=0" rel="noreferrer noopener" target="_blank">' + EscapeHtml(mesh.name) + ' settings (.msh)</a>'); }
x += "</div>";
@ -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
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -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,