More xterm improvements, Windows console size set at start.

This commit is contained in:
Ylian Saint-Hilaire 2020-01-24 14:10:37 -08:00
parent 58029d3b16
commit 513dc56169
4 changed files with 27 additions and 14 deletions

View File

@ -1143,19 +1143,24 @@ function createMeshCore(agent) {
// Remote terminal using native pipes
if (process.platform == 'win32') {
try {
var cols = 80, rows = 25;
if (this.httprequest.xoptions) {
if (this.httprequest.xoptions.rows) { rows = this.httprequest.xoptions.rows; }
if (this.httprequest.xoptions.cols) { cols = this.httprequest.xoptions.cols; }
}
if (!require('win-terminal').PowerShellCapable() && (this.httprequest.protocol == 6 || this.httprequest.protocol == 9)) { throw ('PowerShell is not supported on this version of windows'); }
if ((this.httprequest.protocol == 1) || (this.httprequest.protocol == 6)) {
// Admin Terminal
if (require('win-virtual-terminal').supported) {
// ConPTY PseudoTerminal
this.httprequest._term = require('win-virtual-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
this.httprequest._term = require('win-virtual-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](cols, rows);
}
else {
// Legacy Terminal
this.httprequest._term = require('win-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
this.httprequest._term = require('win-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](cols, rows);
}
}
else {
} else {
// Logged in user
var userPromise = require('user-sessions').enumerateUsers();
userPromise.that = this;
@ -1165,11 +1170,10 @@ function createMeshCore(agent) {
var username = u.Active[0].Username;
if (require('win-virtual-terminal').supported) {
// ConPTY PseudoTerminal
that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-virtual-terminal', script: getJSModule('win-virtual-terminal') }], launch: { module: 'win-virtual-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
}
else {
that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-virtual-terminal', script: getJSModule('win-virtual-terminal') }], launch: { module: 'win-virtual-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [cols, rows] } });
} else {
// Legacy Terminal
that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-terminal', script: getJSModule('win-terminal') }], launch: { module: 'win-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
that.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-terminal', script: getJSModule('win-terminal') }], launch: { module: 'win-terminal', method: (that.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [cols, rows] } });
}
that.httprequest._dispatcher.ws = that;
that.httprequest._dispatcher.on('connection', function (c) {
@ -1212,7 +1216,7 @@ function createMeshCore(agent) {
var python = fs.existsSync('/usr/bin/python') ? '/usr/bin/python' : false;
var shell = bash || sh;
var env = { HISTCONTROL: 'ignoreboth', TERM: 'xterm' }; // LINES: '100', COLUMNS: '100'
var env = { HISTCONTROL: 'ignoreboth', TERM: 'xterm' };
if (this.httprequest.xoptions) {
if (this.httprequest.xoptions.rows) { env.LINES = ('' + this.httprequest.xoptions.rows); }
if (this.httprequest.xoptions.cols) { env.COLUMNS = ('' + this.httprequest.xoptions.cols); }

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.4.7-t",
"version": "0.4.7-u",
"keywords": [
"Remote Management",
"Intel AMT",

View File

@ -5297,7 +5297,7 @@
var url = '/xterm?nodeid=' + encodeURIComponent(nodeid) + '&auto=1';
var node = getNodeFromId(nodeid);
if (node == null) return;
if ([1, 2, 3, 4, 21, 22].indexOf(node.agent.id) >= 0) { url += '&fixsize=1'; }
//if ([1, 2, 3, 4, 21, 22].indexOf(node.agent.id) >= 0) { url += '&fixsize=1'; }
window.open(url, 'xterm:' + nodeid);
return false;
}

View File

@ -36,7 +36,7 @@
<div id="bigfail" style="display:none;left:calc((100vh / 2))"><b>&#10007;</b></div>
<div id="metadatadiv" style="padding:20px;color:lightgrey;text-align:left;display:none"></div>
<div id=terminal style="max-height:calc(100vh - 54px);height:calc(100vh - 54px);"></div>
<div id=TermConsoleMsg style="cursor:pointer;z-index:10;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=clearConsoleMsg()></div>
<div id=TermConsoleMsg style="display:none;cursor:pointer;z-index:10;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=clearConsoleMsg()></div>
</div>
<div id=deskarea4 class="areaHead">
<div class="toright2">
@ -89,7 +89,10 @@
meshserver.Start();
// When the user resizes the window, re-fit
window.onresize = function () { if (termfit != null) { termfit.fit(); } }
window.onresize = function () {
if (termfit != null) { termfit.fit(); }
if (resizeTimer == null) { resizeTimer = setTimeout(sendResize, 200); }
}
// Update the terminal status and buttons
QH('termstatus', StatusStrs[0]);
@ -154,7 +157,13 @@
}
}
function tunnelUpdate(data) { if (typeof data == 'string') { term.writeUtf8(data); } else { term.writeUtf8(new Uint8Array(data)); } }
function tunnelUpdate(data) {
if (typeof data == 'string') {
term.writeUtf8(data);
} else {
term.writeUtf8(new Uint8Array(data));
}
}
// Called when the terminal state changes
function onTunnelStateChange(xterminal, state) {