Skip to content

Commit

Permalink
Add full IPv6 redis connection capability in a full IPv6 network or i…
Browse files Browse the repository at this point in the history
…n a mix network (IPv4 and IPv6)
  • Loading branch information
migounette committed Jun 23, 2014
1 parent c68b3f7 commit 9c68a28
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ limits total time for client to reconnect. Value is provided in milliseconds and
* `max_attempts` defaults to `null`. By default client will try reconnecting until connected. Setting `max_attempts`
limits total amount of reconnects.
* `auth_pass` defaults to `null`. By default client will try connecting without auth. If set, client will run redis auth command on connect.
* `family` defaults to `IPv4`. By default client will try connecting with a IPv4 DNS resolution when a FQDN host is set. You can also specify and IPv6 for forcing a IPv6 FQDN resolution.

```js
var redis = require("redis"),
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

## v0.10.4 - Jun 23, 2014

* Add redis-cli createClient(port, host, options) full IPv6 Network capability
Specify the family type IPv4 or IPv6 in the options object.

eg: { 'family' : 'IPv6' }

## v0.10.3 - May 22, 2014

* Update command list to match Redis 2.8.9 (Charles Feng)
Expand Down
17 changes: 11 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,21 @@ RedisClient.prototype.eval = RedisClient.prototype.EVAL = function () {


exports.createClient = function (port_arg, host_arg, options) {
var port = port_arg || default_port,
host = host_arg || default_host,
redis_client, net_client;

net_client = net.createConnection(port, host);
var cnxOptions = {
'port' : port_arg || default_port,
'host' : host_arg || default_host,
'family' : options.family || 'IPv4'
};

var redis_client, net_client;

net_client = net.createConnection(cnxOptions);

redis_client = new RedisClient(net_client, options);

redis_client.port = port;
redis_client.host = host;
redis_client.port = cnxOptions.port;
redis_client.host = cnxOptions.host;

return redis_client;
};
Expand Down

0 comments on commit 9c68a28

Please sign in to comment.