diff --git a/.github/workflows/issue-translator.yml b/.github/workflows/issue-translator.yml new file mode 100644 index 0000000000000000000000000000000000000000..d9fdac8f597701b4b32e0b5fbd1031f395459ddd --- /dev/null +++ b/.github/workflows/issue-translator.yml @@ -0,0 +1,15 @@ +name: Issue Translator +on: + issue_comment: + types: [created] + issues: + types: [opened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: usthe/issues-translate-action@v2.7 + with: + IS_MODIFY_TITLE: false + CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. \ No newline at end of file diff --git a/.github/workflows/linuxbuild.yml b/.github/workflows/linuxbuild.yml index 03ae11eb4c170442b6de1461fbf0c0db8fdabdb0..6847e392108acf46cf4f2bc4f8f019903a566134 100644 --- a/.github/workflows/linuxbuild.yml +++ b/.github/workflows/linuxbuild.yml @@ -3,9 +3,9 @@ name: ubuntu build workflows on: push: branches: [ "develop" ] - pull_request: - branches: [ "develop" ] - + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' permissions: contents: read @@ -61,4 +61,10 @@ jobs: - name: test run: | cd XEngine_Release - ./XEngine_AuthorizeService -t \ No newline at end of file + ./XEngine_AuthorizeService -t + + - name: Upload folder as artifact with ubuntu + uses: actions/upload-artifact@v4 + with: + name: XEngine_AuthorizeService-x86_64-Ubuntu + path: XEngine_Release/ \ No newline at end of file diff --git a/.github/workflows/macbuild.yml b/.github/workflows/macbuild.yml index d0d4ed55066897cd6541a0cfb465907943cf4f97..a8b90dbc350154115073df5a585b944466630364 100644 --- a/.github/workflows/macbuild.yml +++ b/.github/workflows/macbuild.yml @@ -3,8 +3,9 @@ name: macos build workflows on: push: branches: [ "develop" ] - pull_request: - branches: [ "develop" ] + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' permissions: contents: read @@ -29,6 +30,7 @@ jobs: with: repository: libxengine/libxengine path: libxengine + ref: 'master' - name: sub module checkout (opensource) run: | @@ -62,3 +64,9 @@ jobs: run: | cd XEngine_Release ./XEngine_AuthorizeService -t + + - name: Upload folder as artifact with mac + uses: actions/upload-artifact@v4 + with: + name: XEngine_AuthorizeService-x86_64-Mac + path: XEngine_Release/ \ No newline at end of file diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml index b28225e64ab4f508420bf593aa5ddc6acd259ca3..5e1f7b55a75e0f2e7e4665dbd14487173c25241d 100644 --- a/.github/workflows/msbuild.yml +++ b/.github/workflows/msbuild.yml @@ -2,13 +2,12 @@ name: windows build workflows on: push: - branches: [ "develop" ] - pull_request: - branches: [ "develop" ] - -permissions: - contents: read - + branches: + - develop + paths: + - 'XEngine_Source/**' + - 'XEngine_Release/**' + jobs: build: strategy: @@ -50,7 +49,7 @@ jobs: # 配置 MSBuild 的路径,准备构建 VC++ 项目 - name: Setup MSBuild - uses: microsoft/setup-msbuild@v1.0.2 + uses: microsoft/setup-msbuild@v2 #编译 - name: Build Solution run: msbuild XEngine_Source/XEngine.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }} @@ -65,13 +64,27 @@ jobs: ./VSCopy_x86.bat ./XEngine_AuthorizeService.exe -t shell: pwsh - - name: Conditional Step for x86 Debug - if: matrix.configuration == 'Debug' && matrix.platform == 'x86' + - name: Conditional Step for x64 Release + if: matrix.configuration == 'Release' && matrix.platform == 'x64' run: | - cp -r XEngine_Source/Debug/*.dll XEngine_Release/ - cp -r XEngine_Source/Debug/*.exe XEngine_Release/ - cp -r XEngine_Source/VSCopy_x86.bat XEngine_Release/ + cp -r XEngine_Source/x64/Release/*.dll XEngine_Release/ + cp -r XEngine_Source/x64/Release/*.exe XEngine_Release/ + cp -r XEngine_Source/VSCopy_x64.bat XEngine_Release/ cd XEngine_Release - ./VSCopy_x86.bat - ./XEngine_AuthorizeService.exe -t + ./VSCopy_x64.bat shell: pwsh + + #将文件夹打包为 artifact + - name: Upload folder as artifact with x86 + if: matrix.configuration == 'Release' && matrix.platform == 'x86' + uses: actions/upload-artifact@v4 + with: + name: XEngine_AuthorizeService-x86_32-Windows + path: XEngine_Release/ + + - name: Upload folder as artifact with x64 + if: matrix.configuration == 'Release' && matrix.platform == 'x64' + uses: actions/upload-artifact@v4 + with: + name: XEngine_AuthorizeService-x86_64-Windows + path: XEngine_Release/ \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000000000000000000000000000000000..dcf5576e0ca1d9f6bbbd81bb9bceacb746f9d784 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,89 @@ +name: release packet + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + + steps: + # 检出代码并包含标签 + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download linuxbuild + uses: dawidd6/action-download-artifact@v6 + with: + workflow: linuxbuild.yml + workflow_conclusion: success + check_artifacts: false + skip_unpack: true + if_no_artifact_found: fail + path: ./XRelease/ + - name: Download macbuild + uses: dawidd6/action-download-artifact@v6 + with: + workflow: macbuild.yml + workflow_conclusion: success + check_artifacts: false + skip_unpack: true + if_no_artifact_found: fail + path: ./XRelease/ + - name: Download msbuild + uses: dawidd6/action-download-artifact@v6 + with: + workflow: msbuild.yml + workflow_conclusion: success + check_artifacts: false + skip_unpack: true + if_no_artifact_found: fail + path: ./XRelease/ + + - name: Display structure of downloaded files + run: ls -al ./XRelease/ + + - name: Get current version and increment X + id: versioning + run: | + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + echo "Latest tag: $latest_tag" + # 提取 X 的值并递增 + major=$(echo $latest_tag | cut -d '.' -f 1) + minor=$(echo $latest_tag | cut -d '.' -f 2) + patch=$(echo $latest_tag | cut -d '.' -f 3) + build=$(echo $latest_tag | cut -d '.' -f 4) + + new_minor=$((minor + 1)) + new_version="$major.$new_minor.$patch.$build" + echo "New version: $new_version" + echo "new_tag=$new_version" >> $GITHUB_OUTPUT + echo "prev_tag=$latest_tag" >> $GITHUB_OUTPUT + + - name: Create and push new tag + run: | + git tag ${{ steps.versioning.outputs.new_tag }} + git push origin ${{ steps.versioning.outputs.new_tag }} + + - name: Generate release notes + run: | + logs=$(git log ${{ steps.versioning.outputs.prev_tag }}..${{ steps.versioning.outputs.new_tag }} --pretty=format:"* %h - %s - %an" --no-merges) + release_notes=$(echo "$logs" | sed 's/ qyt$/ @xengine-qyt/') + echo "$release_notes" + echo "$release_notes" > release_notes.txt + + - name: Release + uses: softprops/action-gh-release@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + draft: false + prerelease: false + tag_name: ${{ steps.versioning.outputs.new_tag }} + name: XEngine_Authorize ${{ steps.versioning.outputs.new_tag }} + body_path: release_notes.txt + files: ./XRelease/*.zip diff --git a/CHANGELOG b/CHANGELOG index c0671bf94fa73d5c0aee2f5ae6c554e2733d9be8..c9812872d0dfcc1808ed3603ccff242245fec410 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,35 @@ +XEngine_Authorize V3.15.0.1001 + +增加:密码加密 +增加:TOKEN自动续期 +增加:服务和管理程序coredump支持 +增加:client 删除用户协议支持 +更新:工作流CI添加了发布CI +更新:依赖库 +优化:启动参数解析 +优化:不支持的协议提示 +优化:管理端用户插入修改初始化值 +修改:用户删除方法 +修改:密码协议现在支持找回和设置功能了 +修正:某些时候退出崩溃 +修正:管理端添加用户失败的问题 +修正:多端登录处理不正确的问题 + +added:pass encrypt supported +added:auto renewal token +added:service app and management app core-dump supported +added:delete client for management app with token +update:workflow and add release ci +update:depend library +improved:start parameter parse +improved:tips when request not support protocol +improved:user insert and modify init value for management app +modify:user delete away +modify:user pass now support get and set +fixed:crashed when exist +fixed:add user incorrect for management app +fixed:multi login handle is incorrect and tips logged in +================================================================ XEngine_Authorize V3.14.0.1001 增加:支持无限制多端登录了 diff --git a/README.en.md b/README.en.md index 456917ff55fcd15081959b99fef98aae40b88311..300efd9eaeb3e38249446c2b548896800c269ec2 100644 --- a/README.en.md +++ b/README.en.md @@ -11,6 +11,9 @@ network verification support tcp and websocket and http protocol verification.it first open source C/C++ network authentication server, supporting various languages ​​and platforms for network authentication and authorization This is a cross-platform simple high-performance network authorization server that provides a complete demo code +## Notice +the compiled release version will only be released on github. + #### why choose us Fast iteration: feature updates are timely Technical support: complete technical documentation and technical support, quick response to your questions @@ -119,6 +122,7 @@ port :tcp port 5300,websocket port 5301,http management port 5302,Transmission v 2. Create new Feat_xxx branch 3. Submit the code 4. New Pull Request +5. merge to develop branch ## development path The V1 version is an XEngine component. Most of the code is concentrated in XEngine diff --git a/README.md b/README.md index 82c281730c7c6266965199f16b15292e53d8df42..f24b22cd3316570705d991ffabfd38abd5023b73 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ c c++network Authorize service 全国首款开源C/C++ 网络验证服务器,支持各种语言各种平台进行网络验证和授时服务 这是一个跨平台简单高性能网络授权服务器,提供了完整的演示代码 +## 注意 +编译发布版本将只在github上面发布. + #### 为什么选择我们 快速迭代:功能更新及时 技术支持:完善的技术文档和技术支持,快速响应你的问题 @@ -130,6 +133,7 @@ Linux or macos:直接运行即可 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request +5. 提交到develop分支 ## 发展历程 V1版本为XEngine组件.大部分代码集中在XEngine中 diff --git a/XEngine_Apps/Authorize_APPClient/Authorize_APPClient.cpp b/XEngine_Apps/Authorize_APPClient/Authorize_APPClient.cpp index 9528c0c7bb93ec6f7ffd904f47fbfcb1d67ea6ee..5e82d26b9efc92fa849e1916f2188ad2516bbcfd 100644 --- a/XEngine_Apps/Authorize_APPClient/Authorize_APPClient.cpp +++ b/XEngine_Apps/Authorize_APPClient/Authorize_APPClient.cpp @@ -35,6 +35,7 @@ using namespace std; //Linux::g++ -std=c++17 -Wall -g Authorize_APPClient.cpp -o Authorize_APPClient.exe -I ../../XEngine_Source/XEngine_Depend/XEngine_Module/jsoncpp -L ../../XEngine_Release -lXEngine_OPenSsl -lXClient_Socket -lXEngine_BaseLib -lXClient_APIHelp -lpthread -ljsoncpp -Wl,-rpath=../../XEngine_Release //#define _DYNAMIC_CODE +//#define _PASS_ENCRYPT bool bRun = true; bool bLogin = true; bool bTimeOut = true; @@ -244,6 +245,14 @@ int AuthClient_Login() strcpy(st_AuthUser.tszUserName, lpszUser); strcpy(st_AuthUser.tszUserPass, lpszPass); +#ifdef _PASS_ENCRYPT + int nPLen = _tcsxlen(st_AuthUser.tszUserPass); + XBYTE byMD5Buffer[MAX_PATH] = {}; + OPenSsl_Api_Digest(st_AuthUser.tszUserPass, byMD5Buffer, &nPLen, false, XENGINE_OPENSSL_API_DIGEST_MD5); + memset(st_AuthUser.tszUserPass, '\0', sizeof(st_AuthUser.tszUserPass)); + BaseLib_OperatorString_StrToHex((LPCXSTR)byMD5Buffer, nPLen, st_AuthUser.tszUserPass); +#endif + if (nDYCode > 0) { st_ProtocolHdr.xhToken = xhToken; diff --git a/XEngine_Docment/Docment_en.docx b/XEngine_Docment/Docment_en.docx index 2940152116fd1a27ef7bbff9cbf575e5e387d9b7..778d4c407f2542ceeec02e95cafa9a5d1cad31f4 100644 Binary files a/XEngine_Docment/Docment_en.docx and b/XEngine_Docment/Docment_en.docx differ diff --git a/XEngine_Docment/Docment_zh.docx b/XEngine_Docment/Docment_zh.docx index fddd479e886fa613abfbcf2b3363eee01d17dbe8..9cebeca480f435fbb56d4b9a272b5bbc540396f7 100644 Binary files a/XEngine_Docment/Docment_zh.docx and b/XEngine_Docment/Docment_zh.docx differ diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json index 58fec8ae6c903f8c5af2b7362016c96268818d9f..b681a84c3204051c12119859cde713135f86e1b3 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Config.json +++ b/XEngine_Release/XEngine_Config/XEngine_Config.json @@ -22,7 +22,15 @@ "st_XCDKey":{ "tszKeyFile":"./APPVer.key", "tszKeyPass":"123123qa" - } + }, + "st_PassCrypto":{ + "bEnable":false, + "nCodec":2 + }, + "st_XToken":{ + "bAutoRenewal":false, + "nRenewalTime":-1 + } }, "XLogin":{ "bHTTPAuth":false, diff --git a/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json b/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json index 4bde3daf8de73697c53e08a0d5d38d39b544ca2e..a421ccfeec891826a83c0d73184d1c39b54d88ef 100644 --- a/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json +++ b/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json @@ -1,5 +1,6 @@ { "XVer":[ + "V3.15.0.1001 Build20241121", "V3.14.0.1001 Build20240920", "V3.13.0.1001 Build20240715", "V3.12.1.1001 Build20240621", diff --git a/XEngine_Release/XEngine_DataBase/.gitignore b/XEngine_Release/XEngine_Coredump/keepfile similarity index 100% rename from XEngine_Release/XEngine_DataBase/.gitignore rename to XEngine_Release/XEngine_Coredump/keepfile diff --git a/XEngine_Release/XEngine_XLog/.gitignore b/XEngine_Release/XEngine_XLog/keepfile similarity index 100% rename from XEngine_Release/XEngine_XLog/.gitignore rename to XEngine_Release/XEngine_XLog/keepfile diff --git a/XEngine_Source/AuthorizeModule_Configure/Config_Define.h b/XEngine_Source/AuthorizeModule_Configure/Config_Define.h index f4ca512cd4d5474a9f7d5157d8fbf1a8762d6123..1741bde8133dc458ffccb0a836eae7ec9742b672 100644 --- a/XEngine_Source/AuthorizeModule_Configure/Config_Define.h +++ b/XEngine_Source/AuthorizeModule_Configure/Config_Define.h @@ -38,6 +38,16 @@ typedef struct XCHAR tszKeyFile[MAX_PATH]; //本地CDKEY文件地址 XCHAR tszKeyPass[MAX_PATH]; //本地CDKEY密码 }st_XCDKey; + struct + { + bool bEnable; //是否启用 + int nCodec; //加密方法:ENUM_XENGINE_OPENSSL_DIGEST + }st_PassCrypto; + struct + { + bool bAutoRenewal; //自动续期 + int nRenewalTime; //续期次数 + }st_XToken; int nCheckTimeNumber; //检测次数 int nCheckTimeout; //超时时间 int nTokenTimeout; //TOKEN登录超时时间 diff --git a/XEngine_Source/AuthorizeModule_Configure/ModuleConfigure_Json/ModuleConfigure_Json.cpp b/XEngine_Source/AuthorizeModule_Configure/ModuleConfigure_Json/ModuleConfigure_Json.cpp index 12717fc3e414e27aa596b61b0f8ab3a6026b408e..f736c2e8bf79fff8ce75721f151cbed2e338b4e7 100644 --- a/XEngine_Source/AuthorizeModule_Configure/ModuleConfigure_Json/ModuleConfigure_Json.cpp +++ b/XEngine_Source/AuthorizeModule_Configure/ModuleConfigure_Json/ModuleConfigure_Json.cpp @@ -101,7 +101,7 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE pSt_ServerConfig->st_XMax.nWSThread = st_JsonXMax["nWSThread"].asInt(); pSt_ServerConfig->st_XMax.nHTTPThread = st_JsonXMax["nHTTPThread"].asInt(); //验证配置 - if (st_JsonRoot["XVerification"].empty() || (7 != st_JsonRoot["XVerification"].size())) + if (st_JsonRoot["XVerification"].empty() || (9 != st_JsonRoot["XVerification"].size())) { Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_AUTHORIZE_MODULE_CONFIGURE_XVER; @@ -117,6 +117,12 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE _tcsxcpy(pSt_ServerConfig->st_XVerification.st_XCDKey.tszKeyFile, st_JsonXVerification["st_XCDKey"]["tszKeyFile"].asCString()); _tcsxcpy(pSt_ServerConfig->st_XVerification.st_XCDKey.tszKeyPass, st_JsonXVerification["st_XCDKey"]["tszKeyPass"].asCString()); + + pSt_ServerConfig->st_XVerification.st_PassCrypto.bEnable = st_JsonXVerification["st_PassCrypto"]["bEnable"].asBool(); + pSt_ServerConfig->st_XVerification.st_PassCrypto.nCodec = st_JsonXVerification["st_PassCrypto"]["nCodec"].asInt(); + + pSt_ServerConfig->st_XVerification.st_XToken.bAutoRenewal = st_JsonXVerification["st_XToken"]["bAutoRenewal"].asBool(); + pSt_ServerConfig->st_XVerification.st_XToken.nRenewalTime = st_JsonXVerification["st_XToken"]["nRenewalTime"].asInt(); //登录配置 if (st_JsonRoot["XLogin"].empty() || (5 != st_JsonRoot["XLogin"].size())) { diff --git a/XEngine_Source/AuthorizeModule_Database/DBModule_SQLite/DBModule_SQLite.cpp b/XEngine_Source/AuthorizeModule_Database/DBModule_SQLite/DBModule_SQLite.cpp index a350bbdf0fd7728e259a6c0191a10b7af302c327..b478108bfdf154cdde956589b33a8c97ab1d194d 100644 --- a/XEngine_Source/AuthorizeModule_Database/DBModule_SQLite/DBModule_SQLite.cpp +++ b/XEngine_Source/AuthorizeModule_Database/DBModule_SQLite/DBModule_SQLite.cpp @@ -91,7 +91,7 @@ bool CDBModule_SQLite::DBModule_SQLite_UserDelete(XENGINE_PROTOCOL_USERINFO* pSt SQLPacket_IsErrorOccur = false; XCHAR tszSQLStatement[1024]; //SQL语句 memset(tszSQLStatement, '\0', 1024); - _xstprintf(tszSQLStatement, _X("DELETE FROM `Authorize_User` WHERE UserName = '%s' AND Password = '%s' AND EmailAddr = '%s' AND IDCard = '%lld'"), pSt_UserInfo->tszUserName, pSt_UserInfo->tszUserPass, pSt_UserInfo->tszEMailAddr, pSt_UserInfo->nIDNumber); + _xstprintf(tszSQLStatement, _X("DELETE FROM `Authorize_User` WHERE UserName = '%s'"), pSt_UserInfo->tszUserName); //执行 if (!DataBase_SQLite_Exec(xhData, tszSQLStatement)) { diff --git a/XEngine_Source/AuthorizeModule_Session/AuthorizeModule_Session.def b/XEngine_Source/AuthorizeModule_Session/AuthorizeModule_Session.def index 7791de028a363ae82a40c7070f345df0174e033a..467624a6c2eaa6986f2e228504aa0fea54e44e9a 100644 --- a/XEngine_Source/AuthorizeModule_Session/AuthorizeModule_Session.def +++ b/XEngine_Source/AuthorizeModule_Session/AuthorizeModule_Session.def @@ -17,4 +17,5 @@ EXPORTS Session_Token_Delete Session_Token_UPDate Session_Token_Get - Session_Token_GetUser \ No newline at end of file + Session_Token_GetUser + Session_Token_RenewalTime \ No newline at end of file diff --git a/XEngine_Source/AuthorizeModule_Session/Session_Define.h b/XEngine_Source/AuthorizeModule_Session/Session_Define.h index fb09594c528607a8ef149c99ca93d2181b97a0b1..7efc656a10e67e94f39d7a89e29268e4ce633a8b 100644 --- a/XEngine_Source/AuthorizeModule_Session/Session_Define.h +++ b/XEngine_Source/AuthorizeModule_Session/Session_Define.h @@ -287,4 +287,23 @@ extern "C" bool Session_Token_Get(XNETHANDLE xhToken, AUTHREG_USERTABLE* pSt_Use 意思:是否成功 备注: *********************************************************************/ -extern "C" bool Session_Token_GetUser(LPCXSTR lpszUser, LPCXSTR lpszPass, XNETHANDLE * pxhToken); \ No newline at end of file +extern "C" bool Session_Token_GetUser(LPCXSTR lpszUser, LPCXSTR lpszPass, XNETHANDLE * pxhToken); +/******************************************************************** +函数名称:Session_Token_RenewalTime +函数功能:续期时间 + 参数.一:xhToken + In/Out:In + 类型:句柄 + 可空:N + 意思:输入要操作的TOKEN + 参数.二:pInt_RenewalTime + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出续期的次数 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool Session_Token_RenewalTime(XNETHANDLE xhToken, int* pInt_RenewalTime); \ No newline at end of file diff --git a/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.cpp b/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.cpp index 6e061c508ba5be842d2f148322e04b8eb40ec21a..c3c69a5f674d26b43bf717d3810f5c86073dcec6 100644 --- a/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.cpp +++ b/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.cpp @@ -287,6 +287,42 @@ bool CSession_Token::Session_Token_GetUser(LPCXSTR lpszUser, LPCXSTR lpszPass, X } return true; } +/******************************************************************** +函数名称:Session_Token_RenewalTime +函数功能:续期时间 + 参数.一:xhToken + In/Out:In + 类型:句柄 + 可空:N + 意思:输入要操作的TOKEN + 参数.二:pInt_RenewalTime + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出续期的次数 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CSession_Token::Session_Token_RenewalTime(XNETHANDLE xhToken, int* pInt_RenewalTime) +{ + Session_IsErrorOccur = false; + + st_Locker.lock_shared(); + unordered_map::iterator stl_MapIterator = stl_MapToken.find(xhToken); + if (stl_MapIterator == stl_MapToken.end()) + { + Session_IsErrorOccur = true; + Session_dwErrorCode = ERROR_AUTHORIZE_MODULE_SESSION_PARAMENT; + st_Locker.unlock_shared(); + return false; + } + stl_MapIterator->second.nRenewalTime++; + *pInt_RenewalTime = stl_MapIterator->second.nRenewalTime; + st_Locker.unlock_shared(); + return true; +} ////////////////////////////////////////////////////////////////////////// // 线程函数 ////////////////////////////////////////////////////////////////////////// diff --git a/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.h b/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.h index eb72aca75531a93ce5b489d27c59c28554f15bfd..368acd65db0db0b0388701c070ecf95a738fe2b7 100644 --- a/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.h +++ b/XEngine_Source/AuthorizeModule_Session/Session_Token/Session_Token.h @@ -15,6 +15,7 @@ typedef struct AUTHREG_USERTABLE st_UserTable; //用户表 XENGINE_LIBTIMER st_LibTimer; //登录时间结构 int nTimeout; //单独指定超时 + int nRenewalTime; //自动续期次数 }AUTHSESSION_TOKENCLIENT, * LPAUTHSESSION_TOKENCLIENT; ////////////////////////////////////////////////////////////////////////// class CSession_Token @@ -30,6 +31,7 @@ public: bool Session_Token_UPDate(XNETHANDLE xhToken); bool Session_Token_Get(XNETHANDLE xhToken, AUTHREG_USERTABLE* pSt_UserTable = NULL); bool Session_Token_GetUser(LPCXSTR lpszUser, LPCXSTR lpszPass, XNETHANDLE* pxhToken); + bool Session_Token_RenewalTime(XNETHANDLE xhToken, int* pInt_RenewalTime); protected: static XHTHREAD Session_Token_Thread(XPVOID lParam); private: diff --git a/XEngine_Source/AuthorizeModule_Session/pch.cpp b/XEngine_Source/AuthorizeModule_Session/pch.cpp index df3b78a38f2ede2e6253b91df7440030d742d4e8..8082f0bc0f59873dd7b8bb88b0917e8cdc9729d4 100644 --- a/XEngine_Source/AuthorizeModule_Session/pch.cpp +++ b/XEngine_Source/AuthorizeModule_Session/pch.cpp @@ -89,4 +89,8 @@ extern "C" bool Session_Token_Get(XNETHANDLE xhToken, AUTHREG_USERTABLE * pSt_Us extern "C" bool Session_Token_GetUser(LPCXSTR lpszUser, LPCXSTR lpszPass, XNETHANDLE * pxhToken) { return m_SessionToken.Session_Token_GetUser(lpszUser, lpszPass, pxhToken); +} +extern "C" bool Session_Token_RenewalTime(XNETHANDLE xhToken, int* pInt_RenewalTime) +{ + return m_SessionToken.Session_Token_RenewalTime(xhToken, pInt_RenewalTime); } \ No newline at end of file diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.cpp index ed293e4d23a74261b599cbb44c2dc9943b6a604d..9ba58efc6757843d98cbe2c3c42b469d18243b8d 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.cpp @@ -38,6 +38,9 @@ void CDialog_Config::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_COMBO2, m_ListEncrypto); DDX_Control(pDX, IDC_EDIT6, m_EditPassword); DDX_Control(pDX, IDC_EDIT11, m_EditDCode); + DDX_Control(pDX, IDC_COMBO7, m_ComboPassCodec); + DDX_Control(pDX, IDC_RADIO4, m_RadioPassDisable); + DDX_Control(pDX, IDC_RADIO3, m_RadioPassEnable); } @@ -48,6 +51,8 @@ BEGIN_MESSAGE_MAP(CDialog_Config, CDialogEx) ON_BN_CLICKED(IDC_RADIO2, &CDialog_Config::OnBnClickedRadio2) ON_BN_CLICKED(IDC_RADIO1, &CDialog_Config::OnBnClickedRadio1) ON_BN_CLICKED(IDC_BUTTON8, &CDialog_Config::OnBnClickedButton8) + ON_BN_CLICKED(IDC_RADIO3, &CDialog_Config::OnBnClickedRadio3) + ON_BN_CLICKED(IDC_RADIO4, &CDialog_Config::OnBnClickedRadio4) END_MESSAGE_MAP() @@ -70,6 +75,15 @@ BOOL CDialog_Config::OnInitDialog() m_CheckCodecEnable.SetCheck(BST_UNCHECKED); m_CheckCodecDisable.SetCheck(BST_CHECKED); + + m_RadioPassDisable.SetCheck(BST_CHECKED); + m_ComboPassCodec.EnableWindow(false); + m_ComboPassCodec.InsertString(0, _T("MD4")); + m_ComboPassCodec.InsertString(1, _T("MD5")); + m_ComboPassCodec.InsertString(2, _T("SHA1")); + m_ComboPassCodec.InsertString(3, _T("SHA256")); + m_ComboPassCodec.SetCurSel(1); + m_ListEncrypto.AddString(_T("XCrypto(X加密)")); m_ListEncrypto.SetCurSel(0); m_ListEncrypto.EnableWindow(false); @@ -101,14 +115,26 @@ void CDialog_Config::OnBnClickedButton1() m_EditPass.GetWindowText(m_StrPass); m_EditDCode.GetWindowText(m_StrDCode); + TCHAR tszMDBuffer[64] = {}; + if (m_RadioPassEnable.GetCheck() == BST_CHECKED) + { + int nPLen = m_StrPass.GetLength(); + XBYTE byMD5Buffer[MAX_PATH] = {}; + OPenSsl_Api_Digest(m_StrPass.GetBuffer(), byMD5Buffer, &nPLen, false, m_ComboPassCodec.GetCurSel() + 1); + BaseLib_OperatorString_StrToHex((LPCXSTR)byMD5Buffer, nPLen, tszMDBuffer); + } + else + { + _tcsxcpy(tszMDBuffer, m_StrPass.GetBuffer()); + } if (m_StrDCode.GetLength() > 0) { m_EditToken.GetWindowText(m_StrToken); - _xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d&token=%s&dcode=%s"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), m_StrPass.GetBuffer(), ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS, m_StrToken.GetBuffer(), m_StrDCode.GetBuffer()); + _xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d&token=%s&dcode=%s"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), tszMDBuffer, ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS, m_StrToken.GetBuffer(), m_StrDCode.GetBuffer()); } else { - _xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), m_StrPass.GetBuffer(), ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS); + _xstprintf(tszUrlAddr, _T("http://%s:%s/api?function=login&user=%s&pass=%s&device=%d"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer(), m_StrUser.GetBuffer(), tszMDBuffer, ENUM_PROTOCOL_FOR_DEVICE_TYPE_PC_WINDOWS); } //请求用户信息 int nMsgLen = 0; @@ -357,3 +383,17 @@ void CDialog_Config::OnBnClickedButton8() m_EditDCode.SetWindowText(tszDCodeStr); BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); } + + +void CDialog_Config::OnBnClickedRadio3() +{ + // TODO: 在此添加控件通知处理程序代码 + m_ComboPassCodec.EnableWindow(TRUE); +} + + +void CDialog_Config::OnBnClickedRadio4() +{ + // TODO: 在此添加控件通知处理程序代码 + m_ComboPassCodec.EnableWindow(FALSE); +} diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.h b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.h index 5ab99f04d04dc000018da8f178dbfc50cfeb53c7..1b0086f9b5d01cbd36abf35e6f8cab961c8aa202 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.h +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Config.h @@ -43,4 +43,9 @@ public: CEdit m_EditPassword; CEdit m_EditDCode; afx_msg void OnBnClickedButton8(); + CComboBox m_ComboPassCodec; + CButton m_RadioPassDisable; + CButton m_RadioPassEnable; + afx_msg void OnBnClickedRadio3(); + afx_msg void OnBnClickedRadio4(); }; diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.cpp index 1bccb00d171095497d2b6064bfaa06e7a676b060..8d6970bd650b287452c587ff5cdfd1a031a47601 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.cpp @@ -33,8 +33,8 @@ void CDialog_Modify::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_COMBO1, m_ComboSerial); DDX_Control(pDX, IDC_COMBO2, m_ComboLeave); DDX_Control(pDX, IDC_EDIT7, m_EditHardCode); - DDX_Control(pDX, IDC_EDIT8, m_EditCreateTime); DDX_Control(pDX, IDC_BUTTON2, m_BtnModify); + DDX_Control(pDX, IDC_DATETIMEPICKER1, m_DateTimeRegister); } @@ -63,12 +63,15 @@ BOOL CDialog_Modify::OnInitDialog() { m_ComboLeave.InsertString(i, lpszXLevelType[i]); } - + m_DateTimeRegister.SetFormat(_T("yyyy-MM-dd HH:mm:ss")); POSITION pSt_Sition = pUserWnd->m_ListCtrlClient.GetFirstSelectedItemPosition(); if (NULL == pSt_Sition) { //没有选择,表示添加 m_BtnModify.SetWindowText(_T("添加")); + + m_ComboSerial.SetCurSel(1); + m_ComboLeave.SetCurSel(11); } else { @@ -144,7 +147,11 @@ BOOL CDialog_Modify::OnInitDialog() m_EditUser.SetWindowText(st_JsonObject["st_UserInfo"]["tszUserName"].asCString()); m_EditPass.SetWindowText(st_JsonObject["st_UserInfo"]["tszUserPass"].asCString()); m_EditEMail.SetWindowText(st_JsonObject["st_UserInfo"]["tszEMailAddr"].asCString()); - m_EditCreateTime.SetWindowText(st_JsonObject["st_UserInfo"]["tszCreateTime"].asCString()); + COleDateTime m_OleDTime; + if (m_OleDTime.ParseDateTime(st_JsonObject["st_UserInfo"]["tszCreateTime"].asCString())) + { + m_DateTimeRegister.SetTime(m_OleDTime); + } CString m_StrNumber; m_StrNumber.Format(_T("%lld"), st_JsonObject["st_UserInfo"]["nIDNumber"].asUInt64()); @@ -179,7 +186,7 @@ void CDialog_Modify::OnBnClickedButton2() m_EditUser.GetWindowText(st_UserTable.st_UserInfo.tszUserName, sizeof(st_UserTable.st_UserInfo.tszUserName)); m_EditPass.GetWindowText(st_UserTable.st_UserInfo.tszUserPass, sizeof(st_UserTable.st_UserInfo.tszUserPass)); m_EditEMail.GetWindowText(st_UserTable.st_UserInfo.tszEMailAddr, sizeof(st_UserTable.st_UserInfo.tszEMailAddr)); - m_EditCreateTime.GetWindowText(st_UserTable.st_UserInfo.tszCreateTime, sizeof(st_UserTable.st_UserInfo.tszCreateTime)); + m_DateTimeRegister.GetWindowText(st_UserTable.st_UserInfo.tszCreateTime, sizeof(st_UserTable.st_UserInfo.tszCreateTime)); m_EditHardCode.GetWindowText(st_UserTable.tszHardCode, sizeof(st_UserTable.tszHardCode)); CString m_StrNumber; @@ -215,6 +222,7 @@ void CDialog_Modify::OnBnClickedButton2() } else { + st_JsonRoot["xhToken"] = _ttxoll(m_StrToken.GetBuffer()); _xstprintf(tszUrlAddr, _T("http://%s:%s/auth/client/modify"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer()); } @@ -230,8 +238,7 @@ void CDialog_Modify::OnBnClickedButton2() st_JsonTable["enSerialType"] = st_UserTable.enSerialType; st_JsonTable["st_UserInfo"] = st_JsonUser; st_JsonRoot["st_UserTable"] = st_JsonTable; - st_JsonRoot["xhToken"] = _ttxoll(m_StrToken.GetBuffer()); - + //是否加密 int nMsgLen = 0; TCHAR* ptszMsgBuffer = NULL; diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.h b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.h index d9a9788b5afccc10bc878daa3658aa1e133410a0..c4546bd758901427bf78370d7cf2ce731354edb0 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.h +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_Modify.h @@ -33,7 +33,7 @@ public: CComboBox m_ComboLeave; afx_msg void OnBnClickedButton2(); CEdit m_EditHardCode; - CEdit m_EditCreateTime; CButton m_BtnModify; afx_msg void OnBnClickedButton3(); + CDateTimeCtrl m_DateTimeRegister; }; diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_User.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_User.cpp index d9a79aad597530ef36dccd1d035f3691b2a7c29d..a69bf8009ab359aa90b20a1ea92a0f03b2b25656 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_User.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/Authorize_Dialog/Dialog_User.cpp @@ -302,7 +302,7 @@ void CDialog_User::OnBnClickedButton3() TCHAR tszUrlAddr[MAX_PATH]; memset(tszUrlAddr, '\0', MAX_PATH); - _xstprintf(tszUrlAddr, _T("http://%s:%s/auth/user/delete"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer()); + _xstprintf(tszUrlAddr, _T("http://%s:%s/auth/client/delete"), m_StrIPAddr.GetBuffer(), m_StrIPPort.GetBuffer()); Json::Value st_JsonRoot; Json::Value st_JsonObject; diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.aps b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.aps index 8a1d171e423e9f41935d293fbd935353240d66d5..1dd52e9c7754868d4f2b10e46c09d50822378429 100644 Binary files a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.aps and b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.aps differ diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.rc b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.rc index e247434c5524eb0fb48bbbca53a086700ed4db12..57de1d2d3eff2b5bfa037627a57723d4f5247cdd 100644 Binary files a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.rc and b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngineAuthorizeApp.rc differ diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngine_AuthorizeAppDlg.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngine_AuthorizeAppDlg.cpp index cda8ac431c4a1f1201603af7d496bfca17d75cea..713599d212a00a804d4b24b1c2cbb030a219e856 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngine_AuthorizeAppDlg.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/XEngine_AuthorizeAppDlg.cpp @@ -40,7 +40,27 @@ BEGIN_MESSAGE_MAP(CXEngineAuthorizeAppDlg, CDialogEx) ON_BN_CLICKED(IDC_BUTTON2, &CXEngineAuthorizeAppDlg::OnBnClickedButton2) END_MESSAGE_MAP() +LONG WINAPI Coredump_ExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) +{ + static int i = 0; + XCHAR tszFileStr[MAX_PATH] = {}; + XCHAR tszTimeStr[128] = {}; + BaseLib_OperatorTime_TimeToStr(tszTimeStr); + _xstprintf(tszFileStr, _X("./XEngine_Coredump/dumpfile_%s_%d.dmp"), tszTimeStr, i++); + HANDLE hDumpFile = CreateFileA(tszFileStr, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE != hDumpFile) + { + MINIDUMP_EXCEPTION_INFORMATION st_DumpInfo = {}; + st_DumpInfo.ExceptionPointers = pExceptionPointers; + st_DumpInfo.ThreadId = GetCurrentThreadId(); + st_DumpInfo.ClientPointers = TRUE; + // 写入 dump 文件 + MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &st_DumpInfo, NULL, NULL); + CloseHandle(hDumpFile); + } + return EXCEPTION_EXECUTE_HANDLER; +} // CXEngineAuthorizeAppDlg 消息处理程序 BOOL CXEngineAuthorizeAppDlg::OnInitDialog() @@ -53,6 +73,7 @@ BOOL CXEngineAuthorizeAppDlg::OnInitDialog() SetIcon(m_hIcon, false); // 设置小图标 // TODO: 在此添加额外的初始化代码 + SetUnhandledExceptionFilter(Coredump_ExceptionFilter); HANDLE hMutex = CreateMutex(NULL, true, _T("XEngine_AuthorizeApp")); if (NULL != hMutex) { diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/pch.h b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/pch.h index b9646560ed72c6cd7d1a09d329cfe6a606587ea8..c5ff5cda282b2981468e87da49f71497ecf682d7 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/pch.h +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/pch.h @@ -13,6 +13,7 @@ #endif //PCH_H #include #include +#include using namespace std; #include #include @@ -69,6 +70,7 @@ extern LPCXSTR lpszStuType[2]; #endif #endif +#pragma comment(lib,"Dbghelp.lib") #pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib.lib") #pragma comment(lib,"XEngine_Core/XEngine_OPenSsl.lib") #pragma comment(lib,"XEngine_Client/XClient_APIHelp.lib") \ No newline at end of file diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/resource.h b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/resource.h index 067adfb8a52a58749de067fc845993cc50fd5028..b2d0d3de86e7cc9303f842ebd483fb8d82a3713b 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/resource.h +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeApp/resource.h @@ -49,6 +49,7 @@ #define IDC_EDIT8 1014 #define IDC_CHECK2 1014 #define IDC_EDIT22 1014 +#define IDC_COMBO7 1014 #define IDC_RADIO1 1015 #define IDC_EDIT23 1015 #define IDC_RADIO2 1016 diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_Client.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_Client.cpp index f1d1ecbe5e99fbcfe7665cdc3507a2fd0c357d96..3ebdbc345a484f974559bde3aa3f37f9c7de9f6c 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_Client.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_Client.cpp @@ -8,6 +8,7 @@ bool XEngine_AuthorizeHTTP_Client(LPCXSTR lpszClientAddr, LPCXSTR lpszAPIName, L LPCXSTR lpszAPIList = _X("list"); LPCXSTR lpszAPIClose = _X("close"); LPCXSTR lpszAPIModify = _X("modify"); + LPCXSTR lpszAPIDelete = _X("delete"); memset(tszSDBuffer, '\0', sizeof(tszSDBuffer)); @@ -120,6 +121,15 @@ bool XEngine_AuthorizeHTTP_Client(LPCXSTR lpszClientAddr, LPCXSTR lpszAPIName, L memset(&st_UserTable, '\0', sizeof(AUTHREG_USERTABLE)); Protocol_Parse_HttpParseTable(lpszMsgBuffer, nMsgLen, &st_UserTable); + + if (st_AuthConfig.st_XVerification.st_PassCrypto.bEnable) + { + int nPLen = _tcsxlen(st_UserTable.st_UserInfo.tszUserPass); + XBYTE byMD5Buffer[MAX_PATH] = {}; + OPenSsl_Api_Digest(st_UserTable.st_UserInfo.tszUserPass, byMD5Buffer, &nPLen, false, st_AuthConfig.st_XVerification.st_PassCrypto.nCodec); + memset(st_UserTable.st_UserInfo.tszUserPass, '\0', sizeof(st_UserTable.st_UserInfo.tszUserPass)); + BaseLib_OperatorString_StrToHex((LPCXSTR)byMD5Buffer, nPLen, st_UserTable.st_UserInfo.tszUserPass); + } bool bSuccess = false; if (0 == st_AuthConfig.st_XSql.nDBType) { @@ -141,5 +151,40 @@ bool XEngine_AuthorizeHTTP_Client(LPCXSTR lpszClientAddr, LPCXSTR lpszAPIName, L XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,请求修改用户信息:%s 成功"), lpszClientAddr, st_UserTable.st_UserInfo.tszUserName); } + else if (0 == _tcsxnicmp(lpszAPIDelete, lpszAPIName, _tcsxlen(lpszAPIDelete))) + { + XENGINE_PROTOCOL_USERINFO st_UserInfo = {}; + Protocol_Parse_HttpParseUser(lpszMsgBuffer, nMsgLen, &st_UserInfo); + + //关闭链接 + int nListCount = 0; + AUTHSESSION_NETCLIENT** ppSt_ListClient; + Session_Authorize_GetClient(&ppSt_ListClient, &nListCount, st_UserInfo.tszUserName); + for (int i = 0; i < nListCount; i++) + { + XEngine_CloseClient(ppSt_ListClient[i]->tszClientAddr, true); + } + BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClient, nListCount); + //删除数据库 + bool bSuccess = false; + if (0 == st_AuthConfig.st_XSql.nDBType) + { + bSuccess = DBModule_SQLite_UserDelete(&st_UserInfo); + } + else + { + bSuccess = DBModule_MySQL_UserDelete(&st_UserInfo); + } + if (!bSuccess) + { + Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 404, "not found client"); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,请求删除用户失败:%s 错误码:%lX"), lpszClientAddr, st_UserInfo.tszUserName, DBModule_GetLastError()); + return false; + } + Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,请求删除用户:%s 成功"), lpszClientAddr, st_UserInfo.tszUserName); + } return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_User.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_User.cpp index ddc78d3572d56a86564c018271cf199104ee3990..5d9d7e7c3648136acaae234d1b7a4b0e74771534 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_User.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/AuthorizeHTTP_Post/AuthorizeHTTP_User.cpp @@ -21,11 +21,30 @@ bool XEngine_AuthorizeHTTP_User(XNETHANDLE xhToken, LPCXSTR lpszClientAddr, LPCX XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,删除失败,删除功能已经被服务器关闭!"), lpszClientAddr); return false; } + AUTHREG_USERTABLE st_UserTable = {}; XENGINE_PROTOCOL_USERINFO st_UserInfo = {}; + Protocol_Parse_HttpParseUser(lpszMsgBuffer, nMsgLen, &st_UserInfo); - //删除数据库 + bool bRet = false; if (0 == st_AuthConfig.st_XSql.nDBType) + { + bRet = DBModule_SQLite_UserQuery(st_UserInfo.tszUserName, &st_UserTable); + } + else + { + bRet = DBModule_MySQL_UserQuery(st_UserInfo.tszUserName, &st_UserTable); + } + //安全验证判断 + if ((0 != _tcsxnicmp(st_UserInfo.tszEMailAddr, st_UserTable.st_UserInfo.tszEMailAddr, _tcsxlen(st_UserInfo.tszEMailAddr))) || (st_UserTable.st_UserInfo.nIDNumber != st_UserInfo.nIDNumber)) + { + Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 400, "user information is incorrent"); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,用户名:%s,删除用户失败,验证信息失败"), lpszClientAddr, st_UserInfo.tszUserName); + return false; + } + //删除数据库 + if (0 == st_AuthConfig.st_XSql.nDBType) { bRet = DBModule_SQLite_UserDelete(&st_UserInfo); } @@ -108,6 +127,16 @@ bool XEngine_AuthorizeHTTP_User(XNETHANDLE xhToken, LPCXSTR lpszClientAddr, LPCX return false; } bSuccess = false; + + if (st_AuthConfig.st_XVerification.st_PassCrypto.bEnable) + { + int nPLen = _tcsxlen(st_UserTable.st_UserInfo.tszUserPass); + XBYTE byMD5Buffer[MAX_PATH] = {}; + OPenSsl_Api_Digest(st_UserTable.st_UserInfo.tszUserPass, byMD5Buffer, &nPLen, false, st_AuthConfig.st_XVerification.st_PassCrypto.nCodec); + memset(st_UserTable.st_UserInfo.tszUserPass, '\0', sizeof(st_UserTable.st_UserInfo.tszUserPass)); + BaseLib_OperatorString_StrToHex((LPCXSTR)byMD5Buffer, nPLen, st_UserTable.st_UserInfo.tszUserPass); + } + if (0 == st_AuthConfig.st_XSql.nDBType) { bSuccess = DBModule_SQLite_UserRegister(&st_UserTable); @@ -177,34 +206,33 @@ bool XEngine_AuthorizeHTTP_User(XNETHANDLE xhToken, LPCXSTR lpszClientAddr, LPCX { AUTHREG_USERTABLE st_UserTable; XENGINE_PROTOCOL_USERINFO st_UserInfo; - XENGINE_PROTOCOL_USERAUTH st_AuthProtocol; - + memset(&st_UserTable, '\0', sizeof(AUTHREG_USERTABLE)); memset(&st_UserInfo, '\0', sizeof(XENGINE_PROTOCOL_USERINFO)); - memset(&st_AuthProtocol, '\0', sizeof(XENGINE_PROTOCOL_USERAUTH)); - + if (!st_FunSwitch.bSwitchPass) { Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 503, "the function is closed"); XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,找回密码失败,密码找回功能已经被服务器关闭!"), lpszClientAddr); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,找回重置密码失败,密码找回重置功能已经被服务器关闭!"), lpszClientAddr); return false; } Protocol_Parse_HttpParseUser(lpszMsgBuffer, nMsgLen, &st_UserInfo); + //得到数据库信息 bool bSuccess = false; - if (0 == st_AuthConfig.st_XSql.nDBType) + if (0 == st_AuthConfig.st_XSql.nDBType) { bSuccess = DBModule_SQLite_UserQuery(st_UserInfo.tszUserName, &st_UserTable); } - else + else { bSuccess = DBModule_MySQL_UserQuery(st_UserInfo.tszUserName, &st_UserTable); } - if (!bSuccess) + if (!bSuccess) { Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 404, "user not found"); XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,用户名:%s,找回密码失败,用户不存在"), lpszClientAddr, st_UserInfo.tszUserName); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,用户名:%s,找回重置密码失败,用户不存在"), lpszClientAddr, st_UserInfo.tszUserName); return false; } //安全验证判断 @@ -212,15 +240,41 @@ bool XEngine_AuthorizeHTTP_User(XNETHANDLE xhToken, LPCXSTR lpszClientAddr, LPCX { Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 400, "user information is incorrent"); XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,用户名:%s,找回密码失败,验证信息失败"), lpszClientAddr, st_UserInfo.tszUserName); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,用户名:%s,找回重置密码失败,验证信息失败"), lpszClientAddr, st_UserInfo.tszUserName); return false; } + //是否开启了密码加密 + if (st_AuthConfig.st_XVerification.st_PassCrypto.bEnable) + { + //开启了,密码重置 + int nPLen = _tcsxlen(st_UserInfo.tszUserPass); + XBYTE byMD5Buffer[MAX_PATH] = {}; + OPenSsl_Api_Digest(st_UserInfo.tszUserPass, byMD5Buffer, &nPLen, false, st_AuthConfig.st_XVerification.st_PassCrypto.nCodec); + memset(st_UserTable.st_UserInfo.tszUserPass, '\0', sizeof(st_UserTable.st_UserInfo.tszUserPass)); + BaseLib_OperatorString_StrToHex((LPCXSTR)byMD5Buffer, nPLen, st_UserTable.st_UserInfo.tszUserPass); + //重置密码 + if (0 == st_AuthConfig.st_XSql.nDBType) + { + bSuccess = DBModule_SQLite_UserSet(&st_UserTable); + } + else + { + bSuccess = DBModule_MySQL_UserSet(&st_UserTable); + } + if (!bSuccess) + { + Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 404, "not found client"); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,请求修改密码失败:%s 错误码:%lX"), lpszClientAddr, st_UserTable.st_UserInfo.tszUserName, DBModule_GetLastError()); + return false; + } + } + XENGINE_PROTOCOL_USERAUTH st_AuthProtocol = {}; _tcsxcpy(st_AuthProtocol.tszUserName, st_UserTable.st_UserInfo.tszUserName); _tcsxcpy(st_AuthProtocol.tszUserPass, st_UserTable.st_UserInfo.tszUserPass); - Protocol_Packet_HttpUserPass(tszSDBuffer, &nSDLen, &st_AuthProtocol); XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,用户名:%s,找回密码成功"), lpszClientAddr, st_UserInfo.tszUserName); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("HTTP客户端:%s,用户名:%s,找回重置密码成功"), lpszClientAddr, st_UserInfo.tszUserName); } else if (0 == _tcsxnicmp(lpszAPIName, lpszAPITry, _tcsxlen(lpszAPIName))) { diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Config.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Config.cpp index d32e456f16b552d079a4fd5413c6367ac9a7fc2c..e21999921659c1e9c82b18807d0b461e8af6ecf7 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Config.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Config.cpp @@ -31,7 +31,7 @@ bool Authorize_Service_Parament(int argc, char** argv) } else if (0 == _tcsxcmp("-d", argv[i])) { - st_AuthConfig.bDeamon = _ttxoi(argv[i + 1]); + st_AuthConfig.bDeamon = _ttxoi(argv[++i]); } else if (0 == _tcsxcmp("-t", argv[i])) { diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Hdr.h b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Hdr.h index da312cb62e7adb613e8ae0032975d4065fe2aef0..2e41e388c105f9b249db19435868fc9507f4cd06 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Hdr.h +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Hdr.h @@ -2,6 +2,7 @@ #ifdef _WINDOWS #include #include +#include #else #include #include @@ -141,6 +142,7 @@ extern XENGINE_FUNCTIONSWITCH st_FunSwitch; #endif #endif #pragma comment(lib,"Ws2_32.lib") +#pragma comment(lib,"Dbghelp.lib") #pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib.lib") #pragma comment(lib,"XEngine_Core/XEngine_Core.lib") #pragma comment(lib,"XEngine_Core/XEngine_ManagePool.lib") diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_HttpTask.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_HttpTask.cpp index f04150658088c1c41071c3050106a4866891868c..42d79f9c5f37c6fd2a0ef91f0cf571d615e8367b 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_HttpTask.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_HttpTask.cpp @@ -193,6 +193,13 @@ bool XEngine_Client_HttpTask(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int } XEngine_AuthorizeHTTP_Try(lpszClientAddr, tszAPIName, lpszMsgBuffer, nMsgLen); } + else + { + Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 400, "reqeust api is not support"); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,请求的API:%s 失败,因为不被支持"), lpszClientAddr, pSt_HTTPParament->tszHttpUri); + return false; + } } else { @@ -208,6 +215,13 @@ bool XEngine_Client_HttpTask(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int { XEngine_AuthorizeHTTP_User(xhToken, lpszClientAddr, tszAPIName, lpszMsgBuffer, nMsgLen); } + else + { + Protocol_Packet_HttpComm(tszSDBuffer, &nSDLen, 400, "reqeust api is not support"); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_AUTH_APP_NETTYPE_HTTP); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP客户端:%s,请求的API:%s 失败,因为不被支持"), lpszClientAddr, pSt_HTTPParament->tszHttpUri); + return false; + } } } else if (0 == _tcsxnicmp(lpszMethodGet, pSt_HTTPParament->tszHttpMethod, _tcsxlen(lpszMethodGet))) diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_TCPTask.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_TCPTask.cpp index ea514126bc4eb6144ec6aa8497c01d93f7be6fe4..5b8faad8730370a1e71cb5aa34aa5983655a4e55 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_TCPTask.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_TCPTask.cpp @@ -181,107 +181,93 @@ bool XEngine_Client_TCPTask(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n } } //是否已经登录 - if (st_FunSwitch.bSwitchMulti) - { - bool bLogin = false; - int nListCount = 0; - AUTHSESSION_NETCLIENT** ppSt_ListClient; + bool bLogin = false; + int nListCount = 0; + AUTHSESSION_NETCLIENT** ppSt_ListClient; - Session_Authorize_GetClient(&ppSt_ListClient, &nListCount, st_AuthProtocol.tszUserName); - for (int i = 0; i < nListCount; i++) + Session_Authorize_GetClient(&ppSt_ListClient, &nListCount, st_AuthProtocol.tszUserName); + for (int i = 0; i < nListCount; i++) + { + //找到客户端,支持的模式 + if (0 == st_AuthConfig.st_XLogin.nMultiMode) { - //找到客户端,支持的模式 - if (0 == st_AuthConfig.st_XLogin.nMultiMode) - { - int nSourceType = 0; - int nDestType = 0; - AuthHelp_MultiLogin_GetRange(ppSt_ListClient[i]->st_UserTable.enDeviceType, &nSourceType); - AuthHelp_MultiLogin_GetRange(st_AuthProtocol.enDeviceType, &nDestType); + int nSourceType = 0; + int nDestType = 0; + AuthHelp_MultiLogin_GetRange(ppSt_ListClient[i]->st_UserTable.enDeviceType, &nSourceType); + AuthHelp_MultiLogin_GetRange(st_AuthProtocol.enDeviceType, &nDestType); - if (nSourceType == nDestType) - { - bLogin = true; - break; - } - } - else if (1 == st_AuthConfig.st_XLogin.nMultiMode) - { - if (ppSt_ListClient[i]->st_UserTable.enDeviceType == st_AuthProtocol.enDeviceType) - { - bLogin = true; - break; - } - } - else if (2 == st_AuthConfig.st_XLogin.nMultiMode) + if (nSourceType == nDestType) { + bLogin = true; break; } - else + } + else if (1 == st_AuthConfig.st_XLogin.nMultiMode) + { + if (ppSt_ListClient[i]->st_UserTable.enDeviceType == st_AuthProtocol.enDeviceType) { - pSt_ProtocolHdr->wReserve = 257; - Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType); - XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,登录失败,服务端设置不正确"), lpszClientAddr, st_AuthProtocol.tszUserName); - return false; + bLogin = true; + break; } } - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClient, nListCount); - //对多端登录的类型进行验证 + else if (2 == st_AuthConfig.st_XLogin.nMultiMode) + { + break; + } + else + { + pSt_ProtocolHdr->wReserve = 257; + Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,登录失败,服务端设置不正确"), lpszClientAddr, st_AuthProtocol.tszUserName); + return false; + } + } + BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClient, nListCount); + //对多端登录的类型进行验证 + if (bLogin && st_FunSwitch.bSwitchMulti) + { if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_SECOND == st_UserTable.enSerialType) { - if (!st_AuthConfig.st_XLogin.st_MulitLogin.bSecond) + if (st_AuthConfig.st_XLogin.st_MulitLogin.bSecond) { - bLogin = true; + bLogin = false; } } else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_TIME == st_UserTable.enSerialType) { - if (!st_AuthConfig.st_XLogin.st_MulitLogin.bTime) + if (st_AuthConfig.st_XLogin.st_MulitLogin.bTime) { - bLogin = true; + bLogin = false; } } else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_DAY == st_UserTable.enSerialType) { - if (!st_AuthConfig.st_XLogin.st_MulitLogin.bDay) + if (st_AuthConfig.st_XLogin.st_MulitLogin.bDay) { - bLogin = true; + bLogin = false; } } else if (ENUM_AUTHORIZE_MODULE_SERIAL_TYPE_CUSTOM == st_UserTable.enSerialType) { - if (!st_AuthConfig.st_XLogin.st_MulitLogin.bCustom) + if (st_AuthConfig.st_XLogin.st_MulitLogin.bCustom) { - bLogin = true; + bLogin = false; } } else { bLogin = true; //其他注册类型禁止登录 } - //判断这次登录是否允许 - if (bLogin) - { - pSt_ProtocolHdr->wReserve = 253; - Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType); - XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,多端登录失败,用户已经登录,类型:%d"), lpszClientAddr, st_AuthProtocol.tszUserName, st_AuthProtocol.enDeviceType); - return false; - } } - else + //判断这次登录是否允许 + if (bLogin) { - int nListCount = 0; - AUTHSESSION_NETCLIENT** ppSt_ListClient; - if (Session_Authorize_GetClient(&ppSt_ListClient, &nListCount, st_AuthProtocol.tszUserName)) - { - pSt_ProtocolHdr->wReserve = 253; - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClient, nListCount); - Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType); - XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,登录失败,用户名已经登录"), lpszClientAddr, st_AuthProtocol.tszUserName); - return false; - } + pSt_ProtocolHdr->wReserve = 253; + Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,用户名:%s,多端登录失败,用户已经登录,类型:%d"), lpszClientAddr, st_AuthProtocol.tszUserName, st_AuthProtocol.enDeviceType); + return false; } //是否被封禁 if (-1 == st_UserTable.st_UserInfo.nUserLevel) @@ -359,5 +345,12 @@ bool XEngine_Client_TCPTask(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("客户端:%s,用户名:%s,登录成功,注册类型:%s,剩余时间:%s"), lpszClientAddr, st_AuthProtocol.tszUserName, lpszXSerialType[st_UserTable.enSerialType], st_UserTable.tszLeftTime); } + else + { + Protocol_Packet_HDRComm(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, nNetType); + XEngine_Client_TaskSend(lpszClientAddr, tszSDBuffer, nSDLen, nNetType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("客户端:%s,请求的协议:%d-%d 不被支持"), lpszClientAddr, pSt_ProtocolHdr->unOperatorType, pSt_ProtocolHdr->unOperatorCode); + return false; + } return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Task.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Task.cpp index 58c3528d05b5550446517e8676906fa1ab5e83c1..8642a3f2349f714d5980ebd4807c5e65a8a3abdb 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Task.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Task.cpp @@ -63,10 +63,33 @@ void CALLBACK XEngine_TaskEvent_Client(LPCXSTR lpszUserAddr, LPCXSTR lpszUserNam } void CALLBACK XEngine_TaskEvent_Token(XNETHANDLE xhToken, XPVOID lParam) { + bool bRemove = true; AUTHREG_USERTABLE st_UserTable; memset(&st_UserTable, '\0', sizeof(AUTHREG_USERTABLE)); Session_Token_Get(xhToken, &st_UserTable); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Token:%lld,用户名:%s,已经超时,权限级别:%d,被移除服务器"), xhToken, st_UserTable.st_UserInfo.tszUserName, st_UserTable.st_UserInfo.nUserLevel); - Session_Token_Delete(xhToken); + //自动续期? + if (st_AuthConfig.st_XVerification.st_XToken.bAutoRenewal) + { + int nRenewalTime = 0; + Session_Token_RenewalTime(xhToken, &nRenewalTime); + + if (-1 == st_AuthConfig.st_XVerification.st_XToken.nRenewalTime) + { + bRemove = false; + } + else + { + if (nRenewalTime <= st_AuthConfig.st_XVerification.st_XToken.nRenewalTime) + { + bRemove = false; + } + } + } + + if (bRemove) + { + Session_Token_Delete(xhToken); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Token:%lld,用户名:%s,已经超时,权限级别:%d,被移除服务器"), xhToken, st_UserTable.st_UserInfo.tszUserName, st_UserTable.st_UserInfo.nUserLevel); + } } \ No newline at end of file diff --git a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/XEngine_AuthorizeService.cpp b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/XEngine_AuthorizeService.cpp index d47fb99afd2f831f9f2670899b9b6340aad84be4..3c60a12a27f50a71abfcba89e226bddffad96106 100644 --- a/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/XEngine_AuthorizeService.cpp +++ b/XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/XEngine_AuthorizeService.cpp @@ -94,11 +94,37 @@ static int ServiceApp_Deamon(int wait) return 0; } +#ifdef _MSC_BUILD +LONG WINAPI Coredump_ExceptionFilter(EXCEPTION_POINTERS* pExceptionPointers) +{ + static int i = 0; + XCHAR tszFileStr[MAX_PATH] = {}; + XCHAR tszTimeStr[128] = {}; + BaseLib_OperatorTime_TimeToStr(tszTimeStr); + _xstprintf(tszFileStr, _X("./XEngine_Coredump/dumpfile_%s_%d.dmp"), tszTimeStr, i++); + + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_FATAL, _X("主程序:软件崩溃,写入dump:%s"), tszFileStr); + HANDLE hDumpFile = CreateFileA(tszFileStr, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE != hDumpFile) + { + MINIDUMP_EXCEPTION_INFORMATION st_DumpInfo = {}; + st_DumpInfo.ExceptionPointers = pExceptionPointers; + st_DumpInfo.ThreadId = GetCurrentThreadId(); + st_DumpInfo.ClientPointers = TRUE; + // 写入 dump 文件 + MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &st_DumpInfo, NULL, NULL); + CloseHandle(hDumpFile); + } + return EXCEPTION_EXECUTE_HANDLER; +} +#endif int main(int argc, char** argv) { #ifdef _WINDOWS WSADATA st_WSAData; WSAStartup(MAKEWORD(2, 2), &st_WSAData); + + SetUnhandledExceptionFilter(Coredump_ExceptionFilter); #endif bIsRun = true; int nRet = -1; diff --git a/XEngine_Source/XEngine_Depend b/XEngine_Source/XEngine_Depend index a7b440b0c648f37d291ae019b67a482111e1a70b..1c1452f13720d22834e09c7e4e78042698411486 160000 --- a/XEngine_Source/XEngine_Depend +++ b/XEngine_Source/XEngine_Depend @@ -1 +1 @@ -Subproject commit a7b440b0c648f37d291ae019b67a482111e1a70b +Subproject commit 1c1452f13720d22834e09c7e4e78042698411486