Skip to content

Commit

Permalink
[RedisClient] handle both connection string format, with or without r…
Browse files Browse the repository at this point in the history
…edis://
  • Loading branch information
FGRibreau committed Feb 22, 2014
1 parent 5f4acb9 commit 26d69be
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
Redsmin proxy [![Build Status](https://secure.travis-ci.org/Redsmin/redsmin.png)](http://travis-ci.org/Redsmin/redsmin) [![Build Status](https://drone.io/github.com/FGRibreau/redsmin/status.png)](https://drone.io/github.com/FGRibreau/redsmin/latest) [![Gittip](http://badgr.co/gittip/fgribreau.png)](https://www.gittip.com/fgribreau/) [![Deps](https://david-dm.org/Redsmin/redsmin.png)](https://david-dm.org/Redsmin/redsmin) [![Version](http://badge.fury.io/js/redsmin.png)](http://badge.fury.io/js/redsmin)
Redsmin proxy [![Build Status](https://drone.io/github.com/Redsmin/redsmin/status.png)](https://drone.io/github.com/Redsmin/redsmin/latest) [![Gittip](http://badgr.co/gittip/fgribreau.png)](https://www.gittip.com/fgribreau/) [![Deps](https://david-dm.org/Redsmin/redsmin.png)](https://david-dm.org/Redsmin/redsmin) [![Version](http://badge.fury.io/js/redsmin.png)](http://badge.fury.io/js/redsmin)
===============

![npm](https://nodei.co/npm/redsmin.png)

Redsmin proxy securely expose one [or more](https://redsmin.uservoice.com/knowledgebase/articles/169404-how-to-run-multiple-redsmin-daemons-on-the-same-se) local Redis instance to [Redsmin](https://redsmin.com).

We're still actively developing this proxy and the Redsmin service so please update often.

We announce changes on our Twitter account [@redsmin](https://twitter.com/redsmin) and our [Facebook page](https://www.facebook.com/redis.redsmin).

### [Installation](https://redsmin.uservoice.com/knowledgebase/articles/121169-can-i-manage-redis-instances-only-accessible-from-)
Expand All @@ -19,16 +17,33 @@ RKEY=REDSMIN_CONNECTION_KEY [RURL=redis://127.0.0.1:6379] [RAUTH=password] redsm

### I'm behind a firewall, what rule should I add ?

Redsmin proxy connects to `ssl.redsmin.com` on port `993` with a secure [TLS socket connection](https://en.wikipedia.org/wiki/Transport_Layer_Security).
Redsmin proxy connects to `ssl.redsmin.com` on port `993` with a secure [TLS socket connection](https://en.wikipedia.org/wiki/Transport_Layer_Security). For troubleshooting: [What ip/port should I locally open to use Redsmin proxy](https://redsmin.uservoice.com/knowledgebase/articles/274294-what-ip-port-should-i-locally-open-to-use-redsmin-).

### Uninstall
------------------

```npm uninstall redsmin -g```
### Edit configuration

------------------
```bash
vim "`npm prefix -g`/lib/node_modules/redsmin/etc/redsmin.json"
```

See: [How to change Redsmin proxy Redis host/port](https://redsmin.uservoice.com/knowledgebase/articles/166408-how-to-change-redsmin-proxy-redis-host-port).

### Uninstall

```bash
npm uninstall redsmin -g
```

### Changelog

#### v1.1.2 (22/02/2014)
* Handle both connection string format, with or without redis://
* Refactored unit-tests

#### v1.1.1 (22/02/2014)
* Fix unit-tests

#### v1.1.0 (03/09/2013)
* Fix another rare case of missing reconnection

Expand Down
10 changes: 9 additions & 1 deletion lib/RedisClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,17 @@ RedisClient.net = require('net');
RedisClient.log = console;

_.extend(RedisClient.prototype, require('events').EventEmitter.prototype, {
PREFIX:'redis://',

updatePortAndHostname:function(uri){
this.uri = uri || 'redis://127.0.0.1:6379';
uri = uri || this.PREFIX + '127.0.0.1:6379';

if(uri.indexOf(this.PREFIX) !== 0){ // add "redis://" if it was not specified
uri = this.PREFIX + uri;
}

var parsedUri = url.parse(uri);
this.uri = uri;
this.port = parsedUri.port || 6379;
this.hostname = parsedUri.hostname || '127.0.0.1';
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "redsmin",
"description": "Redsmin proxy daemon for the Redsmin service",
"version": "1.1.1",
"version": "1.1.2",
"keywords": [
"redis",
"redis-gui",
Expand Down
19 changes: 13 additions & 6 deletions test/RedisClient.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ function stubRedsminEndpoint(fn){
// Quiet console output
RedisClient.log = sinon.stub(_.clone(console));

var R = null;
var R = null;
var endpoint = null;
var HOST = '127.0.1.1';
var PORT = 6378;

exports['RedisClient'] = {
setUp: function(done) {
// setup here
Expand Down Expand Up @@ -51,10 +54,7 @@ exports['RedisClient'] = {
connect:function(t){
t.expect(5);

var host = 6378;
var hostname = '127.0.0.1';

RedisClient.net.createConnection = tcreateConnection(t, host, hostname);
RedisClient.net.createConnection = tcreateConnection(t, PORT, HOST);

R.on('connect', function(){
t.ok(true, 'connected');
Expand All @@ -63,7 +63,14 @@ exports['RedisClient'] = {
});

t.equal(R.connected, false);
R.connect('redis://127.0.0.1:6378');
R.connect('redis://'+HOST+':'+PORT);
},

'updatePortAndHostname with a connection string without redis://': function(t){
R.updatePortAndHostname(HOST+':'+PORT);
t.equal(R.port, PORT);
t.equal(R.hostname, HOST);
t.done();
},

/**
Expand Down

0 comments on commit 26d69be

Please sign in to comment.