Terminal improvements.

This commit is contained in:
Ylian Saint-Hilaire 2020-02-10 12:22:01 -08:00
parent d1ddf2aa8f
commit e4520efd0e
9 changed files with 77 additions and 86 deletions

View File

@ -591,10 +591,11 @@ function run(argv) {
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
if ((settings.hostname == null) || (typeof settings.hostname != 'string') || (settings.hostname == '')) { settings.hostname = '127.0.0.1'; } if ((settings.hostname == null) || (typeof settings.hostname != 'string') || (settings.hostname == '')) { settings.hostname = '127.0.0.1'; }
if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; } if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
if ((settings.script == null) || (typeof settings.script != 'string') || (settings.script == '')) { if (mescriptJSON != '') { settings.scriptjson = mescriptJSON; } else { console.log('No or invalid \"script\" file specified, use --script [filename].'); exit(1); return; } } //if ((settings.script == null) || (typeof settings.script != 'string') || (settings.script == '')) { if (mescriptJSON != '') { settings.scriptjson = mescriptJSON; } else { console.log('No or invalid \"script\" file specified, use --script [filename].'); exit(1); return; } }
if ((settings.script == null) || (typeof settings.script != 'string') || (settings.script == '')) { console.log('No or invalid \"script\" file specified, use --script [filename].'); exit(1); return; }
startMeScript(); startMeScript();
} else if (settings.action == 'amtuuid') { } else if (settings.action == 'amtuuid') {
// Start running // Start running
if (settings.hostname != null) { if (settings.hostname != null) {
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; } if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; } if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }

View File

@ -301,10 +301,8 @@ module.exports.CertificateOperations = function (parent) {
var cert = obj.pki.createCertificate(); var cert = obj.pki.createCertificate();
cert.publicKey = keys.publicKey; cert.publicKey = keys.publicKey;
cert.serialNumber = String(Math.floor((Math.random() * 100000) + 1)); cert.serialNumber = String(Math.floor((Math.random() * 100000) + 1));
cert.validity.notBefore = new Date(); cert.validity.notBefore = new Date(2018, 0, 1);
cert.validity.notBefore.setFullYear(cert.validity.notBefore.getFullYear() - 1); // Create a certificate that is valid one year before, to make sure out-of-sync clocks don"t reject this cert. cert.validity.notAfter = new Date(2049, 11, 31);
cert.validity.notAfter = new Date();
cert.validity.notAfter.setFullYear(cert.validity.notAfter.getFullYear() + 30);
if (addThumbPrintToName === true) { commonName += '-' + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); } if (addThumbPrintToName === true) { commonName += '-' + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); }
if (country == null) { country = "unknown"; } if (country == null) { country = "unknown"; }
if (organization == null) { organization = "unknown"; } if (organization == null) { organization = "unknown"; }
@ -325,10 +323,8 @@ module.exports.CertificateOperations = function (parent) {
var cert = obj.pki.createCertificate(); var cert = obj.pki.createCertificate();
cert.publicKey = keys.publicKey; cert.publicKey = keys.publicKey;
cert.serialNumber = String(Math.floor((Math.random() * 100000) + 1)); cert.serialNumber = String(Math.floor((Math.random() * 100000) + 1));
cert.validity.notBefore = new Date(); cert.validity.notBefore = new Date(2018, 0, 1);
cert.validity.notBefore.setFullYear(cert.validity.notAfter.getFullYear() - 1); // Create a certificate that is valid one year before, to make sure out-of-sync clocks don"t reject this cert. cert.validity.notAfter = new Date(2049, 11, 31);
cert.validity.notAfter = new Date();
cert.validity.notAfter.setFullYear(cert.validity.notAfter.getFullYear() + 30);
if (addThumbPrintToName === true) { commonName += "-" + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); } if (addThumbPrintToName === true) { commonName += "-" + obj.pki.getPublicKeyFingerprint(cert.publicKey, { encoding: 'hex' }).substring(0, 6); }
var attrs = [{ name: 'commonName', value: commonName }]; var attrs = [{ name: 'commonName', value: commonName }];
if (country != null) { attrs.push({ name: 'countryName', value: country }); } if (country != null) { attrs.push({ name: 'countryName', value: country }); }

View File

@ -644,8 +644,8 @@ var CreateAmtRemoteTerminal = function (divid, options) {
} }
} }
obj.TermSendKeys = function (keys) { if (obj.debugmode == 2) { console.log("TSend(" + keys.length + "): " + rstr2hex(keys), keys); } obj.parent.sendText(keys); } obj.TermSendKeys = function (keys) { if (obj.debugmode == 2) { console.log("TSend(" + keys.length + "): " + rstr2hex(keys), keys); } obj.parent.send(keys); }
obj.TermSendKey = function (key) { if (obj.debugmode == 2) { console.log("TSend(1): " + rstr2hex(String.fromCharCode(key)), key); } obj.parent.sendText(String.fromCharCode(key)); } obj.TermSendKey = function (key) { if (obj.debugmode == 2) { console.log("TSend(1): " + rstr2hex(String.fromCharCode(key)), key); } obj.parent.send(String.fromCharCode(key)); }
function _TermMoveUp(linecount) { function _TermMoveUp(linecount) {
var x, y; var x, y;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2972,8 +2972,7 @@
"pt": "Auto", "pt": "Auto",
"ru": "Автоматически", "ru": "Автоматически",
"xloc": [ "xloc": [
"default.handlebars->container->column_l->p1->devListToolbarSpan->1->0->kvmListToolbar->5", "default.handlebars->container->column_l->p1->devListToolbarSpan->1->0->kvmListToolbar->5"
"default.handlebars->container->column_l->p12->termTable->1->1->6->1->1->terminalSizeDropDown->termSizeList->2"
] ]
}, },
{ {

View File

@ -629,7 +629,7 @@
<input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()" /> <input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()" />
</span> </span>
<span id="terminalSizeDropDown" style="display:none"> <span id="terminalSizeDropDown" style="display:none">
<select id="termSizeList" onkeypress="return false"><option value="1">80x25</option><option value="2">100x30</option><option value="3" selected>Auto</option></select> <select id="termSizeList" onkeypress="return false"><option value="1">80x25</option><option value="2">100x30</option></select>
</span> </span>
<span id="specialKeyDropDown"> <span id="specialKeyDropDown">
<select id="specialkeylist" onkeypress="return false"></select> <select id="specialkeylist" onkeypress="return false"></select>
@ -1333,14 +1333,6 @@
if (('{{{lang}}}' != 'en') && ('{{{lang}}}' != '')) { QC('body').add('nonenglish'); } if (('{{{lang}}}' != 'en') && ('{{{lang}}}' != '')) { QC('body').add('nonenglish'); }
var elements = document.getElementsByClassName('topbar_td'); var elements = document.getElementsByClassName('topbar_td');
for (var i in elements) { if (elements[i].innerHTML) { elements[i].innerHTML = elements[i].innerHTML.split(' ').join('&nbsp;'); } } for (var i in elements) { if (elements[i].innerHTML) { elements[i].innerHTML = elements[i].innerHTML.split(' ').join('&nbsp;'); } }
// Display extra buttons on legacy terminal
if (args.xterm === 0) {
QV('termarea3xdiv', false);
QV('bsbutton', true);
QV('pastebutton', true);
QV('terminalSizeDropDown', true);
}
} }
function adjustPanels() { function adjustPanels() {
@ -1398,12 +1390,13 @@
QS('p15agentConsole')['max-height'] = 'calc(100vh - ' + (84 + xh + xh2) + 'px)'; QS('p15agentConsole')['max-height'] = 'calc(100vh - ' + (84 + xh + xh2) + 'px)';
QS('p15agentConsoleText')['height'] = 'calc(100vh - ' + (81 + xh + xh2) + 'px)'; QS('p15agentConsoleText')['height'] = 'calc(100vh - ' + (81 + xh + xh2) + 'px)';
QS('p15agentConsoleText')['max-height'] = 'calc(100vh - ' + (81 + xh + xh2) + 'px)'; QS('p15agentConsoleText')['max-height'] = 'calc(100vh - ' + (81 + xh + xh2) + 'px)';
var xtermActive = !((args.xterm === 0) || ((terminal != null) && (xterm == null)));
if (fullscreen) { if (fullscreen) {
QS('deskarea3x')['height'] = null; QS('deskarea3x')['height'] = null;
QS('deskarea3x')['max-height'] = null; QS('deskarea3x')['max-height'] = null;
QS('p14iframe')['height'] = null; QS('p14iframe')['height'] = null;
QS('p14iframe')['max-height'] = null; QS('p14iframe')['max-height'] = null;
if (args.xterm !== 0) { if (xtermActive) {
QS('termarea3x')['height'] = 'calc(100vh - 55px)'; QS('termarea3x')['height'] = 'calc(100vh - 55px)';
QS('termarea3xdiv')['height'] = 'calc(100vh - 55px)'; QS('termarea3xdiv')['height'] = 'calc(100vh - 55px)';
QS('termarea3x')['max-width'] = 'calc(1px)'; QS('termarea3x')['max-width'] = 'calc(1px)';
@ -1413,7 +1406,7 @@
QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)'; QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)';
QS('p14iframe')['height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)'; QS('p14iframe')['height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)';
QS('p14iframe')['max-height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)'; QS('p14iframe')['max-height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)';
if (args.xterm !== 0) { if (xtermActive) {
QS('termarea3x')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)'; QS('termarea3x')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)';
QS('termarea3xdiv')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)'; QS('termarea3xdiv')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)';
QS('termarea3x')['max-width'] = 'calc(1px)'; QS('termarea3x')['max-width'] = 'calc(1px)';
@ -5853,12 +5846,13 @@
var fullscreen = false; var fullscreen = false;
var browserfullscreen = false; var browserfullscreen = false;
function deskToggleFull(e) { function deskToggleFull(e) {
var xtermActive = !((args.xterm === 0) || ((terminal != null) && (xterm == null)));
fullscreen = !fullscreen; fullscreen = !fullscreen;
if (fullscreen) { if (fullscreen) {
QC('body').add('fulldesk'); QC('body').add('fulldesk');
QS('deskarea3x')['height'] = '100%'; QS('deskarea3x')['height'] = '100%';
QS('deskarea3x')['max-height'] = '100%'; QS('deskarea3x')['max-height'] = '100%';
if (args.xterm !== 0) { if (xtermActive) {
// XTerm terminal // XTerm terminal
QS('termTable')['position'] = 'absolute'; QS('termTable')['position'] = 'absolute';
QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = '0'; QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = '0';
@ -5880,7 +5874,7 @@
var xh = (((hide & 1) ? 0 : 66) + ((hide & 2) ? 0 : 24) + ((hide & 4) ? 0 : 45) + ((hide & 8) ? 0 : 60)); // 0 to 195 var xh = (((hide & 1) ? 0 : 66) + ((hide & 2) ? 0 : 24) + ((hide & 4) ? 0 : 45) + ((hide & 8) ? 0 : 60)); // 0 to 195
QS('deskarea3x')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)'; QS('deskarea3x')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)'; QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
if (args.xterm !== 0) { if (xtermActive) {
// XTerm terminal // XTerm terminal
QS('termTable')['position'] = null; QS('termTable')['position'] = null;
QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = null; QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = null;
@ -6327,6 +6321,7 @@
QV('disconnectbutton2span', (termState == true)); QV('disconnectbutton2span', (termState == true));
QV('connectbutton2span', (termState == false) && (mesh.mtype == 2) && (currentNode.agent.caps & 2)); QV('connectbutton2span', (termState == false) && (mesh.mtype == 2) && (currentNode.agent.caps & 2));
QV('connectbutton2hspan', (termState == false) && ((terminalNode.intelamt != null) && (mesh.mtype == 1 || terminalNode.intelamt.state == 2) && ((terminalNode.intelamt.ver != null) || (mesh.mtype == 1)))); QV('connectbutton2hspan', (termState == false) && ((terminalNode.intelamt != null) && (mesh.mtype == 1 || terminalNode.intelamt.state == 2) && ((terminalNode.intelamt.ver != null) || (mesh.mtype == 1))));
QV('terminalSizeDropDown', (termState == false) && ((terminalNode.intelamt != null) && (mesh.mtype == 1 || terminalNode.intelamt.state == 2) && ((terminalNode.intelamt.ver != null) || (mesh.mtype == 1))));
// Enable buttons // Enable buttons
var online = ((terminalNode.conn & 1) != 0); // If Agent (1) connected, enable Terminal var online = ((terminalNode.conn & 1) != 0); // If Agent (1) connected, enable Terminal
@ -6350,6 +6345,15 @@
Q('id_tfxkeysbutton').value = fxEmulations[terminal.m.fxEmulation]; Q('id_tfxkeysbutton').value = fxEmulations[terminal.m.fxEmulation];
Q('id_tcrbutton').value = (terminal.m.lineFeed == '\r\n')?"CR+LF":"LF"; Q('id_tcrbutton').value = (terminal.m.lineFeed == '\r\n')?"CR+LF":"LF";
} }
// Display extra buttons on legacy terminal
var xtermActive = !((args.xterm === 0) || ((terminal != null) && (xterm == null)));
QV('termarea3xdiv', xtermActive);
QV('Term', !xtermActive);
QV('bsbutton', !xtermActive);
QV('pastebutton', !xtermActive);
QV('devListToolbarViewIcons2', xtermActive);
QE('termSizeList', terminal == null);
} }
// Called when the terminal state changes // Called when the terminal state changes
@ -6362,7 +6366,6 @@
switch (state) { switch (state) {
case 0: case 0:
// Disconnected, clear the terminal // Disconnected, clear the terminal
QE('termSizeList', true);
QH('termtitle', ''); QH('termtitle', '');
QV('termRecordIcon', false); QV('termRecordIcon', false);
if (xterm == null) { if (xterm == null) {
@ -6375,14 +6378,12 @@
if (terminal != null) { terminal.Stop(); terminal = null; } if (terminal != null) { terminal.Stop(); terminal = null; }
break; break;
case 3: case 3:
QE('termSizeList', false);
if (xterminal && (xterminal.serverIsRecording == true)) { QV('termRecordIcon', true); } if (xterminal && (xterminal.serverIsRecording == true)) { QV('termRecordIcon', true); }
terminal.startTime = new Date(); terminal.startTime = new Date();
if (updateSessionTimer == null) { updateSessionTimer = setInterval(updateSessionTime, 1000); } if (updateSessionTimer == null) { updateSessionTimer = setInterval(updateSessionTime, 1000); }
if (xterm != null) { xterm.focus(); } if (xterm != null) { xterm.focus(); }
break; break;
default: default:
QE('termSizeList', false);
//console.log('Unhandled onTerminalStateChange state', state); //console.log('Unhandled onTerminalStateChange state', state);
break; break;
} }
@ -6401,6 +6402,9 @@
obj.xxStateChange = function (state) { } obj.xxStateChange = function (state) { }
obj.ProcessBinaryData = function (data) { obj.onTunnelUpdate(data); } obj.ProcessBinaryData = function (data) { obj.onTunnelUpdate(data); }
obj.ProcessData = function (data) { obj.onTunnelUpdate(data); } obj.ProcessData = function (data) { obj.onTunnelUpdate(data); }
obj.terminalEmulation = 1;
obj.fxEmulation = 0;
obj.lineFeed = '\r\n';
return obj; return obj;
} }
@ -6409,7 +6413,7 @@
// Send the new terminal size to the agent // Send the new terminal size to the agent
function xTermSendResize() { function xTermSendResize() {
xtermResizeTimer = null; xtermResizeTimer = null;
if ((xterm != null) && (terminal != null)) { terminal.sendCtrlMsg(JSON.stringify({ ctrlChannel: '102938', type: 'termsize', cols: xterm.cols, rows: xterm.rows })); } if ((xterm != null) && (terminal != null) && (terminal.sendCtrlMsg != null)) { terminal.sendCtrlMsg(JSON.stringify({ ctrlChannel: '102938', type: 'termsize', cols: xterm.cols, rows: xterm.rows })); }
} }
function connectTerminal(e, contype, options) { function connectTerminal(e, contype, options) {
@ -6419,51 +6423,31 @@
// Setup the Intel AMT terminal // Setup the Intel AMT terminal
if ((terminalNode.intelamt.user == null) || (terminalNode.intelamt.user == '')) { editDeviceAmtSettings(terminalNode._id, connectTerminal, 2); return; } if ((terminalNode.intelamt.user == null) || (terminalNode.intelamt.user == '')) { editDeviceAmtSettings(terminalNode._id, connectTerminal, 2); return; }
var termoptions = {}; var termoptions = {};
if (Q('termSizeList').value == 2) { termoptions.width = 100; termoptions.height = 30; } if (Q('termSizeList').value == 1) { termoptions.cols = 80; termoptions.rows = 25; }
else if (Q('termSizeList').value == 2) { termoptions.cols = 100; termoptions.rows = 30; }
if (args.xterm !== 0) { // Get out of full screen
// Setup a mesh agent xterm terminal if (fullscreen) { deskToggleFull(); }
// Setup the terminal with auto-fit
if (xterm != null) { xterm.dispose(); }
xtermfit = new FitAddon.FitAddon();
xterm = new Terminal();
if (xtermfit) { xterm.loadAddon(xtermfit); }
xterm.open(Q('termarea3xdiv')); // termarea3x
xterm.onData(function (data) { if (terminal != null) { terminal.send(data); } })
if (xtermfit) { xtermfit.fit(); }
xterm.onTitleChange(function (title) { QH('termtitle', ' - ' + EscapeHtml(title)); });
xterm.onResize(function (size) {
// Despam resize
if (xtermResizeTimer) clearTimeout(xtermResizeTimer);
xtermResizeTimer = setTimeout(xTermSendResize, 200);
});
// Setup a terminal tunnel to the agent // Setup legacy terminal
terminal = CreateAmtRedirect(CreateRemoteTunnel(tunnelUpdate, termoptions), authCookie); QV('termarea3xdiv', false);
terminal.debugmode = debugmode; QV('Term', true);
terminal.m.debugmode = debugmode; terminal = CreateAmtRedirect(CreateAmtRemoteTerminal('Term', termoptions), authCookie);
terminal.Start(terminalNode._id, 16994, '*', '*', 0); terminal.debugmode = debugmode;
terminal.onStateChanged = onTerminalStateChange; terminal.m.debugmode = debugmode;
terminal.contype = 2; terminal.m.onTitleChange = function (sender, title) { QH('termtitle', ' - ' + EscapeHtml(title)); }
} else { terminal.onStateChanged = onTerminalStateChange;
// Setup a mesh agent legacy terminal terminal.Start(terminalNode._id, 16994, '*', '*', 0);
terminal = CreateAmtRedirect(CreateAmtRemoteTerminal('Term', termoptions), authCookie); terminal.contype = 2;
terminal.debugmode = debugmode; Q('id_ttypebutton').value = terminalEmulations[terminal.m.terminalEmulation];
terminal.m.debugmode = debugmode;
terminal.m.onTitleChange = function (sender, title) { QH('termtitle', ' - ' + EscapeHtml(title)); }
terminal.onStateChanged = onTerminalStateChange;
terminal.Start(terminalNode._id, 16994, '*', '*', 0);
terminal.contype = 2;
Q('id_ttypebutton').value = terminalEmulations[terminal.m.terminalEmulation];
}
} else { } else {
// Terminal setup // Terminal setup
var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number'))?options.protocol:1 }; var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number'))?options.protocol:1 };
if (options && options.requireLogin) { termoptions.requireLogin = true; } if (options && options.requireLogin) { termoptions.requireLogin = true; }
if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) { if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) {
if (Q('termSizeList').value == 2) { termoptions.cols = 100; termoptions.rows = 30; termoptions.xterm = true; } if (Q('termSizeList').value == 1) { termoptions.cols = 80; termoptions.rows = 25; termoptions.xterm = true; }
if (Q('termSizeList').value == 3) { else if (Q('termSizeList').value == 2) { termoptions.cols = 100; termoptions.rows = 30; termoptions.xterm = true; }
else if (Q('termSizeList').value == 3) {
// TODO: Try to improve terminal auto-size. // TODO: Try to improve terminal auto-size.
termoptions.cols = Math.floor((Q('column_l').clientWidth - 60) / 10); termoptions.cols = Math.floor((Q('column_l').clientWidth - 60) / 10);
termoptions.rows = Math.floor((Q('column_l').clientHeight - 120) / 20); termoptions.rows = Math.floor((Q('column_l').clientHeight - 120) / 20);
@ -6482,7 +6466,9 @@
if (args.xterm !== 0) { if (args.xterm !== 0) {
// Setup a mesh agent xterm terminal // Setup a mesh agent xterm terminal
QV('termarea3xdiv', true);
QV('Term', false);
// Setup the terminal with auto-fit // Setup the terminal with auto-fit
if (xterm != null) { xterm.dispose(); } if (xterm != null) { xterm.dispose(); }
xtermfit = new FitAddon.FitAddon(); xtermfit = new FitAddon.FitAddon();
@ -6517,6 +6503,9 @@
} }
}; };
} else { } else {
QV('termarea3xdiv', false);
QV('Term', true);
// Setup a mesh agent legacy terminal // Setup a mesh agent legacy terminal
terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term', termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl); terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term', termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
terminal.options = termoptions; terminal.options = termoptions;
@ -6575,7 +6564,13 @@
function termSendKey(key, id) { function termSendKey(key, id) {
if (!terminal || xxdialogMode) return; if (!terminal || xxdialogMode) return;
if (xterm != null) { if (xterm != null) {
terminal.sendText(String.fromCharCode(key)); if (terminal.sendText) {
// MeshAgent
terminal.sendText(String.fromCharCode(key));
} else {
// CIRA
terminal.send(String.fromCharCode(key));
}
xterm.focus(); xterm.focus();
} else if (terminal != null) { } else if (terminal != null) {
terminal.m.TermSendKey(key); terminal.m.TermSendKey(key);

View File

@ -1843,6 +1843,11 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
// Server name is an IPv4 address // Server name is an IPv4 address
obj.fs.readFile(obj.parent.path.join(obj.parent.webPublicPath, 'scripts/cira_setup_script_ip.mescript'), 'utf8', function (err, data) { obj.fs.readFile(obj.parent.path.join(obj.parent.webPublicPath, 'scripts/cira_setup_script_ip.mescript'), 'utf8', function (err, data) {
if (err != null) { func(null); return; } if (err != null) { func(null); return; }
// Randomize the environement detection
var randomDnsName;
do { randomDnsName = getRandomLowerCase(14); } while (randomDnsName == 'aabbccddeeffgg');
while (data.indexOf('aabbccddeeffgg') >= 0) { data = data.replace('aabbccddeeffgg', randomDnsName); }
var scriptFile = JSON.parse(data); var scriptFile = JSON.parse(data);
// Change a few things in the script // Change a few things in the script
@ -1862,19 +1867,18 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
scriptFile.mescript = Buffer.from(scriptEngine.script_compile(runscript), 'binary').toString('base64'); scriptFile.mescript = Buffer.from(scriptEngine.script_compile(runscript), 'binary').toString('base64');
scriptFile.scriptText = runscript; scriptFile.scriptText = runscript;
// Randomize the environement detection
var randomDnsName;
do { randomDnsName = getRandomLowerCase(14); } while (randomDnsName == 'aabbccddeeffgg');
var text = JSON.stringify(scriptFile, null, ' ');
for (var i = 0; i < 5; i++) { text = text.replace('aabbccddeeffgg', randomDnsName); }
// Send the script // Send the script
func(Buffer.from(text)); func(Buffer.from(JSON.stringify(scriptFile, null, ' ')));
}); });
} else { } else {
// Server name is a hostname // Server name is a hostname
obj.fs.readFile(obj.parent.path.join(obj.parent.webPublicPath, 'scripts/cira_setup_script_dns.mescript'), 'utf8', function (err, data) { obj.fs.readFile(obj.parent.path.join(obj.parent.webPublicPath, 'scripts/cira_setup_script_dns.mescript'), 'utf8', function (err, data) {
if (err != null) { res.sendStatus(404); return; } if (err != null) { res.sendStatus(404); return; }
// Randomize the environement detection
var randomDnsName;
do { randomDnsName = getRandomLowerCase(14); } while (randomDnsName == 'aabbccddeeffgg');
while (data.indexOf('aabbccddeeffgg') >= 0) { data = data.replace('aabbccddeeffgg', randomDnsName); }
var scriptFile = JSON.parse(data); var scriptFile = JSON.parse(data);
// Change a few things in the script // Change a few things in the script
@ -1893,14 +1897,8 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
scriptFile.mescript = Buffer.from(scriptEngine.script_compile(runscript), 'binary').toString('base64'); scriptFile.mescript = Buffer.from(scriptEngine.script_compile(runscript), 'binary').toString('base64');
scriptFile.scriptText = runscript; scriptFile.scriptText = runscript;
// Randomize the environement detection
var randomDnsName;
do { randomDnsName = getRandomLowerCase(14); } while (randomDnsName == 'aabbccddeeffgg');
var text = JSON.stringify(scriptFile, null, ' ');
for (var i = 0; i < 5; i++) { text = text.replace('aabbccddeeffgg', randomDnsName); }
// Send the script // Send the script
func(Buffer.from(text)); func(Buffer.from(JSON.stringify(scriptFile, null, ' ')));
}); });
} }
} }