mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-12-26 07:05:52 -05:00
Fixes for #2973
This commit is contained in:
parent
d0122a56af
commit
19f596ce86
@ -172,9 +172,10 @@ if (process.platform == 'darwin' && !process.versions) {
|
||||
// Add an Intel AMT event to the log
|
||||
function addAmtEvent(msg) {
|
||||
if (obj.amtevents == null) { obj.amtevents = []; }
|
||||
var d = new Date();
|
||||
obj.amtevents.push(zeroPad(d.getHours(), 2) + ':' + zeroPad(d.getMinutes(), 2) + ':' + zeroPad(d.getSeconds(), 2) + ', ' + msg);
|
||||
var d = new Date(), e = zeroPad(d.getHours(), 2) + ':' + zeroPad(d.getMinutes(), 2) + ':' + zeroPad(d.getSeconds(), 2) + ', ' + msg;
|
||||
obj.amtevents.push(e);
|
||||
if (obj.amtevents.length > 100) { obj.amtevents.splice(0, obj.amtevents.length - 100); }
|
||||
if (obj.showamtevent) { require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: e }); }
|
||||
}
|
||||
function zeroPad(num, size) { var s = '000000000' + num; return s.substr(s.length - size); }
|
||||
|
||||
@ -3966,14 +3967,17 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
||||
break;
|
||||
}
|
||||
case 'amtevents': {
|
||||
if (obj.amtevents == null) { response = 'No events.'; } else { response = obj.amtevents.join('\r\n'); }
|
||||
if ((args['_'].length == 1) && (args['_'][0] == 'on')) { obj.showamtevent = true; response = 'Intel AMT configuration events live view enabled.'; }
|
||||
else if ((args['_'].length == 1) && (args['_'][0] == 'off')) { delete obj.showamtevent; response = 'Intel AMT configuration events live view disabled.'; }
|
||||
else if (obj.amtevents == null) { response = 'No events.'; } else { response = obj.amtevents.join('\r\n'); }
|
||||
break;
|
||||
}
|
||||
case 'amtconfig': {
|
||||
if (amt == null) { response = "Intel AMT not detected."; break; }
|
||||
if (apftunnel != null) { response = "Intel AMT server tunnel already active"; break; }
|
||||
if (amt == null) { response = 'Intel AMT not detected.'; break; }
|
||||
if (apftunnel != null) { response = 'Intel AMT server tunnel already active'; break; }
|
||||
if (!obj.showamtevent) { obj.showamtevent = true; require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: 'Enabled live view of Intel AMT configuration events, \"amtevents off\" to disable.' }); }
|
||||
amt.getMeiState(15, function (state) {
|
||||
if ((state == null) || (state.ProvisioningState == null)) { require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: "Intel AMT not ready for configuration." }); } else {
|
||||
if ((state == null) || (state.ProvisioningState == null)) { require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: 'Intel AMT not ready for configuration.' }); } else {
|
||||
getAmtOsDnsSuffix(state, function () {
|
||||
var rx = '';
|
||||
var apfarg = {
|
||||
@ -3994,12 +3998,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
||||
apftunnel = require('amt-apfclient')({ debug: false }, apfarg);
|
||||
apftunnel.onJsonControl = handleApfJsonControl;
|
||||
apftunnel.onChannelClosed = function () { addAmtEvent('User LMS tunnel closed.'); apftunnel = null; }
|
||||
try {
|
||||
apftunnel.connect();
|
||||
rx = "Started Intel AMT configuration";
|
||||
} catch (ex) {
|
||||
rx = JSON.stringify(ex);
|
||||
}
|
||||
try { apftunnel.connect(); } catch (ex) { rx = JSON.stringify(ex); }
|
||||
}
|
||||
if (rx != '') { require('MeshAgent').SendCommand({ action: 'msg', type: 'console', value: rx }); }
|
||||
});
|
||||
@ -4132,8 +4131,9 @@ function sendAgentMessage(msg, icon, serverid, first) {
|
||||
return (arguments.length > 0 ? sendAgentMessage.messages.peek().id : sendAgentMessage.messages);
|
||||
}
|
||||
function getOpenDescriptors() {
|
||||
var r = [];
|
||||
switch (process.platform) {
|
||||
case "freebsd":
|
||||
case "freebsd": {
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stderr.on('data', function (c) { });
|
||||
@ -4157,14 +4157,10 @@ function getOpenDescriptors() {
|
||||
child.stdin.write('\nexit\n');
|
||||
child.waitExit();
|
||||
|
||||
try {
|
||||
return (JSON.parse(child.stdout.str.trim()));
|
||||
}
|
||||
catch (e) {
|
||||
return ([]);
|
||||
}
|
||||
try { r = JSON.parse(child.stdout.str.trim()); } catch (ex) { }
|
||||
break;
|
||||
case "linux":
|
||||
}
|
||||
case "linux": {
|
||||
var child = require('child_process').execFile('/bin/sh', ['sh']);
|
||||
child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); });
|
||||
child.stderr.on('data', function (c) { });
|
||||
@ -4183,17 +4179,12 @@ function getOpenDescriptors() {
|
||||
child.stdin.write('\nexit\n');
|
||||
child.waitExit();
|
||||
|
||||
try {
|
||||
return (JSON.parse(child.stdout.str.trim()));
|
||||
}
|
||||
catch (e) {
|
||||
return ([]);
|
||||
}
|
||||
try { r = JSON.parse(child.stdout.str.trim()); } catch (ex) { }
|
||||
break;
|
||||
default:
|
||||
return ([]);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
function closeDescriptors(libc, descriptors) {
|
||||
var fd = null;
|
||||
while (descriptors.length > 0) {
|
||||
|
@ -3777,9 +3777,11 @@
|
||||
else if (sort == 1) { nodes.sort(powerSort); }
|
||||
else if (sort == 2) { if (showRealNames == true) { nodes.sort(deviceHostSort); } else { nodes.sort(deviceSort); } }
|
||||
else if (sort == 5) {
|
||||
// if the last seen column is not turned on, turn it on first (we require this to sort the data)
|
||||
// If the last seen column is not turned on, turn it on first (we require this to sort the data)
|
||||
if (!(deviceViewSettings && deviceViewSettings.devsCols && deviceViewSettings.devsCols.indexOf('lastseen') >= 0)) {
|
||||
// force initialize the view settings
|
||||
// Request last connection data if not requested yet
|
||||
if (requestedLastConnects == false) { requestedLastConnects = true; meshserver.send({ action: 'lastconnects' }); }
|
||||
// Force initialize the view settings
|
||||
if (deviceViewSettings == null) { deviceViewSettings = {}; }
|
||||
if (!Array.isArray(deviceViewSettings.devsCols)) { deviceViewSettings.devsCols = ['user','ip','conn', 'lastseen']; }
|
||||
else { deviceViewSettings.devsCols.push('lastseen'); }
|
||||
@ -3787,7 +3789,6 @@
|
||||
nodes.sort(lastConnectSort);
|
||||
}
|
||||
|
||||
|
||||
// Compute the width of the device view.
|
||||
var totalDeviceViewWidth = Q('column_l').clientWidth - 60;
|
||||
var deviceBoxWidth = Math.floor(totalDeviceViewWidth / 301);
|
||||
@ -4268,7 +4269,7 @@
|
||||
if (deviceViewSettings.devsCols.indexOf('user') >= 0) { r += '<td style=text-align:center>' + getUserShortStr(node); } // User
|
||||
if (deviceViewSettings.devsCols.indexOf('ip') >= 0) { r += '<td style=text-align:center>' + (node.ip != null ? node.ip : ''); } // IP address
|
||||
if (deviceViewSettings.devsCols.indexOf('conn') >= 0) { r += '<td style=text-align:center>' + states.join(' + '); } // Connectivity
|
||||
if (deviceViewSettings.devsCols.indexOf('lastseen') >= 0) { r += '<td style=text-align:center;font-size:x-small>' + ((node.conn & 23 > 0 || node.lastconnect == null) ? '' : printDateTime(new Date(node.lastconnect))); }
|
||||
if (deviceViewSettings.devsCols.indexOf('lastseen') >= 0) { r += '<td style=text-align:center;font-size:x-small>'; if (node.conn & 1) { r += "Connected"; } else if (node.lastconnect != null) { r += printDateTime(new Date(node.lastconnect)); } }
|
||||
|
||||
div.innerHTML = r;
|
||||
} else if ((view == 3) || (view == 5)) {
|
||||
@ -5295,7 +5296,7 @@
|
||||
function powerSort(a, b) { var ap = a.pwr?a.pwr:0; var bp = b.pwr?b.pwr:0; if (ap > bp) return -1; if (ap < bp) return 1; if (ap == bp) { if (showRealNames == true) { if (a.rnamel > b.rnamel) return 1; if (a.rnamel < b.rnamel) return -1; return 0; } else { if (a.namel > b.namel) return 1; if (a.namel < b.namel) return -1; return 0; } } return 0; }
|
||||
function deviceSort(a, b) { if (a.namel > b.namel) return 1; if (a.namel < b.namel) return -1; return 0; }
|
||||
function deviceHostSort(a, b) { if (a.rnamel > b.rnamel) return 1; if (a.rnamel < b.rnamel) return -1; return 0; }
|
||||
function lastConnectSort(a, b) { return a.lastconnect - b.lastconnect; }
|
||||
function lastConnectSort(a, b) { var aa = a.lastconnect, bb = b.lastconnect; if (aa == null) { aa = 99999999999999; } if (bb == null) { bb = 99999999999999; } if (a.conn & 1) { aa = 99999999999998; } if (b.conn & 1) { bb = 99999999999998; } if (aa == bb) { return nameSort(a, b); } return (aa - bb); }
|
||||
function onSearchFocus(x) { searchFocus = x; }
|
||||
function clearDeviceSearch() { Q('KvmSearchInput').value = Q('SearchInput').value = ''; Q('DevFilterSelect').value = 0; onOnlineCheckBox(); mainUpdate(1); }
|
||||
function onMapSearchFocus(x) { mapSearchFocus = x; }
|
||||
|
Loading…
Reference in New Issue
Block a user