mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-26 07:57:56 +03:00
Windows hashing fix for MeshAssistant.
This commit is contained in:
parent
3cb606fcad
commit
db03a0959e
Binary file not shown.
@ -2401,40 +2401,58 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
// List of possible mesh agent install scripts
|
// List of possible mesh agent install scripts
|
||||||
var meshToolsList = {
|
var meshToolsList = {
|
||||||
'MeshCentralRouter': { localname: 'MeshCentralRouter.exe', dlname: 'winrouter' },
|
'MeshCentralRouter': { localname: 'MeshCentralRouter.exe', dlname: 'winrouter' },
|
||||||
'MeshCentralAssistant': { localname: 'MeshCentralAssistant.exe', dlname: 'winassistant' }
|
'MeshCentralAssistant': { localname: 'MeshCentralAssistant.exe', dlname: 'winassistant', winhash: true }
|
||||||
//'MeshCentralRouterMacOS': { localname: 'MeshCentralRouter.dmg', dlname: 'MeshCentralRouter.dmg' }
|
//'MeshCentralRouterMacOS': { localname: 'MeshCentralRouter.dmg', dlname: 'MeshCentralRouter.dmg' }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update the list of available mesh agents
|
// Update the list of available mesh agents
|
||||||
obj.updateMeshTools = function () {
|
obj.updateMeshTools = function () {
|
||||||
for (var toolname in meshToolsList) {
|
for (var toolname in meshToolsList) {
|
||||||
var toolpath = obj.path.join(__dirname, 'agents', meshToolsList[toolname].localname);
|
if (meshToolsList[toolname].winhash === true) {
|
||||||
var stream = null;
|
var toolpath = obj.path.join(__dirname, 'agents', meshToolsList[toolname].localname);
|
||||||
try {
|
var hashStream = obj.crypto.createHash('sha384');
|
||||||
stream = obj.fs.createReadStream(toolpath);
|
hashStream.toolname = toolname;
|
||||||
stream.on('data', function (data) { this.hash.update(data, 'binary'); this.hashx += data.length; });
|
hashStream.toolpath = toolpath;
|
||||||
stream.on('error', function (data) {
|
hashStream.dlname = meshToolsList[toolname].dlname;
|
||||||
// If there is an error reading this file, make sure this agent is not in the agent table
|
hashStream.hashx = 0;
|
||||||
if (obj.meshToolsBinaries[this.toolname] != null) { delete obj.meshToolsBinaries[this.toolname]; }
|
hashStream.on('data', function (data) {
|
||||||
});
|
obj.meshToolsBinaries[this.toolname] = { hash: data.toString('hex'), hashx: this.hashx, path: this.toolpath, dlname: this.dlname, url: this.url };
|
||||||
stream.on('end', function () {
|
|
||||||
// Add the agent to the agent table with all information and the hash
|
|
||||||
obj.meshToolsBinaries[this.toolname] = {};
|
|
||||||
obj.meshToolsBinaries[this.toolname].hash = this.hash.digest('hex');
|
|
||||||
obj.meshToolsBinaries[this.toolname].hashx = this.hashx;
|
|
||||||
obj.meshToolsBinaries[this.toolname].path = this.agentpath;
|
|
||||||
obj.meshToolsBinaries[this.toolname].dlname = this.dlname;
|
|
||||||
obj.meshToolsBinaries[this.toolname].url = 'https://' + obj.certificates.CommonName + ':' + ((typeof obj.args.aliasport == 'number') ? obj.args.aliasport : obj.args.port) + '/meshagents?meshaction=' + this.dlname;
|
obj.meshToolsBinaries[this.toolname].url = 'https://' + obj.certificates.CommonName + ':' + ((typeof obj.args.aliasport == 'number') ? obj.args.aliasport : obj.args.port) + '/meshagents?meshaction=' + this.dlname;
|
||||||
var stats = null;
|
var stats = null;
|
||||||
try { stats = obj.fs.statSync(this.agentpath); } catch (e) { }
|
try { stats = obj.fs.statSync(this.toolpath); } catch (e) { }
|
||||||
if (stats != null) { obj.meshToolsBinaries[this.toolname].size = stats.size; }
|
if (stats != null) { obj.meshToolsBinaries[this.toolname].size = stats.size; }
|
||||||
});
|
});
|
||||||
stream.toolname = toolname;
|
var options = { sourcePath: toolpath, targetStream: hashStream };
|
||||||
stream.agentpath = toolpath;
|
obj.exeHandler.hashExecutableFile(options);
|
||||||
stream.dlname = meshToolsList[toolname].dlname;
|
} else {
|
||||||
stream.hash = obj.crypto.createHash('sha384', stream);
|
var toolpath = obj.path.join(__dirname, 'agents', meshToolsList[toolname].localname);
|
||||||
stream.hashx = 0;
|
var stream = null;
|
||||||
} catch (e) { }
|
try {
|
||||||
|
stream = obj.fs.createReadStream(toolpath);
|
||||||
|
stream.on('data', function (data) { this.hash.update(data, 'binary'); this.hashx += data.length; });
|
||||||
|
stream.on('error', function (data) {
|
||||||
|
// If there is an error reading this file, make sure this agent is not in the agent table
|
||||||
|
if (obj.meshToolsBinaries[this.toolname] != null) { delete obj.meshToolsBinaries[this.toolname]; }
|
||||||
|
});
|
||||||
|
stream.on('end', function () {
|
||||||
|
// Add the agent to the agent table with all information and the hash
|
||||||
|
obj.meshToolsBinaries[this.toolname] = {};
|
||||||
|
obj.meshToolsBinaries[this.toolname].hash = this.hash.digest('hex');
|
||||||
|
obj.meshToolsBinaries[this.toolname].hashx = this.hashx;
|
||||||
|
obj.meshToolsBinaries[this.toolname].path = this.agentpath;
|
||||||
|
obj.meshToolsBinaries[this.toolname].dlname = this.dlname;
|
||||||
|
obj.meshToolsBinaries[this.toolname].url = 'https://' + obj.certificates.CommonName + ':' + ((typeof obj.args.aliasport == 'number') ? obj.args.aliasport : obj.args.port) + '/meshagents?meshaction=' + this.dlname;
|
||||||
|
var stats = null;
|
||||||
|
try { stats = obj.fs.statSync(this.agentpath); } catch (e) { }
|
||||||
|
if (stats != null) { obj.meshToolsBinaries[this.toolname].size = stats.size; }
|
||||||
|
});
|
||||||
|
stream.toolname = toolname;
|
||||||
|
stream.agentpath = toolpath;
|
||||||
|
stream.dlname = meshToolsList[toolname].dlname;
|
||||||
|
stream.hash = obj.crypto.createHash('sha384', stream);
|
||||||
|
stream.hashx = 0;
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user