Intel AMT CIRA auto-config almost done.

Ylian Saint-Hilaire committed Oct 18, 2020 at 21:06 UTC 51ae65b5dca20eaf947a2e5baed4ef51ff95e1b6
5 files changed +254 -26
agents/MeshCmd-signed.exe
Binary files a/agents/MeshCmd-signed.exe and b/agents/MeshCmd-signed.exe differ
agents/MeshCmd64-signed.exe
Binary files a/agents/MeshCmd64-signed.exe and b/agents/MeshCmd64-signed.exe differ
amt/amt.js
+1 -1
@@ -279,7 +279,7 @@ function AmtStackCreateService(wsmanStack) {
279 obj.AMT_RedirectionService_RequestStateChange = function (RequestedState, callback_func) { obj.Exec("AMT_RedirectionService", "RequestStateChange", { "RequestedState": RequestedState }, callback_func); }
280 obj.AMT_RedirectionService_TerminateSession = function (SessionType, callback_func) { obj.Exec("AMT_RedirectionService", "TerminateSession", { "SessionType": SessionType }, callback_func); }
281 obj.AMT_RemoteAccessService_AddMpServer = function (AccessInfo, InfoFormat, Port, AuthMethod, Certificate, Username, Password, CN, callback_func) { obj.Exec("AMT_RemoteAccessService", "AddMpServer", { "AccessInfo": AccessInfo, "InfoFormat": InfoFormat, "Port": Port, "AuthMethod": AuthMethod, "Certificate": Certificate, "Username": Username, "Password": Password, "CN": CN }, callback_func); }
282 - obj.AMT_RemoteAccessService_AddRemoteAccessPolicyRule = function (Trigger, TunnelLifeTime, ExtendedData, MpServer, callback_func) { obj.Exec("AMT_RemoteAccessService", "AddRemoteAccessPolicyRule", { "Trigger": Trigger, "TunnelLifeTime": TunnelLifeTime, "ExtendedData": ExtendedData, "MpServer": MpServer }, callback_func); }
282 + obj.AMT_RemoteAccessService_AddRemoteAccessPolicyRule = function (Trigger, TunnelLifeTime, ExtendedData, MpServer, InternalMpServer, callback_func) { obj.Exec('AMT_RemoteAccessService', 'AddRemoteAccessPolicyRule', { 'Trigger': Trigger, 'TunnelLifeTime': TunnelLifeTime, 'ExtendedData': ExtendedData, 'MpServer': MpServer, 'InternalMpServer': InternalMpServer }, callback_func); }
283 obj.AMT_RemoteAccessService_CloseRemoteAccessConnection = function (_method_dummy, callback_func) { obj.Exec("AMT_RemoteAccessService", "CloseRemoteAccessConnection", { "_method_dummy": _method_dummy }, callback_func); }
284 obj.AMT_SetupAndConfigurationService_CommitChanges = function (_method_dummy, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "CommitChanges", { "_method_dummy": _method_dummy }, callback_func); }
285 obj.AMT_SetupAndConfigurationService_Unprovision = function (ProvisioningMode, callback_func) { obj.Exec("AMT_SetupAndConfigurationService", "Unprovision", { "ProvisioningMode": ProvisioningMode }, callback_func); }
amtmanager.js
+252 -24
@@ -113,6 +113,7 @@ module.exports.CreateAmtManager = function(parent) {
113 if (typeof connection == 'object') { dev.mpsConnection = connection; }
114 dev.consoleMsg = function deviceConsoleMsg(msg) { if (typeof deviceConsoleMsg.conn == 'object') { deviceConsoleMsg.conn.ControlMsg({ action: 'console', msg: msg }); } }
115 dev.consoleMsg.conn = connection;
116 + dev.consoleMsg.dev = dev;
117 dev.controlMsg = function deviceControlMsg(msg) { if (typeof deviceControlMsg.conn == 'object') { deviceControlMsg.conn.ControlMsg(msg); } }
118 dev.controlMsg.conn = connection;
119 parent.debug('amt', "Start Management", nodeid, connType);
@@ -188,6 +189,11 @@ module.exports.CreateAmtManager = function(parent) {
189 }
190 }
191
192 +
193 + //
194 + // Intel AMT Connection Setup
195 + //
196 +
197 // Update information about a device
198 function fetchIntelAmtInformation(dev) {
199 parent.db.Get(dev.nodeid, function (err, nodes) {
@@ -331,7 +337,7 @@ module.exports.CreateAmtManager = function(parent) {
337 if (dev.aquired == null) { dev.aquired = {}; }
338 dev.aquired.controlMode = responses['IPS_HostBasedSetupService'].response.CurrentControlMode; // 1 = CCM, 2 = ACM
339 var verSplit = stack.wsman.comm.amtVersion.split('.');
334 - if (verSplit.length >= 3) { dev.aquired.version = verSplit[0] + '.' + verSplit[1] + '.' + verSplit[2]; dev.aquired.majorver = parseInt(verSplit[0]); }
340 + if (verSplit.length >= 3) { dev.aquired.version = verSplit[0] + '.' + verSplit[1] + '.' + verSplit[2]; dev.aquired.majorver = parseInt(verSplit[0]); dev.aquired.minorver = parseInt(verSplit[1]); }
341 dev.aquired.realm = stack.wsman.comm.digestRealm;
342 dev.aquired.user = stack.wsman.comm.user;
343 dev.aquired.pass = stack.wsman.comm.pass;
@@ -346,19 +352,22 @@ module.exports.CreateAmtManager = function(parent) {
352 attemptTlsSync(dev, function () {
353 // Check Intel AMT root certificate state
354 attemptRootCertSync(dev, function () {
349 - // See if we need to get hardware inventory
350 - attemptFetchHardwareInventory(dev, function () {
351 - dev.consoleMsg('Done.');
352 - if (dev.connType != 2) {
353 - // Start power polling if not connected to LMS
354 - var ppfunc = function powerPoleFunction() { fetchPowerState(powerPoleFunction.dev); }
355 - ppfunc.dev = dev;
356 - dev.polltimer = new setTimeout(ppfunc, 290000); // Poll for power state every 4 minutes 50 seconds.
357 - fetchPowerState(dev);
358 - } else {
359 - // For LMS connections, close now.
360 - dev.controlMsg({ action: "close" });
361 - }
355 + // Check Intel AMT CIRA settings
356 + attemptCiraSync(dev, function () {
357 + // See if we need to get hardware inventory
358 + attemptFetchHardwareInventory(dev, function () {
359 + dev.consoleMsg('Done.');
360 + if (dev.connType != 2) {
361 + // Start power polling if not connected to LMS
362 + var ppfunc = function powerPoleFunction() { fetchPowerState(powerPoleFunction.dev); }
363 + ppfunc.dev = dev;
364 + dev.polltimer = new setTimeout(ppfunc, 290000); // Poll for power state every 4 minutes 50 seconds.
365 + fetchPowerState(dev);
366 + } else {
367 + // For LMS connections, close now.
368 + dev.controlMsg({ action: 'close' });
369 + }
370 + });
371 });
372 });
373 });
@@ -382,6 +391,11 @@ module.exports.CreateAmtManager = function(parent) {
391 }
392 }
393
394 +
395 + //
396 + // Intel AMT Database Update
397 + //
398 +
399 // Change the current core information string and event it
400 function UpdateDevice(dev) {
401 if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
@@ -468,6 +482,11 @@ module.exports.CreateAmtManager = function(parent) {
482 });
483 }
484
485 +
486 + //
487 + // Intel AMT Power State
488 + //
489 +
490 // Get the current power state of a device
491 function fetchPowerState(dev) {
492 if (isAmtDeviceValid(dev) == false) return;
@@ -529,6 +548,11 @@ module.exports.CreateAmtManager = function(parent) {
548 //console.log('performPowerActionResponse', status);
549 }
550
551 +
552 + //
553 + // Intel AMT Clock Syncronization
554 + //
555 +
556 // Attempt to sync the Intel AMT clock if needed, call func back when done.
557 // Care should be take not to have many pending WSMAN called when performing clock sync.
558 function attemptSyncClock(dev, func) {
@@ -566,6 +590,11 @@ module.exports.CreateAmtManager = function(parent) {
590 devTaskCompleted(dev)
591 }
592
593 +
594 + //
595 + // Intel AMT TLS setup
596 + //
597 +
598 // Check if Intel AMT TLS state is correct
599 function attemptTlsSync(dev, func) {
600 if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
@@ -605,7 +634,7 @@ module.exports.CreateAmtManager = function(parent) {
634 var xxCertificates = responses['AMT_PublicKeyCertificate'].responses;
635 for (var i in xxCertificates) {
636 xxCertificates[i].TrustedRootCertficate = (xxCertificates[i]['TrustedRootCertficate'] == true);
608 - xxCertificates[i].X509Certificate = Buffer.from(xxCertificates[i]['X509Certificate'], 'base64').toString('binary');
637 + xxCertificates[i].X509CertificateBin = Buffer.from(xxCertificates[i]['X509Certificate'], 'base64').toString('binary');
638 xxCertificates[i].XIssuer = parseCertName(xxCertificates[i]['Issuer']);
639 xxCertificates[i].XSubject = parseCertName(xxCertificates[i]['Subject']);
640 }
@@ -715,16 +744,21 @@ module.exports.CreateAmtManager = function(parent) {
744 if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
745 if (status != 200) { dev.consoleMsg("Failed perform commit."); removeAmtDevice(dev); return; }
746 dev.consoleMsg("Enabled TLS");
718 - // TODO: Switch our communications to TLS.
747 + // TODO: Switch our communications to TLS (Restart our management of this node)
748 devTaskCompleted(dev);
749 });
750 }
751 }
752
753 +
754 + //
755 + // Intel AMT Server Root Certificate
756 + //
757 +
758 // Check if Intel AMT has the server root certificate
759 function attemptRootCertSync(dev, func) {
760 if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
727 - if (dev.policy.ciraPolicy != 2) { func(); return; } // Server root certificate does not need to be present is CIRA is not needed
761 + if ((dev.connType != 2) || (dev.policy.ciraPolicy != 2)) { func(); return; } // Server root certificate does not need to be present is CIRA is not needed
762
763 // Find the current TLS certificate & MeshCentral root certificate
764 var xxMeshCentralRoot = null;
@@ -746,6 +780,193 @@ module.exports.CreateAmtManager = function(parent) {
780 } else { func(); }
781 }
782
783 +
784 + //
785 + // Intel AMT CIRA Setup
786 + //
787 +
788 + // Check if Intel AMT has the server root certificate
789 + function attemptCiraSync(dev, func) {
790 + if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
791 + if ((dev.connType != 2) || (dev.policy.ciraPolicy != 2)) { func(); return; } // Only setup CIRA when LMS connection is used and a CIRA policy is enabled.
792 +
793 + // Get current CIRA settings
794 + // TODO: We only deal with remote access starting with Intel AMT 6 and beyond
795 + dev.taskCount = 1;
796 + dev.taskCompleted = func;
797 + var requests = ['*AMT_EnvironmentDetectionSettingData', 'AMT_ManagementPresenceRemoteSAP', 'AMT_RemoteAccessCredentialContext', 'AMT_RemoteAccessPolicyAppliesToMPS', 'AMT_RemoteAccessPolicyRule', '*AMT_UserInitiatedConnectionService', 'AMT_MPSUsernamePassword'];
798 + if (dev.aquired.majorver > 11) { requests.push('*IPS_HTTPProxyService', 'IPS_HTTPProxyAccessPoint'); }
799 + dev.amtstack.BatchEnum(null, requests, function (stack, name, responses, status) {
800 + const dev = stack.dev;
801 + if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
802 + //dev.consoleMsg("Added server root certificate.");
803 +
804 + if ((dev.aquired.majorver > 11) && (status == 400)) {
805 + // Check if only the HTTP proxy objects failed
806 + status = 200;
807 + if (responses['IPS_HTTPProxyAccessPoint'].status == 400) { delete responses['IPS_HTTPProxyAccessPoint']; }
808 + if (responses['IPS_HTTPProxyService'].status == 400) { delete responses['IPS_HTTPProxyService']; }
809 + for (var i in responses) { if (responses[i].status != 200) { status = responses[i].status; } }
810 + }
811 + if ((status != 200) || (responses['AMT_UserInitiatedConnectionService'] == null) || (responses['AMT_UserInitiatedConnectionService'].response == null)) { dev.consoleMsg("Failed get CIRA state."); removeAmtDevice(dev); return; }
812 +
813 + dev.cira = {};
814 + dev.cira.xxRemoteAccess = responses;
815 + dev.cira.xxEnvironementDetection = responses['AMT_EnvironmentDetectionSettingData'].response;
816 + dev.cira.xxEnvironementDetection['DetectionStrings'] = MakeToArray(dev.cira.xxEnvironementDetection['DetectionStrings']);
817 + dev.cira.xxCiraServers = responses['AMT_ManagementPresenceRemoteSAP'].responses;
818 + dev.cira.xxUserInitiatedCira = responses['AMT_UserInitiatedConnectionService'].response;
819 + dev.cira.xxRemoteAccessCredentiaLinks = responses['AMT_RemoteAccessCredentialContext'].responses;
820 + dev.cira.xxMPSUserPass = responses['AMT_MPSUsernamePassword'].responses;
821 +
822 + // Set CIRA initiation to BIOS & OS enabled
823 + if (dev.cira.xxUserInitiatedCira['EnabledState'] != 32771) { // 32768: "Disabled", 32769: "BIOS enabled", 32770: "OS enable", 32771: "BIOS & OS enabled"
824 + dev.amtstack.AMT_UserInitiatedConnectionService_RequestStateChange(32771, null, function (stack, name, responses, status) { }); // This is not a critical call.
825 + }
826 +
827 + // Figure out policies attached to servers. Create a policy type to server table.
828 + dev.cira.xxPolicies = { 'User': [], 'Alert': [], 'Periodic': [] };
829 + for (var i in responses['AMT_RemoteAccessPolicyAppliesToMPS'].responses) {
830 + var policy = responses['AMT_RemoteAccessPolicyAppliesToMPS'].responses[i];
831 + var server = Clone(getItem(dev.cira.xxCiraServers, 'Name', getItem(policy['ManagedElement']['ReferenceParameters']['SelectorSet']['Selector'], '@Name', 'Name')['Value']));
832 + server.MpsType = policy['MpsType']; // MpsType was added in Intel AMT 11.6
833 + var ptype = (getItem(policy['PolicySet']['ReferenceParameters']['SelectorSet']['Selector'], '@Name', 'PolicyRuleName')['Value']).split(' ')[0];
834 + dev.cira.xxPolicies[ptype].push(server);
835 + }
836 +
837 + // Fetch the server's CIRA settings
838 + dev.cira.mpsPresent = null;
839 + dev.cira.mpsPolicy = false;
840 + if (dev.policy.ciraPolicy == 2) { // DEBUG
841 + dev.cira.meshidx = dev.meshid.split('/')[2].replace(/\@/g, 'X').replace(/\$/g, 'X').substring(0, 16);
842 + dev.cira.mpsName = parent.webserver.certificates.AmtMpsName;
843 + var serverNameSplit = dev.cira.mpsName.split('.');
844 + dev.cira.mpsPort = ((parent.args.mpsaliasport != null) ? parent.args.mpsaliasport : parent.args.mpsport);
845 + dev.cira.mpsAddressFormat = 201; // 201 = FQDN, 3 = IPv4
846 + if ((serverNameSplit.length == 4) && (parseInt(serverNameSplit[0]) == serverNameSplit[0]) && (parseInt(serverNameSplit[1]) == serverNameSplit[1]) && (parseInt(serverNameSplit[2]) == serverNameSplit[2]) && (parseInt(serverNameSplit[3]) == serverNameSplit[3])) { dev.cira.mpsAddressFormat = 3; }
847 +
848 + // Check if our server is already present
849 + if (dev.cira.xxCiraServers.length > 0) {
850 + for (var i = 0; i < dev.cira.xxCiraServers.length; i++) {
851 + var mpsServer = dev.cira.xxCiraServers[i];
852 + if ((mpsServer.AccessInfo == dev.cira.mpsName) && (mpsServer.Port == dev.cira.mpsPort) && (mpsServer.InfoFormat == dev.cira.mpsAddressFormat)) { dev.cira.mpsPresent = mpsServer['Name']; }
853 + }
854 + }
855 +
856 + // Check if our server is already present
857 + if (dev.cira.xxPolicies['Periodic'].length > 0) {
858 + var mpsServer = dev.cira.xxPolicies['Periodic'][0];
859 + if ((mpsServer.AccessInfo == dev.cira.mpsName) && (mpsServer.Port == dev.cira.mpsPort) && (mpsServer.InfoFormat == dev.cira.mpsAddressFormat)) { dev.cira.mpsPolicy = true; }
860 + }
861 + }
862 +
863 + // Remove all MPS policies that are not ours
864 + if ((dev.cira.xxPolicies['User Initiated'] != null) && (dev.cira.xxPolicies['User Initiated'].length > 0)) { dev.consoleMsg("Removing CIRA user trigger."); dev.amtstack.Delete('AMT_RemoteAccessPolicyRule', { 'PolicyRuleName': 'User Initiated' }, function (stack, name, responses, status) { }); }
865 + if ((dev.cira.xxPolicies['Alert'] != null) && (dev.cira.xxPolicies['Alert'].length > 0)) { dev.consoleMsg("Removing CIRA alert trigger."); dev.amtstack.Delete('AMT_RemoteAccessPolicyRule', { 'PolicyRuleName': 'Alert' }, function (stack, name, responses, status) { }); }
866 + if ((dev.cira.xxPolicies['Periodic'] != null) && (dev.cira.xxPolicies['Periodic'].length > 0) && (dev.cira.mpsPolicy == false)) { dev.consoleMsg("Removing CIRA periodic trigger."); dev.amtstack.Delete('AMT_RemoteAccessPolicyRule', { 'PolicyRuleName': 'Periodic' }, function (stack, name, responses, status) { }); }
867 +
868 + // Remove all MPS servers that are not ours
869 + if (dev.cira.xxCiraServers.length > 0) {
870 + for (var i = 0; i < dev.cira.xxCiraServers.length; i++) {
871 + var mpsServer = dev.cira.xxCiraServers[i];
872 + if ((mpsServer.AccessInfo != dev.cira.mpsName) || (mpsServer.Port != dev.cira.mpsPort) || (mpsServer.InfoFormat != dev.cira.mpsAddressFormat)) {
873 + dev.consoleMsg("Removing MPS server.");
874 + dev.amtstack.Delete('AMT_ManagementPresenceRemoteSAP', { 'Name': mpsServer['Name'] }, function (stack, name, responses, status) { });
875 + }
876 + }
877 + }
878 +
879 + // If we need to setup CIRA, start by checking the MPS server
880 + if (dev.policy.ciraPolicy == 2) { addMpsServer(dev); } else { checkEnvironmentDetection(dev); }
881 + });
882 + }
883 +
884 + function addMpsServer(dev) {
885 + // Add the MPS server if not present
886 + if (dev.cira.mpsPresent == null) {
887 + dev.taskCount++;
888 + dev.amtstack.AMT_RemoteAccessService_AddMpServer(dev.cira.mpsName, dev.cira.mpsAddressFormat, dev.cira.mpsPort, 2, null, dev.cira.meshidx, 'P@ssw0rd', dev.cira.mpsName, function (stack, name, response, status) {
889 + const dev = stack.dev;
890 + if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
891 + if (status != 200) { dev.consoleMsg("Failed to create new MPS server."); removeAmtDevice(dev); return; }
892 + dev.cira.mpsPresent = getItem(response.Body.MpServer.ReferenceParameters.SelectorSet.Selector, '@Name', 'Name').Value;
893 + dev.consoleMsg("Created new MPS server.");
894 + addMpsPolicy(dev);
895 + });
896 + } else {
897 + // MPS server is present, check MPS trigger policy
898 + addMpsPolicy(dev);
899 + }
900 + }
901 +
902 + function addMpsPolicy(dev) {
903 + if (dev.cira.mpsPolicy == false) {
904 + var cilaSupport = ((dev.aquired.majorver > 11) || ((dev.aquired.majorver == 11) && (dev.aquired.minorver >= 6)));
905 + var trigger = 2; // 1 = Alert, 2 = Periodic
906 +
907 + // Setup extended data
908 + var extendedData = null;
909 + if (trigger == 2) {
910 + var timertype = 0; // 0 = Periodic, 1 = Time of day
911 + var exdata = IntToStr(10); // Interval trigger, 10 seconds
912 + extendedData = Buffer.from(IntToStr(timertype) + exdata, 'binary').toString('base64');
913 + }
914 +
915 + // Create the MPS server references
916 + var server1 = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</Address><ReferenceParameters xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing"><ResourceURI xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">http://intel.com/wbem/wscim/1/amt-schema/1/AMT_ManagementPresenceRemoteSAP</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="Name">' + dev.cira.mpsPresent + '</Selector></SelectorSet></ReferenceParameters>';
917 + var server2 = null;
918 +
919 + // Put the CIRA/CILA servers in the right bins.
920 + var ciraServers = [], cilaServers = [];
921 + if (server1) { ciraServers.push(server1); if (server2) { ciraServers.push(server2); } }
922 +
923 + // Go ahead and create the new CIRA/CILA policy.
924 + dev.taskCount++;
925 + dev.amtstack.AMT_RemoteAccessService_AddRemoteAccessPolicyRule(trigger, 0, extendedData, ciraServers, cilaServers, function (stack, name, responses, status) {
926 + const dev = stack.dev;
927 + if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
928 + if (status != 200) { dev.consoleMsg("Failed to create new MPS policy."); removeAmtDevice(dev); return; }
929 + dev.consoleMsg("Created new MPS policy.");
930 + checkEnvironmentDetection(dev);
931 + });
932 + } else {
933 + checkEnvironmentDetection(dev);
934 + }
935 + }
936 +
937 + function checkEnvironmentDetection(dev) {
938 + var changes = false;
939 + var editEnvironmentDetectionTmp = [];
940 +
941 + //console.log('checkEnvironmentDetection', dev.cira.xxEnvironementDetection);
942 + if (dev.policy.ciraPolicy == 2) {
943 + // Check that we have a random environment detection
944 + // TODO
945 + } else {
946 + // Check environment detection is clear
947 + // TODO
948 + }
949 +
950 + if (changes == true) {
951 + var t = Clone(dev.cire.xxEnvironementDetection);
952 + t['DetectionStrings'] = editEnvironmentDetectionTmp;
953 + //console.log('AMT_EnvironmentDetectionSettingData', t);
954 + amtstack.Put('AMT_EnvironmentDetectionSettingData', t, function (stack, name, responses, status) {
955 + const dev = stack.dev;
956 + if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
957 + if (status != 200) { dev.consoleMsg("Failed to set environement detection."); removeAmtDevice(dev); return; }
958 + dev.consoleMsg("Environment detection set.");
959 + devTaskCompleted(dev);
960 + }, 0, 1);
961 + } else {
962 + devTaskCompleted(dev);
963 + }
964 + }
965 +
966 + //
967 + // Intel AMT Hardware Inventory and Networking
968 + //
969 +
970 function attemptFetchHardwareInventory(dev, func) {
971 if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
972 const mesh = parent.webserver.meshes[dev.meshid];
@@ -761,12 +982,6 @@ module.exports.CreateAmtManager = function(parent) {
982 }
983 }
984
764 - // Called this when a task is completed, when all tasks are completed the call back function will be called.
765 - function devTaskCompleted(dev) {
766 - dev.taskCount--;
767 - if (dev.taskCount == 0) { var f = dev.taskCompleted; delete dev.taskCount; delete dev.taskCompleted; if (f != null) { f(); } }
768 - }
769 -
985 function attemptFetchNetworkResponse(stack, name, responses, status) {
986 const dev = stack.dev;
987 if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
@@ -928,6 +1143,16 @@ module.exports.CreateAmtManager = function(parent) {
1143 devTaskCompleted(dev);
1144 }
1145
1146 + //
1147 + // General Methods
1148 + //
1149 +
1150 + // Called this when a task is completed, when all tasks are completed the call back function will be called.
1151 + function devTaskCompleted(dev) {
1152 + dev.taskCount--;
1153 + if (dev.taskCount == 0) { var f = dev.taskCompleted; delete dev.taskCount; delete dev.taskCompleted; if (f != null) { f(); } }
1154 + }
1155 +
1156 function guidToStr(g) { return g.substring(6, 8) + g.substring(4, 6) + g.substring(2, 4) + g.substring(0, 2) + '-' + g.substring(10, 12) + g.substring(8, 10) + '-' + g.substring(14, 16) + g.substring(12, 14) + '-' + g.substring(16, 20) + '-' + g.substring(20); }
1157
1158 // Check which key pair matches the public key in the certificate
@@ -936,7 +1161,7 @@ module.exports.CreateAmtManager = function(parent) {
1161 var cert = certs[i];
1162 try {
1163 if (keys.length == 0) return;
939 - var b = obj.parent.certificateOperations.forge.asn1.fromDer(cert.X509Certificate);
1164 + var b = obj.parent.certificateOperations.forge.asn1.fromDer(cert.X509CertificateBin);
1165 var a = obj.parent.certificateOperations.forge.pki.certificateFromAsn1(b).publicKey;
1166 var publicKeyPEM = obj.parent.certificateOperations.forge.pki.publicKeyToPem(a).substring(28 + 32).replace(/(\r\n|\n|\r)/gm, "");
1167 for (var j = 0; j < keys.length; j++) {
@@ -950,6 +1175,9 @@ module.exports.CreateAmtManager = function(parent) {
1175 }
1176
1177 function Clone(v) { return JSON.parse(JSON.stringify(v)); }
1178 + function MakeToArray(v) { if (!v || v == null || typeof v == 'object') return v; return [v]; }
1179 + function getItem(x, y, z) { for (var i in x) { if (x[i][y] == z) return x[i]; } return null; }
1180 + function IntToStr(v) { return String.fromCharCode((v >> 24) & 0xFF, (v >> 16) & 0xFF, (v >> 8) & 0xFF, v & 0xFF); }
1181
1182 function parseCertName(x) {
1183 var j, r = {}, xx = x.split(',');
views/default.handlebars
+1 -1
@@ -6542,7 +6542,7 @@
6542 if (os == 16) { osn = "MeshCmd (macOS, 64bit)"; }
6543 if (os == 25) { osn = "MeshCmd (Linux ARM, 32bit)"; }
6544 QH('meshcmddownloadid', osn);
6545 - Q('meshcmddownloadid').setAttribute('href', 'meshagents?meshcmd=' + os + (urlargs.key?('&key=' + urlargs.key):''));
6545 + Q('meshcmddownloadid').onclick = function() { downloadFile('meshagents?meshcmd=' + os + (urlargs.key?('&key=' + urlargs.key):''), null, true); }
6546 }
6547
6548 function p10showiconselector() {