mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 21:09:06 +08:00
05.11
Former-commit-id: 22e7d5214db47ac228d50989b01e3a5e71a719d4
This commit is contained in:
parent
ab410524d8
commit
c7ba2112bb
@ -69,7 +69,7 @@ link_directories(${VECWISE_THIRD_PARTY_BUILD}/lib64)
|
||||
# WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(test_client)
|
||||
#add_subdirectory(test_client)
|
||||
|
||||
if (BUILD_UNIT_TEST)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unittest)
|
||||
|
133
cpp/src/license/BoostArchive.h
Normal file
133
cpp/src/license/BoostArchive.h
Normal file
@ -0,0 +1,133 @@
|
||||
//
|
||||
// Created by zilliz on 19-5-10.
|
||||
//
|
||||
|
||||
#ifndef VECWISE_ENGINE_BOOSTARCHIVE_H
|
||||
#define VECWISE_ENGINE_BOOSTARCHIVE_H
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <boost/archive/text_iarchive.hpp>
|
||||
#include <boost/archive/text_oarchive.hpp>
|
||||
|
||||
using std::list;
|
||||
using std::ifstream;
|
||||
using std::ofstream;
|
||||
using std::string;
|
||||
using std::map;
|
||||
|
||||
template <class T>
|
||||
class BoostArchive
|
||||
{
|
||||
public:
|
||||
typedef T entity_type;
|
||||
typedef boost::archive::binary_iarchive InputArchive;
|
||||
typedef boost::archive::binary_oarchive OutputArchive;
|
||||
|
||||
BoostArchive(const string & archive_file_path)
|
||||
: _file_path_name(archive_file_path)
|
||||
, _p_ofs(NULL)
|
||||
, _p_output_archive(NULL)
|
||||
, _entity_nums(0)
|
||||
{
|
||||
load_arvhive_info();
|
||||
}
|
||||
~BoostArchive()
|
||||
{
|
||||
close_output();
|
||||
}
|
||||
//存储一个对象,序列化
|
||||
void store(const entity_type & entity);
|
||||
|
||||
//反序列化, 提取所有对象
|
||||
bool restore(list<entity_type> & entitys);
|
||||
|
||||
size_t size() const
|
||||
{
|
||||
return _entity_nums;
|
||||
}
|
||||
|
||||
private:
|
||||
void save_archive_info() //保存已序列化的对象个数信息
|
||||
{
|
||||
ofstream ofs;
|
||||
ofs.open(get_archive_info_file_path(),std::ios::out | std::ios::trunc);
|
||||
if (ofs.is_open())
|
||||
{
|
||||
ofs << _entity_nums;
|
||||
}
|
||||
ofs.close();
|
||||
}
|
||||
|
||||
void load_arvhive_info()//读取已序列化的对象个数信息
|
||||
{
|
||||
ifstream ifs;
|
||||
ifs.open(get_archive_info_file_path(),std::ios_base::in);
|
||||
if (ifs.is_open() && !ifs.eof())
|
||||
{
|
||||
int enity_num = 0;
|
||||
ifs >> enity_num;
|
||||
_entity_nums = enity_num;
|
||||
}
|
||||
ifs.close();
|
||||
}
|
||||
|
||||
string get_archive_info_file_path()
|
||||
{
|
||||
return "/tmp/vecwise_engine.meta";
|
||||
}
|
||||
|
||||
void close_output()
|
||||
{
|
||||
if (NULL != _p_output_archive)
|
||||
{
|
||||
delete _p_output_archive;
|
||||
_p_output_archive = NULL;
|
||||
save_archive_info();
|
||||
}
|
||||
if (NULL != _p_ofs)
|
||||
{
|
||||
delete _p_ofs;
|
||||
_p_ofs = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
size_t _entity_nums;
|
||||
string _file_path_name;
|
||||
ofstream * _p_ofs;
|
||||
OutputArchive * _p_output_archive;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
bool BoostArchive<T>::restore( list<entity_type> & entitys )
|
||||
{
|
||||
close_output();
|
||||
load_arvhive_info();
|
||||
ifstream ifs(_file_path_name);
|
||||
if (ifs)
|
||||
{
|
||||
InputArchive ia(ifs);
|
||||
for (size_t cnt = 0; cnt < _entity_nums; ++cnt)
|
||||
{
|
||||
entity_type entity;
|
||||
ia & entity;
|
||||
entitys.push_back(entity);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void BoostArchive<T>::store( const entity_type & entity )
|
||||
{
|
||||
if (NULL == _p_output_archive)
|
||||
{
|
||||
_p_ofs = new ofstream(_file_path_name);
|
||||
_p_output_archive = new OutputArchive(*_p_ofs);
|
||||
}
|
||||
(*_p_output_archive) & entity;
|
||||
++_entity_nums;
|
||||
}
|
||||
#endif //VECWISE_ENGINE_BOOSTARCHIVE_H
|
371
cpp/src/license/License.cpp
Normal file
371
cpp/src/license/License.cpp
Normal file
@ -0,0 +1,371 @@
|
||||
#include "License.h"
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
ServerError
|
||||
LicenseSave(const std::string& path,const int& deviceCount,const std::vector<std::string>& shas)
|
||||
{
|
||||
std::ofstream file(path);
|
||||
|
||||
boost::archive::binary_oarchive oa(file);
|
||||
oa << deviceCount;
|
||||
for(int i=0;i<deviceCount;i++)
|
||||
{
|
||||
oa << shas[i];
|
||||
}
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseLoad(const std::string& path,int& deviceCount,std::vector<std::string>& shas)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
|
||||
boost::archive::binary_iarchive ia(file);
|
||||
ia >> deviceCount;
|
||||
std::string sha;
|
||||
for(int i=0;i<deviceCount;i++)
|
||||
{
|
||||
ia >> sha;
|
||||
shas.push_back(sha);
|
||||
}
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
Licensefileread(const std::string& path)
|
||||
{
|
||||
std::ifstream fileread;
|
||||
fileread.open(path,std::ios::in);
|
||||
if(!fileread)
|
||||
{
|
||||
printf("Can't open file\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
fileread.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
Licensefileread (const std::string& path,std::ifstream& fileread){
|
||||
fileread.open(path,std::ios::in);
|
||||
if(!fileread)
|
||||
{
|
||||
printf("Can't open file\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
Licensefilewrite (const std::string& path,std::ofstream& filewrite) {
|
||||
filewrite.open(path,std::ios::out);
|
||||
if(!filewrite)
|
||||
{
|
||||
printf("Can't write file\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseGetCount(int &deviceCount)
|
||||
{
|
||||
nvmlReturn_t result = nvmlInit();
|
||||
if (NVML_SUCCESS != result)
|
||||
{
|
||||
printf("Failed to initialize NVML: %s\n", nvmlErrorString(result));
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
|
||||
if (error_id != cudaSuccess)
|
||||
{
|
||||
printf("cudaGetDeviceCount returned %d\n-> %s\n", (int)error_id, cudaGetErrorString(error_id));
|
||||
printf("Result = FAIL\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseGetuuid(int& deviceCount, std::vector<std::string>& uuids)
|
||||
{
|
||||
nvmlReturn_t result = nvmlInit();
|
||||
if (NVML_SUCCESS != result)
|
||||
{
|
||||
printf("Failed to initialize NVML: %s\n", nvmlErrorString(result));
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
|
||||
if (error_id != cudaSuccess)
|
||||
{
|
||||
printf("cudaGetDeviceCount returned %d\n-> %s\n", (int)error_id, cudaGetErrorString(error_id));
|
||||
printf("Result = FAIL\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
if (deviceCount == 0)
|
||||
{
|
||||
printf("There are no available device(s) that support CUDA\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
for (int dev = 0; dev < deviceCount; ++dev)
|
||||
{
|
||||
nvmlDevice_t device;
|
||||
result = nvmlDeviceGetHandleByIndex(dev, &device);
|
||||
printf("device id: %d\n", dev);
|
||||
if (NVML_SUCCESS != result)
|
||||
{
|
||||
printf("Failed to get handle for device %i: %s\n", dev, nvmlErrorString(result));
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
char* uuid = (char*)malloc(80);
|
||||
unsigned int length = 80;
|
||||
nvmlReturn_t err = nvmlDeviceGetUUID(device, uuid, length);
|
||||
if(err != NVML_SUCCESS) {
|
||||
printf("nvmlDeviceGetUUID error: %d\n", err);
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
printf("\n device: %d, uuid = %s \n", dev, uuid);
|
||||
uuids.push_back(std::string(uuid));
|
||||
free(uuid);
|
||||
uuid = NULL;
|
||||
}
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseGetuuidmd5(const int& deviceCount,std::vector<std::string>& uuids,std::vector<std::string>& md5s)
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
unsigned char outmd[16];
|
||||
char temp[2];
|
||||
std::string md5="";
|
||||
for(int dev=0;dev<deviceCount;dev++)
|
||||
{
|
||||
md5.clear();
|
||||
memset(outmd,0, sizeof(outmd));
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx,uuids[dev].c_str(),uuids[dev].size());
|
||||
MD5_Final(outmd,&ctx);
|
||||
for(int i=0;i<16;i++)
|
||||
{
|
||||
std::sprintf(temp,"%02X",outmd[i]);
|
||||
md5+=temp;
|
||||
}
|
||||
md5s.push_back(md5);
|
||||
}
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseGetfilemd5(const std::string& path,std::string& filemd5)
|
||||
{
|
||||
// MD5_CTX ctx;
|
||||
// unsigned char outmd[16];
|
||||
// char temp[2];
|
||||
// char* buffer = (char*)malloc(1024);
|
||||
// std::ifstream fileread;
|
||||
// Licensefileread(path,fileread);
|
||||
// memset(outmd,0,sizeof(outmd));
|
||||
// memset(buffer,0,sizeof(buffer));
|
||||
// MD5_Init(&ctx);
|
||||
// while(!fileread.eof()) {
|
||||
// fileread.get(buffer,1024,EOF);
|
||||
// MD5_Update(&ctx, buffer, strlen(buffer));
|
||||
// memset(buffer, 0, sizeof(buffer));
|
||||
// }
|
||||
// MD5_Final(outmd,&ctx);
|
||||
// for(int i=0;i<16;i++)
|
||||
// {
|
||||
// std::sprintf(temp,"%02X",outmd[i]);
|
||||
// filemd5+=temp;
|
||||
// }
|
||||
// free(buffer);
|
||||
// buffer=NULL;
|
||||
// fileread.close();
|
||||
// return SERVER_SUCCESS;
|
||||
|
||||
|
||||
filemd5.clear();
|
||||
|
||||
std::ifstream file(path.c_str(), std::ifstream::binary);
|
||||
if (!file)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
MD5_CTX md5Context;
|
||||
MD5_Init(&md5Context);
|
||||
|
||||
char buf[1024 * 16];
|
||||
while (file.good()) {
|
||||
file.read(buf, sizeof(buf));
|
||||
MD5_Update(&md5Context, buf, file.gcount());
|
||||
}
|
||||
|
||||
unsigned char result[MD5_DIGEST_LENGTH];
|
||||
MD5_Final(result, &md5Context);
|
||||
|
||||
char hex[35];
|
||||
memset(hex, 0, sizeof(hex));
|
||||
for (int i = 0; i < MD5_DIGEST_LENGTH; ++i)
|
||||
{
|
||||
sprintf(hex + i * 2, "%02X", result[i]);
|
||||
}
|
||||
hex[32] = '\0';
|
||||
filemd5 = std::string(hex);
|
||||
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseGetuuidsha(const int& deviceCount,std::vector<std::string>& uuids,std::vector<std::string>& shas)
|
||||
{
|
||||
SHA256_CTX ctx;
|
||||
unsigned char outmd[32];
|
||||
char temp[2];
|
||||
std::string sha="";
|
||||
for(int dev=0;dev<deviceCount;dev++)
|
||||
{
|
||||
sha.clear();
|
||||
memset(outmd,0, sizeof(outmd));
|
||||
SHA256_Init(&ctx);
|
||||
SHA256_Update(&ctx,uuids[dev].c_str(),uuids[dev].size());
|
||||
SHA256_Final(outmd,&ctx);
|
||||
for(int i=0;i<32;i++)
|
||||
{
|
||||
std::sprintf(temp,"%02X",outmd[i]);
|
||||
sha += temp;
|
||||
}
|
||||
shas.push_back(sha);
|
||||
}
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseGetfiletime(const std::string& path,time_t& last_time)
|
||||
{
|
||||
struct stat buf;
|
||||
stat(path.c_str(),&buf);
|
||||
last_time =buf.st_mtime;
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseGetfilesize(const std::string& path,off_t& file_size)
|
||||
{
|
||||
struct stat buf;
|
||||
if(stat(path.c_str(),&buf)==-1)
|
||||
{
|
||||
printf(" GET fiel_size is wrong");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
file_size =buf.st_size;
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseLegalitycheck(const std::string& path)
|
||||
{
|
||||
int deviceCount;
|
||||
std::vector<std::string> uuids;
|
||||
LicenseGetuuid(deviceCount,uuids);
|
||||
std::vector<std::string> shas;
|
||||
LicenseGetuuidsha(deviceCount,uuids,shas);
|
||||
|
||||
|
||||
int deviceCountcheck;
|
||||
std::vector<std::string> shascheck;
|
||||
LicenseLoad(path,deviceCountcheck,shascheck);
|
||||
|
||||
if(deviceCount!=deviceCountcheck)
|
||||
{
|
||||
printf("deviceCount is wrong\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
for(int i=0;i<deviceCount;i++)
|
||||
{
|
||||
if(shascheck[i]!=shas[i])
|
||||
{
|
||||
printf("uuidsha %d is wrong\n",i);
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicensefileSave(const std::string& path,const std::string& path2){
|
||||
|
||||
std::string filemd5;
|
||||
LicenseGetfilemd5(path,filemd5);
|
||||
std::ofstream file(path2);
|
||||
time_t last_time;
|
||||
LicenseGetfiletime(path,last_time);
|
||||
|
||||
boost::archive::binary_oarchive oa(file);
|
||||
oa << filemd5;
|
||||
oa << last_time;
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicensefileLoad(const std::string& path2,std::string& filemd5,time_t& last_time){
|
||||
|
||||
std::ifstream file(path2);
|
||||
|
||||
boost::archive::binary_iarchive ia(file);
|
||||
ia >> filemd5;
|
||||
ia >> last_time;
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseIntegritycheck(const std::string& path,const std::string& path2)
|
||||
{
|
||||
std::string filemd5;
|
||||
LicenseGetfilemd5(path,filemd5);
|
||||
time_t last_time;
|
||||
LicenseGetfiletime(path,last_time);
|
||||
|
||||
time_t last_timecheck;
|
||||
std::string filemd5check;
|
||||
LicensefileLoad(path2,filemd5check,last_timecheck);
|
||||
|
||||
if(filemd5!=filemd5check)
|
||||
{
|
||||
printf("This file has been modified\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
if(last_time!=last_timecheck)
|
||||
{
|
||||
printf("last_time is wrong\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseValidate(const std::string& path) {
|
||||
|
||||
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
81
cpp/src/license/License.h
Normal file
81
cpp/src/license/License.h
Normal file
@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
|
||||
#include "utils/Error.h"
|
||||
#include <cuda.h>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
#include "boost/archive/binary_oarchive.hpp"
|
||||
#include "boost/archive/binary_iarchive.hpp"
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include <nvml.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
|
||||
ServerError
|
||||
LicenseSave(const std::string& path,const int& deviceCount,const std::vector<std::string>& shas);
|
||||
|
||||
ServerError
|
||||
LicenseLoad(const std::string& path,int& deviceCount,std::vector<std::string>& shas);
|
||||
|
||||
ServerError
|
||||
Licensefileread (const std::string& path,std::ifstream& fileread);
|
||||
|
||||
ServerError
|
||||
Licensefilewrite (const std::string& path,std::ofstream& filewrite);
|
||||
|
||||
ServerError
|
||||
LicenseGetuuid(int& deviceCount, std::vector<std::string>& uuids);
|
||||
|
||||
ServerError
|
||||
LicenseGetuuidmd5(const int& deviceCount,std::vector<std::string>& uuids,std::vector<std::string>& md5s);
|
||||
|
||||
ServerError
|
||||
LicenseGetfilemd5(const std::string& path,std::string& filemd5);
|
||||
|
||||
ServerError
|
||||
LicenseGetuuidsha(const int& deviceCount,std::vector<std::string>& uuids,std::vector<std::string>& shas);
|
||||
|
||||
ServerError
|
||||
LicenseIntegritycheck(const std::string& path,const std::string& path2);
|
||||
|
||||
ServerError
|
||||
LicenseGetfiletime(const std::string& path,time_t& last_time);
|
||||
|
||||
ServerError
|
||||
LicenseLegalitycheck(const std::string& path);
|
||||
|
||||
ServerError
|
||||
LicensefileSave(const std::string& path,const std::string& path2);
|
||||
|
||||
ServerError
|
||||
LicensefileLoad(const std::string& path2,std::string& filemd5,time_t& last_time);
|
||||
|
||||
|
||||
ServerError
|
||||
LicenseGetfilesize(const std::string& path,off_t& file_size);
|
||||
|
||||
ServerError
|
||||
LicenseValidate(const std::string& path);
|
||||
|
||||
ServerError
|
||||
Licensefileread(const std::string& path);
|
||||
|
||||
ServerError
|
||||
LicenseGetCount(int &deviceCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
51
cpp/src/license/LicenseCreateTime.cpp
Normal file
51
cpp/src/license/LicenseCreateTime.cpp
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// Created by zilliz on 19-5-11.
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "utils/Error.h"
|
||||
#include "license/License.h"
|
||||
#include "license/LicensePublic.h"
|
||||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
//TEST(LicenseTest, LICENSE_TEST) {
|
||||
//
|
||||
// std::string path1 = "/tmp/vecwise_engine.sha";
|
||||
// std::string path2 = "/tmp/vecwise_engine.license";
|
||||
// std::cout << "This is create licenseTime " << std::endl;
|
||||
//
|
||||
// server::ServerError err;
|
||||
// int deviceCount=0;
|
||||
//
|
||||
// std::vector<std::string> shas;
|
||||
// err = server::LicenseLoad(path1,deviceCount,shas);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// std::map<int,std::string> uuidEncryption;
|
||||
// std::cout<< "deviceCount : " << deviceCount << std::endl;
|
||||
// for(int i=0;i<deviceCount;i++)
|
||||
// {
|
||||
// std::cout<< "uuidshas : " << shas[i] << std::endl;
|
||||
// uuidEncryption.insert(std::make_pair(i,shas[i]));
|
||||
// }
|
||||
// int64_t RemainingTime;
|
||||
// std::cout<< "cin RemainingTime: (Hours)" << std::endl;
|
||||
// std::cin >> RemainingTime ;
|
||||
//
|
||||
// err = server::LiSave(path2,deviceCount,uuidEncryption,RemainingTime);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// int64_t RemainingTimecheck;
|
||||
// std::map<int,std::string> uuidEncryptioncheck;
|
||||
// int deviceCountcheck;
|
||||
// err = server::LiLoad(path2,deviceCountcheck,uuidEncryptioncheck,RemainingTimecheck);
|
||||
//
|
||||
// printf("\n deviceCountcheck = %d\n",deviceCountcheck);
|
||||
// std::cout<< "RemainingTimecheck: " << RemainingTimecheck<< std::endl;
|
||||
// std::cout<< "success" << std::endl;
|
||||
//
|
||||
//}
|
31
cpp/src/license/LicenseCreateuuidshafile.cpp
Normal file
31
cpp/src/license/LicenseCreateuuidshafile.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by zilliz on 19-5-11.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "utils/Error.h"
|
||||
#include "license/License.h"
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
//
|
||||
//TEST(LicenseTest, LICENSE_TEST) {
|
||||
//
|
||||
// std::string path1 = "/tmp/vecwise_engine.sha";
|
||||
// std::cout << "This is create uuidshafile " << std::endl;
|
||||
//
|
||||
// server::ServerError err;
|
||||
// int deviceCount=0;
|
||||
// std::vector<std::string> uuids;
|
||||
//
|
||||
// err = server::LicenseGetuuid(deviceCount,uuids);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// std::vector<std::string> shas;
|
||||
// err = server::LicenseGetuuidsha(deviceCount,uuids,shas);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// err = server::LicenseSave(path1,deviceCount,shas);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
//}
|
@ -1,6 +1,6 @@
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "This is license generator" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
284
cpp/src/license/LicensePublic.cpp
Normal file
284
cpp/src/license/LicensePublic.cpp
Normal file
@ -0,0 +1,284 @@
|
||||
//
|
||||
// Created by zilliz on 19-5-10.
|
||||
//
|
||||
|
||||
#include "LicensePublic.h"
|
||||
#include "license/License.h"
|
||||
//#include "BoostArchive.h"
|
||||
#define RTime 100
|
||||
|
||||
using std::string;
|
||||
using std::map;
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
// GET /tmp/vecwise_engine.license
|
||||
class Licensedata1
|
||||
{
|
||||
public:
|
||||
Licensedata1()
|
||||
:_deviceCount(0)
|
||||
,_RemainingTime(RTime)
|
||||
{}
|
||||
|
||||
Licensedata1(const int& deviceCount,const map<int,string>& uuidEncryption)
|
||||
:_deviceCount(deviceCount)
|
||||
,_uuidEncryption(uuidEncryption)
|
||||
,_RemainingTime(RTime)
|
||||
{}
|
||||
|
||||
Licensedata1(const int& deviceCount,const map<int,string>& uuidEncryption,const int64_t& RemainingTime)
|
||||
:_deviceCount(deviceCount)
|
||||
,_uuidEncryption(uuidEncryption)
|
||||
,_RemainingTime(RemainingTime)
|
||||
{}
|
||||
|
||||
int GetdeviceCount()
|
||||
{
|
||||
return _deviceCount;
|
||||
}
|
||||
map<int,string> GetuuidEncryption()
|
||||
{
|
||||
return _uuidEncryption;
|
||||
}
|
||||
int64_t GetRemainingTime()
|
||||
{
|
||||
return _RemainingTime;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template <typename Archive>
|
||||
void serialize(Archive &ar, const unsigned int version)
|
||||
{
|
||||
ar & _deviceCount;
|
||||
ar & _uuidEncryption;
|
||||
ar & _RemainingTime;
|
||||
}
|
||||
|
||||
public:
|
||||
int _deviceCount;
|
||||
map<int,string> _uuidEncryption;
|
||||
int64_t _RemainingTime;
|
||||
};
|
||||
|
||||
|
||||
class STLlicensedata
|
||||
{
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template <typename Archive>
|
||||
void serialize(Archive& ar, const unsigned int version)
|
||||
{
|
||||
ar & m_licensedata;
|
||||
}
|
||||
|
||||
public:
|
||||
Licensedata1* m_licensedata;
|
||||
};
|
||||
|
||||
|
||||
ServerError
|
||||
LiSave(const string& path,const int& deviceCount,const map<int,string>& uuidEncryption)
|
||||
{
|
||||
std::ofstream file(path);
|
||||
boost::archive::binary_oarchive oa(file);
|
||||
oa.register_type<Licensedata1>();
|
||||
STLlicensedata stllicensedata;
|
||||
|
||||
Licensedata1 *p = new Licensedata1(deviceCount,uuidEncryption);
|
||||
stllicensedata.m_licensedata = p;
|
||||
oa << stllicensedata;
|
||||
|
||||
delete p;
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LiSave(const string& path,const int& deviceCount,const map<int,string>& uuidEncryption, const int64_t& RemainingTime)
|
||||
{
|
||||
std::ofstream file(path);
|
||||
boost::archive::binary_oarchive oa(file);
|
||||
oa.register_type<Licensedata1>();
|
||||
STLlicensedata stllicensedata;
|
||||
|
||||
Licensedata1 *p = new Licensedata1(deviceCount,uuidEncryption,RemainingTime);
|
||||
stllicensedata.m_licensedata = p;
|
||||
oa << stllicensedata;
|
||||
|
||||
delete p;
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LiLoad(const string& path,int& deviceCount,map<int,string>& uuidEncryption,int64_t& RemainingTime)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
boost::archive::binary_iarchive ia(file);
|
||||
ia.register_type<Licensedata1>();
|
||||
STLlicensedata stllicensedata;
|
||||
ia >> stllicensedata;
|
||||
deviceCount = stllicensedata.m_licensedata->GetdeviceCount();
|
||||
uuidEncryption = stllicensedata.m_licensedata->GetuuidEncryption();
|
||||
RemainingTime = stllicensedata.m_licensedata->GetRemainingTime();
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
// GET /tmp/vecwise_engine2.license
|
||||
|
||||
class Licensefiledata
|
||||
{
|
||||
public:
|
||||
Licensefiledata()
|
||||
:_update_time(0)
|
||||
,_file_size(0)
|
||||
,_filemd5("")
|
||||
{}
|
||||
|
||||
Licensefiledata(const time_t& update_time,const off_t& file_size,const string& filemd5)
|
||||
:_update_time(update_time)
|
||||
,_file_size(file_size)
|
||||
,_filemd5(filemd5)
|
||||
{}
|
||||
|
||||
time_t Getupdate_time()
|
||||
{
|
||||
return _update_time;
|
||||
}
|
||||
off_t Getfile_size()
|
||||
{
|
||||
return _file_size;
|
||||
}
|
||||
string Getfilemd5()
|
||||
{
|
||||
return _filemd5;
|
||||
}
|
||||
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template <typename Archive>
|
||||
void serialize(Archive &ar, const unsigned int version)
|
||||
{
|
||||
ar & _update_time;
|
||||
ar & _file_size;
|
||||
ar & _filemd5;
|
||||
}
|
||||
|
||||
public:
|
||||
time_t _update_time;
|
||||
off_t _file_size;
|
||||
string _filemd5;
|
||||
};
|
||||
|
||||
|
||||
class STLlicensefiledata
|
||||
{
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
template <typename Archive>
|
||||
void serialize(Archive& ar, const unsigned int version)
|
||||
{
|
||||
ar & m_licensefiledata;
|
||||
}
|
||||
|
||||
public:
|
||||
Licensefiledata* m_licensefiledata;
|
||||
};
|
||||
|
||||
|
||||
ServerError
|
||||
LifileSave(const string& path,const time_t& update_time,const off_t& file_size,const string& filemd5)
|
||||
{
|
||||
std::ofstream file(path);
|
||||
boost::archive::binary_oarchive oa(file);
|
||||
oa.register_type<Licensefiledata>();
|
||||
STLlicensefiledata stllicensefiledata;
|
||||
|
||||
Licensefiledata *p = new Licensefiledata(update_time,file_size,filemd5);
|
||||
stllicensefiledata.m_licensefiledata = p;
|
||||
oa << stllicensefiledata;
|
||||
|
||||
delete p;
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LifileLoad(const string& path,time_t& update_time,off_t& file_size,string& filemd5)
|
||||
{
|
||||
std::ifstream file(path);
|
||||
boost::archive::binary_iarchive ia(file);
|
||||
ia.register_type<Licensefiledata>();
|
||||
STLlicensefiledata stllicensefiledata;
|
||||
ia >> stllicensefiledata;
|
||||
update_time = stllicensefiledata.m_licensefiledata->Getupdate_time();
|
||||
file_size = stllicensefiledata.m_licensefiledata->Getfile_size();
|
||||
filemd5 = stllicensefiledata.m_licensefiledata->Getfilemd5();
|
||||
file.close();
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void Alterfile(const string &path1, const string &path2 ,const boost::system::error_code &ec, boost::asio::deadline_timer* pt)
|
||||
{
|
||||
int deviceCount;
|
||||
map<int,string> uuidEncryption;
|
||||
int64_t RemainingTime;
|
||||
LiLoad(path1,deviceCount,uuidEncryption,RemainingTime);
|
||||
|
||||
std::cout<< "RemainingTime: " << RemainingTime <<std::endl;
|
||||
|
||||
if(RemainingTime==0)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
RemainingTime--;
|
||||
LiSave(path1,deviceCount,uuidEncryption,RemainingTime);
|
||||
|
||||
int deviceCountcheck;
|
||||
map<int,string> uuidEncryptioncheck;
|
||||
int64_t RemainingTimecheck;
|
||||
LiLoad(path1,deviceCountcheck,uuidEncryptioncheck,RemainingTimecheck);
|
||||
|
||||
std::cout<< "RemainingTimecheck: " << RemainingTimecheck <<std::endl;
|
||||
|
||||
time_t update_time;
|
||||
LicenseGetfiletime(path1,update_time);
|
||||
off_t file_size;
|
||||
LicenseGetfilesize(path1,file_size);
|
||||
string filemd5;
|
||||
LicenseGetfilemd5(path1,filemd5);
|
||||
|
||||
std::cout<< "filemd5: " << filemd5 <<std::endl;
|
||||
|
||||
LifileSave(path2,update_time,file_size,filemd5);
|
||||
time_t update_timecheck;
|
||||
off_t file_sizecheck;
|
||||
string filemd5check;
|
||||
LifileLoad(path2,update_timecheck,file_sizecheck,filemd5check);
|
||||
|
||||
std::cout<< "update_timecheck: " << update_timecheck <<std::endl;
|
||||
std::cout<< "file_sizecheck: " << file_sizecheck <<std::endl;
|
||||
std::cout<< "filemd5check: " << filemd5check <<std::endl;
|
||||
|
||||
pt->expires_at(pt->expires_at() + boost::posix_time::hours(1)) ;
|
||||
pt->async_wait(boost::bind(Alterfile,path1,path2, boost::asio::placeholders::error, pt));
|
||||
|
||||
}
|
||||
void Runtime(const string &path1, const string &path2 )
|
||||
{
|
||||
boost::asio::io_service io;
|
||||
boost::asio::deadline_timer t(io, boost::posix_time::hours(1));
|
||||
t.async_wait(boost::bind(Alterfile,path1,path2, boost::asio::placeholders::error, &t));
|
||||
io.run();
|
||||
return;;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
68
cpp/src/license/LicensePublic.h
Normal file
68
cpp/src/license/LicensePublic.h
Normal file
@ -0,0 +1,68 @@
|
||||
//
|
||||
// Created by zilliz on 19-5-10.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "utils/Error.h"
|
||||
#include <cuda.h>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include <nvml.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
class BoostArchive;
|
||||
class Licensedata1;
|
||||
|
||||
|
||||
class Licensefiledata;
|
||||
class STLlicensefiledata;
|
||||
|
||||
|
||||
ServerError
|
||||
LiSave(const std::string& path,const int& deviceCount,const std::map<int,std::string>& uuidEncryption);
|
||||
|
||||
ServerError
|
||||
LiLoad(const std::string& path,int& deviceCount,std::map<int,std::string>& uuidEncryption,int64_t& RemainingTime);
|
||||
|
||||
ServerError
|
||||
LifileSave(const std::string& path,const time_t& update_time,const off_t& file_size,const std::string& filemd5);
|
||||
|
||||
ServerError
|
||||
LifileLoad(const std::string& path,time_t& update_time,off_t& file_size,std::string& filemd5);
|
||||
|
||||
ServerError
|
||||
LiSave(const std::string& path,const int& deviceCount,const std::map<int,std::string>& uuidEncryption, const int64_t& RemainingTime);
|
||||
|
||||
void Alterfile(const std::string &path1, const std::string &path2 ,const boost::system::error_code &ec, boost::asio::deadline_timer* pt);
|
||||
void Runtime(const std::string &path1, const std::string &path2 );
|
||||
|
||||
// void Print(const boost::system::error_code &ec,boost::asio::deadline_timer* pt, int * pcount );
|
||||
// void Run();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
13
cpp/src/license/LicenseRun.cpp
Normal file
13
cpp/src/license/LicenseRun.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
//
|
||||
// Created by zilliz on 19-5-11.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "utils/Error.h"
|
||||
#include "license/License.h"
|
||||
#include "license/LicensePublic.h"
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
|
@ -31,6 +31,7 @@ constexpr ServerError SERVER_INVALID_ARGUMENT = ToGlobalServerErrorCode(0x004);
|
||||
constexpr ServerError SERVER_FILE_NOT_FOUND = ToGlobalServerErrorCode(0x005);
|
||||
constexpr ServerError SERVER_NOT_IMPLEMENT = ToGlobalServerErrorCode(0x006);
|
||||
constexpr ServerError SERVER_BLOCKING_QUEUE_EMPTY = ToGlobalServerErrorCode(0x007);
|
||||
constexpr ServerError SERVER_LICENSE_VALIDATION_FAIL = ToGlobalServerErrorCode(0x008);
|
||||
|
||||
class ServerException : public std::exception {
|
||||
public:
|
||||
|
@ -11,34 +11,32 @@ aux_source_directory(../../src/cache cache_srcs)
|
||||
aux_source_directory(../../src/wrapper wrapper_src)
|
||||
|
||||
include_directories(/usr/local/cuda/include)
|
||||
link_directories("/usr/local/cuda/lib64")
|
||||
link_directories(/usr/local/cuda)
|
||||
link_directories(/usr/local/cuda/lib64)
|
||||
link_directories(/usr/lib/x86_64-linux-gnu)
|
||||
link_directories(/usr/lib/nvidia-415)
|
||||
|
||||
set(require_files
|
||||
../../src/server/ServerConfig.cpp
|
||||
../../src/utils/CommonUtil.cpp
|
||||
../../src/utils/TimeRecorder.cpp
|
||||
../../src/license/License.cpp
|
||||
)
|
||||
../../src/license/LicensePublic.cpp
|
||||
../../src/license/LicenseCreateuuidshafile.cpp
|
||||
)
|
||||
|
||||
set(db_test_src
|
||||
${unittest_srcs}
|
||||
${config_files}
|
||||
${cache_srcs}
|
||||
${db_srcs}
|
||||
${wrapper_src}
|
||||
${require_files}
|
||||
license_tests.cpp)
|
||||
|
||||
cuda_add_executable(license_test ${db_test_src})
|
||||
|
||||
set(db_libs
|
||||
faiss
|
||||
nvidia-ml
|
||||
cudart
|
||||
cublas
|
||||
sqlite3
|
||||
boost_system
|
||||
boost_filesystem
|
||||
lz4
|
||||
crypto
|
||||
boost_serialization
|
||||
)
|
||||
|
||||
target_link_libraries(license_test ${unittest_libs} ${db_libs})
|
||||
|
@ -5,12 +5,184 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <gtest/gtest.h>
|
||||
#include "license/License.h"
|
||||
#include "license/LicensePublic.h"
|
||||
#include "utils/Error.h"
|
||||
|
||||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
TEST(LicenseTest, LICENSE_TEST) {
|
||||
|
||||
std::string path1 = "/tmp/vecwise_engine.license";
|
||||
server::ServerError err = server::LicenseValidate(path1);
|
||||
std::string path2 = "/tmp/vecwise_engine2.license";
|
||||
std::cout << "This is run " << std::endl;
|
||||
|
||||
server::ServerError err;
|
||||
|
||||
err = server::Licensefileread(path1);
|
||||
if(err!=server::SERVER_SUCCESS)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int deviceCount=0;
|
||||
std::vector<std::string> uuids;
|
||||
|
||||
err = server::LicenseGetuuid(deviceCount,uuids);
|
||||
ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
|
||||
std::vector<std::string> shas;
|
||||
err = server::LicenseGetuuidsha(deviceCount,uuids,shas);
|
||||
ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
|
||||
err = server::LicenseSave(path1,deviceCount,shas);
|
||||
ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
//TEST(LicenseTest, LICENSE_TEST) {
|
||||
// std::string path1 = "/tmp/vecwise_engine.license";
|
||||
// std::string path2 = "/tmp/vecwise_engine2.license";
|
||||
//
|
||||
// server::ServerError err;
|
||||
// server::Runtime(path1,path2);
|
||||
|
||||
|
||||
// time_t update_time;
|
||||
// off_t file_size;
|
||||
// std::string filemd5;
|
||||
//
|
||||
// time_t update_timecheck;
|
||||
// off_t file_sizecheck;
|
||||
// std::string filemd5check;
|
||||
//
|
||||
// err = server::LicenseGetfiletime(path1,update_time);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// err = server::LicenseGetfilesize(path1,file_size);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// err = server::LicenseGetfilemd5(path1,filemd5);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// err = server::LifileSave(path2,update_time,file_size,filemd5);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// err = server::LifileLoad(path2,update_timecheck,file_sizecheck,filemd5check);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
//
|
||||
// std::cout<< "update_time : " << update_time <<std::endl;
|
||||
// std::cout<< "update_timecheck : " << update_timecheck <<std::endl;
|
||||
//
|
||||
// std::cout<< "file_size : " << file_size<<std::endl;
|
||||
// std::cout<< "file_sizecheck : " << file_sizecheck <<std::endl;
|
||||
//
|
||||
// std::cout<< "filemd5 : " << filemd5 <<std::endl;
|
||||
// std::cout<< "filemd5check : " << filemd5check <<std::endl;
|
||||
|
||||
|
||||
// server::ServerError err = server::LicenseValidate(path1);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// int deviceCount = 0;
|
||||
// std::vector<std::string> uuids;
|
||||
//
|
||||
// deviceCount = 2;
|
||||
// uuids.push_back("121");
|
||||
// uuids.push_back("324");
|
||||
// err = server::LicenseGetuuid(deviceCount,uuids);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
// printf("\n deviceCount = %d\n",deviceCount);
|
||||
//
|
||||
// std::vector<std::string> uuidmd5s;
|
||||
// err = server::LicenseGetuuidmd5(deviceCount,uuids,uuidmd5s);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// printf(" md5s \n");
|
||||
// for(int i=0;i<deviceCount;i++)
|
||||
// std::cout<< uuidmd5s[i] << std::endl;
|
||||
//
|
||||
// std::vector<std::string> uuidshas;
|
||||
// err = server::LicenseGetuuidsha(deviceCount,uuids,uuidshas);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// std::map<int,std::string> uuidEncryption;
|
||||
// for(int i=0;i<deviceCount;i++)
|
||||
// {
|
||||
// uuidEncryption.insert(std::make_pair(i,uuidshas[i]));
|
||||
// }
|
||||
// for(int i=0;i<deviceCount;i++)
|
||||
// {
|
||||
// std::cout<< "uuidshas : " << uuidshas[i] << std::endl;
|
||||
// }
|
||||
//
|
||||
// err = server::LiSave(path1,deviceCount,uuidEncryption);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// int64_t RemainingTime;
|
||||
// int deviceCountcheck;
|
||||
// std::map<int,std::string> uuidEncryptioncheck;
|
||||
// err = server::LiLoad(path1,deviceCountcheck,uuidEncryptioncheck,RemainingTime);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// printf("----- checking ----\n");
|
||||
// printf("\n deviceCount = %d\n",deviceCountcheck);
|
||||
// for(auto it : uuidEncryptioncheck)
|
||||
// {
|
||||
// std::cout<< "uuidshas : " << it.second << std::endl;
|
||||
// }
|
||||
// std::cout<< "RemainingTime :" << RemainingTime << std::endl;
|
||||
//
|
||||
// printf(" shas \n");
|
||||
// for(int i=0;i<deviceCount;i++)
|
||||
// std::cout<< uuidshas[i] << std::endl;
|
||||
//
|
||||
//
|
||||
//
|
||||
// err = server::LicenseSave(path1,deviceCount,uuidshas);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// std::cout<<" file save success " << std::endl;
|
||||
//
|
||||
//
|
||||
//
|
||||
// err = server::LicenseLegalitycheck(path1);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
// std::cout<<" Legality check success " << std::endl;
|
||||
//
|
||||
// int deviceCountcheck;
|
||||
// std::vector<std::string> uuidshascheck;
|
||||
//
|
||||
// err = server::LicenseLoad(path1,deviceCountcheck,uuidshascheck);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// std::cout<<" deviceCountcheck :" << deviceCountcheck << std::endl;
|
||||
// std::cout<<" uuidshascheck :" << uuidshascheck[0] << std::endl;
|
||||
//
|
||||
//
|
||||
// std::string filemd5;
|
||||
// err = server::LicenseGetfilemd5(path1,filemd5);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
// std::cout<<" filemd5 :" << filemd5 << std::endl;
|
||||
//
|
||||
// err= server::LicensefileSave(path1,path2);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// time_t last_timecheck;
|
||||
// std::string filemd5check;
|
||||
// err= server::LicensefileLoad(path2,filemd5check,last_timecheck);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
// std::cout<<" filemd5check :" << filemd5check << std::endl;
|
||||
//
|
||||
// time_t last_time;
|
||||
// err = server::LicenseGetfiletime(path1,last_time);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// std::cout<<" last_time : " << last_time << std::endl;
|
||||
// std::cout<<" last_timecheck :" << last_timecheck << std::endl;
|
||||
//
|
||||
// err = server::LicenseIntegritycheck(path1,path2);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
|
||||
//}
|
||||
|
Loading…
Reference in New Issue
Block a user