updated tsid selection

This commit is contained in:
Bryan Roe 2019-12-16 15:07:20 -08:00
parent 42ecc12fe5
commit e82f9dd912

View File

@ -1151,29 +1151,38 @@ function createMeshCore(agent) {
else else
{ {
// Logged in user // Logged in user
var username = require('user-sessions').getUsername(require('user-sessions').consoleUid()); var userPromise = require('user-sessions').enumerateUsers();
if (require('win-virtual-terminal').supported) userPromise.that = this;
userPromise.then(function (u)
{ {
// ConPTY PseudoTerminal var that = this.that;
this.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-virtual-terminal', script: getJSModule('win-virtual-terminal') }], launch: { module: 'win-virtual-terminal', method: (this.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } }); if (u.Active.length > 0)
}
else
{
// Legacy Terminal
this.httprequest._dispatcher = require('win-dispatcher').dispatch({ user: username, modules: [{ name: 'win-terminal', script: getJSModule('win-terminal') }], launch: { module: 'win-terminal', method: (this.httprequest.protocol == 9 ? 'StartPowerShell' : 'Start'), args: [80, 25] } });
}
this.httprequest._dispatcher.ws = this;
this.httprequest._dispatcher.on('connection', function (c)
{
console.log('client connected');
this.ws._term = c;
c.pipe(this.ws, { dataTypeSkip: 1 });
this.ws.pipe(c, { dataTypeSkip: 1, end: false });
this.ws.prependListener('end', function ()
{ {
if (this.httprequest._term) { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); } 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
{
// 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.ws = that;
that.httprequest._dispatcher.on('connection', function (c)
{
console.log('client connected');
this.ws._term = c;
c.pipe(this.ws, { dataTypeSkip: 1 });
this.ws.pipe(c, { dataTypeSkip: 1, end: false });
this.ws.prependListener('end', function ()
{
if (this.httprequest._term) { this.httprequest._term.end(function () { console.log("Terminal was closed"); }); }
});
});
}
});
} }
} catch (e) } catch (e)
{ {
@ -1271,9 +1280,7 @@ function createMeshCore(agent) {
// Look for a TSID // Look for a TSID
var tsid = null; var tsid = null;
if ((this.httprequest.xoptions != null) && (typeof this.httprequest.xoptions.tsid == 'number')) { tsid = this.httprequest.xoptions.tsid; } if ((this.httprequest.xoptions != null) && (typeof this.httprequest.xoptions.tsid == 'number')) { tsid = this.httprequest.xoptions.tsid; }
//if (require('MeshAgent')._tsid != null) { tsid = require('MeshAgent')._tsid; } require('MeshAgent')._tsid = tsid;
//sendConsoleText('tsid: ' + tsid);
//require('MeshAgent')._tsid = tsid;
// Remote desktop using native pipes // Remote desktop using native pipes
this.httprequest.desktop = { state: 0, kvm: mesh.getRemoteDesktopStream(tsid), tunnel: this }; this.httprequest.desktop = { state: 0, kvm: mesh.getRemoteDesktopStream(tsid), tunnel: this };