From 01025a7ec1ad2de53beeed9bbd9c281d1de1d4d2 Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Wed, 7 Aug 2019 11:08:36 -0700 Subject: [PATCH] Added copy in network interface dialog, commented out sysinfo until agent binary fix. --- agents/meshcore.js | 16 +++++++++------- agents/meshcore.min.js | 16 +++++++++------- meshagent.js | 4 ++++ package.json | 2 +- views/default-min.handlebars | 2 +- views/default.handlebars | 17 +++++++++-------- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/agents/meshcore.js b/agents/meshcore.js index d68fc305..eb907df1 100644 --- a/agents/meshcore.js +++ b/agents/meshcore.js @@ -822,6 +822,7 @@ function createMeshCore(agent) sendConsoleText('getScript: ' + JSON.stringify(data)); break; } + /* case 'sysinfo': { // Fetch system information 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.TotalVisibleMemorySize; } catch (ex) { } } - /* if (process.platform == 'win32') { 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 }); } } } - var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag + var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag TODO pr.callname = 'defrag'; pr.sessionid = data.sessionid; pr.then(defragResult, defragResult); } else { - */ - 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 }); } - //} + 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 }); } + } } catch (ex) { } break; } + */ case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; } case 'pong': { break; } default: @@ -1650,7 +1650,7 @@ function createMeshCore(agent) var response = null; switch (cmd) { 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; } /* @@ -1814,6 +1814,7 @@ function createMeshCore(agent) } break; } + /* case 'cpuinfo': { // Return system information // CPU & memory utilization pr = require('sysinfo').cpuUtilization(); @@ -1849,6 +1850,7 @@ function createMeshCore(agent) } break; } + */ 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 + '.'; if (amt != null) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amt.lmsstate] + '.'; } diff --git a/agents/meshcore.min.js b/agents/meshcore.min.js index d68fc305..eb907df1 100644 --- a/agents/meshcore.min.js +++ b/agents/meshcore.min.js @@ -822,6 +822,7 @@ function createMeshCore(agent) sendConsoleText('getScript: ' + JSON.stringify(data)); break; } + /* case 'sysinfo': { // Fetch system information 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.TotalVisibleMemorySize; } catch (ex) { } } - /* if (process.platform == 'win32') { 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 }); } } } - var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag + var pr = require('win-info').defrag({ volume: 'C:' }); // Defrag TODO pr.callname = 'defrag'; pr.sessionid = data.sessionid; pr.then(defragResult, defragResult); } else { - */ - 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 }); } - //} + 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 }); } + } } catch (ex) { } break; } + */ case 'ping': { mesh.SendCommand('{"action":"pong"}'); break; } case 'pong': { break; } default: @@ -1650,7 +1650,7 @@ function createMeshCore(agent) var response = null; switch (cmd) { 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; } /* @@ -1814,6 +1814,7 @@ function createMeshCore(agent) } break; } + /* case 'cpuinfo': { // Return system information // CPU & memory utilization pr = require('sysinfo').cpuUtilization(); @@ -1849,6 +1850,7 @@ function createMeshCore(agent) } break; } + */ 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 + '.'; if (amt != null) { response += '\r\nBuilt-in LMS: ' + ['Disabled', 'Connecting..', 'Connected'][amt.lmsstate] + '.'; } diff --git a/meshagent.js b/meshagent.js index 50815893..baf10701 100644 --- a/meshagent.js +++ b/meshagent.js @@ -911,9 +911,11 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { } // Fetch system information + /* 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' })); } }); + */ // Do this if IP location is enabled on this domain TODO: Set IP location per device group? if (domain.iplocation == true) { @@ -1304,6 +1306,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { } break; } + /* case 'sysinfo': { //console.log('sysinfo', obj.nodeid, JSON.stringify(command.data.hash)); command.data._id = 'si' + obj.dbNodeKey; @@ -1317,6 +1320,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) { }); break; } + */ default: { parent.agentStats.unknownAgentActionCount++; console.log('Unknown agent action (' + obj.remoteaddrport + '): ' + command.action + '.'); diff --git a/package.json b/package.json index 001441e0..2ae91e78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "meshcentral", - "version": "0.3.9-h", + "version": "0.3.9-i", "keywords": [ "Remote Management", "Intel AMT", diff --git a/views/default-min.handlebars b/views/default-min.handlebars index f43a9fc3..e658cd75 100644 --- a/views/default-min.handlebars +++ b/views/default-min.handlebars @@ -1 +1 @@ - {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file + {{{title}}}
{{{title}}}
{{{title2}}}

{{{logoutControl}}}

 

\ No newline at end of file diff --git a/views/default.handlebars b/views/default.handlebars index 8c22ee46..54a03a56 100644 --- a/views/default.handlebars +++ b/views/default.handlebars @@ -1497,13 +1497,13 @@ var splitip = currentNode.lastaddr.split(':'); if (splitip.length > 2) { // IPv6 - x += addHtmlValue2('Last agent address', currentNode.lastaddr); + x += addHtmlValue2('Last agent address', currentNode.lastaddr + ' '); } else { // IPv4 if (isPrivateIP(currentNode.lastaddr)) { - x += addHtmlValue2('Last agent address', splitip[0]); + x += addHtmlValue2('Last agent address', splitip[0] + ' '); } else { - x += addHtmlValue2('Last agent address', '' + splitip[0] + ''); + x += addHtmlValue2('Last agent address', '' + splitip[0] + ' '); } } } @@ -1515,11 +1515,11 @@ if (net.name) { x += addHtmlValue2('Name', '' + EscapeHtml(net.name) + ''); } if (net.desc) { x += addHtmlValue2('Description', EscapeHtml(net.desc).replace('(R)', '®').replace('(r)', '®')); } if (net.dnssuffix) { x += addHtmlValue2('DNS suffix', EscapeHtml(net.dnssuffix)); } - if (net.mac) { x += addHtmlValue2('MAC address', '' + EscapeHtml(net.mac.toLowerCase()) + ''); } - if (net.v4addr) { x += addHtmlValue2('IPv4 address', EscapeHtml(net.v4addr)); } - if (net.v4mask) { x += addHtmlValue2('IPv4 mask', EscapeHtml(net.v4mask)); } - if (net.v4gateway) { x += addHtmlValue2('IPv4 gateway', EscapeHtml(net.v4gateway)); } - if (net.gatewaymac) { x += addHtmlValue2('Gateway MAC', '' + EscapeHtml(net.gatewaymac.toLowerCase()) + ''); } + if (net.mac) { x += addHtmlValue2('MAC address', '' + EscapeHtml(net.mac.toLowerCase()) + ' '); } + if (net.v4addr) { x += addHtmlValue2('IPv4 address', EscapeHtml(net.v4addr) + ' '); } + if (net.v4mask) { x += addHtmlValue2('IPv4 mask', EscapeHtml(net.v4mask) + ' '); } + if (net.v4gateway) { x += addHtmlValue2('IPv4 gateway', EscapeHtml(net.v4gateway) + ' '); } + if (net.gatewaymac) { x += addHtmlValue2('Gateway MAC', '' + EscapeHtml(net.gatewaymac.toLowerCase()) + ' '); } } 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 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 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 printDate(d) { return d.toLocaleDateString(args.locale); } function printTime(d) { return d.toLocaleTimeString(args.locale); }