(c *redis.Conn, auth string)
| 181 | } |
| 182 | |
| 183 | func (bc *BackendConn) verifyAuth(c *redis.Conn, auth string) error { |
| 184 | if auth == "" { |
| 185 | return nil |
| 186 | } |
| 187 | |
| 188 | multi := []*redis.Resp{ |
| 189 | redis.NewBulkBytes([]byte("AUTH")), |
| 190 | redis.NewBulkBytes([]byte(auth)), |
| 191 | } |
| 192 | |
| 193 | if err := c.EncodeMultiBulk(multi, true); err != nil { |
| 194 | return err |
| 195 | } |
| 196 | |
| 197 | resp, err := c.Decode() |
| 198 | switch { |
| 199 | case err != nil: |
| 200 | return err |
| 201 | case resp == nil: |
| 202 | return ErrRespIsRequired |
| 203 | case resp.IsError(): |
| 204 | return fmt.Errorf("error resp: %s", resp.Value) |
| 205 | case resp.IsString(): |
| 206 | return nil |
| 207 | default: |
| 208 | return fmt.Errorf("error resp: should be string, but got %s", resp.Type) |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | func (bc *BackendConn) selectDatabase(c *redis.Conn, database int) error { |
| 213 | if database == 0 { |
no test coverage detected