mirror of https://github.com/milvus-io/milvus.git
parent
c7ba2112bb
commit
5eb854b1b6
|
@ -43,7 +43,7 @@ Licensefileread(const std::string& path)
|
|||
fileread.open(path,std::ios::in);
|
||||
if(!fileread)
|
||||
{
|
||||
printf("Can't open file\n");
|
||||
printf("NO License\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
fileread.close();
|
||||
|
|
|
@ -12,10 +12,14 @@
|
|||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
|
||||
|
||||
//TEST(LicenseTest, LICENSE_TEST) {
|
||||
//
|
||||
// std::string path1 = "/tmp/vecwise_engine.sha";
|
||||
// std::string path2 = "/tmp/vecwise_engine.license";
|
||||
// std::string path3 = "/tmp/vecwise_engine2.license";
|
||||
//
|
||||
// std::cout << "This is create licenseTime " << std::endl;
|
||||
//
|
||||
// server::ServerError err;
|
||||
|
@ -39,13 +43,29 @@ using namespace zilliz::vecwise;
|
|||
// 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);
|
||||
//// 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;
|
||||
//
|
||||
// time_t update_time;
|
||||
// off_t file_size;
|
||||
// std::string filemd5;
|
||||
//
|
||||
// server::LicenseGetfiletime(path2,update_time);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
// server::LicenseGetfilesize(path2,file_size);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
// server::LicenseGetfilemd5(path2,filemd5);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
//
|
||||
// err = server::LifileSave(path3,update_time,file_size,filemd5);
|
||||
// ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
//
|
||||
// printf("\n deviceCountcheck = %d\n",deviceCountcheck);
|
||||
// std::cout<< "RemainingTimecheck: " << RemainingTimecheck<< std::endl;
|
||||
// std::cout<< "success" << std::endl;
|
||||
//
|
||||
//}
|
||||
//}
|
||||
|
|
|
@ -223,6 +223,78 @@ LifileLoad(const string& path,time_t& update_time,off_t& file_size,string& filem
|
|||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseLegality_check(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::map<int,std::string> uuidEncryption;
|
||||
int64_t RemainingTime;
|
||||
LiLoad(path,deviceCountcheck,uuidEncryption,RemainingTime);
|
||||
|
||||
if(deviceCount!=deviceCountcheck)
|
||||
{
|
||||
printf("deviceCount is wrong\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
for(int i=0;i<deviceCount;i++)
|
||||
{
|
||||
if(uuidEncryption[i]!=shas[i])
|
||||
{
|
||||
printf("uuidsha %d is wrong\n",i);
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
}
|
||||
if(RemainingTime <=0 )
|
||||
{
|
||||
printf("License expired\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
ServerError
|
||||
LicenseIntegrity_check(const std::string& path,const std::string& path2)
|
||||
{
|
||||
std::string filemd5;
|
||||
LicenseGetfilemd5(path,filemd5);
|
||||
time_t update_time;
|
||||
LicenseGetfiletime(path,update_time);
|
||||
off_t file_size;
|
||||
LicenseGetfilesize(path,file_size);
|
||||
|
||||
time_t update_timecheck;
|
||||
std::string filemd5check;
|
||||
off_t file_sizecheck;
|
||||
LifileLoad(path2,update_timecheck,file_sizecheck,filemd5check);
|
||||
|
||||
if(filemd5!=filemd5check)
|
||||
{
|
||||
printf("This file has been modified\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
if(update_time!=update_timecheck)
|
||||
{
|
||||
printf("update_time is wrong\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
if(file_size!=file_sizecheck)
|
||||
{
|
||||
printf("file_size is wrong\n");
|
||||
return SERVER_UNEXPECTED_ERROR;
|
||||
}
|
||||
|
||||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Alterfile(const string &path1, const string &path2 ,const boost::system::error_code &ec, boost::asio::deadline_timer* pt)
|
||||
{
|
||||
|
@ -233,8 +305,9 @@ void Alterfile(const string &path1, const string &path2 ,const boost::system::er
|
|||
|
||||
std::cout<< "RemainingTime: " << RemainingTime <<std::endl;
|
||||
|
||||
if(RemainingTime==0)
|
||||
if(RemainingTime<=0)
|
||||
{
|
||||
std::cout<< "License expired" <<std::endl;
|
||||
exit(1);
|
||||
}
|
||||
RemainingTime--;
|
||||
|
|
|
@ -34,12 +34,18 @@ namespace zilliz {
|
|||
namespace vecwise {
|
||||
namespace server {
|
||||
|
||||
class BoostArchive;
|
||||
class Licensedata1;
|
||||
class
|
||||
BoostArchive;
|
||||
|
||||
class
|
||||
Licensedata1;
|
||||
|
||||
|
||||
class Licensefiledata;
|
||||
class STLlicensefiledata;
|
||||
class
|
||||
Licensefiledata;
|
||||
|
||||
class
|
||||
STLlicensefiledata;
|
||||
|
||||
|
||||
ServerError
|
||||
|
@ -57,11 +63,21 @@ LifileLoad(const std::string& path,time_t& update_time,off_t& file_size,std::str
|
|||
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 );
|
||||
ServerError
|
||||
LicenseIntegrity_check(const std::string& path,const std::string& path2);
|
||||
|
||||
ServerError
|
||||
LicenseLegality_check(const std::string& path);
|
||||
|
||||
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();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,31 @@
|
|||
#include "license/LicensePublic.h"
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
|
||||
//TEST(LicenseTest, LICENSE_TEST) {
|
||||
//
|
||||
// std::string path1 = "/tmp/vecwise_engine.license";
|
||||
// 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);
|
||||
// }
|
||||
// err = server::LicenseIntegrity_check(path1,path2);
|
||||
// if(err!=server::SERVER_SUCCESS)
|
||||
// {
|
||||
// std::cout << "Integrity_check is wrong " << std::endl;
|
||||
// exit(1);
|
||||
// }
|
||||
// err = server::LicenseLegality_check(path1);
|
||||
// if(err!=server::SERVER_SUCCESS)
|
||||
// {
|
||||
// std::cout << "Legality_check is wrong " << std::endl;
|
||||
// exit(1);
|
||||
// }
|
||||
// std::cout << " runing " << std::endl;
|
||||
// server::Runtime(path1,path2);
|
||||
//}
|
|
@ -24,22 +24,26 @@ TEST(LicenseTest, LICENSE_TEST) {
|
|||
{
|
||||
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);
|
||||
|
||||
err = server::LicenseIntegrity_check(path1,path2);
|
||||
if(err!=server::SERVER_SUCCESS)
|
||||
{
|
||||
std::cout << "Integrity_check is wrong " << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
err = server::LicenseLegality_check(path1);
|
||||
if(err!=server::SERVER_SUCCESS)
|
||||
{
|
||||
std::cout << "Legality_check is wrong " << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
std::cout << " runing " << std::endl;
|
||||
server::Runtime(path1,path2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//TEST(LicenseTest, LICENSE_TEST) {
|
||||
// std::string path1 = "/tmp/vecwise_engine.license";
|
||||
// std::string path2 = "/tmp/vecwise_engine2.license";
|
||||
|
|
Loading…
Reference in New Issue