lishengyin 1 週間 前
コミット
06a5a960a6

+ 8 - 7
framework/request/include/HepuGetSaltRe.h

@@ -13,7 +13,7 @@ class HepuGetSaltRe
     private:
     public:
         const string cmd = "userSaltGet";
-        int ackvalue ;
+        int ackvalue;
         string salt;
         int loginEnc;
 
@@ -39,20 +39,21 @@ class HepuGetSaltRe
             if(end == doc.FindMember("param") || !doc["param"].IsObject()) {
                 return false;
             }else{
-                if(end == doc.FindMember("ackvalue") || !doc["ackvalue"].IsInt()) {
+                const rapidjson::Value& object = doc["param"];
+                if(end == object.FindMember("ackvalue") || !object["ackvalue"].IsInt()) {
                     return false;
                 }else{
-                    ackvalue = doc["ackvalue"].GetInt();
+                    ackvalue = object["ackvalue"].GetInt();
                 }
-                if(end == doc.FindMember("salt") || !doc["salt"].IsString()) {
+                if(end == object.FindMember("salt") || !object["salt"].IsString()) {
                     return false;
                 }else{
-                    salt = doc["salt"].GetString();
+                    salt = object["salt"].GetString();
                 }
-                if(end == doc.FindMember("loginEnc") || !doc["loginEnc"].IsInt()) {
+                if(end == object.FindMember("loginEnc") || !object["loginEnc"].IsInt()) {
                     return false;
                 }else{
-                    loginEnc = doc["loginEnc"].GetInt();
+                    loginEnc = object["loginEnc"].GetInt();
                 }
             }
             return true;

+ 3 - 2
framework/request/include/HepuHBRe.h

@@ -37,10 +37,11 @@ class HepuHBRe
             if(end == doc.FindMember("param") || !doc["param"].IsObject()) {
                 return false;
             }else{
-                if(end == doc.FindMember("ackvalue") || !doc["ackvalue"].IsInt()) {
+                const rapidjson::Value& object = doc["param"];
+                if(end == object.FindMember("ackvalue") || !object["ackvalue"].IsInt()) {
                     return false;
                 }else{
-                    ackvalue = doc["ackvalue"].GetInt();
+                    ackvalue = object["ackvalue"].GetInt();
                 }
             }
             return true;

+ 5 - 4
framework/request/include/HepuLoginRe.h

@@ -37,16 +37,17 @@ class HepuLoginRe
             if(end == doc.FindMember("param") || !doc["param"].IsObject()) {
                 return false;
             }else{
-                if(end == doc.FindMember("ackvalue") || !doc["ackvalue"].IsInt()) {
+                const rapidjson::Value& object = doc["param"];
+                if(end == object.FindMember("ackvalue") || !object["ackvalue"].IsInt()) {
                     return false;
                 }else{
-                    ackvalue = doc["token"].GetInt();
+                    ackvalue = object["ackvalue"].GetInt();
                 }   
 
-                if(end == doc.FindMember("token") || !doc["token"].IsString()) {
+                if(end == object.FindMember("token") || !object["token"].IsString()) {
                     return false;
                 }else{
-                    token = doc["token"].GetString();
+                    token = object["token"].GetString();
                 }
             }
 

+ 7 - 6
framework/request/include/HepuTargetRe.h

@@ -39,22 +39,23 @@ class HepuTargetRe
             if(end == doc.FindMember("param") || !doc["param"].IsObject()) {
                 return false;
             }else{
-                if(end == doc.FindMember("ackvalue") || !doc["ackvalue"].IsInt()) {
+                const rapidjson::Value& object = doc["param"];
+                if(end == object.FindMember("ackvalue") || !object["ackvalue"].IsInt()) {
                     return false;
                 }else{
-                    ackvalue = doc["ackvalue"].GetInt();
+                    ackvalue = object["ackvalue"].GetInt();
                 }
 
-                if(end == doc.FindMember("channelid") || !doc["channelid"].IsInt()) {
+                if(end == object.FindMember("channelid") || !object["channelid"].IsInt()) {
                     return false;
                 }else{
-                    channelid = doc["channelid"].GetInt();
+                    channelid = object["channelid"].GetInt();
                 }
 
-                if(end == doc.FindMember("bTracking") || !doc["bTracking"].IsBool()) {
+                if(end == object.FindMember("bTracking") || !object["bTracking"].IsBool()) {
                     return false;
                 }else{
-                    bTracking = doc["bTracking"].GetBool();
+                    bTracking = object["bTracking"].GetBool();
                 }
             }
             return true;

BIN
lib/libgsd_modules.so


BIN
lib/libgsd_plugins.so


+ 37 - 34
modules/Hepu/src/Hepu.cpp

@@ -11,9 +11,9 @@ namespace gsd{
     }
 
     int32_t Hepu::Init(std::string username, std::string url, int port){
-        cout<<"Hepu username: "<<username<<endl;
-        cout<<"Hepu api url: "<<url<<endl;
-        cout<<"Hepu port: "<<port<<endl;
+        //cout<<"Hepu username: "<<username<<endl;
+        //cout<<"Hepu api url: "<<url<<endl;
+        //cout<<"Hepu port: "<<port<<endl;
         this->username_ = username;
         m_hepu = std::make_shared<httplib::Client>(url, port);
         if(m_hepu == NULL){
@@ -21,7 +21,10 @@ namespace gsd{
             return ERR;
         }
 
-
+	if(this->getSalt() != OK){
+	    ErrorL << "Failed to get salt from Hepu IPC.";
+      	    return ERR;
+	}
 
         if(this->LoginHepu() != OK){
             ErrorL << "Failed to login to Hepu IPC.";
@@ -54,24 +57,24 @@ namespace gsd{
         hepuloginMsg.objectToJson(msg);
         msg += "\r\n";
 
-        cout<<"login json msg: "<<endl;
-        cout<<msg<<endl;
+        //cout<<"login json msg: "<<endl;
+        //cout<<msg<<endl;
 
         if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
-            cout<<res->body<<endl;
+            //cout<<res->body<<endl;
             if(res->status != 100){
                 HepuLoginRe hepuloginReMsg;
                 if(!hepuloginReMsg.jsonToObject(res->body)){
-                    cout<<"login res json2object fail."<<endl;
+                    //cout<<"login res json2object fail."<<endl;
                     return ERR;
                 }
                 if(hepuloginReMsg.ackvalue != 100){
-                    cout<<"login res ack err: "<<hepuloginReMsg.ackvalue<<endl;
+                    //cout<<"login res ack err: "<<hepuloginReMsg.ackvalue<<endl;
                     return ERR;
                 }
                 if(hepuloginReMsg.token.size()){
                     this->token_ = hepuloginReMsg.token;
-                    cout<<"login res token: "<<hepuloginReMsg.token<<endl;
+                    //cout<<"login res token: "<<hepuloginReMsg.token<<endl;
                     return OK;
                 }
                 return ERR;
@@ -79,7 +82,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
-            cout<<"The Hepu is not avaliable, "<<err<<endl;
+            //cout<<"The Hepu is not avaliable, "<<err<<endl;
             ErrorL << "The service is not available,"<<err<<endl;
             return ERR;
         }
@@ -98,15 +101,15 @@ namespace gsd{
         hepuGetSaltMsg.objectToJson(msg);
         msg+="\r\n";
 
-        cout<<"get salt json msg: "<<endl;
-        cout<<msg<<endl;
+        //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;
+            //cout<<res->body<<endl;
             if(res->status != 100){
                 HepuGetSaltRe hepuGetSaltReMsg;
                 if(!hepuGetSaltReMsg.jsonToObject(res->body)){
-                    cout<<"get salt res json2object fail."<<endl;
+                    //cout<<"get salt res json2object fail."<<endl;
                     return ERR;
                 }
                 this->salt_ = hepuGetSaltReMsg.salt;
@@ -115,7 +118,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
-            cout<<"hepu getsalt failed,"<<err<<endl;
+            //cout<<"hepu getsalt failed,"<<err<<endl;
             ErrorL <<"Hepu getsalt failed,"<<err<<endl;
             return ERR;
         }
@@ -131,15 +134,15 @@ namespace gsd{
         hepuGetSaltMsg.objectToJson(msg);
         msg+="\r\n";
 
-        cout<<"get salt json msg: "<<endl;
-        cout<<msg<<endl;
+        //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;
+            //cout<<res->body<<endl;
             if(res->status != 100){
                 HepuGetSaltRe hepuGetSaltReMsg;
                 if(!hepuGetSaltReMsg.jsonToObject(res->body)){
-                    cout<<"get salt res json2object fail."<<endl;
+                    //cout<<"get salt res json2object fail."<<endl;
                     return ERR;
                 }
                 this->salt_ = hepuGetSaltReMsg.salt;
@@ -148,7 +151,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
-            cout<<"hepu getsalt failed,"<<err<<endl;
+            //cout<<"hepu getsalt failed,"<<err<<endl;
             ErrorL <<"Hepu getsalt failed,"<<err<<endl;
             return ERR;
         }
@@ -163,19 +166,19 @@ namespace gsd{
         hepuHBMsg.objectToJson(msg);
         msg+="\r\n";
         
-        cout<<"hb json msg: "<<endl;
-        cout<<msg<<endl;
+        //cout<<"hb json msg: "<<endl;
+        //cout<<msg<<endl;
 
         if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
-            cout<<res->body<<endl;
+            //cout<<res->body<<endl;
             if(res->status != 100){
                 HepuHBRe hepuHBReMsg;
                 if(!hepuHBReMsg.jsonToObject(res->body)){
-                    cout<<"hb res json2object fail."<<endl;
+                    //cout<<"hb res json2object fail."<<endl;
                     return ERR;
                 }
                 if(hepuHBReMsg.ackvalue != 100){
-                    cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
+                    //cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
                     return ERR;
                 }
                 return OK;
@@ -183,7 +186,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
-            cout<<"Hepu heartbeat failed,"<<err<<endl;
+            //cout<<"Hepu heartbeat failed,"<<err<<endl;
             ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
             return ERR;
         }
@@ -199,19 +202,19 @@ namespace gsd{
         hepuHBMsg.objectToJson(msg);
         msg+="\r\n";
         
-        cout<<"hb json msg: "<<endl;
-        cout<<msg<<endl;
+        //cout<<"hb json msg: "<<endl;
+        //cout<<msg<<endl;
 
         if(auto res = m_hepu->Post("/cgi-bin/proc.cgi", msg,"application/json")){
-            cout<<res->body<<endl;
+            //cout<<res->body<<endl;
             if(res->status != 100){
                 HepuHBRe hepuHBReMsg;
                 if(!hepuHBReMsg.jsonToObject(res->body)){
-                    cout<<"hb res json2object fail."<<endl;
+                    //cout<<"hb res json2object fail."<<endl;
                     return ERR;
                 }
                 if(hepuHBReMsg.ackvalue != 100){
-                    cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
+                    //cout<<"hb res ack err: "<<hepuHBReMsg.ackvalue<<endl;
                     return ERR;
                 }
                 return OK;
@@ -219,7 +222,7 @@ namespace gsd{
             return ERR;
         }else{
             auto err = res.error();
-            cout<<"Hepu heartbeat failed,"<<err<<endl;
+            //cout<<"Hepu heartbeat failed,"<<err<<endl;
             ErrorL << "Hepu Heartbeat failed,"<<err<<endl;
             return ERR;
         }
@@ -284,4 +287,4 @@ namespace gsd{
         this->port_ = port;
     }
 
-}
+}

+ 1 - 1
modules/config/src/config.cpp

@@ -77,7 +77,7 @@ bool config::Update(){
     this->app = this->getApp();
     
      // 同步数据
-    this->getBasicConfig();
+    //this->getBasicConfig();
 
     if(config::getPtr()->LowVersion){
         int count = m_ini.getIntValue("Device", "count", ret);

+ 7 - 4
plugins/HepuPlugin/src/HepuPlugin.cpp

@@ -18,10 +18,10 @@ namespace gsd
         this->m_hepuClient->setUsr(config::getPtr()->HepuUsr);
         this->m_hepuClient->setPort(config::getPtr()->HepuPort);
         if(this->m_hepuClient->Init(config::getPtr()->HepuUsr , config::getPtr()->HepuIP, config::getPtr()->HepuPort) == OK){
-            cout<<"Hepu IPC http login success."<<endl;
+            //cout<<"Hepu IPC http login success."<<endl;
             InfoL << "Hepu IPC http login success."<<endl;
         }else{
-            cout<<"Hepu IPC http login failed."<<endl;
+            //cout<<"Hepu IPC http login failed."<<endl;
             WarnL << "Hepu IPC http login failed."<<endl;
         }
 
@@ -34,19 +34,22 @@ namespace gsd
 
     bool HepuPlugin::StartTask(){
         if(this->pool == nullptr)
+        {
+            //cout<<"Pool is null"<<endl;
             return false;
+        }
         this->pool->async([&](){
             while(!this->stop_){
                 if(this->PluginAlive) this->HBThrd();
             }
         });
-        cout<<"Pool start"<<endl;
+        //cout<<"Pool start"<<endl;
         this->pool->start();
         return true;
     }
 
     void HepuPlugin::HBThrd(){
-        InfoL<<"Send Heartbeat "<<endl;
+        //InfoL<<"Send Heartbeat "<<endl;
         if(this->m_hepuClient == nullptr)
         {
             this->RestPlugin();

+ 9 - 7
source/UserApp/src/UserApp.cpp

@@ -107,22 +107,24 @@ namespace gsd
             }, nullptr);
         }
 
+         
         // TCP启动任务
         if(this->m_TcpPlugin != nullptr) this->m_TcpPlugin->StartTask();
-
+        //cout<<"Start tcp tasks"<<endl;
         // Expel启动任务
         if(this->m_ExpelPlugin != nullptr) this->m_ExpelPlugin->StartTask();
-
+        //cout<<"Start expel tasks"<<endl; 
         // Monitor启动任务
         if(this->m_MonitorPlugin != nullptr) this->m_MonitorPlugin->StartTask();
-
+        //cout<<"Start monitor tasks"<<endl;
         // auditPlugin
         if(this->m_AuditPlugin != nullptr) this->m_AuditPlugin->StartTask();
-
+        //cout<<"Start Audit tasks"<<endl;
         // HTTP启动任务
-        if(this->m_HttpPlugin != nullptr) this->m_HttpPlugin->StartTask();
-
-        if(this->m_HepuPlugin != nullptr) this->m_HepuPlugin->StartTask();
+        //if(this->m_HttpPlugin != nullptr) this->m_HttpPlugin->StartTask();
+        //cout<<"Start http tasks"<<endl;
+        if(this->m_HepuPlugin != nullptr) {cout<<"Start hepu tasks"<<endl;this->m_HepuPlugin->StartTask();}
+        else cout<<"Hepuplugin is null"<<endl;
         
         return true;
     }  

BIN
source/bin/gsd