diff --git a/agents/meshcore.js b/agents/meshcore.js index adee50d2..7862125e 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -2572,8 +2572,6 @@ function createMeshCore(agent) { //if (process.platform == 'win32') { try { pr = require('win-info').pendingReboot(); } catch (ex) { pr = null; } } // Pending reboot if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); } } - - mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"}); } diff --git a/agents/meshcore.min.js b/agents/meshcore.min.js index e8788bd2..7862125e 100644 --- a/agents/meshcore.min.js +++ b/agents/meshcore.min.js @@ -1202,7 +1202,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'); @@ -1266,23 +1266,36 @@ 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(); } - this.ws.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.ws.httprequest.desktop.kvm.users.sort().join(', ')); - this.ws.httprequest.desktop.kvm.connectionBar.httprequest = this.ws.httprequest; - this.ws.httprequest.desktop.kvm.connectionBar.on('close', function () + try { - MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest); - for (var i in this.httprequest.desktop.kvm._pipedStreams) + 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') { - this.httprequest.desktop.kvm._pipedStreams[i].end(); + MeshServerLog('Remote Desktop Connection Bar Failed or Not Supported (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest); } - this.httprequest.desktop.kvm.end(); - }); + } + 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 () + { + MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest); + for (var i in this.httprequest.desktop.kvm._pipedStreams) + { + this.httprequest.desktop.kvm._pipedStreams[i].end(); + } + this.httprequest.desktop.kvm.end(); + }); + } } this.ws.httprequest.desktop.kvm.pipe(this.ws, { dataTypeSkip: 1 }); this.ws.resume(); @@ -1307,23 +1320,33 @@ 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(); } - this.httprequest.desktop.kvm.connectionBar = require('notifybar-desktop')('Sharing desktop with: ' + this.httprequest.desktop.kvm.users.sort().join(', ')); - this.httprequest.desktop.kvm.connectionBar.httprequest = this.httprequest; - this.httprequest.desktop.kvm.connectionBar.on('close', function () + try { - MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest); - for (var i in this.httprequest.desktop.kvm._pipedStreams) + 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 () { - this.httprequest.desktop.kvm._pipedStreams[i].end(); - } - this.httprequest.desktop.kvm.end(); - }); + MeshServerLog('Remote Desktop Connection forcefully closed by local user (' + this.httprequest.remoteaddr + ')', this.httprequest); + for (var i in this.httprequest.desktop.kvm._pipedStreams) + { + this.httprequest.desktop.kvm._pipedStreams[i].end(); + } + this.httprequest.desktop.kvm.end(); + }); + } } this.httprequest.desktop.kvm.pipe(this, { dataTypeSkip: 1 }); } @@ -1765,6 +1788,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': { @@ -2516,8 +2572,6 @@ function createMeshCore(agent) { //if (process.platform == 'win32') { try { pr = require('win-info').pendingReboot(); } catch (ex) { pr = null; } } // Pending reboot if ((meshCoreObj.av == null) || (JSON.stringify(meshCoreObj.av) != JSON.stringify(av))) { meshCoreObj.av = av; mesh.SendCommand(meshCoreObj); } } - - mesh.SendCommand({ action: "plugin", plugin: "__all", hook: "sendPeriodicServerUpdate"}); } diff --git a/meshagent.js b/meshagent.js index 50e75982..708a7e2e 100644 --- a/meshagent.js +++ b/meshagent.js @@ -1275,7 +1275,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { break; } case 'plugin': { - if (typeof command.plugin != 'string') break; + if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break; try { var pluginHandler = require('./pluginHandler.js').pluginHandler(parent.parent); if (command.plugin == '__all') {