summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2014-10-31 10:38:22 +0100
committerSalvatore Sanfilippo <antirez@gmail.com>2014-10-31 10:38:22 +0100
commit5a526c22cc39c4b455f7e2f69eb9d48112d5eb33 (patch)
tree71fdd155b323824dda62dc092a974164506bd6f0
parenta07674307925c9af0226a71c11daffabea3ad764 (diff)
parentdaca1edb6ec8d8b467d2e94a39431c47dff7052b (diff)
downloadredis-5a526c22cc39c4b455f7e2f69eb9d48112d5eb33.tar.gz
Merge pull request #2096 from mattsta/cluster-ipv6
Enable Cluster IPv6 Support
-rw-r--r--src/cluster.c2
-rwxr-xr-xsrc/redis-trib.rb12
2 files changed, 8 insertions, 6 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 1967b3f42..608f8d2c5 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -178,7 +178,7 @@ int clusterLoadConfig(char *filename) {
clusterAddNode(n);
}
/* Address and port */
- if ((p = strchr(argv[1],':')) == NULL) goto fmterr;
+ if ((p = strrchr(argv[1],':')) == NULL) goto fmterr;
*p = '\0';
memcpy(n->ip,argv[1],strlen(argv[1])+1);
n->port = atoi(p+1);
diff --git a/src/redis-trib.rb b/src/redis-trib.rb
index cff0f360f..466a81137 100755
--- a/src/redis-trib.rb
+++ b/src/redis-trib.rb
@@ -50,14 +50,16 @@ end
class ClusterNode
def initialize(addr)
s = addr.split(":")
- if s.length != 2
- puts "Invalid node name #{addr}"
- exit 1
+ if s.length < 2
+ puts "Invalid IP or Port (given as #{addr}) - use IP:Port format"
+ exit 1
end
+ port = s.pop # removes port from split array
+ ip = s.join(":") # if s.length > 1 here, it's IPv6, so restore address
@r = nil
@info = {}
- @info[:host] = s[0]
- @info[:port] = s[1]
+ @info[:host] = ip
+ @info[:port] = port
@info[:slots] = {}
@info[:migrating] = {}
@info[:importing] = {}