Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Better AUTH

  • Loading branch information...
commit 6bd29166ff1d7c1ccdab9a0df523403344950e9c 1 parent 454b2a3
Tim tim-smart authored
8 deps/node-redis/index.js
View
@@ -2,9 +2,10 @@ var net = require('net'),
utils = require('./utils'),
Parser = require('./parser');
-var RedisClient = function RedisClient(port, host) {
+var RedisClient = function RedisClient(port, host, auth) {
this.host = host;
this.port = port;
+ this.auth = auth;
this.stream = net.createConnection(port, host);;
this.connected = false;
// Command queue.
@@ -34,6 +35,11 @@ var RedisClient = function RedisClient(port, host) {
self.stream.setTimeout(0);
self.connected = true;
+ // Send auth.
+ if (self.auth) {
+ self.sendCommand('AUTH', [self.auth], null);
+ }
+
// Resend commands if we need to.
var command,
commands = self.commands.array;
3  deps/node-redis/package.json
View
@@ -10,5 +10,6 @@
"type": "git",
"url": "http://github.com/Tim-Smart/node-redis.git"
},
- "engine": [ "node >=0.2.2" ]
+ "engine": [ "node >=0.2.2" ],
+ "main": "./"
}
18 index.js
View
@@ -28,13 +28,9 @@ var Queue = function (options) {
var self = this;
this.name = options.name;
- this.client = redis.createClient(options.port, options.host);
+ this.client = redis.createClient(options.port, options.host, options.auth);
this.prefix = options.prefix || '';
- if (options.auth) {
- this.client.auth(options.auth);
- }
-
this.client.on('error', function (error) {
self.emit('error', error);
});
@@ -111,11 +107,7 @@ var Worker = function (options) {
this.continual = false;
// Client for use with child jobs.
- this._child_client = redis.createClient(this.port, this.host);
-
- if (this.auth) {
- this._child_client.auth(this.auth);
- }
+ this._child_client = redis.createClient(this.port, this.host, this.auth);
this._child_client.on('error', function (error) {
self.emit('error', error);
@@ -173,11 +165,7 @@ Worker.prototype.next = function () {
Worker.prototype.start = function () {
var self = this;
- this.client = redis.createClient(this.port, this.host);
-
- if (this.auth) {
- this.client.auth(this.auth);
- }
+ this.client = redis.createClient(this.port, this.host, this.auth);
this.client.on('error', function (error) {
self.emit('error', error);
Please sign in to comment.
Something went wrong with that request. Please try again.