Added way to not save SMBIOS information in the DB.

This commit is contained in:
Ylian Saint-Hilaire 2020-04-24 13:37:37 -07:00
parent fc4f469e63
commit 7653d1c398
2 changed files with 14 additions and 11 deletions

10
db.js
View File

@ -726,19 +726,19 @@ module.exports.CreateDB = function (parent, func) {
conn.release();
const docs = [];
for (var i in rows) { if (rows[i].doc) { docs.push(performTypedRecordDecrypt(JSON.parse(rows[i].doc))); } }
if (func) try { func(null, docs); } catch (ex) { console.log(ex); }
if (func) try { func(null, docs); } catch (ex) { console.log('SQLERR1', ex); }
})
.catch(function (err) { conn.release(); if (func) try { func(err); } catch (ex) { console.log(ex); } });
}).catch(function (err) { if (func) { try { func(err); } catch (ex) { console.log(ex); } } });
.catch(function (err) { conn.release(); if (func) try { func(err); } catch (ex) { console.log('SQLERR2', ex); } });
}).catch(function (err) { if (func) { try { func(err); } catch (ex) { console.log('SQLERR3', ex); } } });
} else if (obj.databaseType == 5) { // MySQL
Datastore.query(query, args, function (error, results, fields) {
if (error != null) {
if (func) try { func(error); } catch (ex) { console.log(ex); }
if (func) try { func(error); } catch (ex) { console.log('SQLERR4', ex); }
} else {
var docs = [];
for (var i in results) { if (results[i].doc) { docs.push(JSON.parse(results[i].doc)); } }
//console.log(docs);
if (func) { try { func(null, docs); } catch (ex) { console.log(ex); } }
if (func) { try { func(null, docs); } catch (ex) { console.log('SQLERR5', ex); } }
}
});
}

View File

@ -1125,12 +1125,15 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
}
case 'smbios':
{
// Store the RAW SMBios table of this computer
// Perform sanity checks before storing
try {
for (var i in command.value) { var k = parseInt(i); if ((k != i) || (i > 255) || (typeof command.value[i] != 'object') || (command.value[i].length == null) || (command.value[i].length > 1024) || (command.value[i].length < 0)) { delete command.value[i]; } }
db.SetSMBIOS({ _id: obj.dbNodeKey, domain: domain.id, time: new Date(), value: command.value });
} catch (ex) { }
// See if we need to save SMBIOS information
if (domain.smbios !== false) {
// Store the RAW SMBios table of this computer
// Perform sanity checks before storing
try {
for (var i in command.value) { var k = parseInt(i); if ((k != i) || (i > 255) || (typeof command.value[i] != 'object') || (command.value[i].length == null) || (command.value[i].length > 1024) || (command.value[i].length < 0)) { delete command.value[i]; } }
db.SetSMBIOS({ _id: obj.dbNodeKey, domain: domain.id, time: new Date(), value: command.value });
} catch (ex) { }
}
// Event the node interface information change (This is a lot of traffic, probably don't need this).
//parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(obj.meshid, [obj.dbNodeKey]), obj, { action: 'smBiosChange', nodeid: obj.dbNodeKey, domain: domain.id, smbios: command.value, nolog: 1 });