Added copy in network interface dialog, commented out sysinfo until agent binary fix.

This commit is contained in:
Ylian Saint-Hilaire 2019-08-07 11:08:36 -07:00
parent bfd56a8a64
commit 01025a7ec1
6 changed files with 33 additions and 24 deletions

View File

@ -822,6 +822,7 @@ function createMeshCore(agent)
sendConsoleText('getScript: ' + JSON.stringify(data)); sendConsoleText('getScript: ' + JSON.stringify(data));
break; break;
} }
/*
case 'sysinfo': { case 'sysinfo': {
// Fetch system information // Fetch system information
if (process.platform != 'win32') break; // Remove this when Linux/MacOS support this. if (process.platform != 'win32') break; // Remove this when Linux/MacOS support this.
@ -837,7 +838,6 @@ function createMeshCore(agent)
try { delete x.TotalVirtualMemorySize; } catch (ex) { } try { delete x.TotalVirtualMemorySize; } catch (ex) { }
try { delete x.TotalVisibleMemorySize; } catch (ex) { } try { delete x.TotalVisibleMemorySize; } catch (ex) { }
} }
/*
if (process.platform == 'win32') if (process.platform == 'win32')
{ {
var defragResult = function (r) var defragResult = function (r)
@ -857,18 +857,18 @@ function createMeshCore(agent)
if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); } if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); }
} }
} }
var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag TODO
pr.callname = 'defrag'; pr.callname = 'defrag';
pr.sessionid = data.sessionid; pr.sessionid = data.sessionid;
pr.then(defragResult, defragResult); pr.then(defragResult, defragResult);
} else { } else {
*/ results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex');
results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex'); if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); }
if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); } }
//}
} catch (ex) { } } catch (ex) { }
break; break;
} }
*/
case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; } case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; }
case 'pong': { break; } case 'pong': { break; }
default: default:
@ -1650,7 +1650,7 @@ function createMeshCore(agent)
var response = null; var response = null;
switch (cmd) { switch (cmd) {
case 'help': { // Displays available commands case 'help': { // Displays available commands
response = 'Available commands: help, info, osinfo, args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps, openurl, amtreset, amtccm, amtacm,\r\namtdeactivate, amtpolicy, getscript, getclip, setclip, log, av, cpuinfo, sysinfo.'; response = 'Available commands: help, info, osinfo, args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps, openurl, amtreset, amtccm, amtacm,\r\namtdeactivate, amtpolicy, getscript, getclip, setclip, log, av.'; // cpuinfo, sysinfo
break; break;
} }
/* /*
@ -1814,6 +1814,7 @@ function createMeshCore(agent)
} }
break; break;
} }
/*
case 'cpuinfo': { // Return system information case 'cpuinfo': { // Return system information
// CPU & memory utilization // CPU & memory utilization
pr = require('sysinfo').cpuUtilization(); pr = require('sysinfo').cpuUtilization();
@ -1849,6 +1850,7 @@ function createMeshCore(agent)
} }
break; break;
} }
*/
case 'info': { // Return information about the agent and agent core module case 'info': { // Return information about the agent and agent core module
response = 'Current Core: ' + meshCoreObj.value + '.\r\nAgent Time: ' + Date() + '.\r\nUser Rights: 0x' + rights.toString(16) + '.\r\nPlatform: ' + process.platform + '.\r\nCapabilities: ' + meshCoreObj.caps + '.\r\nServer URL: ' + mesh.ServerUrl + '.'; response = 'Current Core: ' + meshCoreObj.value + '.\r\nAgent Time: ' + Date() + '.\r\nUser Rights: 0x' + rights.toString(16) + '.\r\nPlatform: ' + process.platform + '.\r\nCapabilities: ' + meshCoreObj.caps + '.\r\nServer URL: ' + mesh.ServerUrl + '.';
if (amt != null) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amt.lmsstate] + '.'; } if (amt != null) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amt.lmsstate] + '.'; }

View File

@ -822,6 +822,7 @@ function createMeshCore(agent)
sendConsoleText('getScript: ' + JSON.stringify(data)); sendConsoleText('getScript: ' + JSON.stringify(data));
break; break;
} }
/*
case 'sysinfo': { case 'sysinfo': {
// Fetch system information // Fetch system information
if (process.platform != 'win32') break; // Remove this when Linux/MacOS support this. if (process.platform != 'win32') break; // Remove this when Linux/MacOS support this.
@ -837,7 +838,6 @@ function createMeshCore(agent)
try { delete x.TotalVirtualMemorySize; } catch (ex) { } try { delete x.TotalVirtualMemorySize; } catch (ex) { }
try { delete x.TotalVisibleMemorySize; } catch (ex) { } try { delete x.TotalVisibleMemorySize; } catch (ex) { }
} }
/*
if (process.platform == 'win32') if (process.platform == 'win32')
{ {
var defragResult = function (r) var defragResult = function (r)
@ -857,18 +857,18 @@ function createMeshCore(agent)
if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); } if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); }
} }
} }
var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag TODO
pr.callname = 'defrag'; pr.callname = 'defrag';
pr.sessionid = data.sessionid; pr.sessionid = data.sessionid;
pr.then(defragResult, defragResult); pr.then(defragResult, defragResult);
} else { } else {
*/ results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex');
results.hash = require('SHA384Stream').create().syncHash(JSON.stringify(results)).toString('hex'); if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); }
if (data.hash != results.hash) { mesh.SendCommand({ "action": "sysinfo", "sessionid": this.sessionid, "data": results }); } }
//}
} catch (ex) { } } catch (ex) { }
break; break;
} }
*/
case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; } case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; }
case 'pong': { break; } case 'pong': { break; }
default: default:
@ -1650,7 +1650,7 @@ function createMeshCore(agent)
var response = null; var response = null;
switch (cmd) { switch (cmd) {
case 'help': { // Displays available commands case 'help': { // Displays available commands
response = 'Available commands: help, info, osinfo, args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps, openurl, amtreset, amtccm, amtacm,\r\namtdeactivate, amtpolicy, getscript, getclip, setclip, log, av, cpuinfo, sysinfo.'; response = 'Available commands: help, info, osinfo, args, print, type, dbget, dbset, dbcompact, eval, parseuri, httpget,\r\nwslist, wsconnect, wssend, wsclose, notify, ls, ps, kill, amt, netinfo, location, power, wakeonlan, scanwifi,\r\nscanamt, setdebug, smbios, rawsmbios, toast, lock, users, sendcaps, openurl, amtreset, amtccm, amtacm,\r\namtdeactivate, amtpolicy, getscript, getclip, setclip, log, av.'; // cpuinfo, sysinfo
break; break;
} }
/* /*
@ -1814,6 +1814,7 @@ function createMeshCore(agent)
} }
break; break;
} }
/*
case 'cpuinfo': { // Return system information case 'cpuinfo': { // Return system information
// CPU & memory utilization // CPU & memory utilization
pr = require('sysinfo').cpuUtilization(); pr = require('sysinfo').cpuUtilization();
@ -1849,6 +1850,7 @@ function createMeshCore(agent)
} }
break; break;
} }
*/
case 'info': { // Return information about the agent and agent core module case 'info': { // Return information about the agent and agent core module
response = 'Current Core: ' + meshCoreObj.value + '.\r\nAgent Time: ' + Date() + '.\r\nUser Rights: 0x' + rights.toString(16) + '.\r\nPlatform: ' + process.platform + '.\r\nCapabilities: ' + meshCoreObj.caps + '.\r\nServer URL: ' + mesh.ServerUrl + '.'; response = 'Current Core: ' + meshCoreObj.value + '.\r\nAgent Time: ' + Date() + '.\r\nUser Rights: 0x' + rights.toString(16) + '.\r\nPlatform: ' + process.platform + '.\r\nCapabilities: ' + meshCoreObj.caps + '.\r\nServer URL: ' + mesh.ServerUrl + '.';
if (amt != null) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amt.lmsstate] + '.'; } if (amt != null) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amt.lmsstate] + '.'; }

View File

@ -911,9 +911,11 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
} }
// Fetch system information // Fetch system information
/*
db.GetHash('si' + obj.dbNodeKey, function (err, results) { db.GetHash('si' + obj.dbNodeKey, function (err, results) {
if ((results != null) && (results.length == 1)) { obj.send(JSON.stringify({ action: 'sysinfo', hash: results[0].hash })); } else { obj.send(JSON.stringify({ action: 'sysinfo' })); } if ((results != null) && (results.length == 1)) { obj.send(JSON.stringify({ action: 'sysinfo', hash: results[0].hash })); } else { obj.send(JSON.stringify({ action: 'sysinfo' })); }
}); });
*/
// Do this if IP location is enabled on this domain TODO: Set IP location per device group? // Do this if IP location is enabled on this domain TODO: Set IP location per device group?
if (domain.iplocation == true) { if (domain.iplocation == true) {
@ -1304,6 +1306,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
} }
break; break;
} }
/*
case 'sysinfo': { case 'sysinfo': {
//console.log('sysinfo', obj.nodeid, JSON.stringify(command.data.hash)); //console.log('sysinfo', obj.nodeid, JSON.stringify(command.data.hash));
command.data._id = 'si' + obj.dbNodeKey; command.data._id = 'si' + obj.dbNodeKey;
@ -1317,6 +1320,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
}); });
break; break;
} }
*/
default: { default: {
parent.agentStats.unknownAgentActionCount++; parent.agentStats.unknownAgentActionCount++;
console.log('Unknown agent action (' + obj.remoteaddrport + '): ' + command.action + '.'); console.log('Unknown agent action (' + obj.remoteaddrport + '): ' + command.action + '.');

View File

@ -1,6 +1,6 @@
{ {
"name": "meshcentral", "name": "meshcentral",
"version": "0.3.9-h", "version": "0.3.9-i",
"keywords": [ "keywords": [
"Remote Management", "Remote Management",
"Intel AMT", "Intel AMT",

File diff suppressed because one or more lines are too long

View File

@ -1497,13 +1497,13 @@
var splitip = currentNode.lastaddr.split(':'); var splitip = currentNode.lastaddr.split(':');
if (splitip.length > 2) { if (splitip.length > 2) {
// IPv6 // IPv6
x += addHtmlValue2('Last agent address', currentNode.lastaddr); x += addHtmlValue2('Last agent address', currentNode.lastaddr + ' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(currentNode.lastaddr) + '\") width=10 height=10>');
} else { } else {
// IPv4 // IPv4
if (isPrivateIP(currentNode.lastaddr)) { if (isPrivateIP(currentNode.lastaddr)) {
x += addHtmlValue2('Last agent address', splitip[0]); x += addHtmlValue2('Last agent address', splitip[0] + ' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(splitip[0]) + '\") width=10 height=10>');
} else { } else {
x += addHtmlValue2('Last agent address', '<a href="https://iplocation.com/?ip=' + splitip[0] + '" rel="noreferrer noopener" target="MeshIPLoopup">' + splitip[0] + '</a>'); x += addHtmlValue2('Last agent address', '<a href="https://iplocation.com/?ip=' + splitip[0] + '" rel="noreferrer noopener" target="MeshIPLoopup">' + splitip[0] + '</a> <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(splitip[0]) + '\") width=10 height=10>');
} }
} }
} }
@ -1515,11 +1515,11 @@
if (net.name) { x += addHtmlValue2('Name', '<b>' + EscapeHtml(net.name) + '</b>'); } if (net.name) { x += addHtmlValue2('Name', '<b>' + EscapeHtml(net.name) + '</b>'); }
if (net.desc) { x += addHtmlValue2('Description', EscapeHtml(net.desc).replace('(R)', '&reg;').replace('(r)', '&reg;')); } if (net.desc) { x += addHtmlValue2('Description', EscapeHtml(net.desc).replace('(R)', '&reg;').replace('(r)', '&reg;')); }
if (net.dnssuffix) { x += addHtmlValue2('DNS suffix', EscapeHtml(net.dnssuffix)); } if (net.dnssuffix) { x += addHtmlValue2('DNS suffix', EscapeHtml(net.dnssuffix)); }
if (net.mac) { x += addHtmlValue2('MAC address', '<a href="https://dnslytics.com/mac-address-lookup/' + net.mac.substring(0,6) + '" rel="noreferrer noopener" target="MeshMACLoopup">' + EscapeHtml(net.mac.toLowerCase()) + '</a>'); } if (net.mac) { x += addHtmlValue2('MAC address', '<a href="https://dnslytics.com/mac-address-lookup/' + net.mac.substring(0, 6) + '" rel="noreferrer noopener" target="MeshMACLoopup">' + EscapeHtml(net.mac.toLowerCase()) + '</a> <img src="images/link4.png" title="Copy MAC address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(net.mac.toLowerCase()) + '\") width=10 height=10>'); }
if (net.v4addr) { x += addHtmlValue2('IPv4 address', EscapeHtml(net.v4addr)); } if (net.v4addr) { x += addHtmlValue2('IPv4 address', EscapeHtml(net.v4addr) + ' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(net.v4addr) + '\") width=10 height=10>'); }
if (net.v4mask) { x += addHtmlValue2('IPv4 mask', EscapeHtml(net.v4mask)); } if (net.v4mask) { x += addHtmlValue2('IPv4 mask', EscapeHtml(net.v4mask) + ' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(net.v4mask) + '\") width=10 height=10>'); }
if (net.v4gateway) { x += addHtmlValue2('IPv4 gateway', EscapeHtml(net.v4gateway)); } if (net.v4gateway) { x += addHtmlValue2('IPv4 gateway', EscapeHtml(net.v4gateway) + ' <img src="images/link4.png" title="Copy address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(net.v4gateway) + '\") width=10 height=10>'); }
if (net.gatewaymac) { x += addHtmlValue2('Gateway MAC', '<a href="https://dnslytics.com/mac-address-lookup/' + net.gatewaymac.substring(0, 6) + '" rel="noreferrer noopener" target="MeshMACLoopup">' + EscapeHtml(net.gatewaymac.toLowerCase()) + '</a>'); } if (net.gatewaymac) { x += addHtmlValue2('Gateway MAC', '<a href="https://dnslytics.com/mac-address-lookup/' + net.gatewaymac.substring(0, 6) + '" rel="noreferrer noopener" target="MeshMACLoopup">' + EscapeHtml(net.gatewaymac.toLowerCase()) + '</a> <img src="images/link4.png" title="Copy MAC address to clipboard" style="cursor:pointer" onclick=copyTextToClip2(\"' + encodeURIComponent(net.gatewaymac.toLowerCase()) + '\") width=10 height=10>'); }
} }
x += '</div>'; x += '</div>';
QH('d2netinfo', x); QH('d2netinfo', x);
@ -8709,6 +8709,7 @@
function u2fSupported() { return (window.u2f && ((navigator.userAgent.indexOf('Chrome/') > 0) || (navigator.userAgent.indexOf('Firefox/') > 0) || (navigator.userAgent.indexOf('Opera/') > 0) || (navigator.userAgent.indexOf('Safari/') > 0))); } function u2fSupported() { return (window.u2f && ((navigator.userAgent.indexOf('Chrome/') > 0) || (navigator.userAgent.indexOf('Firefox/') > 0) || (navigator.userAgent.indexOf('Opera/') > 0) || (navigator.userAgent.indexOf('Safari/') > 0))); }
function findOne(arr1, arr2) { if ((arr1 == null) || (arr2 == null)) return false; return arr2.some(function (v) { return arr1.indexOf(v) >= 0; }); }; function findOne(arr1, arr2) { if ((arr1 == null) || (arr2 == null)) return false; return arr2.some(function (v) { return arr1.indexOf(v) >= 0; }); };
function copyTextToClip(txt) { function selectElementText(e) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(e); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(e); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); } } var e = document.createElement('DIV'); e.textContent = txt; document.body.appendChild(e); selectElementText(e); document.execCommand('copy'); e.remove(); } function copyTextToClip(txt) { function selectElementText(e) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(e); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(e); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); } } var e = document.createElement('DIV'); e.textContent = txt; document.body.appendChild(e); selectElementText(e); document.execCommand('copy'); e.remove(); }
function copyTextToClip2(txt) { function selectElementText(e) { if (document.selection) { var range = document.body.createTextRange(); range.moveToElementText(e); range.select(); } else if (window.getSelection) { var range = document.createRange(); range.selectNode(e); window.getSelection().removeAllRanges(); window.getSelection().addRange(range); } } var e = document.createElement('DIV'); e.textContent = decodeURIComponent(txt); document.body.appendChild(e); selectElementText(e); document.execCommand('copy'); e.remove(); }
function capitalizeFirstLetter(x) { return x.charAt(0).toUpperCase() + x.slice(1); } function capitalizeFirstLetter(x) { return x.charAt(0).toUpperCase() + x.slice(1); }
function printDate(d) { return d.toLocaleDateString(args.locale); } function printDate(d) { return d.toLocaleDateString(args.locale); }
function printTime(d) { return d.toLocaleTimeString(args.locale); } function printTime(d) { return d.toLocaleTimeString(args.locale); }