Added commented out code for ConPTY support

This commit is contained in:
Bryan Roe 2019-11-26 10:36:57 -08:00
parent fe81928cbb
commit 2243c3b34f
1 changed files with 33 additions and 10 deletions

View File

@ -1081,14 +1081,33 @@ function createMeshCore(agent) {
};
// Remote terminal using native pipes
if (process.platform == "win32") {
try {
if (((this.httprequest.protocol == 6) || (this.httprequest.protocol == 9)) && (require('win-terminal').PowerShellCapable() == true)) {
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 9
} else {
this.httprequest._term = require('win-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 8
if (process.platform == "win32")
{
try
{
if (((this.httprequest.protocol == 6) || (this.httprequest.protocol == 8)) && (require('win-terminal').PowerShellCapable() == true))
{
//if (require('win-virtual-terminal').supported)
//{
// this.httprequest._term = require('win-virtual-terminal').StartPowerShell(80, 25);
//}
//else
//{
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25); // TODO: Start as logged in used when protocol is 8
//}
} else
{
//if (require('win-virtual-terminal').supported)
//{
// this.httprequest._term = require('win-virtual-terminal').Start(80, 25);
//}
//else
//{
this.httprequest._term = require('win-terminal').Start(80, 25); // TODO: Start as logged in used when protocol is 7
//}
}
} catch (e) {
} catch (e)
{
MeshServerLog('Failed to start remote terminal session, ' + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
this.end();
@ -1097,8 +1116,11 @@ function createMeshCore(agent) {
this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); });
} else {
try {
}
else
{
try
{
if (fs.existsSync('/usr/bin/python') && fs.existsSync('/bin/bash')) {
this.httprequest.process = childProcess.execFile('/usr/bin/python', ['python', '-c', "import pty; pty.spawn([\"/bin/bash\"])"], { uid: (this.httprequest.protocol == 8) ? require('user-sessions').consoleUid() : null }); // Start as active user
if (process.platform == 'linux') { this.httprequest.process.stdin.write("export TERM='xterm'\nalias ls='ls --color=auto'\nclear\n"); }
@ -1109,7 +1131,8 @@ function createMeshCore(agent) {
this.httprequest.process = childProcess.execFile('/bin/sh', ['sh'], { type: childProcess.SpawnTypes.TERM, uid: (this.httprequest.protocol == 8)?require('user-sessions').consoleUid():null }); // Start as active user
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
}
} catch (e) {
} catch (e)
{
MeshServerLog("Failed to start remote terminal session, " + e.toString() + ' (' + this.httprequest.remoteaddr + ')', this.httprequest);
this.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: e.toString() }));
this.end();