Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2016-02-12 06:16:46 +0300
committermichael-grunder <michael.grunder@gmail.com>2016-02-12 08:22:13 +0300
commit4b2b65e6ae35978a1c8ecc610ff55a38b74b19e4 (patch)
treeb5c9d06f18483006883e662ab24d1de0a7efc1b7 /cluster_library.c
parentf9747938b6546e724cc3e2f5ba3fe1d94574772a (diff)
Add IPv6 support
Diffstat (limited to 'cluster_library.c')
-rw-r--r--cluster_library.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/cluster_library.c b/cluster_library.c
index 0fc7f7d2..8810a289 100644
--- a/cluster_library.c
+++ b/cluster_library.c
@@ -843,8 +843,9 @@ cluster_init_seeds(redisCluster *cluster, HashTable *ht_seeds) {
// Grab a copy of the string
str = Z_STRVAL_P(z_seed);
- // Must be in host:port form
- if(!(psep = strchr(str, ':')))
+ /* Make sure we have a colon for host:port. Search right to left in the
+ * case of IPv6 */
+ if ((psep = strrchr(str, ':')) == NULL)
continue;
// Allocate a structure for this seed
@@ -918,12 +919,12 @@ static int cluster_set_redirection(redisCluster* c, char *msg, int moved)
/* Move past "MOVED" or "ASK */
msg += moved ? MOVED_LEN : ASK_LEN;
- // We need a slot seperator
- if(!(host = strchr(msg, ' '))) return -1;
+ /* Make sure we can find host */
+ if ((host = strchr(msg, ' ')) == NULL) return -1;
*host++ = '\0';
- // We need a : that seperates host from port
- if(!(port = strchr(host,':'))) return -1;
+ /* Find port, searching right to left in case of IPv6 */
+ if ((port = strrchr(host, ':')) == NULL) return -1;
*port++ = '\0';
// Success, apply it