Skip to content

Add the redis-family configuration option for ioredis to support ipv6 #532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 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]
Expand Down Expand Up @@ -203,6 +204,7 @@ REDIS_TLS_SERVER_NAME
REDIS_DB
REDIS_HOSTS
REDIS_OPTIONAL
REDIS_FAMILY
SENTINEL_PORT
SENTINEL_HOST
SENTINEL_NAME
Expand Down
8 changes: 7 additions & 1 deletion bin/redis-commander.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 0 to support both.',
default: 0
})
.options('sentinel-port', {
type: 'number',
describe: 'The port to find sentinel on.'
Expand Down Expand Up @@ -461,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 = {
Expand All @@ -471,6 +476,7 @@ function createConnectionObjectFromArgs(argList) {
password: argList['redis-password'] || '',
connectionName: config.get('redis.connectionName'),
optional: argList['redis-optional'],
family: argList['redis-family'] || 0,
clusterNoTlsValidation: argList['clusterNoTlsValidation']
};

Expand Down
4 changes: 4 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down