More xterm improvements, Windows console size set at start.

Ylian Saint-Hilaire committed Jan 24, 2020 at 14:10 UTC 9fa78978ae5e15bc78f89294bb55b750ee24daa1
4 files changed +27 -14
agents/meshcore.js
+13 -9
@@ -1143,19 +1143,24 @@ function createMeshCore(agent) {
1143 // Remote terminal using native pipes
1144 if (process.platform == 'win32') {
1145 try {
1146 + var cols = 80, rows = 25;
1147 + if (this.httprequest.xoptions) {
1148 + if (this.httprequest.xoptions.rows) { rows = this.httprequest.xoptions.rows; }
1149 + if (this.httprequest.xoptions.cols) { cols = this.httprequest.xoptions.cols; }
1150 + }
1151 +
1152 if (!require('win-terminal').PowerShellCapable() && (this.httprequest.protocol == 6 || this.httprequest.protocol == 9)) { throw ('PowerShell is not supported on this version of windows'); }
1153 if ((this.httprequest.protocol == 1) || (this.httprequest.protocol == 6)) {
1154 // Admin Terminal
1155 if (require('win-virtual-terminal').supported) {
1156 // ConPTY PseudoTerminal
1151 - this.httprequest._term = require('win-virtual-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
1157 + this.httprequest._term = require('win-virtual-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](cols, rows);
1158 }
1159 else {
1160 // Legacy Terminal
1155 - this.httprequest._term = require('win-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](80, 25);
1161 + this.httprequest._term = require('win-terminal')[this.httprequest.protocol == 6 ? 'StartPowerShell' : 'Start'](cols, rows);
1162 }
1157 - }
1158 - else {
1163 + } else {
1164 // Logged in user
1165 var userPromise = require('user-sessions').enumerateUsers();
1166 userPromise.that = this;
@@ -1165,11 +1170,10 @@ function createMeshCore(agent) {
1170 var username = u.Active[0].Username;
1171 if (require('win-virtual-terminal').supported) {
1172 // ConPTY PseudoTerminal
1168 - 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] } });
1169 - }
1170 - else {
1173 + 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] } });
1174 + } else {
1175 // Legacy Terminal
1172 - 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] } });
1176 + 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] } });
1177 }
1178 that.httprequest._dispatcher.ws = that;
1179 that.httprequest._dispatcher.on('connection', function (c) {
@@ -1212,7 +1216,7 @@ function createMeshCore(agent) {
1216
1217 var python = fs.existsSync('/usr/bin/python') ? '/usr/bin/python' : false;
1218 var shell = bash || sh;
1215 - var env = { HISTCONTROL: 'ignoreboth', TERM: 'xterm' }; // LINES: '100', COLUMNS: '100'
1219 + var env = { HISTCONTROL: 'ignoreboth', TERM: 'xterm' };
1220 if (this.httprequest.xoptions) {
1221 if (this.httprequest.xoptions.rows) { env.LINES = ('' + this.httprequest.xoptions.rows); }
1222 if (this.httprequest.xoptions.cols) { env.COLUMNS = ('' + this.httprequest.xoptions.cols); }
package.json
+1 -1
@@ -1,6 +1,6 @@
1 {
2 "name": "meshcentral",
3 - "version": "0.4.7-t",
3 + "version": "0.4.7-u",
4 "keywords": [
5 "Remote Management",
6 "Intel AMT",
views/default.handlebars
+1 -1
@@ -5297,7 +5297,7 @@
5297 var url = '/xterm?nodeid=' + encodeURIComponent(nodeid) + '&auto=1';
5298 var node = getNodeFromId(nodeid);
5299 if (node == null) return;
5300 - if ([1, 2, 3, 4, 21, 22].indexOf(node.agent.id) >= 0) { url += '&fixsize=1'; }
5300 + //if ([1, 2, 3, 4, 21, 22].indexOf(node.agent.id) >= 0) { url += '&fixsize=1'; }
5301 window.open(url, 'xterm:' + nodeid);
5302 return false;
5303 }
views/xterm.handlebars
+12 -3
@@ -36,7 +36,7 @@
36 <div id="bigfail" style="display:none;left:calc((100vh / 2))"><b>&#10007;</b></div>
37 <div id="metadatadiv" style="padding:20px;color:lightgrey;text-align:left;display:none"></div>
38 <div id=terminal style="max-height:calc(100vh - 54px);height:calc(100vh - 54px);"></div>
39 - <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>
39 + <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>
40 </div>
41 <div id=deskarea4 class="areaHead">
42 <div class="toright2">
@@ -89,7 +89,10 @@
89 meshserver.Start();
90
91 // When the user resizes the window, re-fit
92 - window.onresize = function () { if (termfit != null) { termfit.fit(); } }
92 + window.onresize = function () {
93 + if (termfit != null) { termfit.fit(); }
94 + if (resizeTimer == null) { resizeTimer = setTimeout(sendResize, 200); }
95 + }
96
97 // Update the terminal status and buttons
98 QH('termstatus', StatusStrs[0]);
@@ -154,7 +157,13 @@
157 }
158 }
159
157 - function tunnelUpdate(data) { if (typeof data == 'string') { term.writeUtf8(data); } else { term.writeUtf8(new Uint8Array(data)); } }
160 + function tunnelUpdate(data) {
161 + if (typeof data == 'string') {
162 + term.writeUtf8(data);
163 + } else {
164 + term.writeUtf8(new Uint8Array(data));
165 + }
166 + }
167
168 // Called when the terminal state changes
169 function onTunnelStateChange(xterminal, state) {