AMT manager improvements.

This commit is contained in:
Ylian Saint-Hilaire 2020-10-07 12:44:50 -07:00
parent 96f686133a
commit 9f8a5646ee
3 changed files with 20 additions and 15 deletions

View File

@ -40,20 +40,25 @@ module.exports.CreateAmtManager = function(parent) {
// Handle server events // Handle server events
obj.HandleEvent = function (source, event, ids, id) { obj.HandleEvent = function (source, event, ids, id) {
if (event.action != 'nodeconnect') return; // React to nodes connecting and disconnecting
if ((event.conn & 14) != 0) { // connectType: Bitmask, 1 = MeshAgent, 2 = Intel AMT CIRA, 4 = Intel AMT local, 8 = Intel AMT Relay, 16 = MQTT if (event.action == 'nodeconnect') {
// We have an OOB connection to Intel AMT, update our information if ((event.conn & 14) != 0) { // connectType: Bitmask, 1 = MeshAgent, 2 = Intel AMT CIRA, 4 = Intel AMT local, 8 = Intel AMT Relay, 16 = MQTT
var dev = obj.amtDevices[event.nodeid]; // We have an OOB connection to Intel AMT, update our information
if (dev == null) { obj.amtDevices[event.nodeid] = dev = { conn: event.conn }; fetchIntelAmtInformation(event.nodeid); } else { dev.conn = event.conn; } var dev = obj.amtDevices[event.nodeid];
} else if (((event.conn & 1) != 0) && (parent.webserver != null)) { if (dev == null) { obj.amtDevices[event.nodeid] = dev = { conn: event.conn }; fetchIntelAmtInformation(event.nodeid); } else { dev.conn = event.conn; }
// We have an agent connection without OOB, check if this agent supports Intel AMT } else if (((event.conn & 1) != 0) && (parent.webserver != null)) {
var agent = parent.webserver.wsagents[event.nodeid]; // We have an agent connection without OOB, check if this agent supports Intel AMT
if ((agent == null) || (agent.agentInfo == null) || (parent.meshAgentsArchitectureNumbers[agent.agentInfo.agentId].amt == false)) { removeDevice(event.nodeid); return; } var agent = parent.webserver.wsagents[event.nodeid];
var dev = obj.amtDevices[event.nodeid]; if ((agent == null) || (agent.agentInfo == null) || (parent.meshAgentsArchitectureNumbers[agent.agentInfo.agentId].amt == false)) { removeDevice(event.nodeid); return; }
if (dev == null) { obj.amtDevices[event.nodeid] = dev = { conn: event.conn }; fetchIntelAmtInformation(event.nodeid); } else { dev.conn = event.conn; } var dev = obj.amtDevices[event.nodeid];
} else { if (dev == null) { obj.amtDevices[event.nodeid] = dev = { conn: event.conn }; fetchIntelAmtInformation(event.nodeid); } else { dev.conn = event.conn; }
removeDevice(event.nodeid); } else {
removeDevice(event.nodeid);
}
} }
// React to node being removed
if (event.action == 'removenode') { removeDevice(event.nodeid); }
} }
// Remove a device // Remove a device

View File

@ -1472,7 +1472,7 @@
} }
case 'ifchange': { case 'ifchange': {
// Network interface changed for a device, if we are currently viewing this device, ask for an update. // Network interface changed for a device, if we are currently viewing this device, ask for an update.
if (currentNode._id == message.event.nodeid) { meshserver.send({ action: 'getnetworkinfo', nodeid: currentNode._id }); } if ((currentNode != null) && (currentNode._id == message.event.nodeid)) { meshserver.send({ action: 'getnetworkinfo', nodeid: currentNode._id }); }
break; break;
} }
case 'devicesessions': { case 'devicesessions': {

View File

@ -2955,7 +2955,7 @@
} }
case 'ifchange': { case 'ifchange': {
// Network interface changed for a device, if we are currently viewing this device, ask for an update. // Network interface changed for a device, if we are currently viewing this device, ask for an update.
if (currentNode._id == message.event.nodeid) { meshserver.send({ action: 'getnetworkinfo', nodeid: currentNode._id }); } if ((currentNode != null) && (currentNode._id == message.event.nodeid)) { meshserver.send({ action: 'getnetworkinfo', nodeid: currentNode._id }); }
break; break;
} }
case 'devicesessions': { case 'devicesessions': {