harthur / brain

Simple feed-forward neural network in JavaScript
MIT License
8.01k stars 857 forks source link

brain does not support redis authentication #12

Closed acacio closed 12 years ago

acacio commented 12 years ago

Some run redis with a auth key (password) and, currently, the brain redis backend does not support AUTH.

I have a simple patch to fix this.

acacio commented 12 years ago
diff --git a/lib/bayesian/backends/redis.js b/lib/bayesian/backends/redis.js
index ce4ca4c..eb2cdc8 100644
--- a/lib/bayesian/backends/redis.js
+++ b/lib/bayesian/backends/redis.js
@@ -6,11 +6,14 @@ var RedisBackend = function(options) {
   var port = options.port || 6379;
   var host = options.hostname || "localhost";
   var opts = options.options || {};
+  var password = options.password || false;

   this.client = function() {
     var client = redis.createClient(port, host, opts);
     if(options.error)
       client.on('error', options.error);
+    if (password)
+      client.auth(password, options.error);
     return client;
   }

@@ -114,4 +117,4 @@ RedisBackend.prototype = {
   }
 }

-exports.RedisBackend = RedisBackend;
\ No newline at end of file
+exports.RedisBackend = RedisBackend;
diff --git a/package.json b/package.json
index 0314822..745f77b 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
     "name": "brain",
     "description": "neural network and classifier library",
-    "version": "0.3.5",
+    "version": "0.3.7",
     "author": "Heather Arthur <fayearthur@gmail.com>",
     "repository": {
         "type": "git",
harthur commented 12 years ago

Thanks!