1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

Fix CLUSTER_NODES ipv6 address parsing (#2269)

This commit is contained in:
Roman Poleguev
2022-09-19 20:31:21 +03:00
committed by GitHub
parent def9f161e5
commit e1c0580d65
2 changed files with 26 additions and 1 deletions

View File

@@ -73,6 +73,31 @@ describe('CLUSTER NODES', () => {
);
});
it('should support ipv6 addresses', () => {
assert.deepEqual(
transformReply(
'id 2a02:6b8:c21:330d:0:1589:ebbe:b1a0:6379@16379 master - 0 0 0 connected 0-549\n'
),
[{
id: 'id',
address: '2a02:6b8:c21:330d:0:1589:ebbe:b1a0:6379@16379',
host: '2a02:6b8:c21:330d:0:1589:ebbe:b1a0',
port: 6379,
cport: 16379,
flags: ['master'],
pingSent: 0,
pongRecv: 0,
configEpoch: 0,
linkState: RedisClusterNodeLinkStates.CONNECTED,
slots: [{
from: 0,
to: 549
}],
replicas: []
}]
);
});
it.skip('with importing slots', () => {
assert.deepEqual(
transformReply(

View File

@@ -85,7 +85,7 @@ export function transformReply(reply: string): Array<RedisClusterMasterNode> {
}
function transformNodeAddress(address: string): RedisClusterNodeAddress {
const indexOfColon = address.indexOf(':'),
const indexOfColon = address.lastIndexOf(':'),
indexOfAt = address.indexOf('@', indexOfColon),
host = address.substring(0, indexOfColon);