diff --git a/platform/src/sys/file_sync_auto/SyncthingMngThread.cpp b/platform/src/sys/file_sync_auto/SyncthingMngThread.cpp index af011536..836625a1 100644 --- a/platform/src/sys/file_sync_auto/SyncthingMngThread.cpp +++ b/platform/src/sys/file_sync_auto/SyncthingMngThread.cpp @@ -30,7 +30,7 @@ -#define SYNCTHING_GUI_APIKEY "kbdct@0755" +#define SYNCTHING_GUI_APIKEY EMS_DEFAULT_PASSWD #define FILE_SYNC_CFG_FILENAME "file_sync_cfg.xml" diff --git a/platform/src/sys/license_manager/Main.cpp b/platform/src/sys/license_manager/Main.cpp new file mode 100644 index 00000000..5eb83b5a --- /dev/null +++ b/platform/src/sys/license_manager/Main.cpp @@ -0,0 +1,13 @@ +#include "mainwindow.h" +#include +#include + +int main(int argc, char *argv[]) +{ + //QApplication a(argc, argv); + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/platform/src/sys/license_manager/license_manager.ico b/platform/src/sys/license_manager/license_manager.ico new file mode 100644 index 00000000..573038da Binary files /dev/null and b/platform/src/sys/license_manager/license_manager.ico differ diff --git a/platform/src/sys/license_manager/license_manager.pro b/platform/src/sys/license_manager/license_manager.pro new file mode 100644 index 00000000..5b69643f --- /dev/null +++ b/platform/src/sys/license_manager/license_manager.pro @@ -0,0 +1,54 @@ +QT += core gui +QT += network +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +TEMPLATE = app +TARGET = license_manager + +# CONFIG += console + + +INCLUDEPATH += ../../include + +win32-msvc* { + LIBS += -ladvapi32 +} + + +# Input +HEADERS += \ + mainwindow.h + +SOURCES += \ + Main.cpp \ + mainwindow.cpp + + +#LIBS += -lboost_system -lboost_chrono -llog4cplus +#LIBS += -lpub_utility_api -lpub_logger_api -lrdb_api -lsys_dog_auth_api -lsys_license_auth_api -lcrypto +LIBS += -lcrypto + + +win32 { + LIBS += -ladvapi32 + LIBS += -ltaskschd + LIBS += -lcomsupp +} + +DEFINES += QAPPLICATION_CLASS=QApplication +#------------------------------------------------------------------- +COMMON_PRI=$$PWD/../../common.pri +exists($$COMMON_PRI) { + include($$COMMON_PRI) +}else { + error("FATAL error: can not find common.pri") +} + +FORMS += \ + mainwindow.ui + +RESOURCES += \ + res.qrc + +contains(DEFINES, OS_WINDOWS) { + RC_ICONS = license_manager.ico +} diff --git a/platform/src/sys/license_manager/mainwindow.cpp b/platform/src/sys/license_manager/mainwindow.cpp new file mode 100644 index 00000000..9bfaa465 --- /dev/null +++ b/platform/src/sys/license_manager/mainwindow.cpp @@ -0,0 +1,204 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" +#include "sys_dog_auth_api/DogAuthInterface.h" +#include "pub_logger_api/logger.h" +#include "common/Common.h" +#include "openssl/err.h" + +//< 公钥 +static const char *szPublicKey = "\ +-----BEGIN PUBLIC KEY-----\n\ +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDnrsIgkFfGVi2Ja5rD0sh5paxH\n\ +EXJb4soJb2RyGMa2qbRgyXLAQaRjGosODl4UJlxr6WOjjkWMXRNpxPztxXjrX3gS\n\ +QKBt1wWkQrnQD/HQNDURBthM+M/St+ai9ZmOdhAJs584Ul6gE+jvMpxPid+bsZs7\n\ +ysTE7nEojz8oNLhISQIDAQAB\n\ +-----END PUBLIC KEY-----\n"; + +static const char *szPrivateKey = "\ +-----BEGIN PRIVATE KEY-----\n\ +MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAOeuwiCQV8ZWLYlr\n\ +msPSyHmlrEcRclviyglvZHIYxraptGDJcsBBpGMaiw4OXhQmXGvpY6OORYxdE2nE\n\ +/O3FeOtfeBJAoG3XBaRCudAP8dA0NREG2Ez4z9K35qL1mY52EAmznzhSXqAT6O8y\n\ +nE+J35uxmzvKxMTucSiPPyg0uEhJAgMBAAECgYEAxKyT2zTtbk8l5OxVuzqqOKot\n\ +bz8eR2ZkgFHxgPILbnDt0OPx58dRl1enB82mi5BtEKZVkThrTdaNblJtLCNgm0Ea\n\ +Hnuh2OVRZvMqhYk2AH9Awscv1ONQ46tHwJb47pBhheCJCybFb29pSIZdvDH6SFjH\n\ +aANfYZyl1TY0mo7SAEkCQQD5pV3NIyLh6Fz/hLBpK4aMaQdEwuberhOnxaqhDywu\n\ +vG3Kbc1y9m7PLixw3uuDKerw54cNfh5knlW5catQsD5jAkEA7ZRY5D49lt/NElUx\n\ +YK/E8T2MP29W5xMXMwwzD3vA1V2Jsqk25RwzyUSV1E9uPiyOEiiuiG9jQUwVQMnZ\n\ +YjO4YwJBAMoUfDujp4bqiu0jQZHAc+eQ1RtqEWxLyQlTzm0VVRR33v+vplDa/pOi\n\ +ssKjEE1aTx22rPHVF1Enggjc5GoqYDUCQQCY2mn6p0TO7jytf9xd/ZhzMYsrQQIj\n\ +d3fkowOzAYcGf8DZDt+/tk5nPtY7G8OtAtOBQWVRaIDugPnnjjZrZSVLAkAyIoh5\n\ +XTRAbawuC7hpoToZTpTW2rJ5DO9LfW3FpkWKFbg9fLIKGV9hTn5aWgeNH/n0x8XV\n\ +jH8afx1na7fvO62l\n\ +-----END PRIVATE KEY-----\n"; + + +using namespace iot_sys; +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + +// this->resize(QSize(300,200)); +// connect(ui->recheckBtn, &QPushButton::clicked, this, &MainWindow::slot_recheckBtn); +} + + +MainWindow::~MainWindow() +{ + delete ui; +} + +//读取密钥 +RSA *MainWindow::createRSA( const unsigned char *szKey, bool bPubKey ) +{ + RSA *pRsa = nullptr; + BIO *pKeyBio; + pKeyBio = BIO_new_mem_buf( szKey, -1 ); + if ( pKeyBio == nullptr ) + { + qDebug( "Failed to create key BIO\n" ); + return nullptr; + } + + if ( bPubKey ) + { + pRsa = PEM_read_bio_RSA_PUBKEY( pKeyBio, &pRsa, nullptr, nullptr ); + } + else + { + pRsa = PEM_read_bio_RSAPrivateKey( pKeyBio, &pRsa, nullptr, nullptr ); + } + if ( pRsa == nullptr ) + { + qDebug( "Failed to create RSA\n" ); + } + BIO_free( pKeyBio ); + return pRsa; +} + +// base64 编码 +char * base64Encode(const char *buffer, int length, bool newLine) +{ + BIO *bmem = NULL; + BIO *b64 = NULL; + BUF_MEM *bptr; + + b64 = BIO_new(BIO_f_base64()); + if (!newLine) { + BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); + } + bmem = BIO_new(BIO_s_mem()); + b64 = BIO_push(b64, bmem); + BIO_write(b64, buffer, length); + BIO_flush(b64); + BIO_get_mem_ptr(b64, &bptr); + BIO_set_close(b64, BIO_NOCLOSE); + + char *buff = (char *)malloc(bptr->length + 1); + memcpy(buff, bptr->data, bptr->length); + buff[bptr->length] = 0; + BIO_free_all(b64); + + return buff; +} + +QString MainWindow::createActiveCode(const QString &strRegCode,const QString &strAppId) +{ + QString strActiveCode = "invalid register code"; + QStringList listRegCode = strRegCode.split("\n"); + if(listRegCode.empty() || listRegCode[0].isEmpty()){ + return strActiveCode; + } + + QString strCode = listRegCode[0] + " " + strAppId; + + RSA *pRsa = createRSA(( unsigned char * ) szPrivateKey, false ); + int len = RSA_size(pRsa); + char *encryptedText = (char *)malloc(len+1); + memset(encryptedText, 0, len+1); + + QByteArray clearDataArry = strCode.toUtf8(); + int nClearDataLen = clearDataArry.length(); + uchar* pClearData = (uchar*)clearDataArry.data(); + + + int nSize = RSA_private_encrypt(nClearDataLen, pClearData, (unsigned char*)encryptedText, pRsa, RSA_PKCS1_PADDING); + + if(nSize > 0 ) + { + QByteArray arr(encryptedText,nSize); + strActiveCode = arr.toBase64().toBase64(); + } + + RSA_free( pRsa ); + free(encryptedText); + + return strActiveCode; +} + +void MainWindow::test(const QString &str,const unsigned char *data) +{ + //< RSA_NO_PADDING 模式最长128 + char szDecryptText[128]; + memset( szDecryptText, 0, 128 ); + + RSA *pRsa = createRSA( (unsigned char * )szPublicKey, true ); + //int nLen = RSA_public_decrypt( 128, ( unsigned char * ) baActiveCode.data(), ( unsigned char * ) szDecryptText, pRsa, RSA_NO_PADDING ); + int nLen = RSA_public_decrypt( 128, data, ( unsigned char * ) szDecryptText, pRsa, RSA_NO_PADDING ); + unsigned long e = ERR_get_error(); + char szErrMsg[1024] = {0}; + char * pTmp = ERR_error_string(e,szErrMsg); + RSA_free( pRsa ); + + if ( nLen <= 0 ) + { + qDebug( "decryptByPublic() failed !" ); + return; + } + +} + +void MainWindow::test1(const QString &str) +{ + QByteArray ba1 = QByteArray::fromBase64(str.toLatin1() ); + QString str1(ba1); + QByteArray baActiveCode = QByteArray::fromBase64(QByteArray::fromBase64(str.toLatin1()) ); + + str1 = baActiveCode; + QByteArray Block = str1.toLatin1(); + int ns = str1.size(); + char szCode[129]; + memset(szCode,0,129); + memcpy(szCode,Block.data(),Block.size()+1); + + //< RSA_NO_PADDING 模式最长128 + char szDecryptText[128]; + memset( szDecryptText, 0, 128 ); + int nsize = baActiveCode.size(); + RSA *pRsa = createRSA( (unsigned char * )szPublicKey, true ); + int nLen = RSA_public_decrypt( 128, ( unsigned char * ) baActiveCode.data(), ( unsigned char * ) szDecryptText, pRsa, RSA_PKCS1_PADDING ); +// int nLen = RSA_public_decrypt( 128, ( unsigned char * )szCode, ( unsigned char * ) szDecryptText, pRsa, RSA_PKCS1_PADDING ); + unsigned long e = ERR_get_error(); + char szErrMsg[1024] = {0}; + char * pTmp = ERR_error_string(e,szErrMsg); + RSA_free( pRsa ); + + if ( nLen <= 0 ) + { + qDebug( "decryptByPublic() failed !" ); + return; + } + +} + +void MainWindow::on_recheckBtn_clicked() +{ + QString strRegCode = ui->reg_code->toPlainText(); + QString strAppId = ui->app_id->text(); + + QString strActiveCode = createActiveCode(strRegCode,strAppId); + + ui->active_code->setText(strActiveCode); +} diff --git a/platform/src/sys/license_manager/mainwindow.h b/platform/src/sys/license_manager/mainwindow.h new file mode 100644 index 00000000..e4d676b7 --- /dev/null +++ b/platform/src/sys/license_manager/mainwindow.h @@ -0,0 +1,36 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include +#include + + +namespace Ui { + class MainWindow; +} + +class QPushButton; + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + + +private slots: + void on_recheckBtn_clicked(); + +private: + RSA *createRSA( const unsigned char *szKey, bool bPubKey ); + QString createActiveCode(const QString &strRegCode,const QString &strAppId); + void test(const QString &str,const unsigned char *data); + void test1(const QString &str); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/platform/src/sys/license_manager/mainwindow.ui b/platform/src/sys/license_manager/mainwindow.ui new file mode 100644 index 00000000..5440c394 --- /dev/null +++ b/platform/src/sys/license_manager/mainwindow.ui @@ -0,0 +1,105 @@ + + + MainWindow + + + + 0 + 0 + 720 + 487 + + + + 授权管理 + + + + + + + + + + + + + + Qt::Horizontal + + + + 30 + 20 + + + + + + + + 注册码: + + + + + + + 机器码: + + + + + + + + + + + + + + 产品名称: + + + + + + + 生成 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + PSCADA + + + + + + + + + + + slot_regedit() + slot_unRegedit() + slot_igoreCurTime() + slot_stopRefesh() + + diff --git a/platform/src/sys/license_manager/res.qrc b/platform/src/sys/license_manager/res.qrc new file mode 100644 index 00000000..1bf90df0 --- /dev/null +++ b/platform/src/sys/license_manager/res.qrc @@ -0,0 +1,5 @@ + + + license_manager.ico + + diff --git a/platform/src/sys/sys.pro b/platform/src/sys/sys.pro index df2830f9..78f46d14 100644 --- a/platform/src/sys/sys.pro +++ b/platform/src/sys/sys.pro @@ -7,7 +7,7 @@ SUBDIRS += \ sys_license_auth_api \ sys_dog_auth_api \ sys_login_api \ - sys_dog_auth_check \ +# sys_dog_auth_check \ sys_network_check_api \ sys_proc_mng_api \ sys_node_mng_api \ @@ -18,7 +18,7 @@ SUBDIRS += \ sys_nodeinfo_tran \ show_node_info \ sys_launcher_srv \ - file_sync_auto + # sys_file_auto sys_dog_auth_api.depends = sys_license_auth_api sys_dog_auth_check.depends = sys_license_auth_api sys_dog_auth_api @@ -28,4 +28,3 @@ sys_proc_mng.depends = sys_network_check_api sys_proc_mng_api sys_node_mng.depends = sys_network_check_api sys_proc_mng_api sys_network_check.depends = sys_network_check_api sys_proc_mng_api sys_nodeinfo_tran.depends = sys_proc_mng_api sys_node_mng_api -file_sync_auto.depends = sys_proc_mng_api sys_node_mng_api diff --git a/platform/src/sys/sys_ctrl/BaseCfgParam.cpp b/platform/src/sys/sys_ctrl/BaseCfgParam.cpp index 507d75a1..7e9bb5fd 100644 --- a/platform/src/sys/sys_ctrl/BaseCfgParam.cpp +++ b/platform/src/sys/sys_ctrl/BaseCfgParam.cpp @@ -4,7 +4,19 @@ @author 曹顶法 */ #include "BaseCfgParam.h" + +//< 屏蔽xml_parser编译告警 +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-copy" +#endif + #include "boost/property_tree/xml_parser.hpp" + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include "boost/typeof/typeof.hpp" #include "boost/filesystem.hpp" #include "Common.h" diff --git a/platform/src/sys/sys_dog_auth_api/DogAuthImpl.cpp b/platform/src/sys/sys_dog_auth_api/DogAuthImpl.cpp index 3a287126..a5314e9a 100644 --- a/platform/src/sys/sys_dog_auth_api/DogAuthImpl.cpp +++ b/platform/src/sys/sys_dog_auth_api/DogAuthImpl.cpp @@ -9,7 +9,7 @@ #include "pub_utility_api/CommonConfigParse.h" #include "pub_utility_api/FileUtil.h" #include -#include +#include "boost/concept_check.hpp" #ifndef DISABLE_DOG_AUTH #ifdef KBD_X86 @@ -17,12 +17,8 @@ #endif #endif -#define AUTH_MODEL_LICENCE 1 //licence模式 -#define AUTH_MODEL_SUPPERDOG 2 //硬件狗授权模式 - -#define AUTH_STATUS_OK 1 //授权状态-成功 -#define AUTH_STATUS_EXPIRED 0 //授权状态-过期 -#define AUTH_STATUS_FAILD -1 //授权状态-失败 +#define AUTH_MODEL_LICENCE 1 +#define AUTH_MODEL_SUPPERDOG 2 #define MEM_MEMBUFFER_SIZE 128 @@ -37,7 +33,6 @@ iot_sys::CDogAuthImpl::CDogAuthImpl() #ifndef DISABLE_DOG_AUTH m_nProductId = PRODUCT_ID_PSCADA; m_ptrLicenseAuth = NULL; - m_nAuthModel = AUTH_MODEL_SUPPERDOG;//默认硬件狗授权 #ifdef KBD_X86 m_dogStatus = DOG_NOT_FOUND ; m_dogHandle = 0 ; @@ -62,63 +57,48 @@ iot_sys::CDogAuthImpl::~CDogAuthImpl() //检查系统授权状态 int iot_sys::CDogAuthImpl::checkAuthStatus() { - if(m_nAuthModel == AUTH_MODEL_LICENCE) - { - return checLicenseAuthStatus(); - } - else if(m_nAuthModel == AUTH_MODEL_SUPPERDOG) - { - return checkDogAuthStatus(); - } - return AUTH_STATUS_FAILD; +// if(iotSuccess == checkDogAuthStatus()) +// { +// return iotSuccess; +// } + if(iotSuccess == checLicenseAuthStatus()) + { + return iotSuccess; + } + return iotFailed; } /** @brief 检查License授权状态 -@return 成功返回iotSucces,失败返回相应错误码 +@return 成功返回iotSuccess,失败返回相应错误码 */ int iot_sys::CDogAuthImpl::checLicenseAuthStatus() { #ifndef DISABLE_DOG_AUTH - - QString strTemp ; - QDate objCurDate = QDate::currentDate(); //当前日期 + QString strAppId ; std::string strLicensePath = iot_public::CFileUtil::getAbsolutePath( "../../product/common/license/" ) ; - if(!m_ptrLicenseAuth->checkRegistration(QString::fromStdString(strLicensePath), "license.txt",strTemp) ) + if(!m_ptrLicenseAuth->checkRegistration(QString::fromStdString(strLicensePath), "license.txt",strAppId) ) { - LOGINFO("授权校验失败,AppId:Time=[%s]!\n",strTemp.toStdString().c_str()); - return AUTH_STATUS_FAILD; + LOGINFO("授权校验失败,AppId=[%s]!\n",strAppId.toStdString().c_str()); + return iotFailed; } - QStringList listTemp = strTemp.split(":") ;//appName:授权截至时间 - if(listTemp.size()<2) + if(strAppId == "PSCADA" || strAppId == "EMS") { - LOGINFO("授权license 解析错误 [%s]!\n",strTemp.toStdString().c_str()); - return AUTH_STATUS_FAILD; + return iotSuccess; } - if((objCurDate.daysTo(QDate::fromString(listTemp.at(1),"yyyy-MM-dd")) < 0) - &&(objCurDate.daysTo(QDate::fromString(listTemp.at(1),"yyyy-MM-dd")) >= -90)) //授权截至时间到 + else { - return AUTH_STATUS_EXPIRED; - } - else if(objCurDate.daysTo(QDate::fromString(listTemp.at(1),"yyyy-MM-dd")) < -90) //3个月未授权,停用 - { - return AUTH_STATUS_FAILD; - } - - QString strAppId = strTemp.split(":").at(0) ; - if(strAppId !="PSCADA") - { - LOGINFO("授权产品ID不匹配,AppId=[%s]!\n",strAppId.toStdString().c_str()); - return AUTH_STATUS_FAILD; + LOGINFO("授权产品ID不匹配,AppId=[%s]!\n", strAppId.toStdString().c_str()); + return iotFailed; } #endif - return AUTH_STATUS_OK; + return iotSuccess; } /** @brief 检查超级狗授权状态 -@return 成功返回iotSucces,失败返回相应错误码 +@return 成功返回iotSuccess,失败返回相应错误码 */ int iot_sys::CDogAuthImpl::checkDogAuthStatus() { @@ -153,22 +133,19 @@ int iot_sys::CDogAuthImpl::checkDogAuthStatus() break; case DOG_NOT_FOUND: LOGDEBUG("超级狗文件读写状态:key/license container not available\n"); - break; - case DOG_FEATURE_EXPIRED: - LOGDEBUG("超级狗文件读写状态:Feature has expired \n"); break; default: LOGDEBUG("超级狗文件读写状态:read memory failed\n"); } - if (DOG_STATUS_OK != m_dogStatus) { //读写失败返回错误码 - return AUTH_STATUS_FAILD; // - } -#else - return AUTH_STATUS_FAILD; -#endif + if (DOG_STATUS_OK != m_dogStatus) { //读写失败返回错误码 + return m_dogStatus; // + } +#else + return iotFailed; #endif - return AUTH_STATUS_OK; +#endif + return iotSuccess; } /* @brief 初始化 */ @@ -188,11 +165,6 @@ int iot_sys::CDogAuthImpl::initialize() { LOGWARN("CDogAuthImpl::initialize() get product id fail, use default.\n"); } - //获取授权模式 - if (objCfgParse.getIntValue("setup_config", "authModel", m_nAuthModel) != iotSuccess) - { - m_nAuthModel = AUTH_MODEL_SUPPERDOG; - } } else { @@ -216,6 +188,8 @@ int iot_sys::CDogAuthImpl::initialize() */ int iot_sys::CDogAuthImpl::loginSupperDog(int nProductId) { + boost::ignore_unused_variable_warning(nProductId); + #ifndef DISABLE_DOG_AUTH #ifdef KBD_X86 //超级狗登陆状态不正常,退出 diff --git a/platform/src/sys/sys_dog_auth_api/DogAuthImpl.h b/platform/src/sys/sys_dog_auth_api/DogAuthImpl.h index 2f96e2ad..1f7fd39e 100644 --- a/platform/src/sys/sys_dog_auth_api/DogAuthImpl.h +++ b/platform/src/sys/sys_dog_auth_api/DogAuthImpl.h @@ -24,26 +24,26 @@ namespace iot_sys /** @brief 检查系统授权状态 - @return 成功返回iotSucces,失败返回相应错误码 + @return 成功返回iotSuccess,失败返回相应错误码 */ virtual int checkAuthStatus() override; /** @brief 初始化 - @return 成功返回iotSucces,失败返回相应错误码 + @return 成功返回iotSuccess,失败返回相应错误码 */ int initialize(); protected: /** @brief 检查超级狗授权状态 - @return 成功返回iotSucces,失败返回相应错误码 + @return 成功返回iotSuccess,失败返回相应错误码 */ int checkDogAuthStatus(); /** @brief 检查License授权状态 - @return 成功返回iotSucces,失败返回相应错误码 + @return 成功返回iotSuccess,失败返回相应错误码 */ int checLicenseAuthStatus(); @@ -62,7 +62,6 @@ namespace iot_sys #endif CLicenseAuthInterfacePtr m_ptrLicenseAuth; int m_nProductId; - int m_nAuthModel;//授权模式 }; typedef boost::shared_ptr CDogAuthImplPtr; diff --git a/platform/src/sys/sys_dog_auth_api/sys_dog_auth_api.pro b/platform/src/sys/sys_dog_auth_api/sys_dog_auth_api.pro index 9faabeb8..849c5294 100644 --- a/platform/src/sys/sys_dog_auth_api/sys_dog_auth_api.pro +++ b/platform/src/sys/sys_dog_auth_api/sys_dog_auth_api.pro @@ -32,15 +32,15 @@ if(CONFIG(disable_dog_auth)) { } else{ # 判架构 - contains(QMAKE_HOST.arch, x86_64):{ + contains(QMAKE_HOST.arch, x86_64): !linux-aarch64*{ message("Host is amd64") - DEFINES += KBD_X86 +# DEFINES += KBD_X86 # 判系统 win32{ - LIBS += -ldog_windows_x64_3151646 +# LIBS += -ldog_windows_x64_3151646 } unix{ - LIBS += -ldog_linux_x86_64_3151646 +# LIBS += -ldog_linux_x86_64_3151646 } } else{ diff --git a/platform/src/sys/sys_dog_auth_check/Main.cpp b/platform/src/sys/sys_dog_auth_check/Main.cpp index 8b703d9a..931b2470 100644 --- a/platform/src/sys/sys_dog_auth_check/Main.cpp +++ b/platform/src/sys/sys_dog_auth_check/Main.cpp @@ -2,6 +2,36 @@ #include #include #include "SingleApplication.h" +#include "pub_utility_api/FileStyle.h" +#include + +void loadStyle() +{ + QString qss = QString(); + std::string strFullPath = iot_public::CFileStyle::getPathOfStyleFile("public.qss","zh","light"); + + QFile qssfile1(QString::fromStdString(strFullPath)); + qssfile1.open(QFile::ReadOnly); + if (qssfile1.isOpen()) + { + qss += QLatin1String(qssfile1.readAll()); + qssfile1.close(); + } + + strFullPath = iot_public::CFileStyle::getPathOfStyleFile("sys_dog_auth_check.qss","zh","light"); + QFile qssfile2(QString::fromStdString(strFullPath)); + qssfile2.open(QFile::ReadOnly); + if (qssfile2.isOpen()) + { + qss += QLatin1String(qssfile2.readAll()); + qssfile2.close(); + } + + if (!qss.isEmpty()) + { + qApp->setStyleSheet(qss); + } +} int main(int argc, char *argv[]) { @@ -13,6 +43,8 @@ int main(int argc, char *argv[]) //QApplication a(argc, argv); SingleApplication a(argc, argv); + loadStyle(); + MainWindow w; QObject::connect( &a, &SingleApplication::instanceStarted, [ &w ]() { w.show(); diff --git a/platform/src/sys/sys_dog_auth_check/dog_auth_check.ico b/platform/src/sys/sys_dog_auth_check/dog_auth_check.ico index 90dc5fe3..573038da 100644 Binary files a/platform/src/sys/sys_dog_auth_check/dog_auth_check.ico and b/platform/src/sys/sys_dog_auth_check/dog_auth_check.ico differ diff --git a/platform/src/sys/sys_dog_auth_check/mainwindow.cpp b/platform/src/sys/sys_dog_auth_check/mainwindow.cpp index 0729aa4e..3812b998 100644 --- a/platform/src/sys/sys_dog_auth_check/mainwindow.cpp +++ b/platform/src/sys/sys_dog_auth_check/mainwindow.cpp @@ -6,9 +6,12 @@ using namespace iot_sys; MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), + CustomUiMainWindow(parent), ui(new Ui::MainWindow) { + setAutoLayout(true); + setWindowTitle(tr("授权检测")); + ui->setupUi(this); this->resize(QSize(300,200)); @@ -30,22 +33,15 @@ void MainWindow::slot_recheckBtn() ui->statusLab->setText(""); CDogAuthInterfacePtr ptrDogAuth = getDogAuthInstance(); - int nRet = ptrDogAuth->checkAuthStatus(); - if (nRet == AUTH_STATUS_OK) - { - LOGINFO("加密狗检测正确(OK)!"); - ui->statusLab->setText(tr("正常")); - } - else if(nRet == AUTH_STATUS_EXPIRED) - { - LOGERROR("加密狗检测错误(授权过期)!"); - ui->statusLab->setText(tr("授权过期,错误码[%1]").arg(nRet)); - } - else + if (nRet > 0) { LOGERROR("加密狗检测错误(FAIL)!"); ui->statusLab->setText(tr("异常,错误码[%1]").arg(nRet)); } - return; + else + { + LOGERROR("加密狗检测正确(OK)!"); + ui->statusLab->setText(tr("正常")); + } } diff --git a/platform/src/sys/sys_dog_auth_check/mainwindow.h b/platform/src/sys/sys_dog_auth_check/mainwindow.h index 6ae35a57..c081151c 100644 --- a/platform/src/sys/sys_dog_auth_check/mainwindow.h +++ b/platform/src/sys/sys_dog_auth_check/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include "pub_widget/CustomMainWindow.h" namespace Ui { class MainWindow; @@ -9,7 +10,7 @@ namespace Ui { class QPushButton; -class MainWindow : public QMainWindow +class MainWindow : public CustomUiMainWindow { Q_OBJECT diff --git a/platform/src/sys/sys_dog_auth_check/sys_dog_auth_check.pro b/platform/src/sys/sys_dog_auth_check/sys_dog_auth_check.pro index 56e335ff..af038f55 100644 --- a/platform/src/sys/sys_dog_auth_check/sys_dog_auth_check.pro +++ b/platform/src/sys/sys_dog_auth_check/sys_dog_auth_check.pro @@ -28,7 +28,7 @@ SOURCES += \ LIBS += -lboost_system -lboost_chrono -llog4cplus -LIBS += -lpub_utility_api -lpub_logger_api -lrdb_api -lsys_dog_auth_api -lsys_license_auth_api -lcrypto +LIBS += -lpub_utility_api -lpub_logger_api -lrdb_api -lsys_dog_auth_api -lsys_license_auth_api -lcrypto -lpub_widget win32 { diff --git a/platform/src/sys/sys_launcher_srv/CSysLauncher.cpp b/platform/src/sys/sys_launcher_srv/CSysLauncher.cpp index aa60aafd..0b910e0f 100644 --- a/platform/src/sys/sys_launcher_srv/CSysLauncher.cpp +++ b/platform/src/sys/sys_launcher_srv/CSysLauncher.cpp @@ -175,5 +175,5 @@ bool CSysLauncher::doStop() return true; } -} //< iot_sys +} //< namespace iot_sys diff --git a/platform/src/sys/sys_launcher_srv/CSysLauncher.h b/platform/src/sys/sys_launcher_srv/CSysLauncher.h index f9a30a67..f0240c51 100644 --- a/platform/src/sys/sys_launcher_srv/CSysLauncher.h +++ b/platform/src/sys/sys_launcher_srv/CSysLauncher.h @@ -49,5 +49,5 @@ private: int m_nRetryCntBeforeStart; }; -} //< iot_sys +} //< namespace iot_sys diff --git a/platform/src/sys/sys_launcher_srv/MainWindows.cpp b/platform/src/sys/sys_launcher_srv/MainWindows.cpp index cdbbcf27..4e1c4a17 100644 --- a/platform/src/sys/sys_launcher_srv/MainWindows.cpp +++ b/platform/src/sys/sys_launcher_srv/MainWindows.cpp @@ -17,11 +17,11 @@ #include "pub_logger_api/logger.h" #include "CSysLauncher.h" +#include "setup/CommonDef.h" void WINAPI serviceMain(); void WINAPI serviceStrl(DWORD dwOpcode); -static TCHAR chServiceName[] = _T("iscs6000_launcher"); static SERVICE_STATUS_HANDLE g_hServiceStatus = NULL; static SERVICE_STATUS g_stStatus; @@ -45,7 +45,7 @@ int main(int /*argc*/, char ** /*argv[]*/) SERVICE_TABLE_ENTRY st[] = { - { chServiceName, (LPSERVICE_MAIN_FUNCTION)serviceMain }, + { g_chLauncherServiceName, (LPSERVICE_MAIN_FUNCTION)serviceMain }, { NULL, NULL } }; @@ -69,7 +69,7 @@ void WINAPI serviceMain() g_stStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; //< 注册服务控制 - g_hServiceStatus = RegisterServiceCtrlHandler(chServiceName, serviceStrl); + g_hServiceStatus = RegisterServiceCtrlHandler(g_chLauncherServiceName, serviceStrl); if (g_hServiceStatus == NULL) { LOGERROR("serviceMain(): RegisterServiceCtrlHandler() return NULL !"); diff --git a/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.cpp b/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.cpp index c49fd0a7..dfaca899 100644 --- a/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.cpp +++ b/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.cpp @@ -11,10 +11,11 @@ #include "sigar_format.h" #include - +#include #include #include #include +#include #include "LicenseAuthImpl.h" //#include "Common.h" @@ -25,15 +26,16 @@ namespace iot_sys { //< 注意:私钥不能写在发布出去的代码中,不排除通过分析编译后的二进制文件可以获得 - -//< 公钥 static const char *szPublicKey = "\ ------BEGIN PUBLIC KEY-----\n\ -MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDA15DXITkGQuLMrFP98RWj6BDQ\n\ -iLK/t3H4e1HbyUIGt8Bdu/CmIm07x8AINbAomBK1Hmd1TL/47Y+XgQ7BduOHEncI\n\ -Gw8+emLpg0ms3p85U1k9qndeOe86gC9j6eFuvl8M4wqkGCIiqcIDSx1Nq2kuL/aw\n\ -VCzHJLc1nVNOBGXBvwIDAQAB\n\ ------END PUBLIC KEY-----\n"; +-----BEGIN RSA PUBLIC KEY-----\n\ +MIIBCgKCAQEA1t7y9Wqvwhjw5IKVKVMzGKAAiPniXPIWyjkmTB0OVQhYNIej6aQ2\n\ +NM2EZZULbYnUvjF5hds9kYM46IIhr2M5RSOWmisKmco0AUe93mhAKTgRdpNXgrjc\n\ +yVdfI9KrjDdt+YYtlrPiLz+QgydOnlGeJlZ86yIZJ87RafQzp5Cun0Cam5+CVrt2\n\ +KOVWGO6tBfmBJtkBxJOGxx1SB9IVCSU3ikZpfwZ8SjvN1UE7y3A8BbGtEaevj2kI\n\ +Amqb8WJaw7BkHGzncVS38qcNo634j9Tzv/ighx+BLSPVZG3jk/KR8nYXwNvLbukQ\n\ +EEULz4rQCoAfMOcJsz6JlIk6kmyUCR9K1QIDAQAB\n\ +-----END RSA PUBLIC KEY-----\n"; + //读取密钥 RSA *CLicenseAuthImpl::createRSA( const unsigned char *szKey, bool bPubKey ) @@ -49,7 +51,7 @@ RSA *CLicenseAuthImpl::createRSA( const unsigned char *szKey, bool bPubKey ) if ( bPubKey ) { - pRsa = PEM_read_bio_RSA_PUBKEY( pKeyBio, &pRsa, nullptr, nullptr ); + pRsa = PEM_read_bio_RSAPublicKey( pKeyBio, &pRsa, nullptr, nullptr ); } else { @@ -67,8 +69,13 @@ RSA *CLicenseAuthImpl::createRSA( const unsigned char *szKey, bool bPubKey ) int CLicenseAuthImpl::publicDecrypt( const unsigned char *pEncData, int nDataLen, const unsigned char *szKey, unsigned char *pDecrypted ) { + RSA *pRsa = createRSA( szKey, true ); - int nRc = RSA_public_decrypt( nDataLen, pEncData, pDecrypted, pRsa, RSA_NO_PADDING ); + if (!pRsa) + { + return 0; + } + int nRc = RSA_public_decrypt( nDataLen, pEncData, pDecrypted, pRsa, RSA_PKCS1_PADDING); RSA_free( pRsa ); return nRc; } @@ -321,21 +328,21 @@ bool CLicenseAuthImpl::checkRegistration_private //< 公钥解密 { //< RSA_NO_PADDING 模式最长128 - char szDecryptText[128]; - memset( szDecryptText, 0, 128 ); - int nLen = publicDecrypt(( unsigned char * ) baActiveCode.data(), 128, + char szDecryptText[512]; + memset( szDecryptText, 0, 512); + int nLen = publicDecrypt(( unsigned char * ) baActiveCode.data(), baActiveCode.size(), ( unsigned char * ) szPublicKey, ( unsigned char * ) szDecryptText ); if ( nLen <= 0 ) { - qDebug( "decryptByPublic() failed !" ); + qDebug( "RSA_public_decrypt() failed !" ); return false; } //< todo 注意:解密后的内容切勿输出,对于科大讯飞TTS别人可以用我们的 APPID,算我们的装机量 const char *pText = szDecryptText; - for ( nLen = 128; nLen > 0; --nLen ) + for ( nLen = 512; nLen > 0; --nLen ) { if ( *pText == 0 ) ++pText; @@ -352,9 +359,19 @@ bool CLicenseAuthImpl::checkRegistration_private baActiveCode = QByteArray( pText, nLen ); QList listAc = baActiveCode.split( ' ' ); - if ( listAc.size() != 2 ) + if ( listAc.size() != 3 ) { - qDebug( "listAc.size() != 2" ); + qDebug( "listAc.size() != 3" ); + return false; + } + + QDateTime curDataTime = QDateTime::currentDateTime(); + QDateTime licTime = QDateTime::fromString(listAc[2],"yyyy-MM-dd_hh:mm:ss"); + uint nCurTime = curDataTime.toTime_t(); + uint nLicTime = licTime.toTime_t(); + if (nCurTime > nLicTime) + { + qDebug("Invalid active time !"); return false; } @@ -380,4 +397,4 @@ bool CLicenseAuthImpl::checkRegistration_private return true; } -} //< namespace iot_application +} //< namespace iot_app diff --git a/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.h b/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.h index 5ccf1d1b..d55e9828 100644 --- a/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.h +++ b/platform/src/sys/sys_license_auth_api/LicenseAuthImpl.h @@ -48,4 +48,4 @@ private: typedef boost::shared_ptr CLicenseAuthImplPtr; -} //< namespace iot_application +} //< namespace iot_app diff --git a/platform/src/sys/sys_login_api/CLoginDlg.cpp b/platform/src/sys/sys_login_api/CLoginDlg.cpp index 3cef74c3..884b78cf 100644 --- a/platform/src/sys/sys_login_api/CLoginDlg.cpp +++ b/platform/src/sys/sys_login_api/CLoginDlg.cpp @@ -7,15 +7,18 @@ #include #include #include "pub_logger_api/logger.h" +#include "pub_widget/PubWidgetInit.h" #include #define INTERNAL_ACCOUNT_MAX_ID 10 //最大内置账号ID CLoginDlg::CLoginDlg(QWidget *parent) : - QDialog(parent), + CustomUiDialog(parent), ui(new Ui::CLoginDlg), m_pReadDb(Q_NULLPTR) { + setResizeable(false); + const std::string strLanguage = std::move(iot_public::getCurLanguage()); const std::string strQmFile = std::move( iot_public::CFileUtil::getPathOfResFile( "sys_login_api/translate/" + strLanguage + ".qm" )); @@ -26,10 +29,12 @@ CLoginDlg::CLoginDlg(QWidget *parent) : QApplication::installTranslator( pTrans ); } + iot_public::installTranslator(strLanguage); + ui->setupUi(this); - Qt::WindowFlags flags=Qt::Dialog; - flags |=Qt::WindowCloseButtonHint; - setWindowFlags(flags); +// Qt::WindowFlags flags=Qt::Dialog; +// flags |=Qt::WindowCloseButtonHint; +// setWindowFlags(flags); init(); initData(); @@ -41,6 +46,8 @@ CLoginDlg::CLoginDlg(QWidget *parent) : m_permFunc1 = QString(); ui->alias->setEnabled(false); ui->password->setFocus(); + + setAutoLayout(true); } CLoginDlg::~CLoginDlg() @@ -148,12 +155,17 @@ bool CLoginDlg::eventFilter(QObject *obj, QEvent *event) emit sigDirectConnect(); return true; } + else if(keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) + { + login(); + return true; + } return false; } else { - return QDialog::eventFilter(obj, event); + return CustomUiDialog::eventFilter(obj, event); } } @@ -299,7 +311,7 @@ void CLoginDlg::initView() ui->userg->setView(new QListView); ui->user->setView(new QListView); ui->password->setEchoMode(QLineEdit::EchoMode::Password); - this->setFixedSize(240,165); +// this->setFixedSize(200,212); this->setWindowTitle(tr("登录")); ui->user->installEventFilter(this); diff --git a/platform/src/sys/sys_login_api/CLoginDlg.ui b/platform/src/sys/sys_login_api/CLoginDlg.ui index 2889ad73..e78cb7f0 100644 --- a/platform/src/sys/sys_login_api/CLoginDlg.ui +++ b/platform/src/sys/sys_login_api/CLoginDlg.ui @@ -6,8 +6,8 @@ 0 0 - 212 - 164 + 268 + 208 diff --git a/platform/src/sys/sys_login_api/en.ts b/platform/src/sys/sys_login_api/en.ts new file mode 100644 index 00000000..8679e3b2 --- /dev/null +++ b/platform/src/sys/sys_login_api/en.ts @@ -0,0 +1,103 @@ + + + + + CLoginDlg + + + CLoginDlg + Login + + + + 账号 + Account + + + + 密码 + Password + + + + 用户组 + User group + + + + 姓名 + Name + + + + + 登录 + Login + + + + 取消 + Cancel + + + + 未找到此普通权限 + The permission was not found + + + + 未进行密码验证 + No password verification + + + + + + + + 提示 + Tip + + + + 用户信息错误! + User infomation error! + + + + 密码不能为空! + Password can not be blank! + + + + 密码错误! + Wrong password! + + + + 不具备权限! + Does not have this permission! + + + + 用户已失效! + User has expired! + + + + + 警告 + Warning + + + + 创建数据库对象失败! + create db object failed! + + + + 打开数据库失败! + open db failed! + + + diff --git a/platform/src/sys/sys_login_api/sys_login_api.pro b/platform/src/sys/sys_login_api/sys_login_api.pro index 21b93dfe..932497cd 100644 --- a/platform/src/sys/sys_login_api/sys_login_api.pro +++ b/platform/src/sys/sys_login_api/sys_login_api.pro @@ -25,7 +25,7 @@ DEFINES += LOGIN_EXPORT #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 LIBS += -ldb_base_api -ldb_api_ex -lpub_logger_api -llog4cplus \ - -lpub_sysinfo_api -lpub_utility_api \ + -lpub_sysinfo_api -lpub_utility_api -lpub_widget SOURCES += \ CLoginDlg.cpp @@ -44,3 +44,5 @@ exists($$COMMON_PRI) { }else { error("FATAL error: can not find common.pri") } + +TRANSLATIONS = $$PWD/en.ts diff --git a/platform/src/sys/sys_network_check/Ping.cpp b/platform/src/sys/sys_network_check/Ping.cpp index 46012191..ad23a437 100644 --- a/platform/src/sys/sys_network_check/Ping.cpp +++ b/platform/src/sys/sys_network_check/Ping.cpp @@ -181,7 +181,7 @@ void iot_sys::CPinger::handleTimeout() if (m_nFailTime >= m_nPingRetryTime) //< 超过指定次数才认为失败 { bUpdateTable = true; - LOGERROR("网络故障"); + LOGERROR("网络故障,目标IP地址:[%s]",m_strDstIP.c_str()); } } diff --git a/platform/src/sys/sys_node_mng/RemoteAppInfoMng.cpp b/platform/src/sys/sys_node_mng/RemoteAppInfoMng.cpp index a3141a80..44ec999d 100644 --- a/platform/src/sys/sys_node_mng/RemoteAppInfoMng.cpp +++ b/platform/src/sys/sys_node_mng/RemoteAppInfoMng.cpp @@ -110,13 +110,31 @@ int iot_sys::CRemoteAppInfoMng::checkRemoteBuffer() { boost::mutex::scoped_lock lock(m_objRecvBufMutex); - const bool bNetworkIsActive = m_ptrNetworkCheck->isNormal(); + bool bNetworkIsActive = false; + SNetworkState stNetSta; + if(iotSuccess == m_ptrNetworkCheck->getLocalNetStatus(stNetSta)) + { + bNetworkIsActive = (stNetSta.bIP1State || stNetSta.bIP2State); + } + int64 lCurTime = getMonotonicMsec(); for (AppKeyToHeartbeatMAP::iterator pNode = m_mapRecvAppInfo.begin(); pNode != m_mapRecvAppInfo.end(); ++pNode) { SAppHeartbeatInfo &stAppInfo = pNode->second; /* @brief 检查冗余相关状态是否发生变化 */ + if(!stNetSta.bIP1State && stAppInfo.bIP1Active) + { + stAppInfo.bIP1Active = false; + stAppInfo.bNetworkStateChanged = true; + } + + if(!stNetSta.bIP2State && stAppInfo.bIP2Active) + { + stAppInfo.bIP2Active = false; + stAppInfo.bNetworkStateChanged = true; + } + if (stAppInfo.bRedundancyStateChanged || stAppInfo.bNetworkStateChanged) { m_ptrNodeInfoMng->updateAppRedundancyInfo(stAppInfo); @@ -260,9 +278,32 @@ int iot_sys::CRemoteAppInfoMng::updateRecvHeartbeatInfo(const SAppHeartbeatInfo /* @brief 更新访问信息字段 */ if (stAppInfo.bIP1Active != stHeartbeat.bIP1Active || stAppInfo.bIP2Active != stHeartbeat.bIP2Active) { - stAppInfo.bIP1Active = stHeartbeat.bIP1Active; - stAppInfo.bIP2Active = stHeartbeat.bIP2Active; - stAppInfo.bNetworkStateChanged = true; + bool bIP1Active = stHeartbeat.bIP1Active; + bool bIP2Active = stHeartbeat.bIP2Active; + + SNetworkState stNetSta; + if(iotSuccess == m_ptrNetworkCheck->getLocalNetStatus(stNetSta)) + { + //为了解决如下情况:本机A、B网都正常,接收者只有A网正常,但是在接收者的内存中记录了AB网都正常 + //调整为:本机某网不正常时,不管对端是否正常,以本机为准 + //为了降低正常情况下此处访问网络状态的次数,没有每次都获取网络状态,而通过与checkRemoteBuffer配合完成 + if(!stNetSta.bIP1State && bIP1Active) + { + bIP1Active = false; + } + + if(!stNetSta.bIP2State && bIP2Active) + { + bIP2Active = false; + } + } + + if(stAppInfo.bIP1Active != bIP1Active || stAppInfo.bIP2Active == bIP2Active) + { + stAppInfo.bIP1Active = stHeartbeat.bIP1Active; + stAppInfo.bIP2Active = stHeartbeat.bIP2Active; + stAppInfo.bNetworkStateChanged = true; + } } /* @brief 更新心跳时间戳 */ diff --git a/platform/src/sys/sys_proc_mng/ProcMngConfigParam.cpp b/platform/src/sys/sys_proc_mng/ProcMngConfigParam.cpp index 793ad521..22b1f4f4 100644 --- a/platform/src/sys/sys_proc_mng/ProcMngConfigParam.cpp +++ b/platform/src/sys/sys_proc_mng/ProcMngConfigParam.cpp @@ -4,7 +4,19 @@ @author 曹顶法 */ #include "ProcMngConfigParam.h" + +//< 屏蔽xml_parser编译告警 +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-copy" +#endif + #include "boost/property_tree/xml_parser.hpp" + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + #include "boost/typeof/typeof.hpp" #include "boost/filesystem.hpp" #include "common/Common.h" diff --git a/platform/src/sys/sys_proc_mng/ProcMngThread.cpp b/platform/src/sys/sys_proc_mng/ProcMngThread.cpp index 06c9f185..b8c505d5 100644 --- a/platform/src/sys/sys_proc_mng/ProcMngThread.cpp +++ b/platform/src/sys/sys_proc_mng/ProcMngThread.cpp @@ -131,12 +131,12 @@ int iot_sys::CProcMngThread::collectSingleProcessInfo(SProcInfoMngParam &stProcI //< 如果获取失败,暂不处理,依赖心跳超时进行异常处理 STableRunProcInfo stRunProcInfo; int nRet = m_ptrRunProcInfoOpt->getProcInfoByKey(stProcInfo.stProcKey, stRunProcInfo); - if (kbdErrProcMngApi_NoRecord == nRet) //< 进程管理启动时,其它应用进程可能未启动 + if (iotErrProcMngApi_NoRecord == nRet) //< 进程管理启动时,其它应用进程可能未启动 { return iotSuccess; } - if (iotSuccess != nRet && kbdErrProcMngApi_NoRecord != nRet) + if (iotSuccess != nRet && iotErrProcMngApi_NoRecord != nRet) { LOGERROR("更新进程信息失败.域[%d],应用[%d],节点[%s],进程[%s],启动参数[%s]", stProcInfo.stProcKey.nDomainId, stProcInfo.stProcKey.nAppId, diff --git a/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.cpp b/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.cpp index 0ffbee22..401fdb68 100644 --- a/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.cpp +++ b/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.cpp @@ -62,7 +62,7 @@ int iot_sys::CRunProcInfoTableOperate::getProcInfoByKey(const SProcessInfoKey &s } else if (nCount == 0) { - return kbdErrProcMngApi_NoRecord; + return iotErrProcMngApi_NoRecord; } else { diff --git a/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.h b/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.h index e345a29a..29950505 100644 --- a/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.h +++ b/platform/src/sys/sys_proc_mng/RunProcInfoTableOperate.h @@ -11,7 +11,7 @@ namespace iot_sys { - const int kbdErrProcMngApi_NoRecord = 2; //< 记录不存在 + const int iotErrProcMngApi_NoRecord = 2; //< 记录不存在 /* @brief 进程信息内存表操作类 */ class CRunProcInfoTableOperate diff --git a/platform/src/sys/sys_proc_mng_api/ProcMngApiThread.cpp b/platform/src/sys/sys_proc_mng_api/ProcMngApiThread.cpp index 91c27228..4c9e0296 100644 --- a/platform/src/sys/sys_proc_mng_api/ProcMngApiThread.cpp +++ b/platform/src/sys/sys_proc_mng_api/ProcMngApiThread.cpp @@ -10,7 +10,8 @@ //#include "pub_sysinfo_api/SysInfoApi.h" #include "pub_utility_api/ProcUtil.h" #include "pub_utility_api/TimeUtil.h" - +#include "pub_utility_api/CommonConfigParse.h" +#include "pub_utility_api/FileUtil.h" using namespace std; using namespace iot_public; @@ -68,7 +69,7 @@ void iot_sys::CProcMngApiThread::execute() if(getMonotonicMsec() - m_lLastCheckDogTime >60*1000) //一分钟检查一次狗错误 { m_lLastCheckDogTime = getMonotonicMsec(); - if(AUTH_STATUS_FAILD == m_ptrDogAuthApi->checkAuthStatus()) //DOG CHECK不成功 + if(iotSuccess != m_ptrDogAuthApi->checkAuthStatus()) //DOG CHECK不成功 { m_nDogTimeOutCount++ ; //超时计次++ if((m_nDogTimeOutCount*60) >= DOG_TIMEOUT) @@ -321,6 +322,15 @@ int iot_sys::CProcMngApiThread::getProcessInfo(SProcRunInfo &stProcInfo) /* @brief 初始化线程相关资源 */ int iot_sys::CProcMngApiThread::initialize() { + CCommonConfigParse objConfig; + if (iotSuccess != objConfig.load(CFileUtil::getPathOfCfgFile("proc_param_cfg.xml"))) + { + LOGERROR("加载配置文件proc_param_cfg.xml失败,进程心跳使用默认参数"); + } + + m_nRunPeriodMsec = objConfig.getIntWithDefault("sys_proc_mng_api","period",200); + LOGINFO("进程心跳周期%d ms",m_nRunPeriodMsec); + #ifndef DISABLE_DOG_AUTH //< 不需要检查加密狗的程序,不构造实例,避免不必要的开销 if(m_bNeedCheckAuth) @@ -402,9 +412,9 @@ int iot_sys::CProcMngApiThread::heartbeat() // 增加心跳间隔时间较大时的日志输出 static int64 nLastHeartBeatItem = 0; - if ( nLastHeartBeatItem != 0 && m_stProcRunInfo.lLastTime - nLastHeartBeatItem > 200 ) + if ( nLastHeartBeatItem != 0 && m_stProcRunInfo.lLastTime - nLastHeartBeatItem > 5 * m_nRunPeriodMsec) { - LOGWARN( "请注意!标准心跳间隔时间【100ms】,当前心跳间隔时间【%dms】", m_stProcRunInfo.lLastTime - nLastHeartBeatItem ); + LOGWARN( "请注意!标准心跳间隔时间【100ms】,当前心跳间隔时间【%d ms】", static_cast(m_stProcRunInfo.lLastTime - nLastHeartBeatItem) ); } nLastHeartBeatItem = m_stProcRunInfo.lLastTime; diff --git a/platform/src/sys/sys_proc_mng_api/ProcMngImpl.h b/platform/src/sys/sys_proc_mng_api/ProcMngImpl.h index c63a60af..3055e359 100644 --- a/platform/src/sys/sys_proc_mng_api/ProcMngImpl.h +++ b/platform/src/sys/sys_proc_mng_api/ProcMngImpl.h @@ -48,14 +48,14 @@ namespace iot_sys /** @brief 向进程管理注册进程信息 @param const SProcessInfoKey & stProcKey 进程标识主键 - @return 成功返回iotSucces,失败返回iotFailed + @return 成功返回iotSuccess,失败返回iotFailed @retval */ //int registerProcInfo(const SProcessInfoKey &stProcKey); /** @brief 初始化 - @return 成功返回iotSucces,失败返回相应错误码 + @return 成功返回iotSuccess,失败返回相应错误码 */ int initialize();