mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-14 08:14:59 -05:00
Merge branch 'master' of https://github.com/Ylianst/MeshCentral
This commit is contained in:
commit
b5c5d49f2a
@ -1059,41 +1059,61 @@ function createMeshCore(agent)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.end = function () {
|
this.end = function ()
|
||||||
if (process.platform == "win32") {
|
{
|
||||||
|
if (process.platform == "win32")
|
||||||
|
{
|
||||||
// Unpipe the web socket
|
// Unpipe the web socket
|
||||||
this.unpipe(this.httprequest._term);
|
this.unpipe(this.httprequest._term);
|
||||||
this.httprequest._term.unpipe(this);
|
if (this.httprequest._term) { this.httprequest._term.unpipe(this); }
|
||||||
|
|
||||||
// Unpipe the WebRTC channel if needed (This will also be done when the WebRTC channel ends).
|
// Unpipe the WebRTC channel if needed (This will also be done when the WebRTC channel ends).
|
||||||
if (this.rtcchannel) {
|
if (this.rtcchannel)
|
||||||
|
{
|
||||||
this.rtcchannel.unpipe(this.httprequest._term);
|
this.rtcchannel.unpipe(this.httprequest._term);
|
||||||
this.httprequest._term.unpipe(this.rtcchannel);
|
if (this.httprequest._term) { this.httprequest._term.unpipe(this.rtcchannel); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up
|
// Clean up
|
||||||
this.httprequest._term.end();
|
if (this.httprequest._term) { this.httprequest._term.end(); }
|
||||||
this.httprequest._term = null;
|
this.httprequest._term = null;
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
// TODO!!
|
// TODO!!
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remote terminal using native pipes
|
// Remote terminal using native pipes
|
||||||
if (process.platform == "win32") {
|
if (process.platform == "win32")
|
||||||
if ((this.httprequest.protocol == 6) && (require('win-terminal').PowerShellCapable() == true)) {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ((this.httprequest.protocol == 6) && (require('win-terminal').PowerShellCapable() == true))
|
||||||
|
{
|
||||||
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25);
|
this.httprequest._term = require('win-terminal').StartPowerShell(80, 25);
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
this.httprequest._term = require('win-terminal').Start(80, 25);
|
this.httprequest._term = require('win-terminal').Start(80, 25);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
|
this.httprequest._term.pipe(this, { dataTypeSkip: 1 });
|
||||||
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
|
this.pipe(this.httprequest._term, { dataTypeSkip: 1, end: false });
|
||||||
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
|
this.prependListener('end', function () { this.httprequest._term.end(function () { console.log('Terminal was closed'); }); });
|
||||||
} else {
|
} else
|
||||||
if (fs.existsSync("/bin/bash")) {
|
{
|
||||||
|
if (fs.existsSync("/bin/bash"))
|
||||||
|
{
|
||||||
this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
|
this.httprequest.process = childProcess.execFile("/bin/bash", ["bash", "-i"], { type: childProcess.SpawnTypes.TERM });
|
||||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
|
if (process.platform == 'linux') { this.httprequest.process.stdin.write("alias ls='ls --color=auto'\nclear\n"); }
|
||||||
} else {
|
} else
|
||||||
|
{
|
||||||
this.httprequest.process = childProcess.execFile("/bin/sh", ["sh"], { type: childProcess.SpawnTypes.TERM });
|
this.httprequest.process = childProcess.execFile("/bin/sh", ["sh"], { type: childProcess.SpawnTypes.TERM });
|
||||||
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
|
if (process.platform == 'linux') { this.httprequest.process.stdin.write("stty erase ^H\nalias ls='ls --color=auto'\nPS1='\\u@\\h:\\w\\$ '\nclear\n"); }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user