Procházet zdrojové kódy

Added support for Redis password.

KrisVos130 před 8 roky
rodič
revize
65db7871fe

+ 1 - 0
README.md

@@ -60,6 +60,7 @@ Once you've installed the required tools:
    	`apis.discord` is currently not needed.  
    	The `apis.mailgun` values can be obtained by setting up a [Mailgun account](http://www.mailgun.com/).  
    	The `redis.url` url should be left alone for Docker, and changed to `redis://localhost:6379/0` for non-Docker.
+   	The `redis.password` should be the Redis password you either put in your `startRedis.cmd` file for Windows, or `docker-compose.yml` for docker.
    	The `mongo.url` needs to have the proper password for the MongoDB musare user, and for non-Docker you need to replace `@musare:27017` with `@localhost:27017`.  
    	The `cookie.domain` value should be the ip or address you use to access the site, without protocols (http/https), so for example `localhost`.   
    	The `cookie.secure` value should be `true` for SSL connections, and `false` for normal http connections.  

+ 2 - 1
backend/config/template.json

@@ -33,7 +33,8 @@
 		]
 	},
   	"redis": {
-	  	"url": "redis://redis:6379/0"
+	  	"url": "redis://redis:6379/0",
+	    "password": "PASSWORD"
 	},
   	"mongo": {
 	  	"url": "mongodb://musare:PASSWORD@mongo:27017/musare"

+ 2 - 2
backend/index.js

@@ -28,7 +28,7 @@ async.waterfall([
 
 	// setup our Redis cache
 	(next) => {
-		cache.init(config.get('redis').url, () => {
+		cache.init(config.get('redis').url, config.get('redis').password, () => {
 			next();
 		});
 	},
@@ -46,7 +46,7 @@ async.waterfall([
 	(next) => io.init(next),
 
 	// setup the notifications
-	(next) => notifications.init(config.get('redis').url, next),
+	(next) => notifications.init(config.get('redis').url, config.get('redis').password, next),
 
 	// setup the stations
 	(next) => stations.init(next),

+ 5 - 3
backend/logic/cache/index.js

@@ -25,12 +25,14 @@ const lib = {
 	 * Initializes the cache module
 	 *
 	 * @param {String} url - the url of the redis server
+	 * @param {String} password - the password of the redis server
 	 * @param {Function} cb - gets called once we're done initializing
 	 */
-	init: (url, cb) => {
+	init: (url, password, cb) => {
 		lib.url = url;
+		lib.password = password;
 
-		lib.client = redis.createClient({ url: lib.url });
+		lib.client = redis.createClient({ url: lib.url, password: lib.password });
 		lib.client.on('error', (err) => {
 			console.error(err);
 			process.exit();
@@ -164,7 +166,7 @@ const lib = {
 		}
 		function subToChannel() {
 			if (subs[channel] === undefined) {
-				subs[channel] = { client: redis.createClient({ url: lib.url }), cbs: [] };
+				subs[channel] = { client: redis.createClient({ url: lib.url, password: lib.password }), cbs: [] };
 				subs[channel].client.on('error', (err) => {
 					console.error(err);
 					process.exit();

+ 4 - 3
backend/logic/notifications.js

@@ -15,11 +15,12 @@ const lib = {
 	 * Initializes the notifications module
 	 *
 	 * @param {String} url - the url of the redis server
+	 * @param {String} password - the password of the redis server
 	 * @param {Function} cb - gets called once we're done initializing
 	 */
-	init: (url, cb) => {
-		pub = redis.createClient({ url: url });
-		sub = redis.createClient({ url: url });
+	init: (url, password, cb) => {
+		pub = redis.createClient({ url, password });
+		sub = redis.createClient({ url, password });
 		sub.on('error', (err) => {
 			console.error(err);
 			process.exit();