mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Fixed utf8 in meshcore.
This commit is contained in:
parent
924d62c940
commit
cd85c66a1d
3 changed files with 10 additions and 6 deletions
|
@ -2479,7 +2479,8 @@ function CreateMeshCentralServer(config, args) {
|
|||
if (modulesDir[i].toLowerCase().endsWith('.json')) {
|
||||
var moduleName = modulesDir[i].substring(0, modulesDir[i].length - 5);
|
||||
if (moduleName.endsWith('.min')) { moduleName = moduleName.substring(0, moduleName.length - 6); } // Remove the ".min" for ".min.json" files.
|
||||
var moduleData = ['var ', moduleName, ' = JSON.parse("', obj.escapeCodeString(obj.fs.readFileSync(obj.path.join(moduleDirPath, modulesDir[i])).toString('utf8')), '");\r\n'];
|
||||
var d = obj.fs.readFileSync(obj.path.join(moduleDirPath, modulesDir[i])).toString('utf8').split('\'').join('\\\'');
|
||||
var moduleData = ['var ', moduleName, ' = JSON.parse(\'', d, '\');\r\n'];
|
||||
|
||||
// Add to all cores
|
||||
modulesAdd['windows-amt'].push(...moduleData);
|
||||
|
@ -2546,15 +2547,17 @@ function CreateMeshCentralServer(config, args) {
|
|||
} else {
|
||||
obj.defaultMeshCores[i] = [obj.common.IntToStr(0), ...modulesAdd[i], meshCore].join('');
|
||||
}
|
||||
obj.defaultMeshCores[i] = Buffer.from(obj.defaultMeshCores[i], 'utf8');
|
||||
obj.defaultMeshCoresHash[i] = obj.crypto.createHash('sha384').update(obj.defaultMeshCores[i]).digest('binary');
|
||||
obj.debug('main', 'Core module ' + i + ' is ' + obj.defaultMeshCores[i].length + ' bytes.');
|
||||
|
||||
//console.log('Core module ' + i + ' is ' + obj.defaultMeshCores[i].length + ' bytes.'); // DEBUG, Print the core size
|
||||
//obj.fs.writeFile("C:\\temp\\" + i + ".js", obj.defaultMeshCores[i].substring(4), function () { }); // DEBUG, Write the core to file
|
||||
//obj.fs.writeFile("C:\\temp\\" + i + ".js", obj.defaultMeshCores[i].slice(4), function () { }); // DEBUG, Write the core to file
|
||||
|
||||
// Compress the mesh cores with DEFLATE
|
||||
var callback = function MeshCoreDeflateCb(err, buffer) { if (err == null) { obj.defaultMeshCoresDeflate[MeshCoreDeflateCb.i] = buffer; } }
|
||||
callback.i = i;
|
||||
require('zlib').deflate(obj.defaultMeshCores[i], { level: require('zlib').Z_BEST_COMPRESSION }, callback);
|
||||
require('zlib').deflate(obj.defaultMeshCores[i], { level: require('zlib').Z_BEST_COMPRESSION }, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue