Skip to content

Commit b841f3a

Browse files
committed
Cluster: store busport with different separator in CLUSTER NODES.
We need to be able to correctly parse the node address in the case of IPv6 addresses.
1 parent 92b9de2 commit b841f3a

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/cluster.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,13 +168,17 @@ int clusterLoadConfig(char *filename) {
168168
if ((p = strrchr(argv[1],':')) == NULL) goto fmterr;
169169
*p = '\0';
170170
memcpy(n->ip,argv[1],strlen(argv[1])+1);
171-
// this_is_broken();
172-
char *busp = strchr(p+1,':');
173-
if (busp) *busp = '\0';
174-
n->port = atoi(p+1);
175-
/* In older versions of nodes.conf the bus port is missing. In this case
176-
* we set it to the default offset of 10000 from the base port. */
177-
n->cport = busp ? atoi(busp+1) : n->port + CLUSTER_PORT_INCR;
171+
char *port = p+1;
172+
char *busp = strchr(port,'@');
173+
if (busp) {
174+
*busp = '\0';
175+
busp++;
176+
}
177+
n->port = atoi(port);
178+
/* In older versions of nodes.conf the "@busport" part is missing.
179+
* In this case we set it to the default offset of 10000 from the
180+
* base port. */
181+
n->cport = busp ? atoi(busp) : n->port + CLUSTER_PORT_INCR;
178182

179183
/* Parse flags */
180184
p = s = argv[2];
@@ -1316,7 +1320,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
13161320
sds ci;
13171321

13181322
ci = representClusterNodeFlags(sdsempty(), flags);
1319-
serverLog(LL_DEBUG,"GOSSIP %.40s %s:%d:%d %s",
1323+
serverLog(LL_DEBUG,"GOSSIP %.40s %s:%d@%d %s",
13201324
g->nodename,
13211325
g->ip,
13221326
ntohs(g->port),
@@ -3742,7 +3746,7 @@ sds clusterGenNodeDescription(clusterNode *node) {
37423746
sds ci;
37433747

37443748
/* Node coordinates */
3745-
ci = sdscatprintf(sdsempty(),"%.40s %s:%d:%d ",
3749+
ci = sdscatprintf(sdsempty(),"%.40s %s:%d@%d ",
37463750
node->name,
37473751
node->ip,
37483752
node->port,

0 commit comments

Comments
 (0)