From 3b2ef66dcd96913149632bdb168ad0a4273ac57a Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Sun, 14 Mar 2021 14:18:50 -0700 Subject: [PATCH] Added --filterid to listdevice in meshctrl.js --- amtmanager.js | 8 ++++---- meshctrl.js | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/amtmanager.js b/amtmanager.js index 267bc5f4..8b3bf906 100644 --- a/amtmanager.js +++ b/amtmanager.js @@ -1716,13 +1716,13 @@ module.exports.CreateAmtManager = function (parent) { // We are not activated now, go to ACM directly. // If this is Intel AMT 14 or better, we are going to attempt a host-based end-to-end TLS activation. if (typeof dev.intelamt.ver == 'string') { var verSplit = dev.intelamt.ver.split('.'); if (verSplit.length >= 3) { dev.aquired.majorver = parseInt(verSplit[0]); dev.aquired.minorver = parseInt(verSplit[1]); } } - //if (dev.aquired.majorver >= 14) { + if (dev.aquired.majorver >= 14) { // Perform host-based TLS ACM activation - //activateIntelAmtTlsAcm(dev, mesh.amt.password, acminfo); - //} else { + activateIntelAmtTlsAcm(dev, mesh.amt.password, acminfo); + } else { // Perform host-based ACM activation activateIntelAmtAcm(dev, mesh.amt.password, acminfo); - //} + } } } } diff --git a/meshctrl.js b/meshctrl.js index 07b5afef..8796d1b0 100644 --- a/meshctrl.js +++ b/meshctrl.js @@ -368,6 +368,7 @@ if (args['_'].length == 0) { console.log(" --count - Only return the device count."); console.log(" --json - Show result as JSON."); console.log(" --csv - Show result as comma seperated values."); + console.log(" --filterid [id,id...] - Show only results for devices with included id."); break; } case 'listusersofdevicegroup': { @@ -1795,6 +1796,28 @@ function serverConnect() { if ((data.result != null) && (data.result != 'ok')) { console.log(data.result); } else { + // Filder devices based on device id. + if (args.filterid) { + var filteridSplit = args.filterid.split(','), filters = []; + for (var i in filteridSplit) { + var f = filteridSplit[i].trim(); + var g = f.split('/'); // If there is any / in the id, just grab the last part. + if (g.length > 0) { f = g[g.length - 1]; } + if (f != '') { filters.push(f); } + } + if (filters.length > 0) { + for (var mid in data.nodes) { + var filteredNodes = []; + for (var nid in data.nodes[mid]) { + var n = data.nodes[mid][nid], match = false; + for (var f in filters) { if (n._id.indexOf(filters[f]) >= 0) { match = true; } } + if (match) { filteredNodes.push(n); } + } + data.nodes[mid] = filteredNodes; + } + } + } + if (args.csv) { // Return a flat list var nodecount = 0;