func openSyncConn(target string, passwd string) (net.Conn, <-chan int64) { c := openNetConn(target, passwd) if _, err := c.Write(redis.MustEncodeToBytes(redis.NewCommand("sync"))); err != nil { log.PanicError(errors.Trace(err), "write sync command failed") } return c, waitRdbDump(c) }
func authPassword(c net.Conn, passwd string) { if passwd == "" { return } _, err := c.Write(redis.MustEncodeToBytes(redis.NewCommand("auth", passwd))) if err != nil { log.PanicError(errors.Trace(err), "write auth command failed") } var b = make([]byte, 5) if _, err := io.ReadFull(c, b); err != nil { log.PanicError(errors.Trace(err), "read auth response failed") } if strings.ToUpper(string(b)) != "+OK\r\n" { log.Panic("auth failed") } }