Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const PeersUpdateRules = require('./api/ws/workers/peers_update_rules');
const Rules = require('./api/ws/workers/rules');
const failureCodes = require('./api/ws/rpc/failure_codes');
const { createLoggerComponent } = require('../../../src/components/logger');
const validator = require('../../controller/validator');
const schema = require('./defaults/config');
const config = validator.parseEnvArgAndValidate(schema, {});
/**
* Instantiate the SocketCluster SCWorker instance with custom logic
* inside the run function. The run function is invoked when the worker process
* is ready to accept requests/connections.
*/
SCWorker.create({
// Pass the custom configuration to P2P HTTP Server to mitigate the security vulnerabilities fixed by Node v8.14.0 - "Slowloris (cve-2018-12122)"
createHTTPServer() {
const httpServer = http.createServer();
httpServer.headersTimeout = config.network.options.httpHeadersTimeout;
httpServer.setTimeout(config.network.options.httpServerSetTimeout);
httpServer.on('timeout', socket => {
socket.destroy();
});
return httpServer;
},
run() {
const self = this;
const scServer = this.getSCServer();
async.auto(
{