|
@@ -20,6 +20,9 @@ namespace gsd{
|
|
ErrorL << "Hepu http client initialization failed.";
|
|
ErrorL << "Hepu http client initialization failed.";
|
|
return ERR;
|
|
return ERR;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
if(this->LoginHepu() != OK){
|
|
if(this->LoginHepu() != OK){
|
|
ErrorL << "Failed to login to Hepu IPC.";
|
|
ErrorL << "Failed to login to Hepu IPC.";
|
|
return ERR;
|
|
return ERR;
|
|
@@ -47,7 +50,7 @@ namespace gsd{
|
|
std::string msg;
|
|
std::string msg;
|
|
hepuloginMsg.token = "";
|
|
hepuloginMsg.token = "";
|
|
hepuloginMsg.username = this->username_;
|
|
hepuloginMsg.username = this->username_;
|
|
- hepuloginMsg.password = this->password_;
|
|
|
|
|
|
+ hepuloginMsg.password = md5(this->password_ + this->salt_);
|
|
hepuloginMsg.objectToJson(msg);
|
|
hepuloginMsg.objectToJson(msg);
|
|
msg += "\r\n";
|
|
msg += "\r\n";
|
|
|
|
|
|
@@ -87,6 +90,71 @@ namespace gsd{
|
|
return this->token_ == "" ? false : true;
|
|
return this->token_ == "" ? false : true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ int32_t Hepu::getSalt(HepuGetSalt& hepuGetSaltMsg){
|
|
|
|
+ if(m_hepu == nullptr) return ERR;
|
|
|
|
+
|
|
|
|
+ std::string msg;
|
|
|
|
+ hepuGetSaltMsg.username = this->username_;
|
|
|
|
+ hepuGetSaltMsg.objectToJson(msg);
|
|
|
|
+ msg+="\r\n";
|
|
|
|
+
|
|
|
|
+ cout<<"get salt json msg: "<<endl;
|
|
|
|
+ cout<<msg<<endl;
|
|
|
|
+
|
|
|
|
+ if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
|
|
|
|
+ cout<<res->body<<endl;
|
|
|
|
+ if(res->status != 100){
|
|
|
|
+ HepuGetSaltRe hepuGetSaltReMsg;
|
|
|
|
+ if(!hepuGetSaltReMsg.jsonToObject(res->body)){
|
|
|
|
+ cout<<"get salt res json2object fail."<<endl;
|
|
|
|
+ return ERR;
|
|
|
|
+ }
|
|
|
|
+ this->salt_ = hepuGetSaltReMsg.salt;
|
|
|
|
+ return OK;
|
|
|
|
+ }
|
|
|
|
+ return ERR;
|
|
|
|
+ }else{
|
|
|
|
+ auto err = res.error();
|
|
|
|
+ cout<<"hepu getsalt failed,"<<err<<endl;
|
|
|
|
+ ErrorL <<"Hepu getsalt failed,"<<err<<endl;
|
|
|
|
+ return ERR;
|
|
|
|
+ }
|
|
|
|
+ return ERR;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ int32_t Hepu::getSalt(){
|
|
|
|
+ if(m_hepu == nullptr) return ERR;
|
|
|
|
+
|
|
|
|
+ HepuGetSalt hepuGetSaltMsg;
|
|
|
|
+ std::string msg;
|
|
|
|
+ hepuGetSaltMsg.username = this->username_;
|
|
|
|
+ hepuGetSaltMsg.objectToJson(msg);
|
|
|
|
+ msg+="\r\n";
|
|
|
|
+
|
|
|
|
+ cout<<"get salt json msg: "<<endl;
|
|
|
|
+ cout<<msg<<endl;
|
|
|
|
+
|
|
|
|
+ if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
|
|
|
|
+ cout<<res->body<<endl;
|
|
|
|
+ if(res->status != 100){
|
|
|
|
+ HepuGetSaltRe hepuGetSaltReMsg;
|
|
|
|
+ if(!hepuGetSaltReMsg.jsonToObject(res->body)){
|
|
|
|
+ cout<<"get salt res json2object fail."<<endl;
|
|
|
|
+ return ERR;
|
|
|
|
+ }
|
|
|
|
+ this->salt_ = hepuGetSaltReMsg.salt;
|
|
|
|
+ return OK;
|
|
|
|
+ }
|
|
|
|
+ return ERR;
|
|
|
|
+ }else{
|
|
|
|
+ auto err = res.error();
|
|
|
|
+ cout<<"hepu getsalt failed,"<<err<<endl;
|
|
|
|
+ ErrorL <<"Hepu getsalt failed,"<<err<<endl;
|
|
|
|
+ return ERR;
|
|
|
|
+ }
|
|
|
|
+ return ERR;
|
|
|
|
+ }
|
|
|
|
+
|
|
int32_t Hepu::sendHepuHB(HepuHB& hepuHBMsg){
|
|
int32_t Hepu::sendHepuHB(HepuHB& hepuHBMsg){
|
|
if(m_hepu == nullptr) return ERR;
|
|
if(m_hepu == nullptr) return ERR;
|
|
|
|
|