From bbf1af2da34001cf1f3af808cc3972dbc78fc6ab Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Thu, 23 Oct 2014 13:44:42 -0400 Subject: Fix redis-trib.rb IP:Port disassembly for IPv6 IP format is now any of: - 127.0.0.1:6379 - ::1:6379 --- src/redis-trib.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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] = {} -- cgit v1.2.1 From daca1edb6ec8d8b467d2e94a39431c47dff7052b Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Thu, 23 Oct 2014 13:45:16 -0400 Subject: Parse cluster state file in IPv6 compatible way We need to pick the port based on the _last_ colon, not the first one. --- src/cluster.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cluster.c b/src/cluster.c index 8a788da67..10ed25db8 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); -- cgit v1.2.1