Updated connection bar logic, to log an event if it fails

This commit is contained in:
Bryan Roe 2019-10-25 10:33:10 -07:00
parent b30f3d6073
commit a31e3040a2

View File

@ -1201,7 +1201,7 @@ function createMeshCore(agent) {
{
for(var i in this.httprequest.desktop.kvm.users)
{
if(this.httprequest.desktop.kvm.users[i] == this.httprequest.username)
if (this.httprequest.desktop.kvm.users[i] == this.httprequest.username && this.httprequest.desktop.kvm.connectionBar)
{
this.httprequest.desktop.kvm.users.splice(i, 1);
this.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
@ -1265,13 +1265,25 @@ function createMeshCore(agent) {
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 0x40))
{
// Connection Bar is required
MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
if (this.ws.httprequest.desktop.kvm.connectionBar)
{
this.ws.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
this.ws.httprequest.desktop.kvm.connectionBar.close();
}
try
{
this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.ws.httprequest.desktop.kvm.users.sort().join(', '));
MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
}
catch(xx)
{
if(process.platform != 'darwin')
{
MeshServerLog('Remote Desktop Connection Bar Failed or Not Supported (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
}
}
if (this.ws.httprequest.desktop.kvm.connectionBar)
{
this.ws.httprequest.desktop.kvm.connectionBar.httprequest = this.ws.httprequest;
this.ws.httprequest.desktop.kvm.connectionBar.on('close', function ()
{
@ -1283,6 +1295,7 @@ function createMeshCore(agent) {
this.httprequest.desktop.kvm.end();
});
}
}
this.ws.httprequest.desktop.kvm.pipe(this.ws, { dataTypeSkip: 1 });
this.ws.resume();
},
@ -1306,13 +1319,22 @@ function createMeshCore(agent) {
if (this.httprequest.consent && (this.httprequest.consent & 0x40))
{
// Connection Bar is required
MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.httprequest.remoteaddr + ')', this.httprequest);
if(this.httprequest.desktop.kvm.connectionBar)
{
this.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
this.httprequest.desktop.kvm.connectionBar.close();
}
try
{
this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', '));
MeshServerLog('Remote Desktop Connection Bar Activated/Updated (' + this.httprequest.remoteaddr + ')', this.httprequest);
}
catch(xx)
{
MeshServerLog('Remote Desktop Connection Bar Failed or not Supported (' + this.httprequest.remoteaddr + ')', this.httprequest);
}
if (this.httprequest.desktop.kvm.connectionBar)
{
this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest;
this.httprequest.desktop.kvm.connectionBar.on('close', function ()
{
@ -1324,6 +1346,7 @@ function createMeshCore(agent) {
this.httprequest.desktop.kvm.end();
});
}
}
this.httprequest.desktop.kvm.pipe(this, { dataTypeSkip: 1 });
}
@ -1764,6 +1787,39 @@ function createMeshCore(agent) {
response = 'Available commands: \r\n' + fin + '.';
break;
}
case 'safemode':
if (process.platform != 'win32')
{
response = 'safemode only supported on Windows Platforms'
}
else
{
if (args['_'].length != 1)
{
response = 'Proper usage: safemode (ON|OFF|STATUS)'; // Display usage
}
else
{
switch(args['_'][0].toUpperCase())
{
default:
response = 'Proper usage: safemode (ON|OFF|STATUS)'; // Display usage
break;
case 'ON':
require('win-bcd').setKey('safeboot', 'Network');
require('win-bcd').enableSafeModeService('Mesh Agent');
break;
case 'OFF':
require('win-bcd').deleteKey('safeboot');
break;
case 'STATUS':
var nextboot = require('win-bcd').getKey('safeboot');
response = 'Current: ' + require('win-bcd').bootMode + ' , NextBoot: ' + (nextboot ? nextboot : 'NORMAL');
break;
}
}
}
break;
/*
case 'border':
{