From 4b4139e86dcb9477a1a9d5fe564e7d255af067cd Mon Sep 17 00:00:00 2001 From: Yohay Date: Sun, 12 Jan 2025 21:54:05 +0200 Subject: [PATCH 1/2] conn with username --- redisconn/conn.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/redisconn/conn.go b/redisconn/conn.go index 72a2907..42db138 100644 --- a/redisconn/conn.go +++ b/redisconn/conn.go @@ -39,6 +39,8 @@ type Opts struct { DB int // Password for AUTH Password string + // Password for AUTH + Username string // IOTimeout - timeout on read/write to socket. // If IOTimeout == 0, then it is set to 1 second // If IOTimeout < 0, then timeout is disabled @@ -556,7 +558,9 @@ func (conn *Connection) dial() error { // Password request var req []byte - if conn.opts.Password != "" { + if conn.opts.Password != "" && conn.opts.Username != "" { + req, _ = redis.AppendRequest(req, redis.Req("AUTH", conn.opts.Username, conn.opts.Password)) + } else if conn.opts.Password != "" { req, _ = redis.AppendRequest(req, redis.Req("AUTH", conn.opts.Password)) } const pingReq = "*1\r\n$4\r\nPING\r\n" From 667456148d5fdd57d7164bb7de5bd7756f3d8a9d Mon Sep 17 00:00:00 2001 From: Yohay Date: Mon, 13 Jan 2025 07:18:22 +0200 Subject: [PATCH 2/2] Update conn.go --- redisconn/conn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redisconn/conn.go b/redisconn/conn.go index 42db138..889903f 100644 --- a/redisconn/conn.go +++ b/redisconn/conn.go @@ -39,7 +39,7 @@ type Opts struct { DB int // Password for AUTH Password string - // Password for AUTH + // Username for AUTH Username string // IOTimeout - timeout on read/write to socket. // If IOTimeout == 0, then it is set to 1 second