Added meshcmd amtconfig --dnssuffix override switch.

Ylian Saint-Hilaire committed Jul 14, 2021 at 12:47 UTC 3a74eb0919e06dcee889d4892964290b7a25dc06
1 file changed +10 -5
agents/meshcmd.js
+10 -5
@@ -155,6 +155,7 @@ function run(argv) {
155 if ((typeof args.timeout) == 'string') { settings.timeout = parseInt(args.timeout); }
156 if ((typeof args.uuidoutput) == 'string' || args.uuidoutput) { settings.uuidoutput = args.uuidoutput; }
157 if ((typeof args.desc) == 'string') { settings.desc = args.desc; }
158 + if ((typeof args.dnssuffix) == 'string') { settings.dnssuffix = args.dnssuffix; }
159 if (args.emailtoken) { settings.emailtoken = true; }
160 if (args.smstoken) { settings.smstoken = true; }
161 if (args.debug === true) { settings.debuglevel = 1; }
@@ -245,6 +246,7 @@ function run(argv) {
246 console.log(' --user [username] The Intel AMT admin username, admin is default.');
247 console.log(' --pass [password] The Intel AMT admin password.');
248 console.log(' --desc [description] Description of the device, used when first added to server.');
249 + console.log(' --dnssuffix [dns] Override the trusted DNS suffix sent to the server.');
250 } else if (action == 'amtdeactivate') {
251 console.log('AmtDeactivate will attempt to deactivate Intel AMT on this computer when in client control mode (CCM). The command must be run on a computer with Intel AMT, must run as administrator and the Intel management driver must be installed. Intel AMT must be activated in client control mode for this command to work. Example usage:\r\n\r\n meshcmd amtdeactivate');
252 } else if (action == 'amtacmdeactivate') {
@@ -540,7 +542,7 @@ function run(argv) {
542 amtMei.getUuid(function (result) { if ((result != null) && (result.uuid != null)) { mestate.uuid = result.uuid; } });
543 amtMei.getRemoteAccessConnectionStatus(function (result) { if ((result != null) && (result.status == 0)) { mestate.networkStatus = result.networkStatus; mestate.remoteAccessStatus = result.remoteAccessStatus; mestate.remoteAccessTrigger = result.remoteAccessTrigger; mestate.mpsHostname = result.mpsHostname; } });
544 amtMei.getDnsSuffix(function (result) {
543 - if (result) { mestate.dns = result; }
545 + if (result) { mestate.DnsSuffix = result; }
546 if (mestate.ver && mestate.ProvisioningState && mestate.ProvisioningMode) {
547 var str = 'Intel ME v' + mestate.ver;
548 if (mestate.sku & 8) { str = 'Intel AMT v' + mestate.ver }
@@ -561,9 +563,9 @@ function run(argv) {
563 if (mestate.net0 != null) { str += '\r\nWired ' + ((mestate.net0.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net0.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net0.mac + (mestate.net0.address == '0.0.0.0' ? '' : (', ' + mestate.net0.address)); }
564 if (mestate.net1 != null) { str += '\r\nWireless ' + ((mestate.net1.enabled == 1) ? 'Enabled' : 'Disabled') + ((mestate.net1.dhcpEnabled == 1) ? ', DHCP' : ', Static') + ', ' + mestate.net1.mac + (mestate.net1.address == '0.0.0.0' ? '' : (', ' + mestate.net1.address)); }
565 if ((mestate.net0 != null) && (mestate.net0.enabled == 1)) {
564 - if (mestate.dns != null) {
566 + if (mestate.DnsSuffix != null) {
567 // Intel AMT has a trusted DNS suffix set, use that one.
566 - str += '\r\nTrusted DNS suffix: ' + mestate.dns;
568 + str += '\r\nTrusted DNS suffix: ' + mestate.DnsSuffix;
569 } else {
570 // Look for the DNS suffix for the Intel AMT Ethernet interface
571 var fqdn = null, interfaces = require('os').networkInterfaces();
@@ -1159,6 +1161,9 @@ function configureAmt2(err, state) {
1161 if ((typeof settings.username == 'string') && (settings.username != '')) { state.amtuser = settings.username; }
1162 }
1163
1164 + // If a DNS suffix override is provided, use that
1165 + if (settings.dnssuffix != null) { state.DnsSuffix = settings.dnssuffix; }
1166 +
1167 // If a description is provided, send it to the server
1168 if ((typeof settings.desc == 'string') && (settings.desc != '')) { state.desc = settings.desc; }
1169
@@ -1422,7 +1427,7 @@ function saveEntireAmtStateDone() {
1427 //
1428
1429 // Get Intel AMT information using MEI
1425 -// TODO: If this call is called many time at once, it's going to cause issues.
1430 +// TODO: If this call is called many time at once, it's going to cause issues - Should be fixed since amtMei is now a singleton.
1431 var getAmtInfoFetching = null;
1432 var getAmtInfoFetchingTimer = null;
1433 function getAmtInfo(func, tag) {
@@ -1449,7 +1454,7 @@ function getAmtInfo(func, tag) {
1454 amtMei.getEHBCState(function (result) { if ((result != null) && (result.EHBC == true)) { amtMeiTmpState.Flags += 1; } });
1455 amtMei.getControlMode(function (result) { if (result != null) { if (result.controlMode == 1) { amtMeiTmpState.Flags += 2; } if (result.controlMode == 2) { amtMeiTmpState.Flags += 4; } } });
1456 //amtMei.getMACAddresses(function (result) { if (result != null) { amtMeiTmpState.mac = result; } });
1452 - amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.dns = result; } });
1457 + amtMei.getDnsSuffix(function (result) { if (result != null) { amtMeiTmpState.DnsSuffix = result; } });
1458 amtMei.getHashHandles(function (handles) {
1459 exitOnCount = handles.length;
1460 for (var i = 0; i < handles.length; ++i) {