Skip to content

Commit e1c0580

Browse files
authored
Fix CLUSTER_NODES ipv6 address parsing (#2269)
1 parent def9f16 commit e1c0580

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

packages/client/lib/commands/CLUSTER_NODES.spec.ts

+25
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,31 @@ describe('CLUSTER NODES', () => {
7373
);
7474
});
7575

76+
it('should support ipv6 addresses', () => {
77+
assert.deepEqual(
78+
transformReply(
79+
'id 2a02:6b8:c21:330d:0:1589:ebbe:b1a0:6379@16379 master - 0 0 0 connected 0-549\n'
80+
),
81+
[{
82+
id: 'id',
83+
address: '2a02:6b8:c21:330d:0:1589:ebbe:b1a0:6379@16379',
84+
host: '2a02:6b8:c21:330d:0:1589:ebbe:b1a0',
85+
port: 6379,
86+
cport: 16379,
87+
flags: ['master'],
88+
pingSent: 0,
89+
pongRecv: 0,
90+
configEpoch: 0,
91+
linkState: RedisClusterNodeLinkStates.CONNECTED,
92+
slots: [{
93+
from: 0,
94+
to: 549
95+
}],
96+
replicas: []
97+
}]
98+
);
99+
});
100+
76101
it.skip('with importing slots', () => {
77102
assert.deepEqual(
78103
transformReply(

packages/client/lib/commands/CLUSTER_NODES.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export function transformReply(reply: string): Array<RedisClusterMasterNode> {
8585
}
8686

8787
function transformNodeAddress(address: string): RedisClusterNodeAddress {
88-
const indexOfColon = address.indexOf(':'),
88+
const indexOfColon = address.lastIndexOf(':'),
8989
indexOfAt = address.indexOf('@', indexOfColon),
9090
host = address.substring(0, indexOfColon);
9191

0 commit comments

Comments
 (0)