2* @description MeshCentral accelerator
3* @author Ylian Saint-Hilaire
4* @copyright Intel Corporation 2018-2022
10/*xjslint plusplus: true */
11/*xjslint maxlen: 256 */
13/*jshint strict: false */
14/*jshint esversion: 6 */
17const crypto = require('crypto');
20// When the parent process terminates, we exit also.
21process.on('disconnect', function () { process.exit(); });
23// Handle parent messages
24process.on('message', function (message) { module.exports.processMessage(message); });
26// Process an incoming message
27module.exports.processMessage = function(message) {
28 switch (message.action) {
30 if (typeof message.key == 'number') { message.key = certStore[message.key].key; }
32 const sign = crypto.createSign('SHA384');
33 sign.end(Buffer.from(message.data, 'binary'));
34 process.send(sign.sign(message.key).toString('binary'));
36 // If this exception happens, try again.
37 if (ex.code == 'ERR_OSSL_DSO_COULD_NOT_LOAD_THE_SHARED_LIBRARY') {
39 const sign = crypto.createSign('SHA384');
40 sign.end(Buffer.from(message.data, 'binary'));
41 process.send(sign.sign(message.key).toString('binary'));
52 certStore = message.certs;
56 //console.log('indexMcRec', message.data);
57 // Hold 5 seconds before starting to index
58 setTimeout(function () { require(require('path').join(__dirname, 'mcrec.js')).indexFile(message.data); }, 5000);
62 console.log('Unknown accelerator action: ' + message.action + '.');