Added secondary agent id to events.
This commit is contained in:
parent
1b44eb8403
commit
c8161aedc3
24
meshagent.js
24
meshagent.js
|
@ -709,7 +709,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
parent.agentStats.invalidMeshType2Count++;
|
parent.agentStats.invalidMeshType2Count++;
|
||||||
console.log('Agent connected with invalid mesh type, holding connection (' + obj.remoteaddrport + ').');
|
console.log('Agent connected with invalid mesh type, holding connection (' + obj.remoteaddrport + ').');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark when this device connected
|
// Mark when this device connected
|
||||||
obj.connectTime = Date.now();
|
obj.connectTime = Date.now();
|
||||||
|
@ -907,10 +907,8 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
//console.log('recoveryAgentCoreIsStable()');
|
//console.log('recoveryAgentCoreIsStable()');
|
||||||
|
|
||||||
// Fetch the the real agent nodeid
|
// Fetch the the real agent nodeid
|
||||||
db.Get('da' + obj.dbNodeKey, function (err, nodes, self)
|
db.Get('da' + obj.dbNodeKey, function (err, nodes, self) {
|
||||||
{
|
if ((nodes != null) && (nodes.length == 1)) {
|
||||||
if ((nodes != null) && (nodes.length == 1))
|
|
||||||
{
|
|
||||||
self.realNodeKey = nodes[0].raid;
|
self.realNodeKey = nodes[0].raid;
|
||||||
|
|
||||||
// Get agent connection state
|
// Get agent connection state
|
||||||
|
@ -919,8 +917,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
if (state) { agentConnected = ((state.connectivity & 1) != 0) }
|
if (state) { agentConnected = ((state.connectivity & 1) != 0) }
|
||||||
|
|
||||||
self.send(JSON.stringify({ action: 'diagnostic', value: { command: 'query', value: self.realNodeKey, agent: agentConnected } }));
|
self.send(JSON.stringify({ action: 'diagnostic', value: { command: 'query', value: self.realNodeKey, agent: agentConnected } }));
|
||||||
} else
|
} else {
|
||||||
{
|
|
||||||
self.send(JSON.stringify({ action: 'diagnostic', value: { command: 'query', value: null } }));
|
self.send(JSON.stringify({ action: 'diagnostic', value: { command: 'query', value: null } }));
|
||||||
}
|
}
|
||||||
}, obj);
|
}, obj);
|
||||||
|
@ -1051,7 +1048,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
// Not a valid signature
|
// Not a valid signature
|
||||||
parent.agentStats.invalidPkcsSignatureCount++;
|
parent.agentStats.invalidPkcsSignatureCount++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (ex) { };
|
} catch (ex) { };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1243,8 +1240,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
switch (command.value.command) {
|
switch (command.value.command) {
|
||||||
case 'register': {
|
case 'register': {
|
||||||
// Only main agent can do this
|
// Only main agent can do this
|
||||||
if (((obj.agentInfo.capabilities & 0x40) == 0) && (typeof command.value.value == 'string') && (command.value.value.length == 64))
|
if (((obj.agentInfo.capabilities & 0x40) == 0) && (typeof command.value.value == 'string') && (command.value.value.length == 64)) {
|
||||||
{
|
|
||||||
// Store links to diagnostic agent id
|
// Store links to diagnostic agent id
|
||||||
var daNodeKey = 'node/' + domain.id + '/' + db.escapeBase64(command.value.value);
|
var daNodeKey = 'node/' + domain.id + '/' + db.escapeBase64(command.value.value);
|
||||||
db.Set({ _id: 'da' + daNodeKey, domain: domain.id, time: obj.connectTime, raid: obj.dbNodeKey }); // DiagnosticAgent --> Agent
|
db.Set({ _id: 'da' + daNodeKey, domain: domain.id, time: obj.connectTime, raid: obj.dbNodeKey }); // DiagnosticAgent --> Agent
|
||||||
|
@ -1276,7 +1272,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
case 'log': {
|
case 'log': {
|
||||||
if (((obj.agentInfo.capabilities & 0x40) != 0) && (typeof command.value.value == 'string') && (command.value.value.length < 256)) {
|
if (((obj.agentInfo.capabilities & 0x40) != 0) && (typeof command.value.value == 'string') && (command.value.value.length < 256)) {
|
||||||
// If this is a diagnostic agent, log the event in the log of the main agent
|
// If this is a diagnostic agent, log the event in the log of the main agent
|
||||||
var event = { etype: 'node', action: 'diagnostic', nodeid: obj.realNodeKey, domain: domain.id, msg: command.value.value };
|
var event = { etype: 'node', action: 'diagnostic', nodeid: obj.realNodeKey, snodeid: obj.dbNodeKey, domain: domain.id, msg: command.value.value };
|
||||||
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, event);
|
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.dbMeshKey, [obj.dbNodeKey]), obj, event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1308,7 +1304,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
}
|
}
|
||||||
case 'plugin': {
|
case 'plugin': {
|
||||||
if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
|
if ((parent.parent.pluginHandler == null) || (typeof command.plugin != 'string')) break;
|
||||||
try {
|
try {
|
||||||
parent.parent.pluginHandler.plugins[command.plugin].serveraction(command, obj, parent);
|
parent.parent.pluginHandler.plugins[command.plugin].serveraction(command, obj, parent);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error loading plugin handler (' + e + ')');
|
console.log('Error loading plugin handler (' + e + ')');
|
||||||
|
@ -1316,7 +1312,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
parent.agentStats.unknownAgentActionCount++;
|
parent.agentStats.unknownAgentActionCount++;
|
||||||
console.log('Unknown agent action (' + obj.remoteaddrport + '): ' + command.action + '.');
|
console.log('Unknown agent action (' + obj.remoteaddrport + '): ' + command.action + '.');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1453,7 +1449,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
|
||||||
if (device.agent.tag != tag) {
|
if (device.agent.tag != tag) {
|
||||||
// Do some clean up if needed, these values should not be in the database.
|
// Do some clean up if needed, these values should not be in the database.
|
||||||
if (device.conn != null) { delete device.conn; }
|
if (device.conn != null) { delete device.conn; }
|
||||||
if (device.pwr != null) { delete device.pwr; }
|
if (device.pwr != null) { delete device.pwr; }
|
||||||
if (device.agct != null) { delete device.agct; }
|
if (device.agct != null) { delete device.agct; }
|
||||||
if (device.cict != null) { delete device.cict; }
|
if (device.cict != null) { delete device.cict; }
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "meshcentral",
|
"name": "meshcentral",
|
||||||
"version": "0.5.1-g",
|
"version": "0.5.1-h",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Remote Management",
|
"Remote Management",
|
||||||
"Intel AMT",
|
"Intel AMT",
|
||||||
|
|
Loading…
Reference in New Issue