Skip to content

Commit

Permalink
Merge pull request #33 from yohayg/feature/con-with-username
Browse files Browse the repository at this point in the history
conn with username
mxmsk authored Jan 16, 2025
2 parents 4dd4738 + 6674561 commit b0afaee
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
@@ -39,6 +39,8 @@ type Opts struct {
DB int
// Password for AUTH
Password string
// Username 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"

0 comments on commit b0afaee

Please sign in to comment.