diff --git a/agents/meshcore.js b/agents/meshcore.js index 5f5c60c8..70e86f47 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -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); } diff --git a/package.json b/package.json index 8ceceaf2..c2688378 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.4.7-t", + "version": "0.4.7-u", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default.handlebars b/views/default.handlebars index f07d105a..f15860c3 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -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; } diff --git a/views/xterm.handlebars b/views/xterm.handlebars index 7e4ce0e4..fc1c9156 100644 --- a/views/xterm.handlebars +++ b/views/xterm.handlebars @@ -36,7 +36,7 @@
-
+
@@ -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) {