mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
move identifiers to server side to allow future updates (#5641)
* move identifiers to server side to allow future updates Signed-off-by: si458 <simonsmith5521@gmail.com> * add rpi support Signed-off-by: si458 <simonsmith5521@gmail.com> --------- Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
a17fd2f268
commit
bfae0d6c6e
2 changed files with 792 additions and 16 deletions
|
@ -622,7 +622,7 @@ if ((require('fs').existsSync(process.cwd() + 'batterystate.txt')) && (require('
|
|||
else {
|
||||
try {
|
||||
// Setup normal battery monitoring
|
||||
if (require('identifiers').isBatteryPowered && require('identifiers').isBatteryPowered()) {
|
||||
if (require('computer-identifiers').isBatteryPowered && require('computer-identifiers').isBatteryPowered()) {
|
||||
require('MeshAgent')._battLevelChanged = function _battLevelChanged(val) {
|
||||
_battLevelChanged.self._currentBatteryLevel = val;
|
||||
_battLevelChanged.self.SendCommand({ action: 'battery', state: _battLevelChanged.self._currentPowerState, level: val });
|
||||
|
@ -657,14 +657,14 @@ try { require('os').name().then(function (v) { meshCoreObj.osdesc = v; meshCoreO
|
|||
// Get Volumes and BitLocker if Windows
|
||||
try {
|
||||
if (process.platform == 'win32'){
|
||||
if (require('identifiers').volumes_promise != null){
|
||||
var p = require('identifiers').volumes_promise();
|
||||
if (require('computer-identifiers').volumes_promise != null){
|
||||
var p = require('computer-identifiers').volumes_promise();
|
||||
p.then(function (res){
|
||||
meshCoreObj.volumes = res;
|
||||
meshCoreObjChanged();
|
||||
});
|
||||
}else if (require('identifiers').volumes != null){
|
||||
meshCoreObj.volumes = require('identifiers').volumes();
|
||||
}else if (require('computer-identifiers').volumes != null){
|
||||
meshCoreObj.volumes = require('computer-identifiers').volumes();
|
||||
meshCoreObjChanged();
|
||||
}
|
||||
}
|
||||
|
@ -1813,7 +1813,7 @@ function onFileWatcher(a, b) {
|
|||
*/
|
||||
|
||||
// Replace all key name spaces with _ in an object recursively.
|
||||
// This is a workaround since require('identifiers').get() returns key names with spaces in them on Linux.
|
||||
// This is a workaround since require('computer-identifiers').get() returns key names with spaces in them on Linux.
|
||||
function replaceSpacesWithUnderscoresRec(o) {
|
||||
if (typeof o != 'object') return;
|
||||
for (var i in o) { if (i.indexOf(' ') >= 0) { o[i.split(' ').join('_')] = o[i]; delete o[i]; } replaceSpacesWithUnderscoresRec(o[i]); }
|
||||
|
@ -1821,8 +1821,7 @@ function replaceSpacesWithUnderscoresRec(o) {
|
|||
|
||||
function getSystemInformation(func) {
|
||||
try {
|
||||
var results = { hardware: require('identifiers').get() }; // Hardware info
|
||||
|
||||
var results = { hardware: require('computer-identifiers').get() }; // Hardware info
|
||||
if (results.hardware && results.hardware.windows) {
|
||||
// Remove extra entries and things that change quickly
|
||||
var x = results.hardware.windows.osinfo;
|
||||
|
@ -1873,9 +1872,11 @@ function getSystemInformation(func) {
|
|||
}
|
||||
if(results.hardware && results.hardware.linux) {
|
||||
if (!results.hardware.identifiers['bios_serial']) {
|
||||
if (require('fs').statSync('/sys/class/dmi/id/product_serial').isFile()){
|
||||
results.hardware.identifiers['bios_serial'] = require('fs').readFileSync('/sys/class/dmi/id/product_serial').toString().trim();
|
||||
}
|
||||
try {
|
||||
if (require('fs').statSync('/sys/class/dmi/id/product_serial').isFile()){
|
||||
results.hardware.identifiers['bios_serial'] = require('fs').readFileSync('/sys/class/dmi/id/product_serial').toString().trim();
|
||||
}
|
||||
} catch (ex) { }
|
||||
}
|
||||
if (!results.hardware.identifiers['bios_mode']) {
|
||||
try {
|
||||
|
@ -1928,9 +1929,9 @@ function getSystemInformation(func) {
|
|||
{
|
||||
results.pendingReboot = require('win-info').pendingReboot(); // Pending reboot
|
||||
|
||||
if (require('identifiers').volumes_promise != null)
|
||||
if (require('computer-identifiers').volumes_promise != null)
|
||||
{
|
||||
var p = require('identifiers').volumes_promise();
|
||||
var p = require('computer-identifiers').volumes_promise();
|
||||
p.then(function (res)
|
||||
{
|
||||
results.hardware.windows.volumes = res;
|
||||
|
@ -1938,9 +1939,9 @@ function getSystemInformation(func) {
|
|||
func(results);
|
||||
});
|
||||
}
|
||||
else if (require('identifiers').volumes != null)
|
||||
else if (require('computer-identifiers').volumes != null)
|
||||
{
|
||||
results.hardware.windows.volumes = require('identifiers').volumes();
|
||||
results.hardware.windows.volumes = require('computer-identifiers').volumes();
|
||||
results.hash = hasher.syncHash(JSON.stringify(results)).toString('hex');
|
||||
func(results);
|
||||
}
|
||||
|
@ -4250,7 +4251,7 @@ function processConsoleCommand(cmd, args, rights, sessionid) {
|
|||
}
|
||||
break;
|
||||
case 'vm':
|
||||
response = 'Virtual Machine = ' + require('identifiers').isVM();
|
||||
response = 'Virtual Machine = ' + require('computer-identifiers').isVM();
|
||||
break;
|
||||
case 'startupoptions':
|
||||
response = JSON.stringify(require('MeshAgent').getStartupOptions());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue