mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
Cluster: fix CLUSTER MEET ip address validation.
This was broken by the IPv6 support patches.
This commit is contained in:
parent
9cf30132cc
commit
042776aff7
@ -2082,8 +2082,15 @@ void clusterCommand(redisClient *c) {
|
||||
long port;
|
||||
|
||||
/* Perform sanity checks on IP/port */
|
||||
if ((inet_pton(AF_INET,c->argv[0]->ptr,&(((struct sockaddr_in *)&sa)->sin_addr)) ||
|
||||
inet_pton(AF_INET6,c->argv[0]->ptr,&(((struct sockaddr_in6 *)&sa)->sin6_addr))) == 0) {
|
||||
if (inet_pton(AF_INET,c->argv[2]->ptr,
|
||||
&(((struct sockaddr_in *)&sa)->sin_addr)))
|
||||
{
|
||||
sa.ss_family = AF_INET;
|
||||
} else if (inet_pton(AF_INET6,c->argv[2]->ptr,
|
||||
&(((struct sockaddr_in6 *)&sa)->sin6_addr)))
|
||||
{
|
||||
sa.ss_family = AF_INET6;
|
||||
} else {
|
||||
addReplyError(c,"Invalid IP address in MEET");
|
||||
return;
|
||||
}
|
||||
@ -2097,9 +2104,17 @@ void clusterCommand(redisClient *c) {
|
||||
/* Finally add the node to the cluster with a random name, this
|
||||
* will get fixed in the first handshake (ping/pong). */
|
||||
n = createClusterNode(NULL,REDIS_NODE_HANDSHAKE|REDIS_NODE_MEET);
|
||||
sa.ss_family == AF_INET ?
|
||||
inet_ntop(AF_INET,(void*)&(((struct sockaddr_in *)&sa)->sin_addr),n->ip,REDIS_CLUSTER_IPLEN) :
|
||||
inet_ntop(AF_INET6,(void*)&(((struct sockaddr_in6 *)&sa)->sin6_addr),n->ip,REDIS_CLUSTER_IPLEN);
|
||||
|
||||
/* Set node->ip as the normalized string representation of the node
|
||||
* IP address. */
|
||||
if (sa.ss_family == AF_INET)
|
||||
inet_ntop(AF_INET,
|
||||
(void*)&(((struct sockaddr_in *)&sa)->sin_addr),
|
||||
n->ip,REDIS_CLUSTER_IPLEN);
|
||||
else
|
||||
inet_ntop(AF_INET6,
|
||||
(void*)&(((struct sockaddr_in6 *)&sa)->sin6_addr),
|
||||
n->ip,REDIS_CLUSTER_IPLEN);
|
||||
n->port = port;
|
||||
clusterAddNode(n);
|
||||
addReply(c,shared.ok);
|
||||
|
Loading…
x
Reference in New Issue
Block a user