8000 Add IPv6 support · jrtkcoder/phpredis@4b2b65e · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b2b65e

Browse files
Add IPv6 support
1 parent f974793 commit 4b2b65e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cluster_library.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -843,8 +843,9 @@ cluster_init_seeds(redisCluster *cluster, HashTable *ht_seeds) {
843843
// Grab a copy of the string
844844
str = Z_STRVAL_P(z_seed);
845845

846-
// Must be in host:port form
847-
if(!(psep = strchr(str, ':')))
846+
/* Make sure we have a colon for host:port. Search right to left in the
847+
* case of IPv6 */
848+
if ((psep = strrchr(str, ':')) == NULL)
848849
continue;
849850

850851
// Allocate a structure for this seed
@@ -918,12 +919,12 @@ static int cluster_set_redirection(redisCluster* c, char *msg, int moved)
918919
/* Move past "MOVED" or "ASK */
919920
msg += moved ? MOVED_LEN : ASK_LEN;
920921

921-
// We need a slot seperator
922-
if(!(host = strchr(msg, ' '))) return -1;
922+
/* Make sure we can find host */
923+
if ((host = strchr(msg, ' ')) == NULL) return -1;
923924
*host++ = '\0';
924925

925-
// We need a : that seperates host from port
926-
if(!(port = strchr(host,':'))) return -1;
926+
/* Find port, searching right to left in case of IPv6 */
927+
if ((port = strrchr(host, ':')) == NULL) return -1;
927928
*port++ = '\0';
928929

929930
// Success, apply it

0 commit comments

Comments
 (0)
0