Fixed broken MeshCMD
Ylian Saint-Hilaire committed
Oct 28, 2019 at 18:25 UTC
f14d405320918cc4373e1fed10c3f99197e24185
5 files changed
+213
-213
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
+106
-106
@@ -1997,13 +1997,13 @@ function kvmSetData(x) {
1997
}
1998
1999
function startLmsWsmanResponse(stack, name, responses, status) {
2000
- if (status == 600) { console.log('ERROR: Unable to connect to Intel(R) AMT.'); }
2001
- else if (status != 200) { console.log('ERROR: Unable to get object from Intel(R) AMT, status = ' + status + '.'); }
2000
+ if (status == 600) { console.log("ERROR: Unable to connect to Intel(R) AMT."); }
2001
+ else if (status != 200) { console.log("ERROR: Unable to get object from Intel(R) AMT, status = " + status + "."); }
2002
else {
2003
//console.log(JSON.stringify(responses), status);
2004
- var amtlogicalelements = responses["CIM_SoftwareIdentity"].responses;
2004
+ var amtlogicalelements = responses['CIM_SoftwareIdentity'].responses;
2005
if (amtlogicalelements.length > 0) {
2006
- var v = getInstance(amtlogicalelements, "AMT")["VersionString"];
2006
+ var v = getInstance(amtlogicalelements, 'AMT')['VersionString'];
2007
amtversion = parseInt(v.split('.')[0]);
2008
amtversionmin = parseInt(v.split('.')[1]);
2009
//console.log(amtversion, amtversionmin);
@@ -2047,7 +2047,7 @@ function processLmsControlData(data) {
2047
2048
function startRouter() {
2049
tcpserver = net.createServer(OnTcpClientConnected);
2050
- tcpserver.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); exit(0); return; });
2050
+ tcpserver.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); exit(0); return; });
2051
tcpserver.listen(settings.localport, function () {
2052
// We started listening.
2053
if (settings.remotetarget == null) {
@@ -2055,7 +2055,7 @@ function startRouter() {
2055
} else {
2056
console.log('Redirecting local port ' + settings.localport + ' to ' + settings.remotetarget + ':' + settings.remoteport + '.');
2057
}
2058
- console.log('Press ctrl-c to exit.');
2058
+ console.log("Press ctrl-c to exit.");
2059
2060
// If settings has a "cmd", run it now.
2061
//process.exec("notepad.exe");
@@ -2066,19 +2066,19 @@ function startRouter() {
2066
function OnTcpClientConnected(c) {
2067
try {
2068
// 'connection' listener
2069
- debug(1, 'Client connected');
2070
- c.on('end', function () { disconnectTunnel(this, this.websocket, 'Client closed'); });
2069
+ debug(1, "Client connected");
2070
+ c.on('end', function () { disconnectTunnel(this, this.websocket, "Client closed"); });
2071
c.pause();
2072
try {
2073
options = http.parseUri(settings.serverurl + '?user=' + settings.username + '&pass=' + settings.password + '&nodeid=' + settings.remotenodeid + '&tcpport=' + settings.remoteport + (settings.remotetarget == null ? '' : '&tcpaddr=' + settings.remotetarget));
2074
- } catch (e) { console.log('Unable to parse \"serverUrl\".'); process.exit(1); return; }
2074
+ } catch (e) { console.log("Unable to parse \"serverUrl\"."); process.exit(1); return; }
2075
options.checkServerIdentity = onVerifyServer;
2076
options.rejectUnauthorized = false;
2077
c.websocket = http.request(options);
2078
c.websocket.tcp = c;
2079
c.websocket.tunneling = false;
2080
c.websocket.upgrade = OnWebSocket;
2081
- c.websocket.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); });
2081
+ c.websocket.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); });
2082
c.websocket.end();
2083
} catch (e) { debug(2, e); }
2084
}
@@ -2087,17 +2087,17 @@ function OnTcpClientConnected(c) {
2087
function disconnectTunnel(tcp, ws, msg) {
2088
if (ws != null) { try { ws.end(); } catch (e) { debug(2, e); } }
2089
if (tcp != null) { try { tcp.end(); } catch (e) { debug(2, e); } }
2090
- debug(1, 'Tunnel disconnected: ' + msg);
2090
+ debug(1, "Tunnel disconnected: " + msg);
2091
}
2092
2093
// Called when the web socket gets connected
2094
function OnWebSocket(msg, s, head) {
2095
- debug(1, 'Websocket connected');
2095
+ debug(1, "Websocket connected");
2096
s.on('data', function (msg) {
2097
if (this.parent.tunneling == false) {
2098
msg = msg.toString();
2099
if ((msg == 'c') || (msg == 'cr')) {
2100
- this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, 'Tunnel active');
2100
+ this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, "Tunnel active");
2101
} else if ((msg.length > 6) && (msg.substring(0, 6) == 'error:')) {
2102
console.log(msg.substring(6));
2103
disconnectTunnel(this.tcp, this, msg.substring(6));
@@ -2110,7 +2110,7 @@ function OnWebSocket(msg, s, head) {
2110
}
2111
2112
// Try to discover the location of the mesh server
2113
-function discoverMeshServer() { console.log('Looking for server...'); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); }
2113
+function discoverMeshServer() { console.log("Looking for server..."); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); }
2114
2115
// Try to discover the location of the mesh server only once
2116
function discoverMeshServerOnce() {
@@ -2119,9 +2119,9 @@ function discoverMeshServerOnce() {
2119
if (interfaces.hasOwnProperty(adapter)) {
2120
for (var i = 0; i < interfaces[adapter].length; ++i) {
2121
var addr = interfaces[adapter][i];
2122
- multicastSockets[i] = dgram.createSocket({ type: (addr.family == "IPv4" ? "udp4" : "udp6") });
2122
+ multicastSockets[i] = dgram.createSocket({ type: (addr.family == 'IPv4' ? 'udp4' : 'udp6') });
2123
multicastSockets[i].bind({ address: addr.address, exclusive: false });
2124
- if (addr.family == "IPv4") {
2124
+ if (addr.family == 'IPv4') {
2125
try {
2126
multicastSockets[i].addMembership(membershipIPv4);
2127
//multicastSockets[i].setMulticastLoopback(true);
@@ -2139,7 +2139,7 @@ function OnMulticastMessage(msg, rinfo) {
2139
var m = msg.toString().split('|');
2140
if ((m.length == 3) && (m[0] == 'MeshCentral2') && (m[1] == settings.serverid)) {
2141
settings.serverurl = m[2].replace('%s', rinfo.address).replace('/agent.ashx', '/meshrelay.ashx');
2142
- console.log('Found server at ' + settings.serverurl + '.');
2142
+ console.log("Found server at " + settings.serverurl + ".");
2143
if (discoveryInterval != null) { clearInterval(discoveryInterval); discoveryInterval = null; }
2144
startRouter();
2145
}
@@ -2182,7 +2182,7 @@ function nextStepStorageUpload2(uploadName, linkName) {
2182
} else {
2183
console.log("Verifying MeshCommander...");
2184
verifyStorage(uploadName, Buffer.from(settings.webapp, 'base64'), function (verified) {
2185
- if (verified == true) { console.log('Done.'); } else { console.log('MeshCommander verification failed.'); }
2185
+ if (verified == true) { console.log("Done."); } else { console.log("MeshCommander verification failed."); }
2186
exit(); return;
2187
});
2188
}
@@ -2200,7 +2200,7 @@ function nextStepStorageUpload3(deleteName) {
2200
2201
// Fetch the Intel AMT storage document
2202
function getAmtStorage(func, noretry) {
2203
- var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: "/amt-storage/", port: settings.localport },
2203
+ var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: '/amt-storage/', port: settings.localport },
2204
function (response) {
2205
if (response.statusCode != 200) { console.log("Unable to connect to Intel(R) AMT."); func(response.statusCode, null); }
2206
response.on('data', function (chunk) { if (response.acc == null) { response.acc = chunk; } else { response.acc += chunk; } });
@@ -2225,7 +2225,7 @@ function getAmtStorage(func, noretry) {
2225
// Fetch the Intel AMT storage document
2226
function pushToStorage(name, linkname, data, func, ptr) {
2227
if (ptr == null) { ptr = 0; }
2228
- var req = digest.request({ protocol: settings.protocol, method: "PUT", host: settings.hostname, path: ("/amt-storage/" + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport });
2228
+ var req = digest.request({ protocol: settings.protocol, method: 'PUT', host: settings.hostname, path: ('/amt-storage/' + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport });
2229
req.on('error', function (e) { console.log("Error occured: " + JSON.stringify(e)); if (func != null) { func(null); } });
2230
req.on('response', function (response) {
2231
debug(1, 'Chunk Done', data.length, ptr);
@@ -2240,7 +2240,7 @@ function pushToStorage(name, linkname, data, func, ptr) {
2240
2241
// Fetch the Intel AMT storage document
2242
function verifyStorage(name, data, func) {
2243
- var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: ("/amt-storage/" + name), port: settings.localport });
2243
+ var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: ('/amt-storage/' + name), port: settings.localport });
2244
req.on('error', function (e) { console.log("Verify error occured: " + JSON.stringify(e)); if (func != null) { func(null); } });
2245
req.on('response', function (response) {
2246
response.ptr = 0;
@@ -2253,8 +2253,8 @@ function verifyStorage(name, data, func) {
2253
2254
// Fetch the Intel AMT storage document
2255
function deleteStorage(name, func, noretry) {
2256
- var req = digest.request({ protocol: settings.protocol, method: "DELETE", host: settings.hostname, path: "/amt-storage/" + name, port: settings.localport });
2257
- req.on('error', function (e) { if ((e == 'Error: Socket was unexpectedly closed') && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } });
2256
+ var req = digest.request({ protocol: settings.protocol, method: 'DELETE', host: settings.hostname, path: '/amt-storage/' + name, port: settings.localport });
2257
+ req.on('error', function (e) { if ((e == "Error: Socket was unexpectedly closed") && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } });
2258
req.on('response', function (response) { if (func != null) { func(response.statusCode); } });
2259
req.end();
2260
}
@@ -2289,11 +2289,11 @@ function performIder() {
2289
} catch (ex) { console.log(ex); }
2290
}
2291
2292
-function onIderStateChange(stack, state) { console.log(['Disconnected', 'Connecting...', 'Connected...', 'Started IDER...'][state]); }
2292
+function onIderStateChange(stack, state) { console.log(["Disconnected", "Connecting...", "Connected...", "Started IDER..."][state]); }
2293
2294
function iderSectorStats(mode, dev, mediaBlocks, lba, len) {
2295
if (iderIdleTimer != null) { clearTimeout(iderIdleTimer); }
2296
- iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout);
2296
+ iderIdleTimer = setTimeout(function () { console.log("Idle timeout"); process.exit(1); }, 1000 * settings.timeout);
2297
}
2298
2299
//
@@ -2325,7 +2325,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2325
for (var y in response['AMT_EthernetPortSettings'].responses) {
2326
var z = response['AMT_EthernetPortSettings'].responses[y];
2327
if (z['WLANLinkProtectionLevel'] || (y == 1)) { amtwirelessif = y; } // Set the wireless interface, this seems to cover new wireless only computers and older computers with dual interfaces.
2328
- if (y == 0) { if ((amtwirelessif != y) && (z["MACAddress"] != "00-00-00-00-00-00")) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC
2328
+ if (y == 0) { if ((amtwirelessif != y) && (z['MACAddress'] != '00-00-00-00-00-00')) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC
2329
}
2330
2331
// Check if configuration change is required
@@ -2333,13 +2333,13 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2333
var docall = false;
2334
var x = JSON.parse(JSON.stringify(response['AMT_EthernetPortSettings'].responses[amtwiredif]));
2335
var y = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2336
- delete x["IpSyncEnabled"];
2337
- delete x["LinkIsUp"];
2338
- delete x["LinkPolicy"];
2339
- delete x["MACAddress"];
2340
- delete x["SharedDynamicIP"];
2341
- delete x["SharedMAC"];
2342
- delete x["SharedStaticIp"];
2336
+ delete x['IpSyncEnabled'];
2337
+ delete x['LinkIsUp'];
2338
+ delete x['LinkPolicy'];
2339
+ delete x['MACAddress'];
2340
+ delete x['SharedDynamicIP'];
2341
+ delete x['SharedMAC'];
2342
+ delete x['SharedStaticIp'];
2343
2344
if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; }
2345
if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; }
@@ -2351,24 +2351,24 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2351
else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) {
2352
// Change to STATIC
2353
x['DHCPEnabled'] = false;
2354
- if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); }
2355
- if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); }
2356
- if (args.gateway) { x["DefaultGateway"] = args.gateway; }
2357
- if (args.dns) { x["PrimaryDNS"] = args.dns; }
2358
- if (args.dns2) { x["SecondaryDNS"] = args.dns2; }
2354
+ if (args.ip) { x['IPAddress'] = args.ip; } else { console.log("Missing IPv4 address, use --ip 1.2.3.4"); process.exit(1); }
2355
+ if (args.subnet) { x['SubnetMask'] = args.subnet; } else { console.log("Missing IPv4 subnet, use --subnet 255.255.255.0"); process.exit(1); }
2356
+ if (args.gateway) { x['DefaultGateway'] = args.gateway; }
2357
+ if (args.dns) { x['PrimaryDNS'] = args.dns; }
2358
+ if (args.dns2) { x['SecondaryDNS'] = args.dns2; }
2359
docall = true;
2360
}
2361
if (docall) {
2362
- if (x["DHCPEnabled"] == true) {
2363
- delete x["IPAddress"];
2364
- delete x["DefaultGateway"];
2365
- delete x["PrimaryDNS"];
2366
- delete x["SecondaryDNS"];
2367
- delete x["SubnetMask"];
2362
+ if (x['DHCPEnabled'] == true) {
2363
+ delete x['IPAddress'];
2364
+ delete x['DefaultGateway'];
2365
+ delete x['PrimaryDNS'];
2366
+ delete x['SecondaryDNS'];
2367
+ delete x['SubnetMask'];
2368
}
2369
pendingAmtConfigActions++;
2370
//console.log(JSON.stringify(x, 4, ' '));
2371
- 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);
2371
+ 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);
2372
}
2373
}
2374
@@ -2379,7 +2379,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2379
2380
if (amtwiredif != -1) { // Wired
2381
var z = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2382
- console.log('--WIRED---');
2382
+ console.log("--WIRED---");
2383
for (var i in z) {
2384
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2385
var name = i;
@@ -2390,7 +2390,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2390
}
2391
if (amtwirelessif != -1) { // Wireless
2392
var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif];
2393
- console.log('--WIRELESS---');
2393
+ console.log("--WIRELESS---");
2394
for (var i in z) {
2395
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2396
var name = i;
@@ -2402,7 +2402,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2402
process.exit(0);
2403
}
2404
} else {
2405
- console.log('Error, status ' + status + '.');
2405
+ console.log("Error, status " + status + ".");
2406
process.exit(1);
2407
}
2408
}
@@ -2432,35 +2432,35 @@ function performAmtFeatureConfig0(state, args) {
2432
function performAmtFeatureConfig1(stack, name, response, status, args) {
2433
if (status == 200) {
2434
// User consent
2435
- var optinrequired = response['IPS_OptInService'].response["OptInRequired"];
2435
+ var optinrequired = response['IPS_OptInService'].response['OptInRequired'];
2436
if (args) {
2437
if ((args.userconsent == 'none') && (optinrequired != 0)) {
2438
pendingAmtConfigActions++;
2439
- response['IPS_OptInService'].response["OptInRequired"] = 0;
2440
- amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2439
+ response['IPS_OptInService'].response['OptInRequired'] = 0;
2440
+ amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2441
}
2442
else if ((args.userconsent == 'kvm') && (optinrequired != 1)) {
2443
pendingAmtConfigActions++;
2444
- response['IPS_OptInService'].response["OptInRequired"] = 1;
2445
- amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2444
+ response['IPS_OptInService'].response['OptInRequired'] = 1;
2445
+ amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2446
}
2447
else if ((args.userconsent == 'all') && (optinrequired != 0xFFFFFFFF)) {
2448
pendingAmtConfigActions++;
2449
- response['IPS_OptInService'].response["OptInRequired"] = 0xFFFFFFFF;
2450
- amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2449
+ response['IPS_OptInService'].response['OptInRequired'] = 0xFFFFFFFF;
2450
+ amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2451
}
2452
}
2453
2454
// Redirection ports
2455
var redirportchange = false;
2456
var redirchange = false;
2457
- var redir = (response['AMT_RedirectionService'].response["ListenerEnabled"] == true);
2457
+ var redir = (response['AMT_RedirectionService'].response['ListenerEnabled'] == true);
2458
2459
- var sol = ((response['AMT_RedirectionService'].response["EnabledState"] & 2) != 0);
2460
- var ider = ((response['AMT_RedirectionService'].response["EnabledState"] & 1) != 0);
2459
+ var sol = ((response['AMT_RedirectionService'].response['EnabledState'] & 2) != 0);
2460
+ var ider = ((response['AMT_RedirectionService'].response['EnabledState'] & 1) != 0);
2461
if (args) {
2462
- if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = true; redirportchange = true; }
2463
- if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = false; redirportchange = true; }
2462
+ if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = true; redirportchange = true; }
2463
+ if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = false; redirportchange = true; }
2464
if ((sol == false) && ((args.sol == 'enabled') || (args.sol == 1))) { sol = true; redirchange = true; }
2465
if ((sol == true) && ((args.sol == 'disabled') || (args.sol == 0))) { sol = false; redirchange = true; }
2466
if ((ider == false) && ((args.ider == 'enabled') || (args.ider == 1))) { ider = true; redirchange = true; }
@@ -2473,7 +2473,7 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2473
var kvm = false;
2474
var kvmchange = false;
2475
if (response['CIM_KVMRedirectionSAP'] != null) {
2476
- kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response["RequestedState"] == 2) || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 2 || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6);
2476
+ kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response['RequestedState'] == 2) || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 2 || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 6);
2477
if (args) {
2478
if ((kvm == false) && ((args.kvm == 'enabled') || (args.kvm == 1))) { kvm = true; kvmchange = true; }
2479
if ((kvm == true) && ((args.kvm == 'disabled') || (args.kvm == 0))) { kvm = false; kvmchange = true; }
@@ -2482,18 +2482,18 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2482
}
2483
2484
if (pendingAmtConfigActions == 0) {
2485
- if (optinrequired == 0) { console.log('User Consent : None'); }
2486
- else if (optinrequired == 1) { console.log('User Consent : KVM'); }
2487
- else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent : All'); }
2488
- else { console.log('User Consent : ' + optinrequired); }
2489
- console.log('Redirection Port : ' + (redir ? 'Enabled' : 'Disabled'));
2490
- console.log('Serial-over-LAN : ' + (sol ? 'Enabled' : 'Disabled'));
2491
- console.log('IDE Redirection : ' + (ider ? 'Enabled' : 'Disabled'));
2492
- if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM) : ' + (kvm ? 'Enabled' : 'Disabled')); }
2485
+ if (optinrequired == 0) { console.log("User Consent : None"); }
2486
+ else if (optinrequired == 1) { console.log("User Consent : KVM"); }
2487
+ else if (optinrequired == 0xFFFFFFFF) { console.log("User Consent : All"); }
2488
+ else { console.log("User Consent : " + optinrequired); }
2489
+ console.log("Redirection Port : " + (redir ? "Enabled" : "Disabled"));
2490
+ console.log("Serial-over-LAN : " + (sol ? "Enabled" : "Disabled"));
2491
+ console.log("IDE Redirection : " + (ider ? "Enabled" : 'Disabled'));
2492
+ if (response['CIM_KVMRedirectionSAP'] != null) { console.log("Remote desktop (KVM) : " + (kvm ? "Enabled" : "Disabled")); }
2493
process.exit(0);
2494
}
2495
} else {
2496
- console.log('Error, status ' + status + '.');
2496
+ console.log("Error, status " + status + ".");
2497
process.exit(1);
2498
}
2499
}
@@ -2514,7 +2514,7 @@ function performAmtPowerAction() {
2514
amtstack.RequestPowerStateChange(settings.poweraction, performAmtPowerActionEx);
2515
} else {
2516
// Get the power state
2517
- amtstack.Get("CIM_AssociatedPowerManagementService", performAmtPowerActionEx2, 0, 1);
2517
+ amtstack.Get('CIM_AssociatedPowerManagementService', performAmtPowerActionEx2, 0, 1);
2518
}
2519
}
2520
@@ -2523,23 +2523,23 @@ function performAmtPowerActionEx(stack, name, response, status) {
2523
console.log(response.Body.ReturnValueStr.split('_').join(' '));
2524
process.exit(0);
2525
} else {
2526
- console.log('Error, status ' + status + '.');
2526
+ console.log("Error, status " + status + ".");
2527
process.exit(1);
2528
}
2529
}
2530
2531
-var DMTFPowerStates = ["", "", "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"];
2531
+var DMTFPowerStates = ['', '', "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"];
2532
function performAmtPowerActionEx2(stack, name, response, status) {
2533
if (status == 200) {
2534
var powerNumber = parseInt(response.Body.PowerState);
2535
if ((powerNumber >= DMTFPowerStates.length) && (powerNumber > 1)) {
2536
- console.log('Unknown power state: ' + response.Body.PowerState);
2536
+ console.log("Unknown power state: " + response.Body.PowerState);
2537
} else {
2538
- console.log('Current power state: ' + DMTFPowerStates[powerNumber]);
2538
+ console.log("Current power state: " + DMTFPowerStates[powerNumber]);
2539
}
2540
process.exit(0);
2541
} else {
2542
- console.log('Error, status ' + status + '.');
2542
+ console.log("Error, status " + status + ".");
2543
process.exit(1);
2544
}
2545
}
@@ -2571,16 +2571,16 @@ for (var i in process.argv) {
2571
if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; }
2572
if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) {
2573
serviceName = 'MicroLMS';
2574
- serviceDisplayName = 'MicroLMS Service for Intel(R) AMT';
2575
- serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)';
2574
+ serviceDisplayName = "MicroLMS Service for Intel(R) AMT";
2575
+ serviceDesc = "Intel AMT Micro Local Manageability Service (MicroLMS)";
2576
} else if ((process.argv[i].toLowerCase() == 'intellms')) {
2577
serviceName = 'LMS';
2578
- serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service';
2579
- serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.';
2578
+ serviceDisplayName = "Intel(R) Management and Security Application Local Management Service";
2579
+ serviceDesc = "Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.";
2580
} else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) {
2581
serviceName = 'MeshCommander';
2582
- serviceDisplayName = 'MeshCommander, Intel AMT Management console';
2583
- serviceDesc = 'MeshCommander is a Intel AMT management console.';
2582
+ serviceDisplayName = "MeshCommander, Intel AMT Management console";
2583
+ serviceDesc = "MeshCommander is a Intel AMT management console.";
2584
}
2585
}
2586
@@ -2589,29 +2589,29 @@ if (serviceName == null) {
2589
else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; }
2590
else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; }
2591
if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } }
2592
- if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); }
2593
-}
2594
-
2595
-var serviceHost = require('service-host');
2596
-var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
2597
-
2598
-// Called when the background service is started.
2599
-meshcmdService.on('serviceStart', function onStart() {
2600
- //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp';
2601
- //process.on('exit', function () { console.log('exit3'); _debugCrash(); });
2602
- console.setDestination(console.Destinations.DISABLED); // Disable console.log().
2603
- //console.setDestination(console.Destinations.LOGFILE);
2604
- //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log);
2605
-
2606
- if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2607
- else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2608
- else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander
2609
- else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); }
2610
-});
2592
+ if (serviceName == null) { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } }
2593
+} else {
2594
+ var serviceHost = require('service-host');
2595
+ var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
2596
+
2597
+ // Called when the background service is started.
2598
+ meshcmdService.on('serviceStart', function onStart() {
2599
+ //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp';
2600
+ //process.on('exit', function () { console.log('exit3'); _debugCrash(); });
2601
+ console.setDestination(console.Destinations.DISABLED); // Disable console.log().
2602
+ //console.setDestination(console.Destinations.LOGFILE);
2603
+ //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log);
2604
+
2605
+ if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2606
+ else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2607
+ else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander
2608
+ else { console.log("Aborting Service Start, because unknown binary: " + process.execPath); process.exit(1); }
2609
+ });
2610
2612
-// Called when the background service is stopping
2613
-meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
2611
+ // Called when the background service is stopping
2612
+ meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
2613
2615
-// Called when the executable is not running as a service, run normally.
2616
-meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } });
2617
-meshcmdService.run();
2614
+ // Called when the executable is not running as a service, run normally.
2615
+ meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } });
2616
+ meshcmdService.run();
2617
+}
\ No newline at end of file
agents/meshcmd.min.js
+106
-106
@@ -1997,13 +1997,13 @@ function kvmSetData(x) {
1997
}
1998
1999
function startLmsWsmanResponse(stack, name, responses, status) {
2000
- if (status == 600) { console.log('ERROR: Unable to connect to Intel(R) AMT.'); }
2001
- else if (status != 200) { console.log('ERROR: Unable to get object from Intel(R) AMT, status = ' + status + '.'); }
2000
+ if (status == 600) { console.log("ERROR: Unable to connect to Intel(R) AMT."); }
2001
+ else if (status != 200) { console.log("ERROR: Unable to get object from Intel(R) AMT, status = " + status + "."); }
2002
else {
2003
//console.log(JSON.stringify(responses), status);
2004
- var amtlogicalelements = responses["CIM_SoftwareIdentity"].responses;
2004
+ var amtlogicalelements = responses['CIM_SoftwareIdentity'].responses;
2005
if (amtlogicalelements.length > 0) {
2006
- var v = getInstance(amtlogicalelements, "AMT")["VersionString"];
2006
+ var v = getInstance(amtlogicalelements, 'AMT')['VersionString'];
2007
amtversion = parseInt(v.split('.')[0]);
2008
amtversionmin = parseInt(v.split('.')[1]);
2009
//console.log(amtversion, amtversionmin);
@@ -2047,7 +2047,7 @@ function processLmsControlData(data) {
2047
2048
function startRouter() {
2049
tcpserver = net.createServer(OnTcpClientConnected);
2050
- tcpserver.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); exit(0); return; });
2050
+ tcpserver.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); exit(0); return; });
2051
tcpserver.listen(settings.localport, function () {
2052
// We started listening.
2053
if (settings.remotetarget == null) {
@@ -2055,7 +2055,7 @@ function startRouter() {
2055
} else {
2056
console.log('Redirecting local port ' + settings.localport + ' to ' + settings.remotetarget + ':' + settings.remoteport + '.');
2057
}
2058
- console.log('Press ctrl-c to exit.');
2058
+ console.log("Press ctrl-c to exit.");
2059
2060
// If settings has a "cmd", run it now.
2061
//process.exec("notepad.exe");
@@ -2066,19 +2066,19 @@ function startRouter() {
2066
function OnTcpClientConnected(c) {
2067
try {
2068
// 'connection' listener
2069
- debug(1, 'Client connected');
2070
- c.on('end', function () { disconnectTunnel(this, this.websocket, 'Client closed'); });
2069
+ debug(1, "Client connected");
2070
+ c.on('end', function () { disconnectTunnel(this, this.websocket, "Client closed"); });
2071
c.pause();
2072
try {
2073
options = http.parseUri(settings.serverurl + '?user=' + settings.username + '&pass=' + settings.password + '&nodeid=' + settings.remotenodeid + '&tcpport=' + settings.remoteport + (settings.remotetarget == null ? '' : '&tcpaddr=' + settings.remotetarget));
2074
- } catch (e) { console.log('Unable to parse \"serverUrl\".'); process.exit(1); return; }
2074
+ } catch (e) { console.log("Unable to parse \"serverUrl\"."); process.exit(1); return; }
2075
options.checkServerIdentity = onVerifyServer;
2076
options.rejectUnauthorized = false;
2077
c.websocket = http.request(options);
2078
c.websocket.tcp = c;
2079
c.websocket.tunneling = false;
2080
c.websocket.upgrade = OnWebSocket;
2081
- c.websocket.on('error', function (e) { console.log('ERROR: ' + JSON.stringify(e)); });
2081
+ c.websocket.on('error', function (e) { console.log("ERROR: " + JSON.stringify(e)); });
2082
c.websocket.end();
2083
} catch (e) { debug(2, e); }
2084
}
@@ -2087,17 +2087,17 @@ function OnTcpClientConnected(c) {
2087
function disconnectTunnel(tcp, ws, msg) {
2088
if (ws != null) { try { ws.end(); } catch (e) { debug(2, e); } }
2089
if (tcp != null) { try { tcp.end(); } catch (e) { debug(2, e); } }
2090
- debug(1, 'Tunnel disconnected: ' + msg);
2090
+ debug(1, "Tunnel disconnected: " + msg);
2091
}
2092
2093
// Called when the web socket gets connected
2094
function OnWebSocket(msg, s, head) {
2095
- debug(1, 'Websocket connected');
2095
+ debug(1, "Websocket connected");
2096
s.on('data', function (msg) {
2097
if (this.parent.tunneling == false) {
2098
msg = msg.toString();
2099
if ((msg == 'c') || (msg == 'cr')) {
2100
- this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, 'Tunnel active');
2100
+ this.parent.tunneling = true; this.pipe(this.parent.tcp); this.parent.tcp.pipe(this); debug(1, "Tunnel active");
2101
} else if ((msg.length > 6) && (msg.substring(0, 6) == 'error:')) {
2102
console.log(msg.substring(6));
2103
disconnectTunnel(this.tcp, this, msg.substring(6));
@@ -2110,7 +2110,7 @@ function OnWebSocket(msg, s, head) {
2110
}
2111
2112
// Try to discover the location of the mesh server
2113
-function discoverMeshServer() { console.log('Looking for server...'); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); }
2113
+function discoverMeshServer() { console.log("Looking for server..."); discoveryInterval = setInterval(discoverMeshServerOnce, 5000); discoverMeshServerOnce(); }
2114
2115
// Try to discover the location of the mesh server only once
2116
function discoverMeshServerOnce() {
@@ -2119,9 +2119,9 @@ function discoverMeshServerOnce() {
2119
if (interfaces.hasOwnProperty(adapter)) {
2120
for (var i = 0; i < interfaces[adapter].length; ++i) {
2121
var addr = interfaces[adapter][i];
2122
- multicastSockets[i] = dgram.createSocket({ type: (addr.family == "IPv4" ? "udp4" : "udp6") });
2122
+ multicastSockets[i] = dgram.createSocket({ type: (addr.family == 'IPv4' ? 'udp4' : 'udp6') });
2123
multicastSockets[i].bind({ address: addr.address, exclusive: false });
2124
- if (addr.family == "IPv4") {
2124
+ if (addr.family == 'IPv4') {
2125
try {
2126
multicastSockets[i].addMembership(membershipIPv4);
2127
//multicastSockets[i].setMulticastLoopback(true);
@@ -2139,7 +2139,7 @@ function OnMulticastMessage(msg, rinfo) {
2139
var m = msg.toString().split('|');
2140
if ((m.length == 3) && (m[0] == 'MeshCentral2') && (m[1] == settings.serverid)) {
2141
settings.serverurl = m[2].replace('%s', rinfo.address).replace('/agent.ashx', '/meshrelay.ashx');
2142
- console.log('Found server at ' + settings.serverurl + '.');
2142
+ console.log("Found server at " + settings.serverurl + ".");
2143
if (discoveryInterval != null) { clearInterval(discoveryInterval); discoveryInterval = null; }
2144
startRouter();
2145
}
@@ -2182,7 +2182,7 @@ function nextStepStorageUpload2(uploadName, linkName) {
2182
} else {
2183
console.log("Verifying MeshCommander...");
2184
verifyStorage(uploadName, Buffer.from(settings.webapp, 'base64'), function (verified) {
2185
- if (verified == true) { console.log('Done.'); } else { console.log('MeshCommander verification failed.'); }
2185
+ if (verified == true) { console.log("Done."); } else { console.log("MeshCommander verification failed."); }
2186
exit(); return;
2187
});
2188
}
@@ -2200,7 +2200,7 @@ function nextStepStorageUpload3(deleteName) {
2200
2201
// Fetch the Intel AMT storage document
2202
function getAmtStorage(func, noretry) {
2203
- var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: "/amt-storage/", port: settings.localport },
2203
+ var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: '/amt-storage/', port: settings.localport },
2204
function (response) {
2205
if (response.statusCode != 200) { console.log("Unable to connect to Intel(R) AMT."); func(response.statusCode, null); }
2206
response.on('data', function (chunk) { if (response.acc == null) { response.acc = chunk; } else { response.acc += chunk; } });
@@ -2225,7 +2225,7 @@ function getAmtStorage(func, noretry) {
2225
// Fetch the Intel AMT storage document
2226
function pushToStorage(name, linkname, data, func, ptr) {
2227
if (ptr == null) { ptr = 0; }
2228
- var req = digest.request({ protocol: settings.protocol, method: "PUT", host: settings.hostname, path: ("/amt-storage/" + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport });
2228
+ var req = digest.request({ protocol: settings.protocol, method: 'PUT', host: settings.hostname, path: ('/amt-storage/' + name + ((ptr != 0) ? '?append=' : '')), port: settings.localport });
2229
req.on('error', function (e) { console.log("Error occured: " + JSON.stringify(e)); if (func != null) { func(null); } });
2230
req.on('response', function (response) {
2231
debug(1, 'Chunk Done', data.length, ptr);
@@ -2240,7 +2240,7 @@ function pushToStorage(name, linkname, data, func, ptr) {
2240
2241
// Fetch the Intel AMT storage document
2242
function verifyStorage(name, data, func) {
2243
- var req = digest.request({ protocol: settings.protocol, method: "GET", host: settings.hostname, path: ("/amt-storage/" + name), port: settings.localport });
2243
+ var req = digest.request({ protocol: settings.protocol, method: 'GET', host: settings.hostname, path: ('/amt-storage/' + name), port: settings.localport });
2244
req.on('error', function (e) { console.log("Verify error occured: " + JSON.stringify(e)); if (func != null) { func(null); } });
2245
req.on('response', function (response) {
2246
response.ptr = 0;
@@ -2253,8 +2253,8 @@ function verifyStorage(name, data, func) {
2253
2254
// Fetch the Intel AMT storage document
2255
function deleteStorage(name, func, noretry) {
2256
- var req = digest.request({ protocol: settings.protocol, method: "DELETE", host: settings.hostname, path: "/amt-storage/" + name, port: settings.localport });
2257
- req.on('error', function (e) { if ((e == 'Error: Socket was unexpectedly closed') && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } });
2256
+ var req = digest.request({ protocol: settings.protocol, method: 'DELETE', host: settings.hostname, path: '/amt-storage/' + name, port: settings.localport });
2257
+ req.on('error', function (e) { if ((e == "Error: Socket was unexpectedly closed") && (noretry != true)) { deleteStorage(name, func, true); } else { if (func != null) { if (e.statusCode) { func(e.statusCode); } else { func(null); } } } });
2258
req.on('response', function (response) { if (func != null) { func(response.statusCode); } });
2259
req.end();
2260
}
@@ -2289,11 +2289,11 @@ function performIder() {
2289
} catch (ex) { console.log(ex); }
2290
}
2291
2292
-function onIderStateChange(stack, state) { console.log(['Disconnected', 'Connecting...', 'Connected...', 'Started IDER...'][state]); }
2292
+function onIderStateChange(stack, state) { console.log(["Disconnected", "Connecting...", "Connected...", "Started IDER..."][state]); }
2293
2294
function iderSectorStats(mode, dev, mediaBlocks, lba, len) {
2295
if (iderIdleTimer != null) { clearTimeout(iderIdleTimer); }
2296
- iderIdleTimer = setTimeout(function () { console.log('Idle timeout'); process.exit(1); }, 1000 * settings.timeout);
2296
+ iderIdleTimer = setTimeout(function () { console.log("Idle timeout"); process.exit(1); }, 1000 * settings.timeout);
2297
}
2298
2299
//
@@ -2325,7 +2325,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2325
for (var y in response['AMT_EthernetPortSettings'].responses) {
2326
var z = response['AMT_EthernetPortSettings'].responses[y];
2327
if (z['WLANLinkProtectionLevel'] || (y == 1)) { amtwirelessif = y; } // Set the wireless interface, this seems to cover new wireless only computers and older computers with dual interfaces.
2328
- if (y == 0) { if ((amtwirelessif != y) && (z["MACAddress"] != "00-00-00-00-00-00")) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC
2328
+ if (y == 0) { if ((amtwirelessif != y) && (z['MACAddress'] != '00-00-00-00-00-00')) { amtwiredif = y; } } // On computers with only wireless, the wired interface will have a null MAC
2329
}
2330
2331
// Check if configuration change is required
@@ -2333,13 +2333,13 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2333
var docall = false;
2334
var x = JSON.parse(JSON.stringify(response['AMT_EthernetPortSettings'].responses[amtwiredif]));
2335
var y = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2336
- delete x["IpSyncEnabled"];
2337
- delete x["LinkIsUp"];
2338
- delete x["LinkPolicy"];
2339
- delete x["MACAddress"];
2340
- delete x["SharedDynamicIP"];
2341
- delete x["SharedMAC"];
2342
- delete x["SharedStaticIp"];
2336
+ delete x['IpSyncEnabled'];
2337
+ delete x['LinkIsUp'];
2338
+ delete x['LinkPolicy'];
2339
+ delete x['MACAddress'];
2340
+ delete x['SharedDynamicIP'];
2341
+ delete x['SharedMAC'];
2342
+ delete x['SharedStaticIp'];
2343
2344
if ((y['IpSyncEnabled'] == false) && (args.ipsync === '1')) { x['IpSyncEnabled'] = true; docall = true; }
2345
if ((y['IpSyncEnabled'] == true) && (args.ipsync === '0')) { x['IpSyncEnabled'] = false; docall = true; }
@@ -2351,24 +2351,24 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2351
else if (args.static && (amtwiredif != -1) && (response['AMT_EthernetPortSettings'].responses[amtwiredif].DHCPEnabled == true)) {
2352
// Change to STATIC
2353
x['DHCPEnabled'] = false;
2354
- if (args.ip) { x["IPAddress"] = args.ip; } else { console.log('Missing IPv4 address, use --ip 1.2.3.4'); process.exit(1); }
2355
- if (args.subnet) { x["SubnetMask"] = args.subnet; } else { console.log('Missing IPv4 subnet, use --subnet 255.255.255.0'); process.exit(1); }
2356
- if (args.gateway) { x["DefaultGateway"] = args.gateway; }
2357
- if (args.dns) { x["PrimaryDNS"] = args.dns; }
2358
- if (args.dns2) { x["SecondaryDNS"] = args.dns2; }
2354
+ if (args.ip) { x['IPAddress'] = args.ip; } else { console.log("Missing IPv4 address, use --ip 1.2.3.4"); process.exit(1); }
2355
+ if (args.subnet) { x['SubnetMask'] = args.subnet; } else { console.log("Missing IPv4 subnet, use --subnet 255.255.255.0"); process.exit(1); }
2356
+ if (args.gateway) { x['DefaultGateway'] = args.gateway; }
2357
+ if (args.dns) { x['PrimaryDNS'] = args.dns; }
2358
+ if (args.dns2) { x['SecondaryDNS'] = args.dns2; }
2359
docall = true;
2360
}
2361
if (docall) {
2362
- if (x["DHCPEnabled"] == true) {
2363
- delete x["IPAddress"];
2364
- delete x["DefaultGateway"];
2365
- delete x["PrimaryDNS"];
2366
- delete x["SecondaryDNS"];
2367
- delete x["SubnetMask"];
2362
+ if (x['DHCPEnabled'] == true) {
2363
+ delete x['IPAddress'];
2364
+ delete x['DefaultGateway'];
2365
+ delete x['PrimaryDNS'];
2366
+ delete x['SecondaryDNS'];
2367
+ delete x['SubnetMask'];
2368
}
2369
pendingAmtConfigActions++;
2370
//console.log(JSON.stringify(x, 4, ' '));
2371
- 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);
2371
+ 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);
2372
}
2373
}
2374
@@ -2379,7 +2379,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2379
2380
if (amtwiredif != -1) { // Wired
2381
var z = response['AMT_EthernetPortSettings'].responses[amtwiredif];
2382
- console.log('--WIRED---');
2382
+ console.log("--WIRED---");
2383
for (var i in z) {
2384
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2385
var name = i;
@@ -2390,7 +2390,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2390
}
2391
if (amtwirelessif != -1) { // Wireless
2392
var z = response['AMT_EthernetPortSettings'].responses[amtwirelessif];
2393
- console.log('--WIRELESS---');
2393
+ console.log("--WIRELESS---");
2394
for (var i in z) {
2395
if (['ElementName', 'InstanceID'].indexOf(i) == -1) {
2396
var name = i;
@@ -2402,7 +2402,7 @@ function performAmtNetConfig1(stack, name, response, status, args) {
2402
process.exit(0);
2403
}
2404
} else {
2405
- console.log('Error, status ' + status + '.');
2405
+ console.log("Error, status " + status + ".");
2406
process.exit(1);
2407
}
2408
}
@@ -2432,35 +2432,35 @@ function performAmtFeatureConfig0(state, args) {
2432
function performAmtFeatureConfig1(stack, name, response, status, args) {
2433
if (status == 200) {
2434
// User consent
2435
- var optinrequired = response['IPS_OptInService'].response["OptInRequired"];
2435
+ var optinrequired = response['IPS_OptInService'].response['OptInRequired'];
2436
if (args) {
2437
if ((args.userconsent == 'none') && (optinrequired != 0)) {
2438
pendingAmtConfigActions++;
2439
- response['IPS_OptInService'].response["OptInRequired"] = 0;
2440
- amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2439
+ response['IPS_OptInService'].response['OptInRequired'] = 0;
2440
+ amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2441
}
2442
else if ((args.userconsent == 'kvm') && (optinrequired != 1)) {
2443
pendingAmtConfigActions++;
2444
- response['IPS_OptInService'].response["OptInRequired"] = 1;
2445
- amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2444
+ response['IPS_OptInService'].response['OptInRequired'] = 1;
2445
+ amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2446
}
2447
else if ((args.userconsent == 'all') && (optinrequired != 0xFFFFFFFF)) {
2448
pendingAmtConfigActions++;
2449
- response['IPS_OptInService'].response["OptInRequired"] = 0xFFFFFFFF;
2450
- amtstack.Put("IPS_OptInService", response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2449
+ response['IPS_OptInService'].response['OptInRequired'] = 0xFFFFFFFF;
2450
+ amtstack.Put('IPS_OptInService', response['IPS_OptInService'].response, function (stack, name, response, status) { if (--pendingAmtConfigActions == 0) { performAmtFeatureConfig0(); } });
2451
}
2452
}
2453
2454
// Redirection ports
2455
var redirportchange = false;
2456
var redirchange = false;
2457
- var redir = (response['AMT_RedirectionService'].response["ListenerEnabled"] == true);
2457
+ var redir = (response['AMT_RedirectionService'].response['ListenerEnabled'] == true);
2458
2459
- var sol = ((response['AMT_RedirectionService'].response["EnabledState"] & 2) != 0);
2460
- var ider = ((response['AMT_RedirectionService'].response["EnabledState"] & 1) != 0);
2459
+ var sol = ((response['AMT_RedirectionService'].response['EnabledState'] & 2) != 0);
2460
+ var ider = ((response['AMT_RedirectionService'].response['EnabledState'] & 1) != 0);
2461
if (args) {
2462
- if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = true; redirportchange = true; }
2463
- if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response["ListenerEnabled"] = false; redirportchange = true; }
2462
+ if ((redir == false) && ((args.redir == 'enabled') || (args.redir == 1))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = true; redirportchange = true; }
2463
+ if ((redir == true) && ((args.redir == 'disabled') || (args.redir == 0))) { response['AMT_RedirectionService'].response['ListenerEnabled'] = false; redirportchange = true; }
2464
if ((sol == false) && ((args.sol == 'enabled') || (args.sol == 1))) { sol = true; redirchange = true; }
2465
if ((sol == true) && ((args.sol == 'disabled') || (args.sol == 0))) { sol = false; redirchange = true; }
2466
if ((ider == false) && ((args.ider == 'enabled') || (args.ider == 1))) { ider = true; redirchange = true; }
@@ -2473,7 +2473,7 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2473
var kvm = false;
2474
var kvmchange = false;
2475
if (response['CIM_KVMRedirectionSAP'] != null) {
2476
- kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response["RequestedState"] == 2) || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 2 || response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6);
2476
+ kvm = ((response['CIM_KVMRedirectionSAP'].response["EnabledState"] == 6 && response['CIM_KVMRedirectionSAP'].response['RequestedState'] == 2) || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 2 || response['CIM_KVMRedirectionSAP'].response['EnabledState'] == 6);
2477
if (args) {
2478
if ((kvm == false) && ((args.kvm == 'enabled') || (args.kvm == 1))) { kvm = true; kvmchange = true; }
2479
if ((kvm == true) && ((args.kvm == 'disabled') || (args.kvm == 0))) { kvm = false; kvmchange = true; }
@@ -2482,18 +2482,18 @@ function performAmtFeatureConfig1(stack, name, response, status, args) {
2482
}
2483
2484
if (pendingAmtConfigActions == 0) {
2485
- if (optinrequired == 0) { console.log('User Consent : None'); }
2486
- else if (optinrequired == 1) { console.log('User Consent : KVM'); }
2487
- else if (optinrequired == 0xFFFFFFFF) { console.log('User Consent : All'); }
2488
- else { console.log('User Consent : ' + optinrequired); }
2489
- console.log('Redirection Port : ' + (redir ? 'Enabled' : 'Disabled'));
2490
- console.log('Serial-over-LAN : ' + (sol ? 'Enabled' : 'Disabled'));
2491
- console.log('IDE Redirection : ' + (ider ? 'Enabled' : 'Disabled'));
2492
- if (response['CIM_KVMRedirectionSAP'] != null) { console.log('Remote desktop (KVM) : ' + (kvm ? 'Enabled' : 'Disabled')); }
2485
+ if (optinrequired == 0) { console.log("User Consent : None"); }
2486
+ else if (optinrequired == 1) { console.log("User Consent : KVM"); }
2487
+ else if (optinrequired == 0xFFFFFFFF) { console.log("User Consent : All"); }
2488
+ else { console.log("User Consent : " + optinrequired); }
2489
+ console.log("Redirection Port : " + (redir ? "Enabled" : "Disabled"));
2490
+ console.log("Serial-over-LAN : " + (sol ? "Enabled" : "Disabled"));
2491
+ console.log("IDE Redirection : " + (ider ? "Enabled" : 'Disabled'));
2492
+ if (response['CIM_KVMRedirectionSAP'] != null) { console.log("Remote desktop (KVM) : " + (kvm ? "Enabled" : "Disabled")); }
2493
process.exit(0);
2494
}
2495
} else {
2496
- console.log('Error, status ' + status + '.');
2496
+ console.log("Error, status " + status + ".");
2497
process.exit(1);
2498
}
2499
}
@@ -2514,7 +2514,7 @@ function performAmtPowerAction() {
2514
amtstack.RequestPowerStateChange(settings.poweraction, performAmtPowerActionEx);
2515
} else {
2516
// Get the power state
2517
- amtstack.Get("CIM_AssociatedPowerManagementService", performAmtPowerActionEx2, 0, 1);
2517
+ amtstack.Get('CIM_AssociatedPowerManagementService', performAmtPowerActionEx2, 0, 1);
2518
}
2519
}
2520
@@ -2523,23 +2523,23 @@ function performAmtPowerActionEx(stack, name, response, status) {
2523
console.log(response.Body.ReturnValueStr.split('_').join(' '));
2524
process.exit(0);
2525
} else {
2526
- console.log('Error, status ' + status + '.');
2526
+ console.log("Error, status " + status + ".");
2527
process.exit(1);
2528
}
2529
}
2530
2531
-var DMTFPowerStates = ["", "", "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"];
2531
+var DMTFPowerStates = ['', '', "Power on", "Light sleep", "Deep sleep", "Power cycle (Soft off)", "Off - Hard", "Hibernate (Off soft)", "Soft off", "Power cycle (Off-hard)", "Master bus reset", "Diagnostic interrupt (NMI)", "Not applicable", "Off - Soft graceful", "Off - Hard graceful", "Master bus reset graceful", "Power cycle (Off - Soft graceful)", "Power cycle (Off - Hard graceful)", "Diagnostic interrupt (INIT)"];
2532
function performAmtPowerActionEx2(stack, name, response, status) {
2533
if (status == 200) {
2534
var powerNumber = parseInt(response.Body.PowerState);
2535
if ((powerNumber >= DMTFPowerStates.length) && (powerNumber > 1)) {
2536
- console.log('Unknown power state: ' + response.Body.PowerState);
2536
+ console.log("Unknown power state: " + response.Body.PowerState);
2537
} else {
2538
- console.log('Current power state: ' + DMTFPowerStates[powerNumber]);
2538
+ console.log("Current power state: " + DMTFPowerStates[powerNumber]);
2539
}
2540
process.exit(0);
2541
} else {
2542
- console.log('Error, status ' + status + '.');
2542
+ console.log("Error, status " + status + ".");
2543
process.exit(1);
2544
}
2545
}
@@ -2571,16 +2571,16 @@ for (var i in process.argv) {
2571
if (process.argv[i].toLowerCase() == 'uninstall') { process.argv[i] = '-uninstall'; }
2572
if ((process.argv[i].toLowerCase() == 'microlms') || (process.argv[i].toLowerCase() == 'amtlms') || (process.argv[i].toLowerCase() == 'lms')) {
2573
serviceName = 'MicroLMS';
2574
- serviceDisplayName = 'MicroLMS Service for Intel(R) AMT';
2575
- serviceDesc = 'Intel AMT Micro Local Manageability Service (MicroLMS)';
2574
+ serviceDisplayName = "MicroLMS Service for Intel(R) AMT";
2575
+ serviceDesc = "Intel AMT Micro Local Manageability Service (MicroLMS)";
2576
} else if ((process.argv[i].toLowerCase() == 'intellms')) {
2577
serviceName = 'LMS';
2578
- serviceDisplayName = 'Intel(R) Management and Security Application Local Management Service';
2579
- serviceDesc = 'Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.';
2578
+ serviceDisplayName = "Intel(R) Management and Security Application Local Management Service";
2579
+ serviceDesc = "Intel(R) Management and Security Application Local Management Service - Provides OS-related Intel(R) ME functionality.";
2580
} else if ((process.argv[i].toLowerCase() == 'meshcommander') || (process.argv[i].toLowerCase() == 'commander')) {
2581
serviceName = 'MeshCommander';
2582
- serviceDisplayName = 'MeshCommander, Intel AMT Management console';
2583
- serviceDesc = 'MeshCommander is a Intel AMT management console.';
2582
+ serviceDisplayName = "MeshCommander, Intel AMT Management console";
2583
+ serviceDesc = "MeshCommander is a Intel AMT management console.";
2584
}
2585
}
2586
@@ -2589,29 +2589,29 @@ if (serviceName == null) {
2589
else if (process.execPath.includes('LMS')) { serviceName = 'LMS'; }
2590
else if (process.execPath.includes('MeshCommander')) { serviceName = 'MeshCommander'; }
2591
if (serviceName == null) { for (var i in process.argv) { if ((process.argv[i].toLowerCase() == '-install') || (process.argv[i].toLowerCase() == '-uninstall')) { console.log('In order to install/uninstall, a service type must be specified.'); process.exit(); } } }
2592
- if (serviceName == null) { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } process.exit(); }
2593
-}
2594
-
2595
-var serviceHost = require('service-host');
2596
-var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
2597
-
2598
-// Called when the background service is started.
2599
-meshcmdService.on('serviceStart', function onStart() {
2600
- //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp';
2601
- //process.on('exit', function () { console.log('exit3'); _debugCrash(); });
2602
- console.setDestination(console.Destinations.DISABLED); // Disable console.log().
2603
- //console.setDestination(console.Destinations.LOGFILE);
2604
- //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log);
2605
-
2606
- if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2607
- else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2608
- else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander
2609
- else { console.log('Aborting Service Start, because unknown binary: ' + process.execPath); process.exit(1); }
2610
-});
2592
+ if (serviceName == null) { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } }
2593
+} else {
2594
+ var serviceHost = require('service-host');
2595
+ var meshcmdService = new serviceHost({ name: serviceName, displayName: serviceDisplayName, startType: 'AUTO_START', description: serviceDesc });
2596
+
2597
+ // Called when the background service is started.
2598
+ meshcmdService.on('serviceStart', function onStart() {
2599
+ //process.coreDumpLocation = 'C:\\tmp\\meshcommander.dmp';
2600
+ //process.on('exit', function () { console.log('exit3'); _debugCrash(); });
2601
+ console.setDestination(console.Destinations.DISABLED); // Disable console.log().
2602
+ //console.setDestination(console.Destinations.LOGFILE);
2603
+ //attachDebuger({ webport: 0, wait: 1 }).then(console.log, console.log);
2604
+
2605
+ if (process.execPath.includes('MicroLMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2606
+ else if (process.execPath.includes('LMS')) { run([process.execPath, 'microlms']); } // Start MicroLMS
2607
+ else if (process.execPath.includes('MeshCommander')) { run([process.execPath, 'meshcommander']); } // Start MeshCommander
2608
+ else { console.log("Aborting Service Start, because unknown binary: " + process.execPath); process.exit(1); }
2609
+ });
2610
2612
-// Called when the background service is stopping
2613
-meshcmdService.on('serviceStop', function onStop() { console.log('Stopping service'); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
2611
+ // Called when the background service is stopping
2612
+ meshcmdService.on('serviceStop', function onStop() { console.log("Stopping service"); process.exit(); }); // The console.log() is for debugging, will be ignored unless "console.setDestination()" is set.
2613
2615
-// Called when the executable is not running as a service, run normally.
2616
-meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log('ERROR: ' + e); } });
2617
-meshcmdService.run();
2614
+ // Called when the executable is not running as a service, run normally.
2615
+ meshcmdService.on('normalStart', function onNormalStart() { try { run(process.argv); } catch (e) { console.log("ERROR: " + e); } });
2616
+ meshcmdService.run();
2617
+}
\ No newline at end of file
package.json
+1
-1
@@ -1,6 +1,6 @@
1
{
2
"name": "meshcentral",
3
- "version": "0.4.3-j",
3
+ "version": "0.4.3-l",
4
"keywords": [
5
"Remote Management",
6
"Intel AMT",