mirror of https://github.com/go-redis/redis.git
Add DisableHelloCmd options
This commit is contained in:
parent
21bd40a47e
commit
3805610dff
|
@ -144,6 +144,10 @@ type Options struct {
|
||||||
|
|
||||||
// Disable set-lib on connect. Default is false.
|
// Disable set-lib on connect. Default is false.
|
||||||
DisableIndentity bool
|
DisableIndentity bool
|
||||||
|
|
||||||
|
// Disable Hello on connect. Default is false.
|
||||||
|
// Hello is used to check the server version,but in Enterprise environment with twproxy,it will cause error,return EOF panic.
|
||||||
|
DisableHelloCmd bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opt *Options) init() {
|
func (opt *Options) init() {
|
||||||
|
|
28
redis.go
28
redis.go
|
@ -285,19 +285,21 @@ func (c *baseClient) initConn(ctx context.Context, cn *pool.Conn) error {
|
||||||
protocol = 3
|
protocol = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
// for redis-server versions that do not support the HELLO command,
|
if !c.opt.DisableHelloCmd {
|
||||||
// RESP2 will continue to be used.
|
// for redis-server versions that do not support the HELLO command,
|
||||||
if err := conn.Hello(ctx, protocol, username, password, "").Err(); err == nil {
|
// RESP2 will continue to be used.
|
||||||
auth = true
|
if err := conn.Hello(ctx, protocol, username, password, "").Err(); err == nil {
|
||||||
} else if !isRedisError(err) {
|
auth = true
|
||||||
// When the server responds with the RESP protocol and the result is not a normal
|
} else if !isRedisError(err) {
|
||||||
// execution result of the HELLO command, we consider it to be an indication that
|
// When the server responds with the RESP protocol and the result is not a normal
|
||||||
// the server does not support the HELLO command.
|
// execution result of the HELLO command, we consider it to be an indication that
|
||||||
// The server may be a redis-server that does not support the HELLO command,
|
// the server does not support the HELLO command.
|
||||||
// or it could be DragonflyDB or a third-party redis-proxy. They all respond
|
// The server may be a redis-server that does not support the HELLO command,
|
||||||
// with different error string results for unsupported commands, making it
|
// or it could be DragonflyDB or a third-party redis-proxy. They all respond
|
||||||
// difficult to rely on error strings to determine all results.
|
// with different error string results for unsupported commands, making it
|
||||||
return err
|
// difficult to rely on error strings to determine all results.
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !c.opt.DisableIndentity {
|
if !c.opt.DisableIndentity {
|
||||||
libName := ""
|
libName := ""
|
||||||
|
|
Loading…
Reference in New Issue