Improved MeshCMD AMTNETWORK command.
Ylian Saint-Hilaire committed
Jul 16, 2019 at 12:25 UTC
b4fef4bc2c50030f221ca470ab601d4bc43aea5c
5 files changed
+73
-41
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
+36
-20
@@ -318,6 +318,7 @@ function run(argv) {
318
console.log('\r\nOptional arguments:\r\n');
319
console.log(' --user [username] The Intel AMT login username, admin is default.');
320
console.log(' --tls Specifies that TLS must be used.');
321
+ console.log(' --ipsync [0 or 1] Change the wired IPSync setting on Intel AMT 7+');
322
console.log(' --dhcp Change IPv4 wired interface to DHCP mode');
323
console.log(' --static Change IPv4 wired interface to static IP mode');
324
console.log(' --ip [1.2.3.4] Static IPv4 address (required)');
@@ -2215,46 +2216,61 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2216
2217
// Check if configuration change is required
2218
if (args) {
2219
+ var docall = false;
2220
+ var x = JSON.parse(JSON.stringify(response['AMT_EthernetPortSettings'].responses[amtwiredif]));
2221
+ var y = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2222
+ delete x["IpSyncEnabled"];
2223
+ delete x["LinkIsUp"];
2224
+ delete x["LinkPolicy"];
2225
+ delete x["MACAddress"];
2226
+ delete x["SharedDynamicIP"];
2227
+ delete x["SharedMAC"];
2228
+ delete x["SharedStaticIp"];
2229
+
2230
+ if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; }
2231
+ if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; }
2232
if (args.dhcp && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == false)) {
2233
// Change to DHCP
2220
- pendingAmtConfigActions++;
2221
- var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2234
x['DHCPEnabled'] = true;
2223
- delete x["IPAddress"];
2224
- delete x["SubnetMask"];
2225
- delete x["DefaultGateway"];
2226
- delete x["PrimaryDNS"];
2227
- delete x["SecondaryDNS"];
2228
- amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2235
+ docall = true;
2236
}
2237
else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) {
2238
// Change to STATIC
2232
- pendingAmtConfigActions++;
2233
- var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2239
x['DHCPEnabled'] = false;
2235
- delete x["IPAddress"];
2236
- delete x["SubnetMask"];
2237
- delete x["DefaultGateway"];
2238
- delete x["PrimaryDNS"];
2239
- delete x["SecondaryDNS"];
2240
if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); }
2241
if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); }
2242
if (args.gateway) { x["DefaultGateway"] = args.gateway; }
2243
if (args.dns) { x["PrimaryDNS"] = args.dns; }
2244
if (args.dns2) { x["SecondaryDNS"] = args.dns2; }
2245
- amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { console.log(status); if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2245
+ docall = true;
2246
+ }
2247
+ if (docall) {
2248
+ if (x["DHCPEnabled"] == true) {
2249
+ delete x["IPAddress"];
2250
+ delete x["DefaultGateway"];
2251
+ delete x["PrimaryDNS"];
2252
+ delete x["SecondaryDNS"];
2253
+ delete x["SubnetMask"];
2254
+ }
2255
+ pendingAmtConfigActions++;
2256
+ //console.log(JSON.stringify(x, 4, ' '));
2257
+ amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (status != 200) { console.log('Error, status ' + status + '.'); } if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }, null, 0, x);
2258
}
2259
}
2260
2261
if (pendingAmtConfigActions == 0) {
2262
+ var maxlen = 0;
2263
+ if (amtwiredif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwiredif]) { if (i.length > maxlen) { maxlen = i.length; } } }
2264
+ if (amtwirelessif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwirelessif]) { if (i.length > maxlen) { maxlen = i.length; } } }
2265
+
2266
if (amtwiredif != -1) { // Wired
2267
var z = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2268
console.log('--WIRED---');
2269
for (var i in z) {
2270
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2271
var name = i;
2256
- while (name.length < 16) { name += ' '; }
2257
- console.log(name + ': ' + z[i]);
2272
+ while (name.length < maxlen) { name += ' '; }
2273
+ console.log(name + ' : ' + z[i]);
2274
}
2275
}
2276
}
@@ -2264,8 +2280,8 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2280
for (var i in z) {
2281
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2282
var name = i;
2267
- while (name.length < 16) { name += ' '; }
2268
- console.log(name + ': ' + z[i]);
2283
+ while (name.length < maxlen) { name += ' '; }
2284
+ console.log(name + ' : ' + z[i]);
2285
}
2286
}
2287
}
agents/meshcmd.min.js
+36
-20
@@ -318,6 +318,7 @@ function run(argv) {
318
console.log('\r\nOptional arguments:\r\n');
319
console.log(' --user [username] The Intel AMT login username, admin is default.');
320
console.log(' --tls Specifies that TLS must be used.');
321
+ console.log(' --ipsync [0 or 1] Change the wired IPSync setting on Intel AMT 7+');
322
console.log(' --dhcp Change IPv4 wired interface to DHCP mode');
323
console.log(' --static Change IPv4 wired interface to static IP mode');
324
console.log(' --ip [1.2.3.4] Static IPv4 address (required)');
@@ -2215,46 +2216,61 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2216
2217
// Check if configuration change is required
2218
if (args) {
2219
+ var docall = false;
2220
+ var x = JSON.parse(JSON.stringify(response['AMT_EthernetPortSettings'].responses[amtwiredif]));
2221
+ var y = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2222
+ delete x["IpSyncEnabled"];
2223
+ delete x["LinkIsUp"];
2224
+ delete x["LinkPolicy"];
2225
+ delete x["MACAddress"];
2226
+ delete x["SharedDynamicIP"];
2227
+ delete x["SharedMAC"];
2228
+ delete x["SharedStaticIp"];
2229
+
2230
+ if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; }
2231
+ if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; }
2232
if (args.dhcp && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == false)) {
2233
// Change to DHCP
2220
- pendingAmtConfigActions++;
2221
- var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2234
x['DHCPEnabled'] = true;
2223
- delete x["IPAddress"];
2224
- delete x["SubnetMask"];
2225
- delete x["DefaultGateway"];
2226
- delete x["PrimaryDNS"];
2227
- delete x["SecondaryDNS"];
2228
- amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2235
+ docall = true;
2236
}
2237
else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) {
2238
// Change to STATIC
2232
- pendingAmtConfigActions++;
2233
- var x = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2239
x['DHCPEnabled'] = false;
2235
- delete x["IPAddress"];
2236
- delete x["SubnetMask"];
2237
- delete x["DefaultGateway"];
2238
- delete x["PrimaryDNS"];
2239
- delete x["SecondaryDNS"];
2240
if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); }
2241
if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); }
2242
if (args.gateway) { x["DefaultGateway"] = args.gateway; }
2243
if (args.dns) { x["PrimaryDNS"] = args.dns; }
2244
if (args.dns2) { x["SecondaryDNS"] = args.dns2; }
2245
- amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { console.log(status); if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } });
2245
+ docall = true;
2246
+ }
2247
+ if (docall) {
2248
+ if (x["DHCPEnabled"] == true) {
2249
+ delete x["IPAddress"];
2250
+ delete x["DefaultGateway"];
2251
+ delete x["PrimaryDNS"];
2252
+ delete x["SecondaryDNS"];
2253
+ delete x["SubnetMask"];
2254
+ }
2255
+ pendingAmtConfigActions++;
2256
+ //console.log(JSON.stringify(x, 4, ' '));
2257
+ amtstack.Put("AMT_EthernetPortSettings", x, function (stack, name, response, status) { if (status != 200) { console.log('Error, status ' + status + '.'); } if (--pendingAmtConfigActions == 0) { performAmtNetConfig0(); } }, null, 0, x);
2258
}
2259
}
2260
2261
if (pendingAmtConfigActions == 0) {
2262
+ var maxlen = 0;
2263
+ if (amtwiredif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwiredif]) { if (i.length > maxlen) { maxlen = i.length; } } }
2264
+ if (amtwirelessif != -1) { for (var i in response['AMT_EthernetPortSettings'].responses[amtwirelessif]) { if (i.length > maxlen) { maxlen = i.length; } } }
2265
+
2266
if (amtwiredif != -1) { // Wired
2267
var z = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2268
console.log('--WIRED---');
2269
for (var i in z) {
2270
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2271
var name = i;
2256
- while (name.length < 16) { name += ' '; }
2257
- console.log(name + ': ' + z[i]);
2272
+ while (name.length < maxlen) { name += ' '; }
2273
+ console.log(name + ' : ' + z[i]);
2274
}
2275
}
2276
}
@@ -2264,8 +2280,8 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2280
for (var i in z) {
2281
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2282
var name = i;
2267
- while (name.length < 16) { name += ' '; }
2268
- console.log(name + ': ' + z[i]);
2283
+ while (name.length < maxlen) { name += ' '; }
2284
+ console.log(name + ' : ' + z[i]);
2285
}
2286
}
2287
}
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.3.7-v",
3
+ "version": "0.3.7-w",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",