Small MQTT improvement.
This commit is contained in:
parent
9d94a758cc
commit
4eecac6cce
|
@ -1785,6 +1785,7 @@ function createMeshCore(agent) {
|
|||
*/
|
||||
case 'av':
|
||||
if (process.platform == 'win32') {
|
||||
// Windows Command: "wmic /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct get /FORMAT:CSV"
|
||||
response = JSON.stringify(require('win-info').av(), null, 1);
|
||||
} else {
|
||||
response = 'Not supported on the platform';
|
||||
|
@ -2513,6 +2514,7 @@ function createMeshCore(agent) {
|
|||
|
||||
if ((flags & 4) && (process.platform == 'win32')) {
|
||||
// Update anti-virus information
|
||||
// Windows Command: "wmic /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct get /FORMAT:CSV"
|
||||
var av, pr;
|
||||
try { av = require('win-info').av(); } catch (ex) { av = null; } // Antivirus
|
||||
//if (process.platform == 'win32') { try { pr = require('win-info').pendingReboot(); } catch (ex) { pr = null; } } // Pending reboot
|
||||
|
|
|
@ -1170,7 +1170,8 @@ function createMeshCore(agent) {
|
|||
this.httprequest.desktop.kvm.parent = this.httprequest.desktop;
|
||||
this.desktop = this.httprequest.desktop;
|
||||
|
||||
this.end = function () {
|
||||
this.end = function ()
|
||||
{
|
||||
--this.desktop.kvm.connectionCount;
|
||||
|
||||
// Unpipe the web socket
|
||||
|
@ -1183,14 +1184,55 @@ function createMeshCore(agent) {
|
|||
this.httprequest.desktop.kvm.unpipe(this.rtcchannel);
|
||||
}
|
||||
|
||||
if (this.desktop.kvm.connectionCount == 0) {
|
||||
if (this.desktop.kvm.connectionCount == 0)
|
||||
{
|
||||
// Display a toast message. This may not be supported on all platforms.
|
||||
// try { require('toaster').Toast('MeshCentral', 'Remote Desktop Control Ended.'); } catch (ex) { }
|
||||
|
||||
this.httprequest.desktop.kvm.end();
|
||||
if(this.httprequest.desktop.kvm.connectionBar)
|
||||
{
|
||||
this.httprequest.desktop.kvm.connectionBar.removeAllListeners('close');
|
||||
this.httprequest.desktop.kvm.connectionBar.close();
|
||||
this.httprequest.desktop.kvm.connectionBar = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(var i in this.httprequest.desktop.kvm.users)
|
||||
{
|
||||
if(this.httprequest.desktop.kvm.users[i] == this.httprequest.username)
|
||||
{
|
||||
this.httprequest.desktop.kvm.users.splice(i, 1);
|
||||
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 ()
|
||||
{
|
||||
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();
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if (this.httprequest.desktop.kvm.hasOwnProperty("connectionCount")) { this.httprequest.desktop.kvm.connectionCount++; } else { this.httprequest.desktop.kvm.connectionCount = 1; }
|
||||
if (this.httprequest.desktop.kvm.hasOwnProperty("connectionCount"))
|
||||
{
|
||||
this.httprequest.desktop.kvm.connectionCount++;
|
||||
this.httprequest.desktop.kvm.users.push(this.httprequest.username);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.httprequest.desktop.kvm.connectionCount = 1;
|
||||
this.httprequest.desktop.kvm.users = [this.httprequest.username];
|
||||
}
|
||||
|
||||
if ((this.httprequest.rights == 0xFFFFFFFF) || (((this.httprequest.rights & MESHRIGHT_REMOTECONTROL) != 0) && ((this.httprequest.rights & MESHRIGHT_REMOTEVIEW) == 0))) {
|
||||
// If we have remote control rights, pipe the KVM input
|
||||
|
@ -1215,10 +1257,32 @@ function createMeshCore(agent) {
|
|||
// Success
|
||||
MeshServerLog('Starting remote desktop after local user accepted (' + this.ws.httprequest.remoteaddr + ')', this.ws.httprequest);
|
||||
this.ws.write(JSON.stringify({ ctrlChannel: '102938', type: 'console', msg: null }));
|
||||
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1)) {
|
||||
if (this.ws.httprequest.consent && (this.ws.httprequest.consent & 1))
|
||||
{
|
||||
// User Notifications is required
|
||||
try { require('toaster').Toast('MeshCentral', this.ws.httprequest.username + ' started a remote desktop session.'); } catch (ex) { }
|
||||
}
|
||||
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 ()
|
||||
{
|
||||
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();
|
||||
},
|
||||
|
@ -1230,13 +1294,36 @@ function createMeshCore(agent) {
|
|||
}
|
||||
else {
|
||||
// User Consent Prompt is not required
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 1)) {
|
||||
if (this.httprequest.consent && (this.httprequest.consent & 1))
|
||||
{
|
||||
// User Notifications is required
|
||||
MeshServerLog('Started remote desktop with toast notification (' + this.httprequest.remoteaddr + ')', this.httprequest);
|
||||
try { require('toaster').Toast('MeshCentral', this.httprequest.username + ' started a remote desktop session.'); } catch (ex) { }
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
MeshServerLog('Started remote desktop without notification (' + this.httprequest.remoteaddr + ')', this.httprequest);
|
||||
}
|
||||
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 ()
|
||||
{
|
||||
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 });
|
||||
}
|
||||
|
||||
|
@ -1698,6 +1785,7 @@ function createMeshCore(agent) {
|
|||
*/
|
||||
case 'av':
|
||||
if (process.platform == 'win32') {
|
||||
// Windows Command: "wmic /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct get /FORMAT:CSV"
|
||||
response = JSON.stringify(require('win-info').av(), null, 1);
|
||||
} else {
|
||||
response = 'Not supported on the platform';
|
||||
|
@ -2426,8 +2514,9 @@ function createMeshCore(agent) {
|
|||
|
||||
if ((flags & 4) && (process.platform == 'win32')) {
|
||||
// Update anti-virus information
|
||||
// Windows Command: "wmic /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct get /FORMAT:CSV"
|
||||
var av, pr;
|
||||
try { av = require('win-info').av(); } catch (ex) { av = []; } // Antivirus
|
||||
try { av = require('win-info').av(); } catch (ex) { av = null; } // Antivirus
|
||||
//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); }
|
||||
}
|
||||
|
|
|
@ -125,7 +125,10 @@ module.exports.CreateMQTTBroker = function (parent, db, args) {
|
|||
var clients = obj.connections[nodeid];
|
||||
if (clients == null) return;
|
||||
if (typeof message == 'string') { message = new Buffer(message); }
|
||||
for (var i in clients) { clients[i].publish({ cmd: 'publish', qos: 0, topic: topic, payload: message, retain: false }); }
|
||||
for (var i in clients) {
|
||||
// if (clients[i].subscriptions[topic] != null) { } // Add this if we only want to send subscribed topics.
|
||||
clients[i].publish({ cmd: 'publish', qos: 0, topic: topic, payload: message, retain: false });
|
||||
}
|
||||
}
|
||||
|
||||
// Handle messages coming from clients
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.4.2-e",
|
||||
"version": "0.4.2-f",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
|
Loading…
Reference in New Issue