Skip to content

Commit

Permalink
conn with username
Browse files Browse the repository at this point in the history
  • Loading branch information
yohayg authored Jan 12, 2025
1 parent 4dd4738 commit 4b4139e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion redisconn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 4b4139e

Please sign in to comment.