Added Intel AMT DDNS support to MeshCMD.
Ylian Saint-Hilaire committed
Nov 16, 2021 at 15:24 UTC
7ab641ed9e325f1a6f39684d81f19e67ba5ec825
4 files changed
+82
-1
agents/MeshCentralRouter.exe
Binary files a/agents/MeshCentralRouter.exe and b/agents/MeshCentralRouter.exe differ
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
agents/meshcmd.js
+82
-1
@@ -110,7 +110,7 @@ function run(argv) {
110
//console.log('addedModules = ' + JSON.stringify(addedModules));
111
var actionpath = 'meshaction.txt';
112
if (args.actionfile != null) { actionpath = args.actionfile; }
113
- var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTINFO', 'AMTINFOJSON', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE', 'AMTSTARTCONFIG', 'AMTSTOPCONFIG'];
113
+ var actions = ['HELP', 'ROUTE', 'MICROLMS', 'AMTCONFIG', 'AMTSCAN', 'AMTPOWER', 'AMTFEATURES', 'AMTNETWORK', 'AMTINFO', 'AMTINFOJSON', 'AMTVERSIONS', 'AMTHASHES', 'AMTSAVESTATE', 'AMTUUID', 'AMTCCM', 'AMTDEACTIVATE', 'AMTACMDEACTIVATE', 'SMBIOS', 'RAWSMBIOS', 'MESHCOMMANDER', 'AMTAUDITLOG', 'AMTEVENTLOG', 'AMTPRESENCE', 'AMTWIFI', 'AMTWAKE', 'AMTSTARTCONFIG', 'AMTSTOPCONFIG', 'AMTDDNS'];
114
115
// Load the action file
116
var actionfile = null;
@@ -201,6 +201,7 @@ function run(argv) {
201
console.log(' AmtWifi - Intel AMT Wifi interface settings.');
202
console.log(' AmtWake - Intel AMT Wake Alarms.');
203
console.log(' AmtRPE - Intel AMT Remote Platform Erase.');
204
+ console.log(' AmtDDNS - Intel AMT DDNS settings.');
205
console.log('\r\nHelp on a specific action using:\r\n');
206
console.log(' meshcmd help [action]');
207
exit(0); return;
@@ -416,6 +417,15 @@ function run(argv) {
417
console.log(' --nvm Perform clear BIOS NVM variables.');
418
console.log(' --bios Perform BIOS reload of golden configuration.');
419
console.log(' --csme Perform CSME unconfigure.');
420
+ } else if (action == 'amtddns') {
421
+ console.log('AmtDDNS is used to query and set the Intel AMT dynamic DNS settings. Example usage:\r\n\r\n meshcmd amtddns --host 1.2.3.4 --user admin --pass mypassword');
422
+ console.log('\r\nRequired arguments:\r\n');
423
+ console.log(' --host [hostname] The IP address or DNS name of Intel AMT, 127.0.0.1 is default.');
424
+ console.log(' --pass [password] The Intel AMT login password.');
425
+ console.log('\r\nOptional arguments:\r\n');
426
+ console.log(' --set [disabled/dhcp/enabled] Set the dynamic DNS mode.');
427
+ console.log(' --interval [minutes] Set update interval in minutes, default is 1440, minimum is 20.');
428
+ console.log(' --ttl [seconds] Set time to live, default is 900.');
429
} else {
430
actions.shift();
431
console.log('Invalid action, usage:\r\n\r\n meshcmd help [action]\r\n\r\nValid actions are: ' + actions.join(', ') + '.');
@@ -784,6 +794,15 @@ function run(argv) {
794
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
795
if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
796
performAmtPlatformErase(args);
797
+ } else if (settings.action == 'amtddns') { // Perform Intel AMT dynamic DNS get/set
798
+ if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
799
+ if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
800
+ if ((settings.username == null) || (typeof settings.username != 'string') || (settings.username == '')) { settings.username = 'admin'; }
801
+ if (args.set != null) { args.set = args.set.toLowerCase(); }
802
+ if ((args.set != null) && (args.set != 'enabled') && (args.set != 'dhcp') && (args.set != 'disabled')) { console.log('Intel AMT DDNS can only bet set to "enabled", "dhcp" or "disabled".'); }
803
+ if (args.interval != null) { args.interval = parseInt(args.interval); if ((typeof args.interval != 'number') || (isNaN(args.interval))) { console.log('Interval must be a number.'); exit(1); return; } if (args.interval < 20) { console.log('Interval must be at least 20 minutes.'); exit(1); return; } }
804
+ if (args.ttl != null) { args.ttl = parseInt(args.ttl); if ((typeof args.ttl != 'number') || (isNaN(args.ttl))) { console.log('TTL must be a number.'); exit(1); return; } }
805
+ performAmtDynamicDNS(args);
806
} else if (settings.action == 'amtfeatures') { // Perform remote Intel AMT feature configuration operation
807
if (settings.hostname == null) { settings.hostname = '127.0.0.1'; }
808
if ((settings.password == null) || (typeof settings.password != 'string') || (settings.password == '')) { console.log('No or invalid \"password\" specified, use --password [password].'); exit(1); return; }
@@ -2621,6 +2640,68 @@ function performAmtWakeConfig1(stack, name, response, status, args) {
2640
}
2641
2642
2643
+//
2644
+// Intel AMT Dinamic DNS
2645
+//
2646
+
2647
+function performAmtDynamicDNS(args) {
2648
+ var transport = require('amt-wsman-duk');
2649
+ var wsman = require('amt-wsman');
2650
+ var amt = require('amt');
2651
+ wsstack = new wsman(transport, settings.hostname, settings.tls ? 16993 : 16992, settings.username, settings.password, settings.tls);
2652
+ amtstack = new amt(wsstack);
2653
+ amtstack.BatchEnum(null, ['*AMT_GeneralSettings'], performAmtDynamicDNS1, args);
2654
+}
2655
+
2656
+function performAmtDynamicDNS1(stack, name, response, status, args) {
2657
+ debug(0, "performAmtDynamicDNS1(" + status + "): " + JSON.stringify(response, null, 2));
2658
+ if (status == 200) {
2659
+ // View the current state
2660
+ var body = response['AMT_GeneralSettings'].responses.Body;
2661
+ var ddnsenabled = body['DDNSUpdateEnabled'];
2662
+ var ddnsserver = body['DDNSUpdateByDHCPServerEnabled'];
2663
+ var ddnsinverval = body['DDNSPeriodicUpdateInterval'];
2664
+ var ddnsttl = body['DDNSTTL'];
2665
+ var ddnsmode = (ddnsenabled == false) ? ((ddnsserver == true) ? 'DHCP' : 'Disabled') : 'Enabled';
2666
+ if (args.set || args.ttl || args.interval) {
2667
+ if (args.set == 'enabled') {
2668
+ body['DDNSUpdateEnabled'] = true;
2669
+ body['DDNSUpdateByDHCPServerEnabled'] = false;
2670
+ } else {
2671
+ if (args.set == 'dhcp') {
2672
+ body['DDNSUpdateEnabled'] = false;
2673
+ body['DDNSUpdateByDHCPServerEnabled'] = true;
2674
+ } else {
2675
+ body['DDNSUpdateEnabled'] = false;
2676
+ body['DDNSUpdateByDHCPServerEnabled'] = false;
2677
+ }
2678
+ }
2679
+ if (args.interval) { body['DDNSPeriodicUpdateInterval'] = args.interval; }
2680
+ if (args.ttl) { body['DDNSTTL'] = args.ttl; }
2681
+ amtstack.Put('AMT_GeneralSettings', body, function (stack, name, response, status, args) {
2682
+ if (status == 200) {
2683
+ delete args.set;
2684
+ delete args.ttl;
2685
+ delete args.interval;
2686
+ amtstack.BatchEnum(null, ['*AMT_GeneralSettings'], performAmtDynamicDNS1, args);
2687
+ } else {
2688
+ console.log('Unable to set new values, error: ' + status);
2689
+ exit(1);
2690
+ }
2691
+ }, args);
2692
+ } else {
2693
+ if (ddnsmode == 'Enabled') {
2694
+ console.log('Intel AMT DDNS mode: ' + ddnsmode + ', TTL: ' + ddnsttl + ' minute(s), Update Interval: ' + ddnsinverval + ' seconds(s).');
2695
+ } else {
2696
+ console.log('Intel AMT DDNS mode: ' + ddnsmode + '.');
2697
+ }
2698
+ exit(1);
2699
+ }
2700
+ } else { console.log("Error, status " + status + "."); exit(1); }
2701
+}
2702
+
2703
+
2704
+
2705
//
2706
// Intel AMT Remote Platform Erase
2707
//