diff --git a/config_example.json b/config_example.json index 32cc33e..6e5e501 100644 --- a/config_example.json +++ b/config_example.json @@ -25,7 +25,8 @@ }, "redis": { "host": "127.0.0.1", - "port": 6379 + "port": 6379, + "password": "" } }, diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index 124da5e..c8d5282 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -82,7 +82,9 @@ function SetupForPool(logger, poolOptions, setupFinished){ logger[severity](logSystem, logComponent, message); }); var redisClient = redis.createClient(poolOptions.redis.port, poolOptions.redis.host); - + // redis auth if enabled + redisClient.auth(poolOptions.redis.password); + var magnitude; var minPaymentSatoshis; var coinPrecision; diff --git a/libs/poolWorker.js b/libs/poolWorker.js index abb28c6..9e07385 100644 --- a/libs/poolWorker.js +++ b/libs/poolWorker.js @@ -19,6 +19,8 @@ module.exports = function(logger){ var proxySwitch = {}; var redisClient = redis.createClient(portalConfig.redis.port, portalConfig.redis.host); + // redis auth if enabled + redisClient.auth(portalConfig.redis.password); //Handle messages from master process sent via IPC process.on('message', function(message) { diff --git a/libs/shareProcessor.js b/libs/shareProcessor.js index f881c58..2864c74 100644 --- a/libs/shareProcessor.js +++ b/libs/shareProcessor.js @@ -27,6 +27,9 @@ module.exports = function(logger, poolConfig){ var logSubCat = 'Thread ' + (parseInt(forkId) + 1); var connection = redis.createClient(redisConfig.port, redisConfig.host); + // redis auth if needed + connection.auth(redisConfig.password); + connection.on('ready', function(){ logger.debug(logSystem, logComponent, logSubCat, 'Share processing setup with redis (' + redisConfig.host + ':' + redisConfig.port + ')'); diff --git a/libs/stats.js b/libs/stats.js index 3e1d91b..7ebdc02 100644 --- a/libs/stats.js +++ b/libs/stats.js @@ -7,6 +7,13 @@ var os = require('os'); var algos = require('stratum-pool/lib/algoProperties.js'); +// redis callback Ready check failed bypass trick +function rediscreateClient(port, host, pass) { + var client = redis.createClient(port, host); + client.auth(pass); + return client; +} + function balanceRound(number) { return parseFloat((Math.round(number * 100000000) / 100000000).toFixed(8)); } @@ -80,14 +87,14 @@ module.exports = function(logger, portalConfig, poolConfigs){ } redisClients.push({ coins: [coin], - client: redis.createClient(redisConfig.port, redisConfig.host) + client: rediscreateClient(redisConfig.port, redisConfig.host, redisConfig.password) }); }); function setupStatsRedis(){ redisStats = redis.createClient(portalConfig.redis.port, portalConfig.redis.host); redisStats.on('error', function(err){ - logger.error(logSystem, 'Historics', 'Redis for stats had an error ' + JSON.stringify(err)); + redisStats.auth(portalConfig.redis.password); }); } diff --git a/libs/website.js b/libs/website.js index 3793e3a..3cfe0b7 100644 --- a/libs/website.js +++ b/libs/website.js @@ -54,7 +54,6 @@ module.exports = function(logger){ var keyScriptTemplate = ''; var keyScriptProcessed = ''; - var processTemplates = function(){ for (var pageName in pageTemplates){ @@ -135,6 +134,7 @@ module.exports = function(logger){ async.waterfall([ function(callback){ var client = redis.createClient(portalConfig.redis.port, portalConfig.redis.host); + client.auth(portalConfig.redis.password); client.hgetall('coinVersionBytes', function(err, coinBytes){ if (err){ client.quit();