mirror of
https://github.com/HDT3213/godis.git
synced 2025-11-02 21:04:01 +08:00
rename godis/redis/reply to godis/redis/protocol
This commit is contained in:
@@ -3,34 +3,34 @@ package database
|
||||
import (
|
||||
"github.com/hdt3213/godis/config"
|
||||
"github.com/hdt3213/godis/interface/redis"
|
||||
"github.com/hdt3213/godis/redis/reply"
|
||||
"github.com/hdt3213/godis/redis/protocol"
|
||||
)
|
||||
|
||||
// Ping the server
|
||||
func Ping(db *DB, args [][]byte) redis.Reply {
|
||||
if len(args) == 0 {
|
||||
return &reply.PongReply{}
|
||||
return &protocol.PongReply{}
|
||||
} else if len(args) == 1 {
|
||||
return reply.MakeStatusReply(string(args[0]))
|
||||
return protocol.MakeStatusReply(string(args[0]))
|
||||
} else {
|
||||
return reply.MakeErrReply("ERR wrong number of arguments for 'ping' command")
|
||||
return protocol.MakeErrReply("ERR wrong number of arguments for 'ping' command")
|
||||
}
|
||||
}
|
||||
|
||||
// Auth validate client's password
|
||||
func Auth(c redis.Connection, args [][]byte) redis.Reply {
|
||||
if len(args) != 1 {
|
||||
return reply.MakeErrReply("ERR wrong number of arguments for 'auth' command")
|
||||
return protocol.MakeErrReply("ERR wrong number of arguments for 'auth' command")
|
||||
}
|
||||
if config.Properties.RequirePass == "" {
|
||||
return reply.MakeErrReply("ERR Client sent AUTH, but no password is set")
|
||||
return protocol.MakeErrReply("ERR Client sent AUTH, but no password is set")
|
||||
}
|
||||
passwd := string(args[0])
|
||||
c.SetPassword(passwd)
|
||||
if config.Properties.RequirePass != passwd {
|
||||
return reply.MakeErrReply("ERR invalid password")
|
||||
return protocol.MakeErrReply("ERR invalid password")
|
||||
}
|
||||
return &reply.OkReply{}
|
||||
return &protocol.OkReply{}
|
||||
}
|
||||
|
||||
func isAuthenticated(c redis.Connection) bool {
|
||||
|
||||
Reference in New Issue
Block a user