From c701893329b06b71c435adc19b89799c386714f0 Mon Sep 17 00:00:00 2001 From: kdevan Date: Tue, 11 Jul 2023 12:48:14 -0700 Subject: [PATCH 1/5] Add family configuration option to ioredis to add ipv6 support family param found here - https://ioredis.readthedocs.io/en/latest/API/ --- bin/redis-commander.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/redis-commander.js b/bin/redis-commander.js index 291afea9..2f2dead2 100755 --- a/bin/redis-commander.js +++ b/bin/redis-commander.js @@ -50,6 +50,11 @@ const args = yargs describe: 'Set to true if no permanent auto-reconnect shall be done if server is down.', default: false }) + .options('redis-family', { + type: 'number', + describe: 'Version of IP stack. Defaults to 4.', + default: 4 + }) .options('sentinel-port', { type: 'number', describe: 'The port to find sentinel on.' @@ -471,6 +476,7 @@ function createConnectionObjectFromArgs(argList) { password: argList['redis-password'] || '', connectionName: config.get('redis.connectionName'), optional: argList['redis-optional'], + family: argList['redis-family'] || 4, clusterNoTlsValidation: argList['clusterNoTlsValidation'] }; From 07bc32d21035c471b0d390de4c1da43f616e3dfc Mon Sep 17 00:00:00 2001 From: kdevan Date: Tue, 11 Jul 2023 12:52:46 -0700 Subject: [PATCH 2/5] Update README.md to include the redis-family configuration option for ioredis for ipv6 support --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f9d254c4..25a58c53 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Options: --redis-password The redis password. [string] --redis-db The redis database. [number] --redis-optional Set to true if no permanent auto-reconnect shall be done if server is down. [boolean] [default: false] + --redis-family Version of IP stack. Defaults to 4. [number] --sentinel-port The port to find sentinel on. [number] --sentinel-host The host to find sentinel on. [string] --sentinels Comma separated list of sentinels with host:port. [string] @@ -203,6 +204,7 @@ REDIS_TLS_SERVER_NAME REDIS_DB REDIS_HOSTS REDIS_OPTIONAL +REDIS_FAMILY SENTINEL_PORT SENTINEL_HOST SENTINEL_NAME From 6318379e9611ccf2e3d7fb282d3203f00af9cf09 Mon Sep 17 00:00:00 2001 From: kdevan Date: Tue, 11 Jul 2023 12:57:58 -0700 Subject: [PATCH 3/5] Add support for setting the redis-family ioredis configuration option from an environment variable --- docker/entrypoint.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e13ec60a..1350650d 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -270,6 +270,10 @@ if [ -n "$REDIS_OPTIONAL" ] && parse_boolean "$REDIS_OPTIONAL"; then set -- "$@" "--redis-optional" fi +if [ -n "$REDIS_FAMILY" ]; then + set -- "$@" "--redis-family" "$REDIS_FAMILY" +fi + if [ -n "$SENTINEL_PORT" ]; then set -- "$@" "--sentinel-port" "$SENTINEL_PORT" fi From cc91c5e4d44ca9fe99daca98d328417e4f3ebb53 Mon Sep 17 00:00:00 2001 From: kdevan Date: Tue, 11 Jul 2023 14:07:22 -0700 Subject: [PATCH 4/5] Change default redis-family value to 0 to support both ipv4 and 6 --- bin/redis-commander.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/redis-commander.js b/bin/redis-commander.js index 2f2dead2..134415ff 100755 --- a/bin/redis-commander.js +++ b/bin/redis-commander.js @@ -52,8 +52,8 @@ const args = yargs }) .options('redis-family', { type: 'number', - describe: 'Version of IP stack. Defaults to 4.', - default: 4 + describe: 'Version of IP stack. Defaults to 0 to support both.', + default: 0 }) .options('sentinel-port', { type: 'number', @@ -466,7 +466,7 @@ function createConnectionObjectFromArgs(argList) { // now create connection object if enough params are set let connObj = null; if (argList['clusters'] || argList['sentinel-host'] || argList['sentinels'] || argList['redis-host'] || argList['redis-port'] || argList['redis-socket'] - || argList['redis-username'] || argList['redis-password'] || argList['redis-db']) { + || argList['redis-username'] || argList['redis-password'] || argList['redis-db'] || argList['redis-family']) { let db = parseInt(argList['redis-db']); connObj = { @@ -476,7 +476,7 @@ function createConnectionObjectFromArgs(argList) { password: argList['redis-password'] || '', connectionName: config.get('redis.connectionName'), optional: argList['redis-optional'], - family: argList['redis-family'] || 4, + family: argList['redis-family'] || 0, clusterNoTlsValidation: argList['clusterNoTlsValidation'] }; From 6c46b0249123df25369631439ac42e84fffb836f Mon Sep 17 00:00:00 2001 From: kdevan Date: Tue, 11 Jul 2023 14:08:35 -0700 Subject: [PATCH 5/5] Update README.md to include new default value for redis-family --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25a58c53..b3a82404 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Options: --redis-password The redis password. [string] --redis-db The redis database. [number] --redis-optional Set to true if no permanent auto-reconnect shall be done if server is down. [boolean] [default: false] - --redis-family Version of IP stack. Defaults to 4. [number] + --redis-family Version of IP stack. 0, 4, or 6. Defaults to 0 to support both ipv4 and ipv6. [number] --sentinel-port The port to find sentinel on. [number] --sentinel-host The host to find sentinel on. [string] --sentinels Comma separated list of sentinels with host:port. [string]