Intel AMT 802.1x improvements.
Ylian Saint-Hilaire committed
Apr 2, 2022 at 23:04 UTC
43d8eafd6ab377b40f403c02ef9029dd3d004e7e
1 file changed
+275
-283
amtmanager.js
+275
-283
@@ -66,6 +66,32 @@ module.exports.CreateAmtManager = function (parent) {
66
delete domain.amtmanager.environmentdetection;
67
}
68
69
+ // Check 802.1x wired profile if present
70
+ if ((domain.amtmanager['802.1x'] != null) && (typeof domain.amtmanager['802.1x'] == 'object')) {
71
+ if (domain.amtmanager['802.1x'].satellitecredentials != null) {
72
+ if (typeof domain.amtmanager['802.1x'].satellitecredentials != 'string') { delete domain.amtmanager['802.1x']; } else {
73
+ const userSplit = domain.amtmanager['802.1x'].satellitecredentials.split('/');
74
+ if (userSplit.length > 3) { delete domain.amtmanager['802.1x']; }
75
+ else if (userSplit.length == 2) { domain.amtmanager['802.1x'].satellitecredentials = 'user/' + domain.id + '/' + userSplit[1]; }
76
+ else if (userSplit.length == 1) { domain.amtmanager['802.1x'].satellitecredentials = 'user/' + domain.id + '/' + userSplit[0]; }
77
+ }
78
+ }
79
+
80
+ if ((domain.amtmanager['802.1x'].satellitecredentials != null) && (typeof domain.amtmanager['802.1x'].servercertificatename != 'string')) {
81
+ delete domain.amtmanager['802.1x'].servercertificatenamecomparison;
82
+ const serverCertCompareStrings = ['', '', 'fullname', 'domainsuffix'];
83
+ if (typeof domain.amtmanager['802.1x'].servercertificatenamecomparison == 'string') {
84
+ domain.amtmanager['802.1x'].servercertificatenamecomparison = serverCertCompareStrings.indexOf(domain.amtmanager['802.1x'].servercertificatenamecomparison.toLowerCase());
85
+ if (domain.amtmanager['802.1x'].servercertificatenamecomparison == -1) { domain.amtmanager['802.1x'].servercertificatenamecomparison = 2; } // Default to full name compare
86
+ }
87
+ }
88
+
89
+ if ((domain.amtmanager['802.1x'].satellitecredentials != null) && (typeof domain.amtmanager['802.1x'].authenticationprotocol == 'string')) {
90
+ domain.amtmanager['802.1x'].authenticationprotocol = netAuthStrings.indexOf(domain.amtmanager['802.1x'].authenticationprotocol.toLowerCase());
91
+ if (domain.amtmanager['802.1x'].authenticationprotocol == -1) { delete domain.amtmanager['802.1x']; }
92
+ }
93
+ }
94
+
95
// Check WIFI profiles
96
//var wifiAuthMethod = { 1: "Other", 2: "Open", 3: "Shared Key", 4: "WPA PSK", 5: "WPA 802.1x", 6: "WPA2 PSK", 7: "WPA2 802.1x", 32768: "WPA3 SAE IEEE 802.1x", 32769: "WPA3 OWE IEEE 802.1x" };
97
//var wifiEncMethod = { 1: "Other", 2: "WEP", 3: "TKIP", 4: "CCMP", 5: "None" }
@@ -73,7 +99,7 @@ module.exports.CreateAmtManager = function (parent) {
99
var goodWifiProfiles = [];
100
for (var i = 0; i < domain.amtmanager.wifiprofiles.length; i++) {
101
var wifiProfile = domain.amtmanager.wifiprofiles[i];
76
- if ((typeof wifiProfile.ssid == 'string') && (wifiProfile.ssid != '') && (((typeof wifiProfile.password == 'string') && (wifiProfile.password != '')) || ((typeof wifiProfile['802.1x'] == 'object') && (wifiProfile['802.1x'] != null)))) {
102
+ if ((typeof wifiProfile.ssid == 'string') && (wifiProfile.ssid != '')) {
103
if ((wifiProfile.name == null) || (wifiProfile.name == '')) { wifiProfile.name = wifiProfile.ssid; }
104
105
// Authentication
@@ -104,29 +130,7 @@ module.exports.CreateAmtManager = function (parent) {
130
if ((typeof wifiProfile.password != 'string') || (wifiProfile.password.length < 8) || (wifiProfile.password.length > 63)) continue;
131
} else if ([5, 7, 32768, 32769].indexOf(wifiProfile.authentication) >= 0) {
132
// 802.1x authentication
107
- if ((wifiProfile['802.1x'] == null) && (typeof wifiProfile['802.1x'] != 'object')) continue;
108
-
109
- if (wifiProfile['802.1x'].satellitecredentials != null) {
110
- if (typeof wifiProfile['802.1x'].satellitecredentials != 'string') continue;
111
- const userSplit = wifiProfile['802.1x'].satellitecredentials.split('/');
112
- if (userSplit.length > 3) continue;
113
- if (userSplit.length == 2) { wifiProfile['802.1x'].satellitecredentials = 'user/' + domain.id + '/' + userSplit[1]; }
114
- else if (userSplit.length == 1) { wifiProfile['802.1x'].satellitecredentials = 'user/' + domain.id + '/' + userSplit[0]; }
115
- }
116
-
117
- if (typeof wifiProfile['802.1x'].servercertificatename != 'string') {
118
- delete wifiProfile['802.1x'].servercertificatenamecomparison;
119
- const serverCertCompareStrings = ['', '', 'fullname', 'domainsuffix'];
120
- if (typeof wifiProfile['802.1x'].servercertificatenamecomparison == 'string') {
121
- wifiProfile['802.1x'].servercertificatenamecomparison = serverCertCompareStrings.indexOf(wifiProfile['802.1x'].servercertificatenamecomparison.toLowerCase());
122
- if (wifiProfile['802.1x'].servercertificatenamecomparison == -1) { wifiProfile['802.1x'].servercertificatenamecomparison = 2; } // Default to full name compare
123
- }
124
- }
125
-
126
- if (typeof wifiProfile['802.1x'].authenticationprotocol == 'string') {
127
- wifiProfile['802.1x'].authenticationprotocol = netAuthStrings.indexOf(wifiProfile['802.1x'].authenticationprotocol.toLowerCase());
128
- if (wifiProfile['802.1x'].authenticationprotocol == -1) continue;
129
- }
133
+ if (domain.amtmanager['802.1x'] == null) continue;
134
}
135
136
goodWifiProfiles.push(wifiProfile);
@@ -136,32 +140,6 @@ module.exports.CreateAmtManager = function (parent) {
140
} else {
141
delete domain.amtmanager.wifiprofiles;
142
}
139
-
140
- // Check 802.1x wired profile if present
141
- if ((domain.amtmanager['802.1x'] != null) && (typeof domain.amtmanager['802.1x'] == 'object')) {
142
- if (domain.amtmanager['802.1x'].satellitecredentials != null) {
143
- if (typeof domain.amtmanager['802.1x'].satellitecredentials != 'string') { delete domain.amtmanager['802.1x']; } else {
144
- const userSplit = domain.amtmanager['802.1x'].satellitecredentials.split('/');
145
- if (userSplit.length > 3) { delete domain.amtmanager['802.1x']; }
146
- else if (userSplit.length == 2) { domain.amtmanager['802.1x'].satellitecredentials = 'user/' + domain.id + '/' + userSplit[1]; }
147
- else if (userSplit.length == 1) { domain.amtmanager['802.1x'].satellitecredentials = 'user/' + domain.id + '/' + userSplit[0]; }
148
- }
149
- }
150
-
151
- if ((domain.amtmanager['802.1x'].satellitecredentials != null) && (typeof domain.amtmanager['802.1x'].servercertificatename != 'string')) {
152
- delete domain.amtmanager['802.1x'].servercertificatenamecomparison;
153
- const serverCertCompareStrings = ['', '', 'fullname', 'domainsuffix'];
154
- if (typeof domain.amtmanager['802.1x'].servercertificatenamecomparison == 'string') {
155
- domain.amtmanager['802.1x'].servercertificatenamecomparison = serverCertCompareStrings.indexOf(domain.amtmanager['802.1x'].servercertificatenamecomparison.toLowerCase());
156
- if (domain.amtmanager['802.1x'].servercertificatenamecomparison == -1) { domain.amtmanager['802.1x'].servercertificatenamecomparison = 2; } // Default to full name compare
157
- }
158
- }
159
-
160
- if ((domain.amtmanager['802.1x'].satellitecredentials != null) && (typeof domain.amtmanager['802.1x'].authenticationprotocol == 'string')) {
161
- domain.amtmanager['802.1x'].authenticationprotocol = netAuthStrings.indexOf(domain.amtmanager['802.1x'].authenticationprotocol.toLowerCase());
162
- if (domain.amtmanager['802.1x'].authenticationprotocol == -1) { delete domain.amtmanager['802.1x']; }
163
- }
164
- }
143
}
144
145
// Check if an Intel AMT device is being managed
@@ -417,30 +395,23 @@ module.exports.CreateAmtManager = function (parent) {
395
var devices = obj.amtDevices[event.nodeid], devFound = null;
396
if (devices != null) { for (var i in devices) { if (devices[i].netAuthSatReqId == event.reqid) { devFound = devices[i]; } } }
397
if (devFound == null) return; // Unable to find a device for this 802.1x profile
420
- const netAuthSatReqId = devFound.netAuthSatReqId;
398
delete devFound.netAuthSatReqId;
399
if (devFound.netAuthSatReqTimer != null) { clearTimeout(devFound.netAuthSatReqTimer); delete devFound.netAuthSatReqTimer; }
400
if ((event.response == null) || (typeof event.response != 'object') || (typeof event.response.authProtocol != 'number')) {
401
// Unable to create a 802.1x profile
402
if (isAmtDeviceValid(devFound) == false) return; // Device no longer exists, ignore this request.
426
- delete devFound.netAuthSatReqDev;
427
- delete devFound.netAuthSatReqSrv;
403
+ delete devFound.netAuthSatReqData;
404
devFound.consoleMsg("MeshCentral Satellite could not create a 802.1x profile for this device.");
405
devTaskCompleted(devFound);
406
} else {
407
// We got a new 802.1x profile
432
- if (devFound.netAuthCredentials == null) { devFound.netAuthCredentials = {}; }
433
- devFound.netAuthCredentials[event.response.authProtocol] = event.response;
408
+ devFound.netAuthCredentials = event.response;
409
devFound.consoleMsg("Setting MeshCentral Satellite 802.1x profile...");
410
436
- if (netAuthSatReqId.startsWith("wired-")) {
437
- // Set the 802.1x wired profile in the device
438
- var devNetAuthProfile = devFound.netAuthSatReqDev;
439
- var srvNetAuthProfile = devFound.netAuthSatReqSrv;
440
- delete devFound.netAuthSatReqDev;
441
- delete devFound.netAuthSatReqSrv;
442
- attempt8021xSyncEx(devFound, devNetAuthProfile, srvNetAuthProfile);
443
- }
411
+ // Set the 802.1x wired profile in the device
412
+ var netAuthSatReqData = devFound.netAuthSatReqData;
413
+ delete devFound.netAuthSatReqData;
414
+ attempt8021xSyncEx(devFound, netAuthSatReqData);
415
}
416
break;
417
}
@@ -727,34 +698,31 @@ module.exports.CreateAmtManager = function (parent) {
698
attemptTlsSync(dev, function (dev) {
699
// If we need to switch to TLS, do it now.
700
if (dev.switchToTls == 1) { delete dev.switchToTls; attemptInitialContact(dev); return; }
730
- // Check Intel AMT 802.1x state
731
- attempt8021xSync(dev, function (dev) {
732
- // Check Intel AMT WIFI state
733
- attemptWifiSync(dev, function (dev) {
734
- // Check Intel AMT root certificate state
735
- attemptRootCertSync(dev, function (dev) {
736
- // Check Intel AMT CIRA settings
737
- attemptCiraSync(dev, function (dev) {
738
- // Check Intel AMT settings
739
- attemptSettingsSync(dev, function (dev) {
740
- // See if we need to get hardware inventory
741
- attemptFetchHardwareInventory(dev, function (dev) {
742
- dev.consoleMsg('Done.');
743
-
744
- // Remove from task limiter if needed
745
- if (dev.taskid != null) { obj.parent.taskLimiter.completed(dev.taskid); delete dev.taskLimiter; }
746
-
747
- if (dev.connType != 2) {
748
- // Start power polling if not connected to LMS
749
- var ppfunc = function powerPoleFunction() { fetchPowerState(powerPoleFunction.dev); }
750
- ppfunc.dev = dev;
751
- dev.polltimer = new setTimeout(ppfunc, 290000); // Poll for power state every 4 minutes 50 seconds.
752
- fetchPowerState(dev);
753
- } else {
754
- // For LMS connections, close now.
755
- dev.controlMsg({ action: 'close' });
756
- }
757
- });
701
+ // Check Intel AMT 802.1x wired state and Intel AMT WIFI state (must be done both at once).
702
+ attemptWifiSync(dev, function (dev) {
703
+ // Check Intel AMT root certificate state
704
+ attemptRootCertSync(dev, function (dev) {
705
+ // Check Intel AMT CIRA settings
706
+ attemptCiraSync(dev, function (dev) {
707
+ // Check Intel AMT settings
708
+ attemptSettingsSync(dev, function (dev) {
709
+ // See if we need to get hardware inventory
710
+ attemptFetchHardwareInventory(dev, function (dev) {
711
+ dev.consoleMsg('Done.');
712
+
713
+ // Remove from task limiter if needed
714
+ if (dev.taskid != null) { obj.parent.taskLimiter.completed(dev.taskid); delete dev.taskLimiter; }
715
+
716
+ if (dev.connType != 2) {
717
+ // Start power polling if not connected to LMS
718
+ var ppfunc = function powerPoleFunction() { fetchPowerState(powerPoleFunction.dev); }
719
+ ppfunc.dev = dev;
720
+ dev.polltimer = new setTimeout(ppfunc, 290000); // Poll for power state every 4 minutes 50 seconds.
721
+ fetchPowerState(dev);
722
+ } else {
723
+ // For LMS connections, close now.
724
+ dev.controlMsg({ action: 'close' });
725
+ }
726
});
727
});
728
});
@@ -1334,55 +1302,147 @@ module.exports.CreateAmtManager = function (parent) {
1302
1303
1304
//
1337
- // Intel AMT 802.1x wired
1305
+ // Intel AMT WIFI
1306
//
1307
1340
- // This method will sync the 802.1x wired profile from the device and the server
1341
- function attempt8021xSync(dev, func) {
1308
+ // This method will sync the WIFI profiles from the device and the server, but does not care about profile priority.
1309
+ // We also sync wired 802.1x at the same time since we only allow a single 802.1x profile per device shared between wired and wireless
1310
+ // We may want to work on an alternate version that does do priority if requested.
1311
+ function attemptWifiSync(dev, func) {
1312
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1313
if (dev.policy.amtPolicy == 0) { func(dev); return; } // If there is no Intel AMT policy, skip this operation.
1344
- if (dev.connType != 2) { func(dev); return; } // Only configure 802.1x over a CIRA-LMS link.
1345
- if (parent.config.domains[dev.domainid].amtmanager['802.1x'] == null) { func(dev); return; } // No 802.1x policy, leave device as-is.
1314
+ if (dev.connType != 2) { func(dev); return; } // Only configure wireless over a CIRA-LMS link
1315
+ //if (parent.config.domains[dev.domainid].amtmanager.wifiprofiles == null) { func(dev); return; } // No server WIFI profiles set, skip this.
1316
+ //if ((dev.mpsConnection.tag.meiState == null) || (dev.mpsConnection.tag.meiState.net1 == null)) { func(dev); return; } // No WIFI on this device, skip this.
1317
1347
- // Get the current 802.1x profilee
1318
+ // Get the current list of WIFI profiles, wireless interface state and wired 802.1x profile
1319
dev.taskCount = 1;
1320
dev.taskCompleted = func;
1350
- dev.amtstack.BatchEnum(null, ['*AMT_8021XProfile'], function (stack, name, responses, status) {
1321
+
1322
+ const objQuery = ['CIM_WiFiEndpointSettings', '*CIM_WiFiPort', '*AMT_WiFiPortConfigurationService', 'CIM_IEEE8021xSettings'];
1323
+ if (parent.config.domains[dev.domainid].amtmanager['802.1x'] != null) { objQuery.push('*AMT_8021XProfile'); }
1324
+ dev.amtstack.BatchEnum(null, objQuery, function (stack, name, responses, status) {
1325
const dev = stack.dev;
1326
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1353
- if (status != 200) { devTaskCompleted(dev); return; } // We can't get the 802.1x settings, maybe no wired interface, ignore and carry on.
1327
+ if (status != 200) { devTaskCompleted(dev); return; } // We can't get wireless settings, ignore and carry on.
1328
+ const domain = parent.config.domains[dev.domainid];
1329
+
1330
+ // Check if wired 802.1x needs updating
1331
+ var newNetAuthProfileRequested = false;
1332
var devNetAuthProfile = responses['AMT_8021XProfile'].response;
1355
- var srvNetAuthProfile = parent.config.domains[dev.domainid].amtmanager['802.1x'];
1356
- var match = true;
1333
+ var srvNetAuthProfile = domain.amtmanager['802.1x'];
1334
+ var wiredMatch = 0;
1335
if ((srvNetAuthProfile === false) && (devNetAuthProfile != null)) {
1336
// Remove the 802.1x profile
1359
- match = false;
1337
+ wiredMatch = 1;
1338
} else if ((srvNetAuthProfile != null) && (devNetAuthProfile == null)) {
1339
// Device has no 802.1x, add it
1362
- match = false;
1340
+ wiredMatch = 2;
1341
} else if ((typeof srvNetAuthProfile == 'object') && (devNetAuthProfile != null)) {
1342
// Check if the existing 802.1x profile look good
1365
- if (devNetAuthProfile.AuthenticationProtocol != srvNetAuthProfile.authenticationprotocol) { match = false; }
1366
- if (devNetAuthProfile.ServerCertificateName != srvNetAuthProfile.servercertificatename) { match = false; }
1367
- if (devNetAuthProfile.ServerCertificateNameComparison != srvNetAuthProfile.servercertificatenamecomparison) { match = false; }
1368
- if (devNetAuthProfile.ActiveInS0 != srvNetAuthProfile.availableins0) { match = false; }
1343
+ if (devNetAuthProfile.AuthenticationProtocol != srvNetAuthProfile.authenticationprotocol) { wiredMatch = 2; }
1344
+ if (devNetAuthProfile.ServerCertificateName != srvNetAuthProfile.servercertificatename) { wiredMatch = 2; }
1345
+ if (devNetAuthProfile.ServerCertificateNameComparison != srvNetAuthProfile.servercertificatenamecomparison) { wiredMatch = 2; }
1346
+ if (devNetAuthProfile.ActiveInS0 != srvNetAuthProfile.availableins0) { wiredMatch = 2; }
1347
if (typeof srvNetAuthProfile.satellitecredentials != 'string') {
1348
// Credentials for this profile are in the config file
1371
- if (devNetAuthProfile.RoamingIdentity != srvNetAuthProfile.roamingidentity) { match = false; }
1372
- if (devNetAuthProfile.Username != srvNetAuthProfile.username) { match = false; }
1373
- if (devNetAuthProfile.Domain != srvNetAuthProfile.domain) { match = false; }
1349
+ if (devNetAuthProfile.RoamingIdentity != srvNetAuthProfile.roamingidentity) { wiredMatch = 2; }
1350
+ if (devNetAuthProfile.Username != srvNetAuthProfile.username) { wiredMatch = 2; }
1351
+ if (devNetAuthProfile.Domain != srvNetAuthProfile.domain) { wiredMatch = 2; }
1352
}
1353
}
1354
+ if (wiredMatch == 2) { newNetAuthProfileRequested = true; }
1355
1377
- // If there is a mismatch, set the new 802.1x profile
1378
- if (match == false) {
1379
- if ((typeof srvNetAuthProfile.satellitecredentials == 'string') && ((dev.netAuthCredentials == null) || (dev.netAuthCredentials[srvNetAuthProfile.authenticationprotocol] == null))) {
1380
- // Credentials for this profile are provided using MeshCentral Satellite
1356
+ // If we have server WIFI profiles to sync, do this now.
1357
+ if (parent.config.domains[dev.domainid].amtmanager.wifiprofiles != null) {
1358
+ // The server and device WIFI profiles, find profiles to add and remove
1359
+ const sevProfiles = parent.config.domains[dev.domainid].amtmanager.wifiprofiles;
1360
+ const devProfiles = responses['CIM_WiFiEndpointSettings'].responses;
1361
+ const netAuthProfiles = responses['CIM_IEEE8021xSettings'].responses;
1362
+ var profilesToAdd = [], profilesToRemove = [];
1363
+ var profilesToAdd2 = [], profilesToRemove2 = [];
1364
+
1365
+ // Look at the WIFI profiles in the device
1366
+ for (var i in sevProfiles) {
1367
+ var sevProfile = sevProfiles[i], wirelessMatch = false;
1368
+ for (var j in devProfiles) {
1369
+ var devProfile = devProfiles[j];
1370
+ if (
1371
+ (devProfile.ElementName == sevProfile.name) &&
1372
+ (devProfile.SSID == sevProfile.ssid) &&
1373
+ (devProfile.AuthenticationMethod == sevProfile.authentication) &&
1374
+ (devProfile.EncryptionMethod == sevProfile.encryption) &&
1375
+ (devProfile.BSSType == sevProfile.type)
1376
+ ) {
1377
+ if (([5, 7, 32768, 32769].indexOf(sevProfile.authentication)) >= 0) {
1378
+ // This is a 802.1x profile, do some extra matching.
1379
+ // Start by finding the 802.1x profile for this WIFI profile
1380
+ var netAuthProfile = null, netAuthMatch = false;
1381
+ for (var k in netAuthProfiles) { if (netAuthProfiles[k].ElementName == devProfile.ElementName) { netAuthProfile = netAuthProfiles[k]; } }
1382
+ if (netAuthProfile != null) {
1383
+ netAuthMatch = true;
1384
+ if (srvNetAuthProfile.authenticationprotocol != netAuthProfile['AuthenticationProtocol']) { netAuthMatch = false; }
1385
+ if (srvNetAuthProfile.roamingidentity != netAuthProfile['RoamingIdentity']) { netAuthMatch = false; }
1386
+ if (srvNetAuthProfile.servercertificatename != netAuthProfile['ServerCertificateName']) { netAuthMatch = false; }
1387
+ if (srvNetAuthProfile.servercertificatenamecomparison != netAuthProfile['ServerCertificateNameComparison']) { netAuthMatch = false; }
1388
+ if (typeof srvNetAuthProfile.satellitecredentials != 'string') {
1389
+ // Credentials for this profile are in the config file
1390
+ if (srvNetAuthProfile.username != netAuthProfile['Username']) { netAuthMatch = false; }
1391
+ if (srvNetAuthProfile.domain != netAuthProfile['Domain']) { netAuthMatch = false; }
1392
+ }
1393
+ }
1394
+ if (netAuthMatch == true) {
1395
+ // The 802.1x profile seems to match what we want, keep it.
1396
+ wirelessMatch = true;
1397
+ devProfile.match = true;
1398
+ }
1399
+ } else {
1400
+ // Not a 802.1x profile, looks fine, keep it.
1401
+ wirelessMatch = true;
1402
+ devProfile.match = true;
1403
+ }
1404
+ }
1405
+ }
1406
+ if (wirelessMatch == false) { profilesToAdd.push(sevProfile); } // Add non-matching profile
1407
+ if ((wirelessMatch == false) || (([5, 7, 32768, 32769].indexOf(sevProfile.authentication)) >= 0)) { profilesToAdd2.push(sevProfile); } // Add non-matching profile or 802.1x profile
1408
+ }
1409
+ for (var j in devProfiles) {
1410
+ var devProfile = devProfiles[j];
1411
+ if (devProfile.InstanceID != null) {
1412
+ if (devProfile.match !== true) { profilesToRemove.push(devProfile); } // Missing profile to remove
1413
+ if ((devProfile.match !== true) || (([5, 7, 32768, 32769].indexOf(devProfile.AuthenticationMethod)) >= 0)) { profilesToRemove2.push(devProfile); } // Missing profile to remove or 802.1x profile
1414
+ }
1415
+ }
1416
+
1417
+ // Compute what priorities are allowed
1418
+ var prioritiesInUse = [];
1419
+ for (var j in devProfiles) { if (devProfiles[j].match == true) { prioritiesInUse.push(devProfiles[j].Priority); } }
1420
+
1421
+ // Check if any other WIFI profiles require a 802.1x request to MeshCentral Satellite
1422
+ if (dev.netAuthCredentials == null) {
1423
+ for (var i in profilesToAdd) { if (([5, 7, 32768, 32769].indexOf(profilesToAdd[i].authentication)) >= 0) { newNetAuthProfileRequested = true; } }
1424
+ }
1425
+
1426
+ // If we need to request a new 802.1x profile, remove all existing 802.1x WIFI profiles and re-add later.
1427
+ if (newNetAuthProfileRequested) {
1428
+ profilesToAdd = profilesToAdd2; // Just use the second list we built for this purpose.
1429
+ profilesToRemove = profilesToRemove2;
1430
+ }
1431
+
1432
+ // Notify of WIFI profile changes
1433
+ if ((profilesToAdd.length > 0) || (profilesToRemove.length > 0)) { dev.consoleMsg("Changing WIFI profiles, adding " + profilesToAdd.length + ", removing " + profilesToRemove.length + "."); }
1434
+
1435
+ // Remove any extra WIFI profiles
1436
+ for (var i in profilesToRemove) {
1437
+ dev.amtstack.Delete('CIM_WiFiEndpointSettings', { InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + profilesToRemove[i].ElementName }, function (stack, name, responses, status) { }, 0, 1);
1438
+ }
1439
+
1440
+ if (newNetAuthProfileRequested) {
1441
+ // Credentials for this 802.1x profile are provided using MeshCentral Satellite
1442
// Send a message to Satellite requesting a 802.1x profile for this device
1443
dev.consoleMsg("Requesting 802.1x credentials for " + netAuthStrings[srvNetAuthProfile.authenticationprotocol] + " from MeshCentral Satellite...");
1383
- dev.netAuthSatReqId = 'wired-' + Buffer.from(parent.crypto.randomBytes(16), 'binary').toString('base64'); // Generate a crypto-secure request id.
1384
- dev.netAuthSatReqDev = devNetAuthProfile;
1385
- dev.netAuthSatReqSrv = srvNetAuthProfile;
1444
+ dev.netAuthSatReqId = Buffer.from(parent.crypto.randomBytes(16), 'binary').toString('base64'); // Generate a crypto-secure request id.
1445
+ dev.netAuthSatReqData = { domain: domain, devNetAuthProfile: devNetAuthProfile, srvNetAuthProfile: srvNetAuthProfile, profilesToAdd: profilesToAdd, prioritiesInUse: prioritiesInUse, responses: responses }
1446
parent.DispatchEvent([srvNetAuthProfile.satellitecredentials], obj, { action: 'satellite', satelliteFlags: 2, nodeid: dev.nodeid, domain: dev.nodeid.split('/')[1], nolog: 1, reqid: dev.netAuthSatReqId, authProtocol: srvNetAuthProfile.authenticationprotocol, devname: dev.name });
1447
1448
// Set a response timeout
@@ -1390,8 +1450,7 @@ module.exports.CreateAmtManager = function (parent) {
1450
if (isAmtDeviceValid(netAuthTimeout.dev) == false) return; // Device no longer exists, ignore this request.
1451
if (dev.netAuthSatReqId != null) {
1452
delete netAuthTimeout.dev.netAuthSatReqId;
1393
- delete netAuthTimeout.dev.netAuthSatReqDev;
1394
- delete netAuthTimeout.dev.netAuthSatReqSrv;
1453
+ delete netAuthTimeout.dev.netAuthSatReqData;
1454
netAuthTimeout.dev.consoleMsg("MeshCentral Satellite did not respond in time, 802.1x profile will not be set.");
1455
devTaskCompleted(netAuthTimeout.dev);
1456
}
@@ -1400,18 +1459,22 @@ module.exports.CreateAmtManager = function (parent) {
1459
dev.netAuthSatReqTimer = setTimeout(netAuthTimeoutFunc, 10000);
1460
return;
1461
} else {
1403
- // Set the 802.1x wired profile in the device
1404
- attempt8021xSyncEx(dev, devNetAuthProfile, srvNetAuthProfile);
1462
+ // No need to call MeshCentral Satellite for a 802.1x profile, so configure everything now.
1463
+ attemptWifiSyncEx(dev, { domain: domain, devNetAuthProfile: devNetAuthProfile, srvNetAuthProfile: srvNetAuthProfile, profilesToAdd: profilesToAdd, prioritiesInUse: prioritiesInUse, responses: responses });
1464
}
1406
- } else {
1407
- // Nothing to do
1408
- devTaskCompleted(dev);
1465
}
1466
});
1467
}
1468
1469
// Set the 802.1x wired profile
1414
- function attempt8021xSyncEx(dev, devNetAuthProfile, srvNetAuthProfile) {
1470
+ function attempt8021xSyncEx(dev, devNetAuthData) {
1471
+ // Unpack
1472
+ const domain = devNetAuthData.domain;
1473
+ const devNetAuthProfile = devNetAuthData.devNetAuthProfile;
1474
+ const srvNetAuthProfile = devNetAuthData.srvNetAuthProfile;
1475
+ const profilesToAdd = devNetAuthData.profilesToAdd;
1476
+ const responses = devNetAuthData.responses;
1477
+
1478
var netAuthProfile = Clone(devNetAuthProfile);
1479
netAuthProfile['Enabled'] = ((srvNetAuthProfile != null) && (typeof srvNetAuthProfile == 'object'));
1480
if (netAuthProfile['Enabled']) {
@@ -1440,8 +1503,8 @@ module.exports.CreateAmtManager = function (parent) {
1503
netAuthProfile['PxeTimeout'] = (typeof srvNetAuthProfile.pxetimeoutinseconds == 'number') ? srvNetAuthProfile.pxetimeoutinseconds : 120;
1504
1505
// If we have a MeshCentral Satellite profile, use that
1443
- if ((dev.netAuthCredentials != null) && (dev.netAuthCredentials[srvNetAuthProfile.authenticationprotocol] != null)) {
1444
- const srvNetAuthProfile2 = dev.netAuthCredentials[srvNetAuthProfile.authenticationprotocol];
1506
+ if (dev.netAuthCredentials != null) {
1507
+ const srvNetAuthProfile2 = dev.netAuthCredentials;
1508
if (srvNetAuthProfile2.username && (srvNetAuthProfile2.username != '')) { netAuthProfile['Username'] = srvNetAuthProfile2.username; }
1509
if (srvNetAuthProfile2.password && (srvNetAuthProfile2.password != '')) { netAuthProfile['Password'] = srvNetAuthProfile2.password; }
1510
if (srvNetAuthProfile2.domain && (srvNetAuthProfile2.domain != '')) { netAuthProfile['Domain'] = srvNetAuthProfile2.domain; }
@@ -1451,171 +1514,100 @@ module.exports.CreateAmtManager = function (parent) {
1514
const dev = stack.dev;
1515
if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1516
if (status == 200) { dev.consoleMsg("802.1x wired profile set."); }
1454
- devTaskCompleted(dev);
1517
+ attemptWifiSyncEx(dev, devNetAuthData);
1518
});
1519
}
1520
1458
- //
1459
- // Intel AMT WIFI
1460
- //
1461
-
1462
- // This method will sync the WIFI profiles from the device and the server, but does not care about profile priority.
1463
- // We may want to work on an alternate version that does do priority if requested.
1464
- function attemptWifiSync(dev, func) {
1465
- if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1466
- if (dev.policy.amtPolicy == 0) { func(dev); return; } // If there is no Intel AMT policy, skip this operation.
1467
- if (dev.connType != 2) { func(dev); return; } // Only configure wireless over a CIRA-LMS link
1468
- //if (parent.config.domains[dev.domainid].amtmanager.wifiprofiles == null) { func(dev); return; } // No server WIFI profiles set, skip this.
1469
- if ((dev.mpsConnection.tag.meiState == null) || (dev.mpsConnection.tag.meiState.net1 == null)) { func(dev); return; } // No WIFI on this device, skip this.
1470
-
1471
- // Get the current list of WIFI profiles and wireless interface state
1472
- dev.taskCount = 1;
1473
- dev.taskCompleted = func;
1474
- dev.amtstack.BatchEnum(null, ['CIM_WiFiEndpointSettings', '*CIM_WiFiPort', '*AMT_WiFiPortConfigurationService', 'CIM_IEEE8021xSettings'], function (stack, name, responses, status) {
1475
- const dev = stack.dev;
1476
- if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1477
- if (status != 200) { devTaskCompleted(dev); return; } // We can't get wireless settings, ignore and carry on.
1478
-
1479
- // If we have server WIFI profiles to sync, do this now.
1480
- if (parent.config.domains[dev.domainid].amtmanager.wifiprofiles != null) {
1481
- // The server and device WIFI profiles, find profiles to add and remove
1482
- const sevProfiles = parent.config.domains[dev.domainid].amtmanager.wifiprofiles;
1483
- const devProfiles = responses['CIM_WiFiEndpointSettings'].responses;
1484
- const netAuthProfiles = responses['CIM_IEEE8021xSettings'].responses;
1485
- var profilesToAdd = [], profilesToRemove = [];
1486
-
1487
- // Look at the WIFI profiles in the device
1488
- for (var i in sevProfiles) {
1489
- var sevProfile = sevProfiles[i], match = false;
1490
- for (var j in devProfiles) {
1491
- var devProfile = devProfiles[j];
1492
- if (
1493
- (devProfile.ElementName == sevProfile.name) &&
1494
- (devProfile.SSID == sevProfile.ssid) &&
1495
- (devProfile.AuthenticationMethod == sevProfile.authentication) &&
1496
- (devProfile.EncryptionMethod == sevProfile.encryption) &&
1497
- (devProfile.BSSType == sevProfile.type)
1498
- ) {
1499
- if (([5, 7, 32768, 32769].indexOf(sevProfile.authentication)) >= 0) {
1500
- // This is a 802.1x profile, do some extra matching.
1501
- // Start by finding the 802.1x profile for this WIFI profile
1502
- var netAuthProfile = null, netAuthMatch = false;
1503
- for (var k in netAuthProfiles) { if (netAuthProfiles[k].ElementName == devProfile.ElementName) { netAuthProfile = netAuthProfiles[k]; } }
1504
- if (netAuthProfile != null) {
1505
- netAuthMatch = true;
1506
- if (sevProfile['802.1x'].authenticationprotocol != netAuthProfile['AuthenticationProtocol']) { netAuthMatch = false; }
1507
- if (sevProfile['802.1x'].roamingidentity != netAuthProfile['RoamingIdentity']) { netAuthMatch = false; }
1508
- if (sevProfile['802.1x'].servercertificatename != netAuthProfile['ServerCertificateName']) { netAuthMatch = false; }
1509
- if (sevProfile['802.1x'].servercertificatenamecomparison != netAuthProfile['ServerCertificateNameComparison']) { netAuthMatch = false; }
1510
- if (sevProfile['802.1x'].username != netAuthProfile['Username']) { netAuthMatch = false; }
1511
- if (sevProfile['802.1x'].domain != netAuthProfile['Domain']) { netAuthMatch = false; }
1512
- }
1513
- if (netAuthMatch == true) {
1514
- // The 802.1x profile seems to match what we want
1515
- match = true;
1516
- devProfile.match = true;
1517
- }
1518
- } else {
1519
- // Not a 802.1x profile, match now.
1520
- match = true;
1521
- devProfile.match = true;
1522
- }
1523
- }
1524
- }
1525
- if (match == false) { profilesToAdd.push(sevProfile); }
1526
- }
1527
- for (var j in devProfiles) {
1528
- var devProfile = devProfiles[j];
1529
- if ((devProfile.match !== true) && (devProfile.InstanceID != null)) { profilesToRemove.push(devProfile); }
1530
- }
1531
-
1532
- // Compute what priorities are allowed
1533
- var prioritiesInUse = [];
1534
- for (var j in devProfiles) { if (devProfiles[j].match == true) { prioritiesInUse.push(devProfiles[j].Priority); } }
1535
-
1536
- // Notify of WIFI profile changes
1537
- if ((profilesToAdd.length > 0) || (profilesToRemove.length > 0)) { dev.consoleMsg("Changing WIFI profiles, adding " + profilesToAdd.length + ", removing " + profilesToRemove.length + "."); }
1538
-
1539
- // Remove any extra WIFI profiles
1540
- for (var i in profilesToRemove) {
1541
- dev.amtstack.Delete('CIM_WiFiEndpointSettings', { InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + profilesToRemove[i].ElementName }, function (stack, name, responses, status) { }, 0, 1);
1542
- }
1543
-
1544
- // Add missing WIFI profiles
1545
- var nextPriority = 0;
1546
- for (var i in profilesToAdd) {
1547
- while (prioritiesInUse.indexOf(nextPriority) >= 0) { nextPriority++; } // Figure out the next available priority slot.
1548
- var profileToAdd = profilesToAdd[i];
1549
- const wifiep = {
1550
- __parameterType: 'reference',
1551
- __resourceUri: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint',
1552
- Name: 'WiFi Endpoint 0'
1553
- };
1554
- const wifiepsettinginput = {
1555
- __parameterType: 'instance',
1556
- __namespace: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings',
1557
- ElementName: profileToAdd.name,
1558
- InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + profileToAdd.name,
1559
- AuthenticationMethod: profileToAdd.authentication,
1560
- EncryptionMethod: profileToAdd.encryption,
1561
- SSID: profileToAdd.ssid,
1562
- Priority: nextPriority,
1563
- }
1564
- var netAuthProfile, netAuthSettingsClientCert, netAuthSettingsServerCaCert;
1565
- if (([4, 6].indexOf(profileToAdd.authentication)) >= 0) { wifiepsettinginput['PSKPassPhrase'] = profileToAdd.password; }
1566
- if (([5, 7, 32768, 32769].indexOf(profileToAdd.authentication)) >= 0) {
1567
- netAuthProfile = {
1568
- '__parameterType': 'instance',
1569
- '__namespace': dev.amtstack.CompleteName('CIM_IEEE8021xSettings'),
1570
- 'ElementName': '8021x-' + profileToAdd.name,
1571
- 'InstanceID': '8021x-' + profileToAdd.name,
1572
- 'ActiveInS0': (profileToAdd['802.1x'].availableins0 !== false),
1573
- 'AuthenticationProtocol': profileToAdd['802.1x'].authenticationprotocol
1574
- };
1575
- if (profileToAdd['802.1x'].roamingidentity) { netAuthProfile['RoamingIdentity'] = profileToAdd['802.1x'].roamingidentity; }
1576
- if (profileToAdd['802.1x'].servercertificatename) { netAuthProfile['ServerCertificateName'] = profileToAdd['802.1x'].servercertificatename; netAuthProfile['ServerCertificateNameComparison'] = profileToAdd['802.1x'].servercertificatenamecomparison; }
1577
- if (profileToAdd['802.1x'].username) { netAuthProfile['Username'] = profileToAdd['802.1x'].username; }
1578
- if (profileToAdd['802.1x'].password) { netAuthProfile['Password'] = profileToAdd['802.1x'].password; }
1579
- if (profileToAdd['802.1x'].domain) { netAuthProfile['Domain'] = profileToAdd['802.1x'].domain; }
1580
- if (profileToAdd['802.1x'].authenticationprotocol > 3) { netAuthProfile['ProtectedAccessCredential'] = profileToAdd['802.1x'].protectedaccesscredentialhex; netAuthProfile['PACPassword'] = profileToAdd['802.1x'].pacpassword; }
1581
- //if (parseInt(Q('idx_d12clientcert').value) >= 0) { netAuthSettingsClientCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</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_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12clientcert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
1582
- //if (parseInt(Q('idx_d12servercert').value) >= 0) { netAuthSettingsServerCaCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</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_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12servercert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
1583
- }
1584
- prioritiesInUse.push(nextPriority); // Occupy the priority slot and add the WIFI profile.
1585
- dev.amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(wifiep, wifiepsettinginput, netAuthProfile, netAuthSettingsClientCert, netAuthSettingsServerCaCert, function (stack, name, responses, status) { });
1521
+ function attemptWifiSyncEx(dev, devNetAuthData) {
1522
+ // Unpack
1523
+ var domain = devNetAuthData.domain;
1524
+ var devNetAuthProfile = devNetAuthData.devNetAuthProfile;
1525
+ var srvNetAuthProfile = devNetAuthData.srvNetAuthProfile;
1526
+ var profilesToAdd = devNetAuthData.profilesToAdd;
1527
+ var responses = devNetAuthData.responses;
1528
+ var prioritiesInUse = devNetAuthData.prioritiesInUse;
1529
+
1530
+ // Add missing WIFI profiles
1531
+ var nextPriority = 0;
1532
+ for (var i in profilesToAdd) {
1533
+ while (prioritiesInUse.indexOf(nextPriority) >= 0) { nextPriority++; } // Figure out the next available priority slot.
1534
+ var profileToAdd = profilesToAdd[i];
1535
+ const wifiep = {
1536
+ __parameterType: 'reference',
1537
+ __resourceUri: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpoint',
1538
+ Name: 'WiFi Endpoint 0'
1539
+ };
1540
+ const wifiepsettinginput = {
1541
+ __parameterType: 'instance',
1542
+ __namespace: 'http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_WiFiEndpointSettings',
1543
+ ElementName: profileToAdd.name,
1544
+ InstanceID: 'Intel(r) AMT:WiFi Endpoint Settings ' + profileToAdd.name,
1545
+ AuthenticationMethod: profileToAdd.authentication,
1546
+ EncryptionMethod: profileToAdd.encryption,
1547
+ SSID: profileToAdd.ssid,
1548
+ Priority: nextPriority,
1549
+ }
1550
+ var netAuthProfile, netAuthSettingsClientCert, netAuthSettingsServerCaCert;
1551
+ if (([4, 6].indexOf(profileToAdd.authentication)) >= 0) { wifiepsettinginput['PSKPassPhrase'] = profileToAdd.password; }
1552
+ if (([5, 7, 32768, 32769].indexOf(profileToAdd.authentication)) >= 0) {
1553
+ netAuthProfile = {
1554
+ '__parameterType': 'instance',
1555
+ '__namespace': dev.amtstack.CompleteName('CIM_IEEE8021xSettings'),
1556
+ 'ElementName': '8021x-' + profileToAdd.name,
1557
+ 'InstanceID': '8021x-' + profileToAdd.name,
1558
+ 'ActiveInS0': (domain.amtmanager['802.1x'].availableins0 !== false),
1559
+ 'AuthenticationProtocol': domain.amtmanager['802.1x'].authenticationprotocol
1560
+ };
1561
+ if (domain.amtmanager['802.1x'].roamingidentity) { netAuthProfile['RoamingIdentity'] = domain.amtmanager['802.1x'].roamingidentity; }
1562
+ if (domain.amtmanager['802.1x'].servercertificatename) { netAuthProfile['ServerCertificateName'] = domain.amtmanager['802.1x'].servercertificatename; netAuthProfile['ServerCertificateNameComparison'] = profileToAdd['802.1x'].servercertificatenamecomparison; }
1563
+ if (domain.amtmanager['802.1x'].username) { netAuthProfile['Username'] = domain.amtmanager['802.1x'].username; }
1564
+ if (domain.amtmanager['802.1x'].password) { netAuthProfile['Password'] = domain.amtmanager['802.1x'].password; }
1565
+ if (domain.amtmanager['802.1x'].domain) { netAuthProfile['Domain'] = domain.amtmanager['802.1x'].domain; }
1566
+ if (domain.amtmanager['802.1x'].authenticationprotocol > 3) { domain.amtmanager['ProtectedAccessCredential'] = profileToAdd['802.1x'].protectedaccesscredentialhex; netAuthProfile['PACPassword'] = profileToAdd['802.1x'].pacpassword; }
1567
+ //if (parseInt(Q('idx_d12clientcert').value) >= 0) { netAuthSettingsClientCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</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_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12clientcert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
1568
+ //if (parseInt(Q('idx_d12servercert').value) >= 0) { netAuthSettingsServerCaCert = '<Address xmlns="http://schemas.xmlsoap.org/ws/2004/08/addressing">http://schemas.xmlsoap.org/ws/2004/08/addressing</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_PublicKeyCertificate</ResourceURI><SelectorSet xmlns="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd"><Selector Name="InstanceID">' + xxCertificates[parseInt(Q('idx_d12servercert').value)]['InstanceID'] + '</Selector></SelectorSet></ReferenceParameters>'; }
1569
+
1570
+ // If we have credentials from MeshCentral Satelite, use that
1571
+ if (dev.netAuthCredentials != null) {
1572
+ const srvNetAuthProfile2 = dev.netAuthCredentials;
1573
+ if (srvNetAuthProfile2.username && (srvNetAuthProfile2.username != '')) { netAuthProfile['Username'] = srvNetAuthProfile2.username; }
1574
+ if (srvNetAuthProfile2.password && (srvNetAuthProfile2.password != '')) { netAuthProfile['Password'] = srvNetAuthProfile2.password; }
1575
+ if (srvNetAuthProfile2.domain && (srvNetAuthProfile2.domain != '')) { netAuthProfile['Domain'] = srvNetAuthProfile2.domain; }
1576
}
1577
}
1578
+ prioritiesInUse.push(nextPriority); // Occupy the priority slot and add the WIFI profile.
1579
+ dev.amtstack.AMT_WiFiPortConfigurationService_AddWiFiSettings(wifiep, wifiepsettinginput, netAuthProfile, netAuthSettingsClientCert, netAuthSettingsServerCaCert, function (stack, name, responses, status) { });
1580
+ }
1581
1589
- // Check if local WIFI profile sync is enabled, if not, enabled it.
1590
- if ((responses['AMT_WiFiPortConfigurationService'] != null) && (responses['AMT_WiFiPortConfigurationService'].response != null) && (responses['AMT_WiFiPortConfigurationService'].response['localProfileSynchronizationEnabled'] == 0)) {
1591
- responses['AMT_WiFiPortConfigurationService'].response['localProfileSynchronizationEnabled'] = 1;
1592
- dev.amtstack.Put('AMT_WiFiPortConfigurationService', responses['AMT_WiFiPortConfigurationService'].response, function (stack, name, response, status) {
1593
- if (status != 200) { dev.consoleMsg("Unable to enable local WIFI profile sync."); } else { dev.consoleMsg("Enabled local WIFI profile sync."); }
1594
- });
1595
- }
1582
+ // Check if local WIFI profile sync is enabled, if not, enabled it.
1583
+ if ((responses['AMT_WiFiPortConfigurationService'] != null) && (responses['AMT_WiFiPortConfigurationService'].response != null) && (responses['AMT_WiFiPortConfigurationService'].response['localProfileSynchronizationEnabled'] == 0)) {
1584
+ responses['AMT_WiFiPortConfigurationService'].response['localProfileSynchronizationEnabled'] = 1;
1585
+ dev.amtstack.Put('AMT_WiFiPortConfigurationService', responses['AMT_WiFiPortConfigurationService'].response, function (stack, name, response, status) {
1586
+ if (status != 200) { dev.consoleMsg("Unable to enable local WIFI profile sync."); } else { dev.consoleMsg("Enabled local WIFI profile sync."); }
1587
+ });
1588
+ }
1589
1597
- // Change the WIFI state if needed. Right now, we always enable it.
1598
- // WifiState = { 3: "Disabled", 32768: "Enabled in S0", 32769: "Enabled in S0, Sx/AC" };
1599
- var wifiState = 32769; // For now, always enable WIFI
1600
- if (responses['CIM_WiFiPort'].responses.Body.EnabledState != 32769) {
1601
- if (wifiState == 3) {
1602
- dev.amtstack.CIM_WiFiPort_RequestStateChange(wifiState, null, function (stack, name, responses, status) {
1603
- const dev = stack.dev;
1604
- if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1605
- if (status == 200) { dev.consoleMsg("Disabled WIFI."); }
1606
- });
1607
- } else {
1608
- dev.amtstack.CIM_WiFiPort_RequestStateChange(wifiState, null, function (stack, name, responses, status) {
1609
- const dev = stack.dev;
1610
- if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1611
- if (status == 200) { dev.consoleMsg("Enabled WIFI."); }
1612
- });
1613
- }
1590
+ // Change the WIFI state if needed. Right now, we always enable it.
1591
+ // WifiState = { 3: "Disabled", 32768: "Enabled in S0", 32769: "Enabled in S0, Sx/AC" };
1592
+ var wifiState = 32769; // For now, always enable WIFI
1593
+ if (responses['CIM_WiFiPort'].responses.Body.EnabledState != 32769) {
1594
+ if (wifiState == 3) {
1595
+ dev.amtstack.CIM_WiFiPort_RequestStateChange(wifiState, null, function (stack, name, responses, status) {
1596
+ const dev = stack.dev;
1597
+ if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1598
+ if (status == 200) { dev.consoleMsg("Disabled WIFI."); }
1599
+ });
1600
+ } else {
1601
+ dev.amtstack.CIM_WiFiPort_RequestStateChange(wifiState, null, function (stack, name, responses, status) {
1602
+ const dev = stack.dev;
1603
+ if (isAmtDeviceValid(dev) == false) return; // Device no longer exists, ignore this request.
1604
+ if (status == 200) { dev.consoleMsg("Enabled WIFI."); }
1605
+ });
1606
}
1607
+ }
1608
1616
- // Done
1617
- devTaskCompleted(dev);
1618
- });
1609
+ // Done
1610
+ devTaskCompleted(dev);
1611
}
1612
1613