mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Improved agent hashing file.
This commit is contained in:
parent
3cca0d5847
commit
081b7316bf
4 changed files with 169 additions and 52 deletions
|
|
@ -1,4 +1,4 @@
|
|||
var fs = require('fs'), r = '';
|
||||
var fs = require('fs');
|
||||
|
||||
var agents = {
|
||||
'MeshService-signed.exe': 3,
|
||||
|
|
@ -27,11 +27,16 @@ var agents = {
|
|||
'meshagent_osx-universal-64': 10005
|
||||
}
|
||||
|
||||
for (var i in agents) { r += hashAgent(i, agents[i]); }
|
||||
console.log(r);
|
||||
var agentinfo = [];
|
||||
for (var i in agents) {
|
||||
var info = getAgentInfo(i, agents[i]);
|
||||
if (info != null) { agentinfo.push(info); }
|
||||
}
|
||||
console.log(JSON.stringify(agentinfo, null, 2));
|
||||
process.exit();
|
||||
|
||||
function hashAgent(filename, id) {
|
||||
if (fs.existsSync(filename) != true) return '';
|
||||
return id + ': ' + filename + '\r\n' + getSHA384FileHash(filename).toString('hex') + '\r\n';
|
||||
function getAgentInfo(filename, id) {
|
||||
if (fs.existsSync(filename) != true) return null;
|
||||
var stats = fs.statSync(filename);
|
||||
return { id: id, filename: filename, hash: getSHA384FileHash(filename).toString('hex'), size: stats.size, mtime: stats.mtime };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue