diff --git a/.github/workflows/issue-translator.yml b/.github/workflows/issue-translator.yml
new file mode 100644
index 0000000..d9fdac8
--- /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
new file mode 100644
index 0000000..1d347e5
--- /dev/null
+++ b/.github/workflows/linuxbuild.yml
@@ -0,0 +1,64 @@
+name: ubuntu build workflows
+
+on:
+ push:
+ branches: [ "develop" ]
+ pull_request:
+ branches: [ "develop" ]
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ strategy:
+ # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
+ fail-fast: false
+ matrix:
+ include:
+ - os: ubuntu-22.04
+ #- os: ubuntu-24.04
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ # 检出您的主仓库代码
+ - name: Checkout main repository code
+ uses: actions/checkout@v4
+ with:
+ ref: 'develop'
+
+ # 检出依赖的xengine仓库到指定的xengine目录
+ - name: Checkout dependency repository (xengine)
+ uses: actions/checkout@v4
+ with:
+ repository: libxengine/libxengine
+ path: libxengine
+
+ - name: sub module checkout (opensource)
+ run: |
+ git submodule init
+ git submodule update
+
+ # 设置依赖库的环境变量
+ - name: Set up Dependency Environment Variables
+ run: |
+ cd libxengine
+ chmod 777 *
+ sudo ./XEngine_LINEnv.sh -i 3
+ cd ..
+ #编译
+ - name: make
+ run: |
+ cd XEngine_Source
+ make
+ make FLAGS=InstallAll
+ make FLAGS=CleanAll
+
+ make RELEASE=1
+ make FLAGS=InstallAll
+ make FLAGS=CleanAll
+ cd ..
+ - name: test
+ run: |
+ cd XEngine_Release
+ ./XEngine_XStorageApp -t
\ No newline at end of file
diff --git a/.github/workflows/macbuild.yml b/.github/workflows/macbuild.yml
new file mode 100644
index 0000000..c2e8fc6
--- /dev/null
+++ b/.github/workflows/macbuild.yml
@@ -0,0 +1,64 @@
+name: macos build workflows
+
+on:
+ push:
+ branches: [ "develop" ]
+ pull_request:
+ branches: [ "develop" ]
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+ strategy:
+ matrix:
+ include:
+ - os: macos-13
+ runs-on: ${{ matrix.os }}
+
+ steps:
+ - name: Checkout main repository code
+ uses: actions/checkout@v4
+ with:
+ ref: 'develop'
+
+ # 检出依赖的xengine仓库到指定的xengine目录
+ - name: Checkout dependency repository (xengine)
+ uses: actions/checkout@v4
+ with:
+ repository: libxengine/libxengine
+ path: libxengine
+
+ - name: sub module checkout (opensource)
+ run: |
+ git submodule init
+ git submodule update
+
+ - name: brew install
+ run: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+
+ # 设置依赖库的环境变量
+ - name: Set up Dependency Environment Variables
+ run: |
+ cd libxengine
+ chmod 777 *
+ ./XEngine_LINEnv.sh -i 3
+ cd ..
+ #编译
+ - name: make debug
+ run: |
+ cd XEngine_Source
+ make PLATFORM=mac
+ make PLATFORM=mac FLAGS=InstallAll
+ make PLATFORM=mac FLAGS=CleanAll
+ - name: make release
+ run: |
+ cd XEngine_Source
+ make PLATFORM=mac RELEASE=1
+ make PLATFORM=mac FLAGS=InstallAll
+ make PLATFORM=mac FLAGS=CleanAll
+ - name: test
+ run: |
+ cd XEngine_Release
+ ./XEngine_XStorageApp -t
diff --git a/.github/workflows/msbuild.yml b/.github/workflows/msbuild.yml
index fd1d032..627328d 100644
--- a/.github/workflows/msbuild.yml
+++ b/.github/workflows/msbuild.yml
@@ -1,32 +1,44 @@
-name: C++ Build with Dependencies
+name: windows build workflows
-#on: [push] # 触发条件,推送和拉取请求时,
on:
- workflow_dispatch: # 添加这行来启用手动触发
+ push:
+ branches: [ "develop" ]
+ pull_request:
+ branches: [ "develop" ]
permissions:
- contents: write
+ contents: read
jobs:
build:
strategy:
+ # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
+ fail-fast: false
matrix:
- configuration: [Release]
- platform: [x86]
+ configuration: [Debug ,Release]
+ platform: [x86 ,x64]
runs-on: windows-latest # 最新的 Windows 环境
steps:
# 检出您的主仓库代码
- name: Checkout main repository code
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
+ with:
+ ref: 'develop'
# 检出依赖的xengine仓库到指定的xengine目录
- name: Checkout dependency repository (xengine)
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
- repository: libxengine/xengine
+ repository: libxengine/libxengine
path: xengine
+
+ - name: sub module checkout (opensource)
+ run: |
+ git submodule init
+ git submodule update
+ shell: pwsh
# 设置依赖库的环境变量
- name: Set up Dependency Environment Variables
@@ -42,61 +54,24 @@ jobs:
#编译
- name: Build Solution
run: msbuild XEngine_Source/XEngine_StorageApp.sln /p:Configuration=${{ matrix.configuration }} /p:Platform=${{ matrix.platform }}
-
- # 打包
- - name: Copy Build binaries for x86
+ #测试
+ - name: Conditional Step for x86 Release
+ if: matrix.configuration == 'Release' && matrix.platform == 'x86'
run: |
- mkdir -p "x86/XEngine_StorageApp"
- cp -r ./XEngine_Release/* x86/XEngine_StorageApp/
- cp -r ./XEngine_Source/Release/*.dll x86/XEngine_StorageApp/
- cp -r ./XEngine_Source/Release/*.exe x86/XEngine_StorageApp/
- cp -r ./XEngine_Source/VSCopy_x86.bat x86/XEngine_StorageApp/
- cd x86/XEngine_StorageApp && ./VSCopy_x86.bat
- cd ..
- cd ..
- 7z a XEngine_StorageApp-x86-Windows.zip ./x86/XEngine_StorageApp/*
+ cp -r XEngine_Source/Release/*.dll XEngine_Release/
+ cp -r XEngine_Source/Release/*.exe XEngine_Release/
+ cp -r XEngine_Source/VSCopy_x86.bat XEngine_Release/
+ cd XEngine_Release
+ ./VSCopy_x86.bat
+ ./XEngine_StorageApp.exe -t
shell: pwsh
-
- - name: Calculate new tag
- id: newtag
- shell: bash
+ - name: Conditional Step for x86 Debug
+ if: matrix.configuration == 'Debug' && matrix.platform == 'x86'
run: |
- git fetch --tags
- TAG=$(git tag --sort=-v:refname | head -n 1)
- MAJOR=$(echo $TAG | cut -d '.' -f 1)
- MINOR=$(echo $TAG | cut -d '.' -f 2)
- PATCH=$(echo $TAG | cut -d '.' -f 3)
- BUILD=$(echo $TAG | cut -d '.' -f 4)
- MINOR_BUMP=$((MINOR + 1))
- NEW_TAG="${MAJOR}.${MINOR_BUMP}.0.${BUILD}"
- echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
- git config --local user.email "action@github.com"
- git config --local user.name "GitHub Action"
- git tag $NEW_TAG
- git push origin $NEW_TAG
-
- # 创建GitHub Release
- - name: Create Release
- id: create_release
- uses: softprops/action-gh-release@v1
- with:
- tag_name: ${{ env.NEW_TAG }}
- name: Release ${{ env.NEW_TAG }}
- body: |
- [${{ github.sha }}](https://github.com/libxengine/XEngine_Storage/commit/${{ github.sha }})
- ${{ github.event.head_commit.message }}
- draft: false
- prerelease: false
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- # 上传x86的zip包作为发布的artifacts
- - name: Upload x86 Release Asset
- uses: actions/upload-release-asset@v1
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- with:
- upload_url: ${{ steps.create_release.outputs.upload_url }}
- asset_path: ./XEngine_StorageApp-x86-Windows.zip
- asset_name: XEngine_StorageApp-x86-Windows.zip
- asset_content_type: application/zip
+ 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/
+ cd XEngine_Release
+ ./VSCopy_x86.bat
+ ./XEngine_StorageApp.exe -t
+ shell: pwsh
diff --git a/CHANGELOG b/CHANGELOG
index 9449c0f..a972f59 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,45 @@
+XEngine_Storage V3.17.0.1001
+
+added:workflows support
+added:start test parameter supported
+added:crash core-dump support for windows
+added:implement encryption and decryption for http basic and digest
+update:sub module library
+improved:start parameter parse
+modify:enum file function match to xengine v8.42
+modify:The upload speed limit is now processed using a new mode, network events + algorithm events, and will not affect other network clients
+fixed:build error on mac os
+fixed:vs Problems with incorrect generation order
+fixed:crash when exist service
+delete:user local authorize and just use proxy api authorize
+
+增加:工作流支持
+增加:启动参数测试支持
+增加:windows coredump支持
+增加:HTTP基本和摘要加解密实现
+更新:子模块支持库
+优化:启动参数优化
+修改:匹配了代码库版本到XEngine V8.42
+修改:上传限速使用了新的方法,网络事件+算法事件,不会影响其他客户端了
+修正:mac系统编译问题
+修正:生成顺序问题
+修正:某些时候退出崩溃问题
+删除:本地验证支持并且验证只使用代理授权验证
+======================================================================================
+XEngine_Storage V3.16.0.1001
+
+增加:上传接口文件准备支持
+增加:webdav协议支持:OPTIONS POST GET PUT PROPFIND PROPPATCH DELETE LOCK UNLOCK
+增加:XML的子模块
+修正:可能跳过存储KEY名称的错误返回
+修正:APIHelp_Distributed_DLStorage 某些时候文件名称和key不正确导致的问题
+
+added:upload create ready supported
+added:webdav protocol support:OPTIONS POST GET PUT PROPFIND PROPPATCH DELETE LOCK UNLOCK
+add:xml module form sub module
+fixed:maybe return error bucket when input mistake storage key
+fixed:APIHelp_Distributed_DLStorage sometime is file name and key is incorrect
+======================================================================================
XEngine_Storage V3.15.0.1001
增加:用户上传下载动作支持
diff --git a/README.en.md b/README.en.md
index 3c244a0..9ad95fd 100644
--- a/README.en.md
+++ b/README.en.md
@@ -22,7 +22,7 @@ feature list:
5. support load banace
6. supprot http auth
7. support log and config
-8. supprot speeds contral
+8. Support multi-threaded file upload and download
9. supprot task start and end proxy forwarding
10. support p2p
11. bt protocol
@@ -40,11 +40,11 @@ feature list:
#### XEngine Evn
you must install XEngine,need V8.10 or above,install XEngine can be refer to xengine Readme docment
-GITEE:https://gitee.com/xyry/libxengine
-GITHUB:https://github.com/libxengine/xengine
+GITEE:https://gitee.com/libxengine/libxengine
+GITHUB:https://github.com/libxengine/libxengine
##### fast to deployment
-git clone https://gitee.com/xyry/libxengine.git or git clone https://github.com/libxengine/xengine.git
+git clone https://gitee.com/libxengine/libxengine.git or git clone https://github.com/libxengine/libxengine.git
window Exection XEngine_WINEnv.bat
Linux Exection:sudo ./XEngine_LINEnv.sh -i 3
Macos Exection:./XEngine_LINEnv.sh -i 3
@@ -104,9 +104,6 @@ P2P distributed download is the same as the hyper-threaded download of other dow
UPLoad File: curl -d 'hello xengine' -X POST "http://192.168.1.8:5102/api?filename=hello.txt&storeagekey=storagekey1"
Download File: curl -X GET "http://192.168.1.8:5101/storagekey1/hello.txt"
-## now task
-P2P WAN file search and download support
-
## Installation Instructions
#### Install
Modify the configuration file to what you need, and then run the service directly
diff --git a/README.md b/README.md
index ccc04fe..63c7f5b 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ c c++ file storage service
5. 支持分布式
6. 支持HTTP验证
7. 支持详尽的日志和配置信息
-8. 支持传输速率控制
+8. 支持多线程方式上传和下载文件
9. 支持任务开始结束代理转发
10. 支持P2P
11. BT协议
@@ -39,11 +39,11 @@ c c++ file storage service
#### XEngine环境
必须安装XEngine,版本需要V8.10或者以上版本,安装XEngine可以参考其Readme文档
-GITEE:https://gitee.com/xyry/libxengine
-GITHUB:https://github.com/libxengine/xengine
+GITEE:https://gitee.com/libxengine/libxengine
+GITHUB:https://github.com/libxengine/libxengine
###### 快速部署
-git clone https://gitee.com/xyry/libxengine.git 或者 git clone https://github.com/libxengine/xengine.git
+git clone https://gitee.com/libxengine/libxengine.git 或者 git clone https://github.com/libxengine/libxengine.git
window执行XEngine_WINEnv.bat 脚本.
Linux执行:sudo ./XEngine_LINEnv.sh -i 3
macos执行:./XEngine_LINEnv.sh -i 3
@@ -52,7 +52,7 @@ macos执行:./XEngine_LINEnv.sh -i 3
由于依赖的子模块,在你checkout仓库后,在仓库目录下执行下面的命令拉取子模块
git submodule init
git submodule update
-如果github访问失败,也可以在XEngine_Source\XEngine_Depend 下直接clone项目:git clone https://gitee.com/xengine/XEngine_OPenSource.git
+如果github访问失败,你也可以clone该项目,在主目录下使用命令:git clone https://gitee.com/xengine/XEngine_OPenSource.git XEngine_Source/XEngine_Depend
#### Windows
使用VS打开并且编译,支持WINDOWS 7SP1以上系统
@@ -104,10 +104,6 @@ make FLAGS=CleanAll 清理编译
P2P分布式下载已经支持,不过目前只能在局域网中,暂时不支持跨网段,需要等待开发完毕
P2P分布式下载与其他下载工具的超线程下载一样,原理是使用HTTP RANGE字段实现.各位可以通过libcurl等库实现此功能.
-## 当前任务
-P2P广域网文件查找与下载支持
-分布式数据库存储
-
## 安装指导
#### 安装
修改配置文件为你需要的,然后直接运行服务即可
diff --git a/XEngine_Docment/Docment_en.docx b/XEngine_Docment/Docment_en.docx
index caf3dce..0af9242 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 3b4cbd4..a90e6bf 100644
Binary files a/XEngine_Docment/Docment_zh.docx and b/XEngine_Docment/Docment_zh.docx differ
diff --git a/XEngine_Release/XEngine_Config/UserList.txt b/XEngine_Release/XEngine_Config/UserList.txt
deleted file mode 100644
index 26cbaa4..0000000
--- a/XEngine_Release/XEngine_Config/UserList.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-123123aa 123123 1024000
-aaadddzxc 123123 1024000
\ No newline at end of file
diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json
index fa4c53c..7b68660 100644
--- a/XEngine_Release/XEngine_Config/XEngine_Config.json
+++ b/XEngine_Release/XEngine_Config/XEngine_Config.json
@@ -39,12 +39,6 @@
"bUPHash":false,
"nHashMode":2
},
- "XAuth":{
- "bUPAuth":false,
- "bDLAuth":false,
- "bCHAuth":false,
- "tszUserList":"./XEngine_Config/UserList.txt"
- },
"XProxy":{
"bUPPass":false,
"bDLPass":false,
@@ -55,7 +49,7 @@
},
"XLimit":{
"bLimitMode":true,
- "nMaxUPLoad":4096000,
+ "nMaxUPLoad":0,
"nMaxDNLoad":4096000,
"nMaxUPConnect":2,
"nMaxDNConnect":2
diff --git a/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json b/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json
index ddf0fff..7a931bc 100644
--- a/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json
+++ b/XEngine_Release/XEngine_Config/XEngine_VersionConfig.json
@@ -1,5 +1,6 @@
{
"XVer":[
+ "3.17.0.1001 Build20241106",
"3.16.0.1001 Build20240813",
"3.15.0.1001 Build20240511",
"3.14.0.1001 Build20240418",
diff --git a/XEngine_Release/XEngine_Coredump/.gitignore b/XEngine_Release/XEngine_Coredump/.gitignore
new file mode 100644
index 0000000..e69de29
diff --git a/XEngine_Source/Makefile b/XEngine_Source/Makefile
index 5a2b58a..a538573 100644
--- a/XEngine_Source/Makefile
+++ b/XEngine_Source/Makefile
@@ -16,6 +16,12 @@ BASE_BTORRENT_PATH = ./StorageModule_BTorrent
APPSERVICE_STORAGE_PATH = ./XEngine_StorageApp
+ifeq ($(PLATFORM),linux)
+ FILEEXT = so
+else ifeq ($(PLATFORM),mac)
+ FILEEXT = dylib
+endif
+
XENGINE_MODULES = libjsoncpp.so libtinyxml2.so libXEngine_InfoReport.so \
libStorageModule_Database.so libStorageModule_Config.so libStorageModule_Session.so libStorageModule_APIHelp.so libStorageModule_Protocol.so libStorageModule_BTorrent.so \
XEngine_StorageApp.exe
@@ -23,21 +29,22 @@ XENGINE_MODULES = libjsoncpp.so libtinyxml2.so libXEngine_InfoReport.so
.PHONY:MakeAll
MakeAll:$(XENGINE_MODULES)
+
libjsoncpp.so:
ifeq ($(FLAGS), InstallAll)
- cp $(THIRD_JSONCPP_PATH)/libjsoncpp.so ../XEngine_Release/
+ cp $(THIRD_JSONCPP_PATH)/libjsoncpp.$(FILEEXT) ../XEngine_Release/
else
make -C $(THIRD_JSONCPP_PATH) PLATFORM=$(PLATFORM) $(FLAGS)
endif
libtinyxml2.so:
ifeq ($(FLAGS), InstallAll)
- cp $(THIRD_TINYXML_PATH)/libtinyxml2.so ../XEngine_Release/
+ cp $(THIRD_TINYXML_PATH)/libtinyxml2.$(FILEEXT) ../XEngine_Release/
else
make -C $(THIRD_TINYXML_PATH) PLATFORM=$(PLATFORM) $(FLAGS)
endif
libXEngine_InfoReport.so:
ifeq ($(FLAGS), InstallAll)
- cp $(THIRD_REPORT_PATH)/libXEngine_InfoReport.so ../XEngine_Release/
+ cp $(THIRD_REPORT_PATH)/libXEngine_InfoReport.$(FILEEXT) ../XEngine_Release/
else
make -C $(THIRD_REPORT_PATH) PLATFORM=$(PLATFORM) $(FLAGS)
endif
diff --git a/XEngine_Source/StorageModule_APIHelp/APIHelp_Api/APIHelp_Api.cpp b/XEngine_Source/StorageModule_APIHelp/APIHelp_Api/APIHelp_Api.cpp
index 3a59f60..bec41bd 100644
--- a/XEngine_Source/StorageModule_APIHelp/APIHelp_Api/APIHelp_Api.cpp
+++ b/XEngine_Source/StorageModule_APIHelp/APIHelp_Api/APIHelp_Api.cpp
@@ -76,7 +76,7 @@ bool CAPIHelp_Api::APIHelp_Api_ProxyAuth(XCHAR* ptszUser, XCHAR* ptszPass, XCHAR
APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_NOTSUPPORT;
return false;
}
- OPenSsl_Help_BasicDecoder(tszAuthStr, ptszUser, ptszPass);
+ APIHelp_Cryption_BasicDecoder(tszAuthStr, ptszUser, ptszPass);
return true;
}
/********************************************************************
@@ -430,23 +430,9 @@ bool CAPIHelp_Api::APIHelp_Api_GetDIRSize(LPCXSTR lpszDIRStr, __int64u* pInt_DIR
APIHelp_IsErrorOccur = false;
int nListCount = 0;
- int nPathType = 0;
__int64u nDirCount = 0; //当前目录大小
XCHAR** ppListFile;
- XCHAR tszFilePath[MAX_PATH] = {};
-
- _tcsxcpy(tszFilePath, lpszDIRStr);
- BaseLib_OperatorString_GetPath(tszFilePath, &nPathType);
- //判断是绝对路径还是相对路径
- if (1 == nPathType)
- {
- _tcsxcat(tszFilePath, _X("\\*"));
- }
- else if (2 == nPathType)
- {
- _tcsxcat(tszFilePath, _X("/*"));
- }
- SystemApi_File_EnumFile(tszFilePath, &ppListFile, &nListCount, true, 1);
+ SystemApi_File_EnumFile(lpszDIRStr, &ppListFile, &nListCount, true, 1);
for (int i = 0; i < nListCount; i++)
{
struct _xtstat st_FStat;
diff --git a/XEngine_Source/StorageModule_APIHelp/APIHelp_Cryption/APIHelp_Cryption.cpp b/XEngine_Source/StorageModule_APIHelp/APIHelp_Cryption/APIHelp_Cryption.cpp
new file mode 100644
index 0000000..5701a17
--- /dev/null
+++ b/XEngine_Source/StorageModule_APIHelp/APIHelp_Cryption/APIHelp_Cryption.cpp
@@ -0,0 +1,237 @@
+#include "pch.h"
+#include "APIHelp_Cryption.h"
+/********************************************************************
+// Created: 2024/10/29 11:43:48
+// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_APIHelp\APIHelp_Cryption\APIHelp_Cryption.cpp
+// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_APIHelp\APIHelp_Cryption
+// File Base: APIHelp_Cryption
+// File Ext: cpp
+// Project: XEngine(网络通信引擎)
+// Author: qyt
+// Purpose: 加解密帮助函数
+// History:
+*********************************************************************/
+CAPIHelp_Cryption::CAPIHelp_Cryption()
+{
+}
+CAPIHelp_Cryption::~CAPIHelp_Cryption()
+{
+}
+//////////////////////////////////////////////////////////////////////////
+// 公有函数
+//////////////////////////////////////////////////////////////////////////
+/********************************************************************
+函数名称:APIHelp_Cryption_BasicEncoder
+函数功能:HTTP基本验证加密函数
+ 参数.一:lpszUser
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入用户名
+ 参数.二:lpszPass
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入密码
+ 参数.三:ptszMsgBuffer
+ In/Out:In
+ 类型:字符指针
+ 可空:N
+ 意思:输出加密后的缓冲区
+ 参数.四:bADD
+ In/Out:In
+ 类型:逻辑型
+ 可空:N
+ 意思:是否添加验证算法类型
+返回值
+ 类型:逻辑型
+ 意思:是否成功
+备注:格式:Basic BASE64
+*********************************************************************/
+bool CAPIHelp_Cryption::APIHelp_Cryption_BasicEncoder(LPCXSTR lpszUser, LPCXSTR lpszPass, XCHAR* ptszMsgBuffer, bool bADD /* = true */)
+{
+ APIHelp_IsErrorOccur = false;
+
+ if ((NULL == lpszUser) || (NULL == lpszPass) || (NULL == ptszMsgBuffer))
+ {
+ APIHelp_IsErrorOccur = true;
+ APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_PARAMENT;
+ return false;
+ }
+ XCHAR tszMsgBuffer[2048];
+ XCHAR tszBaseBuffer[2048];
+
+ memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
+ memset(tszBaseBuffer, '\0', sizeof(tszBaseBuffer));
+
+ int nLen = _xstprintf(tszMsgBuffer, _X("%s:%s"), lpszUser, lpszPass);
+ if (!OPenSsl_Codec_Base64(tszMsgBuffer, tszBaseBuffer, &nLen))
+ {
+ return false;
+ }
+ if (bADD)
+ {
+ _xstprintf(ptszMsgBuffer, _X("Basic %s"), tszBaseBuffer);
+ }
+ else
+ {
+ _tcsxcpy(ptszMsgBuffer, tszBaseBuffer);
+ }
+ return true;
+}
+/********************************************************************
+函数名称:APIHelp_Cryption_BasicDecoder
+函数功能:HTTP基本验证解密函数
+ 参数.一:lpszMsgBuffer
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入要解密的缓冲区
+ 参数.二:ptszUser
+ In/Out:Out
+ 类型:字符指针
+ 可空:N
+ 意思:输出用户名
+ 参数.三:ptszPass
+ In/Out:Out
+ 类型:字符指针
+ 可空:N
+ 意思:输出密码
+返回值
+ 类型:逻辑型
+ 意思:是否成功
+备注:HttpProtocol_ServerHelp_GetAuthInfo 返回的内容
+ 格式:Basic BASE64
+*********************************************************************/
+bool CAPIHelp_Cryption::APIHelp_Cryption_BasicDecoder(LPCXSTR lpszMsgBuffer, XCHAR* ptszUser, XCHAR* ptszPass)
+{
+ APIHelp_IsErrorOccur = false;
+
+ if ((NULL == lpszMsgBuffer) || (NULL == ptszUser) || (NULL == ptszPass))
+ {
+ APIHelp_IsErrorOccur = true;
+ APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_PARAMENT;
+ return false;
+ }
+ XCHAR tszBaseBuffer[2048];
+ memset(tszBaseBuffer, '\0', sizeof(tszBaseBuffer));
+ //是否有Basic
+ if (NULL == _tcsxstr(lpszMsgBuffer, _X("Basic")))
+ {
+ int nMsgLen = _tcsxlen(lpszMsgBuffer);
+ if (!OPenSsl_Codec_Base64(lpszMsgBuffer, tszBaseBuffer, &nMsgLen, false))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ int nMsgLen = _tcsxlen(lpszMsgBuffer) - 6;
+ if (!OPenSsl_Codec_Base64(lpszMsgBuffer + 6, tszBaseBuffer, &nMsgLen, false))
+ {
+ return false;
+ }
+ }
+ //分割用户名和密码
+ XCHAR* ptszPassString = NULL;
+ XCHAR* ptszUserString = _tcsxtok_s(tszBaseBuffer, _X(":"), &ptszPassString);
+ if (NULL == ptszUserString)
+ {
+ APIHelp_IsErrorOccur = true;
+ APIHelp_dwErrorCode = ERROR_STORAGE_MODULE_APIHELP_FORMAT;
+ return false;
+ }
+ _tcsxcpy(ptszUser, ptszUserString);
+ _tcsxcpy(ptszPass, ptszPassString);
+
+ return true;
+}
+/********************************************************************
+函数名称:APIHelp_Cryption_Digest
+函数功能:摘要计算函数
+ 参数.一:ptszResponseStr
+ In/Out:Out
+ 类型:字符指针
+ 可空:N
+ 意思:输出计算后的RESPONSE字符串
+ 参数.二:lpszUser
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入用户名
+ 参数.三:lpszPass
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入密码
+ 参数.四:lpszRealm
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入作用域,服务器发送的
+ 参数.五:lpszMethod
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入请求的方法
+ 参数.六:lpszUrl
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入请求的URL地址
+ 参数.七:lpszNonce
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:服务器生成并且发送的
+ 参数.八:lpszCNonce
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:客户端生成的随机字符串
+ 参数.九:lpszNC
+ In/Out:In
+ 类型:常量字符指针
+ 可空:Y
+ 意思:验证的次数,建议为NULL.
+返回值
+ 类型:逻辑型
+ 意思:是否成功
+备注:信息摘要支持QOP=AUTH 算法MD5的验证模式
+*********************************************************************/
+bool CAPIHelp_Cryption::APIHelp_Cryption_Digest(XCHAR* ptszResponseStr, LPCXSTR lpszUser, LPCXSTR lpszPass, LPCXSTR lpszRealm, LPCXSTR lpszMethod, LPCXSTR lpszUrl, LPCXSTR lpszNonce, LPCXSTR lpszCNonce, LPCXSTR lpszNC /* = NULL */)
+{
+ APIHelp_IsErrorOccur = false;
+
+ XCHAR tszResponseStr[2048];
+ XBYTE tszResponseMD5[2048];
+ XBYTE tszUserMD5[MAX_PATH];
+ XBYTE tszUrlMD5[MAX_PATH];
+ XCHAR tszUserStr[MAX_PATH];
+ XCHAR tszUrlStr[MAX_PATH];
+ XCHAR tszUserHex[MAX_PATH];
+ XCHAR tszUrlHex[MAX_PATH];
+
+ memset(tszResponseStr, '\0', sizeof(tszResponseStr));
+ memset(tszResponseMD5, '\0', sizeof(tszResponseMD5));
+ memset(tszUserMD5, '\0', MAX_PATH);
+ memset(tszUrlMD5, '\0', MAX_PATH);
+ memset(tszUserStr, '\0', MAX_PATH);
+ memset(tszUrlStr, '\0', MAX_PATH);
+ memset(tszUserHex, '\0', MAX_PATH);
+ memset(tszUrlHex, '\0', MAX_PATH);
+
+ //计算HA1 的MD5字符串 MD5(USER:PASS:REAL)
+ int nRet = _xstprintf(tszUserStr, _X("%s:%s:%s"), lpszUser, lpszRealm, lpszPass);
+ OPenSsl_Api_Digest(tszUserStr, tszUserMD5, &nRet);
+ BaseLib_OperatorString_StrToHex((XCHAR*)tszUserMD5, nRet, tszUserHex);
+ //计算HA2 的MD5字符串,根据验证模式来计算
+ nRet = _xstprintf(tszUrlStr, _X("%s:%s"), lpszMethod, lpszUrl);
+ OPenSsl_Api_Digest(tszUrlStr, tszUrlMD5, &nRet);
+ BaseLib_OperatorString_StrToHex((XCHAR*)tszUrlMD5, nRet, tszUrlHex);
+ //计算RESPONSE值
+ nRet = _xstprintf(tszResponseStr, _X("%s:%s:%s:%s:auth:%s"), tszUserHex, lpszNonce, lpszNC, lpszCNonce, tszUrlHex);
+ OPenSsl_Api_Digest(tszResponseStr, tszResponseMD5, &nRet);
+ BaseLib_OperatorString_StrToHex((XCHAR*)tszResponseMD5, nRet, ptszResponseStr);
+ return true;
+}
\ No newline at end of file
diff --git a/XEngine_Source/StorageModule_APIHelp/APIHelp_Cryption/APIHelp_Cryption.h b/XEngine_Source/StorageModule_APIHelp/APIHelp_Cryption/APIHelp_Cryption.h
new file mode 100644
index 0000000..9d9fed1
--- /dev/null
+++ b/XEngine_Source/StorageModule_APIHelp/APIHelp_Cryption/APIHelp_Cryption.h
@@ -0,0 +1,23 @@
+#pragma once
+/********************************************************************
+// Created: 2024/10/29 11:43:31
+// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_APIHelp\APIHelp_Cryption\APIHelp_Cryption.h
+// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_APIHelp\APIHelp_Cryption
+// File Base: APIHelp_Cryption
+// File Ext: h
+// Project: XEngine(网络通信引擎)
+// Author: qyt
+// Purpose: 加解密帮助函数
+// History:
+*********************************************************************/
+
+class CAPIHelp_Cryption
+{
+public:
+ CAPIHelp_Cryption();
+ ~CAPIHelp_Cryption();
+public:
+ bool APIHelp_Cryption_BasicEncoder(LPCXSTR lpszUser, LPCXSTR lpszPass, XCHAR* ptszMsgBuffer, bool bADD = true);
+ bool APIHelp_Cryption_BasicDecoder(LPCXSTR lpszMsgBuffer, XCHAR* ptszUser, XCHAR* ptszPass);
+ bool APIHelp_Cryption_Digest(XCHAR* ptszResponseStr, LPCXSTR lpszUser, LPCXSTR lpszPass, LPCXSTR lpszRealm, LPCXSTR lpszMethod, LPCXSTR lpszUrl, LPCXSTR lpszNonce, LPCXSTR lpszCNonce, LPCXSTR lpszNC = NULL);
+};
diff --git a/XEngine_Source/StorageModule_APIHelp/APIHelp_Define.h b/XEngine_Source/StorageModule_APIHelp/APIHelp_Define.h
index 5b10dc2..dbebf30 100644
--- a/XEngine_Source/StorageModule_APIHelp/APIHelp_Define.h
+++ b/XEngine_Source/StorageModule_APIHelp/APIHelp_Define.h
@@ -370,4 +370,115 @@ extern "C" bool APIHelp_Api_GetDIRSize(LPCXSTR lpszDIRStr, __int64u* pInt_DIRSiz
意思:是否成功
备注:
*********************************************************************/
-extern "C" bool APIHelp_Api_UrlStr(XCHAR* ptszKeyStr, LPCXSTR lpszUrl);
\ No newline at end of file
+extern "C" bool APIHelp_Api_UrlStr(XCHAR* ptszKeyStr, LPCXSTR lpszUrl);
+/************************************************************************/
+/* 加解密函数 */
+/************************************************************************/
+/********************************************************************
+函数名称:APIHelp_Cryption_BasicEncoder
+函数功能:HTTP基本验证加密函数
+ 参数.一:lpszUser
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入用户名
+ 参数.二:lpszPass
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入密码
+ 参数.三:ptszMsgBuffer
+ In/Out:In
+ 类型:字符指针
+ 可空:N
+ 意思:输出加密后的缓冲区
+ 参数.四:bADD
+ In/Out:In
+ 类型:逻辑型
+ 可空:N
+ 意思:是否添加验证算法类型
+返回值
+ 类型:逻辑型
+ 意思:是否成功
+备注:格式:Basic BASE64
+*********************************************************************/
+extern "C" bool APIHelp_Cryption_BasicEncoder(LPCXSTR lpszUser, LPCXSTR lpszPass, XCHAR* ptszMsgBuffer, bool bADD = true);
+/********************************************************************
+函数名称:APIHelp_Cryption_BasicDecoder
+函数功能:HTTP基本验证解密函数
+ 参数.一:lpszMsgBuffer
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入要解密的缓冲区
+ 参数.二:ptszUser
+ In/Out:Out
+ 类型:字符指针
+ 可空:N
+ 意思:输出用户名
+ 参数.三:ptszPass
+ In/Out:Out
+ 类型:字符指针
+ 可空:N
+ 意思:输出密码
+返回值
+ 类型:逻辑型
+ 意思:是否成功
+备注:HttpProtocol_ServerHelp_GetAuthInfo 返回的内容
+ 格式:Basic BASE64
+*********************************************************************/
+extern "C" bool APIHelp_Cryption_BasicDecoder(LPCXSTR lpszMsgBuffer, XCHAR* ptszUser, XCHAR* ptszPass);
+/********************************************************************
+函数名称:APIHelp_Cryption_Digest
+函数功能:摘要计算函数
+ 参数.一:ptszResponseStr
+ In/Out:Out
+ 类型:字符指针
+ 可空:N
+ 意思:输出计算后的RESPONSE字符串
+ 参数.二:lpszUser
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入用户名
+ 参数.三:lpszPass
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入密码
+ 参数.四:lpszRealm
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入作用域,服务器发送的
+ 参数.五:lpszMethod
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入请求的方法
+ 参数.六:lpszUrl
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入请求的URL地址
+ 参数.七:lpszNonce
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:服务器生成并且发送的
+ 参数.八:lpszCNonce
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:客户端生成的随机字符串
+ 参数.九:lpszNC
+ In/Out:In
+ 类型:常量字符指针
+ 可空:Y
+ 意思:验证的次数,建议为NULL.
+返回值
+ 类型:逻辑型
+ 意思:是否成功
+备注:信息摘要支持QOP=AUTH 算法MD5的验证模式
+*********************************************************************/
+extern "C" bool APIHelp_Cryption_Digest(XCHAR* ptszResponseStr, LPCXSTR lpszUser, LPCXSTR lpszPass, LPCXSTR lpszRealm, LPCXSTR lpszMethod, LPCXSTR lpszUrl, LPCXSTR lpszNonce, LPCXSTR lpszCNonce, LPCXSTR lpszNC = NULL);
\ No newline at end of file
diff --git a/XEngine_Source/StorageModule_APIHelp/APIHelp_Error.h b/XEngine_Source/StorageModule_APIHelp/APIHelp_Error.h
index 14ac1c5..f615b62 100644
--- a/XEngine_Source/StorageModule_APIHelp/APIHelp_Error.h
+++ b/XEngine_Source/StorageModule_APIHelp/APIHelp_Error.h
@@ -21,4 +21,5 @@
#define ERROR_STORAGE_MODULE_APIHELP_NOTHASH 0x0030014 //没有HASH值
#define ERROR_STORAGE_MODULE_APIHELP_NOTMATCH 0x0030015 //HASH不匹配
#define ERROR_STORAGE_MODULE_APIHELP_SIZE 0x0030016 //目录大小已经满了
-#define ERROR_STORAGE_MODULE_APIHELP_CODE 0x0030017 //服务器返回失败
\ No newline at end of file
+#define ERROR_STORAGE_MODULE_APIHELP_CODE 0x0030017 //服务器返回失败
+#define ERROR_STORAGE_MODULE_APIHELP_FORMAT 0x0030018 //格式化失败
\ No newline at end of file
diff --git a/XEngine_Source/StorageModule_APIHelp/Makefile b/XEngine_Source/StorageModule_APIHelp/Makefile
index 826689c..d1a9981 100644
--- a/XEngine_Source/StorageModule_APIHelp/Makefile
+++ b/XEngine_Source/StorageModule_APIHelp/Makefile
@@ -10,14 +10,19 @@ LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp
LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp
LIB = -lXEngine_BaseLib -lXEngine_OPenSsl -lRfcComponents_HttpProtocol -lXEngine_SystemApi -ljsoncpp
LIBEX =
-OBJECTS = APIHelp_Distributed.o APIHelp_Api.o pch.o
+OBJECTS = APIHelp_Distributed.o APIHelp_Api.o APIHelp_Cryption.o pch.o
ifeq ($(RELEASE),1)
FLAGS = -c
DEBUG =
else
-FLAGS = -c -lc_p
-DEBUG = -g -pg
+ ifeq ($(PLATFORM),mac)
+ FLAGS = -c
+ DEBUG = -g
+ else
+ FLAGS = -c -lc_p
+ DEBUG = -g -pg
+ endif
endif
ifeq ($(UNICODE),1)
@@ -55,6 +60,8 @@ APIHelp_Distributed.o:./APIHelp_Distributed/APIHelp_Distributed.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./APIHelp_Distributed/APIHelp_Distributed.cpp
APIHelp_Api.o:./APIHelp_Api/APIHelp_Api.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./APIHelp_Api/APIHelp_Api.cpp
+APIHelp_Cryption.o:./APIHelp_Cryption/APIHelp_Cryption.cpp
+ $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./APIHelp_Cryption/APIHelp_Cryption.cpp
pch.o:./pch.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./pch.cpp
diff --git a/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj b/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj
index fab0354..ac648c5 100644
--- a/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj
+++ b/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj
@@ -169,6 +169,7 @@
+
@@ -177,6 +178,7 @@
+
diff --git a/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj.filters b/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj.filters
index 14ad6f8..3f3cae4 100644
--- a/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj.filters
+++ b/XEngine_Source/StorageModule_APIHelp/StorageModule_APIHelp.vcxproj.filters
@@ -25,6 +25,12 @@
{70c91174-907f-422b-8db6-f8ee8298447c}
+
+ {1db63e4d-1a66-425d-8ec3-464e7980c4ae}
+
+
+ {78596bd9-1685-40fa-83af-fd179d268bf0}
+
@@ -45,6 +51,9 @@
头文件\APIHelp_Api
+
+ 头文件\APIHelp_Cryption
+
@@ -59,6 +68,9 @@
源文件\APIHelp_Api
+
+ 源文件\APIHelp_Cryption
+
diff --git a/XEngine_Source/StorageModule_APIHelp/pch.cpp b/XEngine_Source/StorageModule_APIHelp/pch.cpp
index de51b8e..48d651a 100644
--- a/XEngine_Source/StorageModule_APIHelp/pch.cpp
+++ b/XEngine_Source/StorageModule_APIHelp/pch.cpp
@@ -1,6 +1,7 @@
#include "pch.h"
#include "APIHelp_Distributed/APIHelp_Distributed.h"
#include "APIHelp_Api/APIHelp_Api.h"
+#include "APIHelp_Cryption/APIHelp_Cryption.h"
/********************************************************************
// Created: 2021/07/08 16:40:04
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_APIHelp\pch.cpp
@@ -17,6 +18,7 @@ XLONG APIHelp_dwErrorCode = 0;
//////////////////////////////////////////////////////////////////////////
CAPIHelp_Distributed m_APIDistributed;
CAPIHelp_Api m_APIHelp;
+CAPIHelp_Cryption m_APICryption;
//////////////////////////////////////////////////////////////////////////
// 导出函数
//////////////////////////////////////////////////////////////////////////
@@ -89,4 +91,19 @@ extern "C" bool APIHelp_Api_GetDIRSize(LPCXSTR lpszDIRStr, __int64u * pInt_DIRSi
extern "C" bool APIHelp_Api_UrlStr(XCHAR* ptszKeyStr, LPCXSTR lpszUrl)
{
return m_APIHelp.APIHelp_Api_UrlStr(ptszKeyStr, lpszUrl);
+}
+/************************************************************************/
+/* 加解密函数 */
+/************************************************************************/
+extern "C" bool APIHelp_Cryption_BasicEncoder(LPCXSTR lpszUser, LPCXSTR lpszPass, XCHAR* ptszMsgBuffer, bool bADD)
+{
+ return m_APICryption.APIHelp_Cryption_BasicEncoder(lpszUser, lpszPass, ptszMsgBuffer, bADD);
+}
+extern "C" bool APIHelp_Cryption_BasicDecoder(LPCXSTR lpszMsgBuffer, XCHAR* ptszUser, XCHAR* ptszPass)
+{
+ return m_APICryption.APIHelp_Cryption_BasicDecoder(lpszMsgBuffer, ptszUser, ptszPass);
+}
+extern "C" bool APIHelp_Cryption_Digest(XCHAR* ptszResponseStr, LPCXSTR lpszUser, LPCXSTR lpszPass, LPCXSTR lpszRealm, LPCXSTR lpszMethod, LPCXSTR lpszUrl, LPCXSTR lpszNonce, LPCXSTR lpszCNonce, LPCXSTR lpszNC)
+{
+ return m_APICryption.APIHelp_Cryption_Digest(ptszResponseStr, lpszUser, lpszPass, lpszRealm, lpszMethod, lpszUrl, lpszNonce, lpszCNonce, lpszNC);
}
\ No newline at end of file
diff --git a/XEngine_Source/StorageModule_BTorrent/Makefile b/XEngine_Source/StorageModule_BTorrent/Makefile
index cd7f043..7afe90b 100644
--- a/XEngine_Source/StorageModule_BTorrent/Makefile
+++ b/XEngine_Source/StorageModule_BTorrent/Makefile
@@ -44,8 +44,13 @@ ifeq ($(RELEASE),1)
FLAGS = -c
DEBUG =
else
-FLAGS = -c -lc_p
-DEBUG = -g -pg
+ ifeq ($(PLATFORM),mac)
+ FLAGS = -c
+ DEBUG = -g
+ else
+ FLAGS = -c -lc_p
+ DEBUG = -g -pg
+ endif
endif
ifeq ($(UNICODE),1)
diff --git a/XEngine_Source/StorageModule_Config/Config_Define.h b/XEngine_Source/StorageModule_Config/Config_Define.h
index 7956a65..12a9525 100644
--- a/XEngine_Source/StorageModule_Config/Config_Define.h
+++ b/XEngine_Source/StorageModule_Config/Config_Define.h
@@ -66,13 +66,6 @@ typedef struct tag_XEngine_ServerConfig
bool bUPHash;
int nHashMode;
}st_XStorage;
- struct
- {
- bool bUPAuth;
- bool bDLAuth;
- bool bCHAuth;
- XCHAR tszUserList[MAX_PATH];
- }st_XAuth;
struct
{
bool bUPPass;
diff --git a/XEngine_Source/StorageModule_Config/Config_Error.h b/XEngine_Source/StorageModule_Config/Config_Error.h
index 7c0b4f1..c7bdff0 100644
--- a/XEngine_Source/StorageModule_Config/Config_Error.h
+++ b/XEngine_Source/StorageModule_Config/Config_Error.h
@@ -24,7 +24,6 @@
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_XPROXY 0x0020009
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_P2XP 0x002000A
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_CERT 0x002000B
-#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_XAUTH 0x002000C
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_CREPORT 0x002000D
#define ERROR_XENGINE_BLOGIC_CONFIG_JSON_LBDISTRIBUTED 0x0020010
diff --git a/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp b/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp
index af1ef4d..8c4b215 100644
--- a/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp
+++ b/XEngine_Source/StorageModule_Config/Config_Json/Config_Json.cpp
@@ -167,18 +167,6 @@ bool CConfig_Json::Config_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVERCONFIG
_tcsxcpy(pSt_ServerConfig->st_XProxy.tszUPPass, st_JsonXProxy["tszUPPass"].asCString());
_tcsxcpy(pSt_ServerConfig->st_XProxy.tszAuthPass, st_JsonXProxy["tszAuthPass"].asCString());
- if (st_JsonRoot["XAuth"].empty() || (4 != st_JsonRoot["XAuth"].size()))
- {
- Config_IsErrorOccur = true;
- Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_XAUTH;
- return false;
- }
- Json::Value st_JsonXAuth = st_JsonRoot["XAuth"];
- pSt_ServerConfig->st_XAuth.bUPAuth = st_JsonXAuth["bUPAuth"].asInt();
- pSt_ServerConfig->st_XAuth.bDLAuth = st_JsonXAuth["bDLAuth"].asInt();
- pSt_ServerConfig->st_XAuth.bCHAuth = st_JsonXAuth["bCHAuth"].asInt();
- _tcsxcpy(pSt_ServerConfig->st_XAuth.tszUserList, st_JsonXAuth["tszUserList"].asCString());
-
if (st_JsonRoot["XLimit"].empty() || (5 != st_JsonRoot["XLimit"].size()))
{
Config_IsErrorOccur = true;
diff --git a/XEngine_Source/StorageModule_Config/Makefile b/XEngine_Source/StorageModule_Config/Makefile
index 2bf899d..6e493ea 100644
--- a/XEngine_Source/StorageModule_Config/Makefile
+++ b/XEngine_Source/StorageModule_Config/Makefile
@@ -16,8 +16,13 @@ ifeq ($(RELEASE),1)
FLAGS = -c
DEBUG =
else
-FLAGS = -c -lc_p
-DEBUG = -g -pg
+ ifeq ($(PLATFORM),mac)
+ FLAGS = -c
+ DEBUG = -g
+ else
+ FLAGS = -c -lc_p
+ DEBUG = -g -pg
+ endif
endif
ifeq ($(UNICODE),1)
diff --git a/XEngine_Source/StorageModule_Database/Database_Memory/Database_Memory.cpp b/XEngine_Source/StorageModule_Database/Database_Memory/Database_Memory.cpp
index 2212730..d33d522 100644
--- a/XEngine_Source/StorageModule_Database/Database_Memory/Database_Memory.cpp
+++ b/XEngine_Source/StorageModule_Database/Database_Memory/Database_Memory.cpp
@@ -282,13 +282,7 @@ bool CDatabase_Memory::Database_Memory_Flush()
{
int nListCount = 0;
XCHAR** pptszListFile;
- XCHAR tszFoundDir[MAX_PATH];
-
- memset(tszFoundDir, '\0', MAX_PATH);
- _tcsxcpy(tszFoundDir, stl_ListIterator->tszFilePath);
- _tcsxcat(tszFoundDir, _X("/*"));
-
- SystemApi_File_EnumFile(tszFoundDir, &pptszListFile, &nListCount, true, 1);
+ SystemApi_File_EnumFile(stl_ListIterator->tszFilePath, &pptszListFile, &nListCount, true, 1);
for (int i = 0; i < nListCount; i++)
{
int nHashLen = 0;
diff --git a/XEngine_Source/StorageModule_Database/Makefile b/XEngine_Source/StorageModule_Database/Makefile
index aa4ad1a..be77f67 100644
--- a/XEngine_Source/StorageModule_Database/Makefile
+++ b/XEngine_Source/StorageModule_Database/Makefile
@@ -8,7 +8,7 @@ RELEASE = 0
UNICODE = 0
LOADHDR = -I ./ -I ../XEngine_ThirdPart/jsoncpp
LOADSO =
-LIB = -lXEngine_BaseLib -lHelpComponents_DataBase
+LIB = -lXEngine_BaseLib -lXEngine_OPenSsl -lHelpComponents_DataBase -lXEngine_SystemApi
LIBEX =
OBJECTS = Database_File.o Database_Memory.o Database_Help.o pch.o
@@ -16,8 +16,13 @@ ifeq ($(RELEASE),1)
FLAGS = -c
DEBUG =
else
-FLAGS = -c -lc_p
-DEBUG = -g -pg
+ ifeq ($(PLATFORM),mac)
+ FLAGS = -c
+ DEBUG = -g
+ else
+ FLAGS = -c -lc_p
+ DEBUG = -g -pg
+ endif
endif
ifeq ($(UNICODE),1)
diff --git a/XEngine_Source/StorageModule_Database/StorageModule_Database.vcxproj b/XEngine_Source/StorageModule_Database/StorageModule_Database.vcxproj
index 698ec50..39ab4e1 100644
--- a/XEngine_Source/StorageModule_Database/StorageModule_Database.vcxproj
+++ b/XEngine_Source/StorageModule_Database/StorageModule_Database.vcxproj
@@ -72,7 +72,7 @@
true
- $(XEngine_Include);$(IncludePath)
+ $(XEngine_Include);..\StorageModule_Database;$(IncludePath)
$(XEngine_Lib32);$(LibraryPath)
diff --git a/XEngine_Source/StorageModule_Protocol/Makefile b/XEngine_Source/StorageModule_Protocol/Makefile
index be89e9d..a6c1fe8 100644
--- a/XEngine_Source/StorageModule_Protocol/Makefile
+++ b/XEngine_Source/StorageModule_Protocol/Makefile
@@ -7,8 +7,8 @@ LIBFLAG =
RELEASE = 0
UNICODE = 0
LOADHDR = -I ./ -I ../XEngine_Depend/XEngine_Module/jsoncpp -I ../XEngine_Depend/XEngine_Module/tinyxml2
-LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp -L ../XEngine_Depend/XEngine_Module/tinyxml2
-LIB = -lXEngine_BaseLib -ljsoncpp -ltinyxml2
+LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp -L ../XEngine_Depend/XEngine_Module/tinyxml2 -L ../StorageModule_Session -L ../StorageModule_APIHelp
+LIB = -lXEngine_BaseLib -lXEngine_SystemApi -ljsoncpp -ltinyxml2 -lStorageModule_Session -lStorageModule_APIHelp
LIBEX =
OBJECTS = Protocol_StoragePacket.o Protocol_StorageParse.o pch.o
@@ -16,8 +16,13 @@ ifeq ($(RELEASE),1)
FLAGS = -c
DEBUG =
else
-FLAGS = -c -lc_p
-DEBUG = -g -pg
+ ifeq ($(PLATFORM),mac)
+ FLAGS = -c
+ DEBUG = -g
+ else
+ FLAGS = -c -lc_p
+ DEBUG = -g -pg
+ endif
endif
ifeq ($(UNICODE),1)
diff --git a/XEngine_Source/StorageModule_Session/Makefile b/XEngine_Source/StorageModule_Session/Makefile
index 826c1ce..dbd3e63 100644
--- a/XEngine_Source/StorageModule_Session/Makefile
+++ b/XEngine_Source/StorageModule_Session/Makefile
@@ -10,14 +10,19 @@ LOADHDR = -I ./
LOADSO =
LIB = -lXEngine_BaseLib
LIBEX =
-OBJECTS = Session_DLStroage.o Session_UPStroage.o Session_User.o Session_Action.o Session_Webdav.o pch.o
+OBJECTS = Session_DLStroage.o Session_UPStroage.o Session_Action.o Session_Webdav.o pch.o
ifeq ($(RELEASE),1)
FLAGS = -c
DEBUG =
else
-FLAGS = -c -lc_p
-DEBUG = -g -pg
+ ifeq ($(PLATFORM),mac)
+ FLAGS = -c
+ DEBUG = -g
+ else
+ FLAGS = -c -lc_p
+ DEBUG = -g -pg
+ endif
endif
ifeq ($(UNICODE),1)
@@ -56,8 +61,6 @@ Session_DLStroage.o:./Session_Stroage/Session_DLStroage.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./Session_Stroage/Session_DLStroage.cpp
Session_UPStroage.o:./Session_Stroage/Session_UPStroage.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./Session_Stroage/Session_UPStroage.cpp
-Session_User.o:./Session_User/Session_User.cpp
- $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./Session_User/Session_User.cpp
Session_Action.o:./Session_Action/Session_Action.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./Session_Action/Session_Action.cpp
Session_Webdav.o:./Session_Webdav/Session_Webdav.cpp
diff --git a/XEngine_Source/StorageModule_Session/Session_Define.h b/XEngine_Source/StorageModule_Session/Session_Define.h
index fff2aad..ee49025 100644
--- a/XEngine_Source/StorageModule_Session/Session_Define.h
+++ b/XEngine_Source/StorageModule_Session/Session_Define.h
@@ -41,56 +41,6 @@ typedef struct
//////////////////////////////////////////////////////////////////////////
extern "C" XLONG Session_GetLastError(int *pInt_SysError = NULL);
/************************************************************************/
-/* 用户管理导出的函数 */
-/************************************************************************/
-/********************************************************************
-函数名称:Session_User_Init
-函数功能:初始化用户管理器
- 参数.一:lpszUserFile
- In/Out:In
- 类型:常量字符指针
- 可空:N
- 意思:输入用户文件地址
-返回值
- 类型:逻辑型
- 意思:是否成功
-备注:
-*********************************************************************/
-extern "C" bool Session_User_Init(LPCXSTR lpszUserFile);
-/********************************************************************
-函数名称:Session_User_Destory
-函数功能:销毁管理器
-返回值
- 类型:逻辑型
- 意思:是否成功
-备注:
-*********************************************************************/
-extern "C" bool Session_User_Destory();
-/********************************************************************
-函数名称:Session_User_Exist
-函数功能:用户名和密码是否存在
- 参数.一:lpszUser
- In/Out:In
- 类型:常量字符指针
- 可空:N
- 意思:输入要判断的用户名
- 参数.二:lpszPass
- In/Out:In
- 类型:常量字符指针
- 可空:N
- 意思:输入要判断的密码
- 参数.三:pInt_Limit
- In/Out:Out
- 类型:整数型指针
- 可空:Y
- 意思:输出获取到的限速
-返回值
- 类型:逻辑型
- 意思:是否成功
-备注:
-*********************************************************************/
-extern "C" bool Session_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass, int* pInt_Limit = NULL);
-/************************************************************************/
/* 存储会话导出的函数 */
/************************************************************************/
/********************************************************************
@@ -333,22 +283,32 @@ extern "C" bool Session_UPStroage_Destory();
类型:常量字符指针
可空:N
意思:输入文件地址
- 参数.四:nFileSize
+ 参数.四:xhSpeed
+ In/Out:Out
+ 类型:整数型
+ 可空:N
+ 意思:输入限速句柄
+ 参数.五:nFileSize
In/Out:Out
类型:整数型
可空:N
意思:输入文件大小
- 参数.五:bRewrite
+ 参数.六:bRewrite
In/Out:In
类型:整数型
可空:N
意思:是否允许覆写
- 参数.六:nPosStart
+ 参数.七:nSpeedLimit
+ In/Out:In
+ 类型:整数型
+ 可空:Y
+ 意思:输入上传限速速率
+ 参数.八:nPosStart
In/Out:In
类型:整数型
可空:Y
意思:输入起始位置
- 参数.七:nPostEnd
+ 参数.九:nPostEnd
In/Out:In
类型:整数型
可空:Y
@@ -358,7 +318,7 @@ extern "C" bool Session_UPStroage_Destory();
意思:是否成功
备注:
*********************************************************************/
-extern "C" bool Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, __int64x nFileSize, bool bRewrite, int nPosStart = 0, int nPostEnd = 0);
+extern "C" bool Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, XHANDLE xhSpeed, __int64x nFileSize, bool bRewrite, int nSpeedLimit = 0, int nPosStart = 0, int nPostEnd = 0);
/********************************************************************
函数名称:Session_UPStroage_GetInfo
函数功能:获取上传客户端信息
@@ -379,6 +339,20 @@ extern "C" bool Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuc
*********************************************************************/
extern "C" bool Session_UPStroage_GetInfo(LPCXSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo);
/********************************************************************
+函数名称:Session_UPStroage_GetSpeed
+函数功能:获得速率限制句柄
+ 参数.一:lpszClientAddr
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入要操作的客户端
+返回值
+ 类型:句柄
+ 意思:返回速率句柄
+备注:
+*********************************************************************/
+extern "C" XHANDLE Session_UPStroage_GetSpeed(LPCXSTR lpszClientAddr);
+/********************************************************************
函数名称:Session_UPStroage_Write
函数功能:写入数据到文件
参数.一:lpszClientAddr
diff --git a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.cpp b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.cpp
index 8e788f7..b96e984 100644
--- a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.cpp
+++ b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.cpp
@@ -82,22 +82,32 @@ bool CSession_UPStroage::Session_UPStroage_Destory()
类型:常量字符指针
可空:N
意思:输入文件地址
- 参数.四:nFileSize
+ 参数.四:xhSpeed
+ In/Out:Out
+ 类型:整数型
+ 可空:N
+ 意思:输入限速句柄
+ 参数.五:nFileSize
In/Out:Out
类型:整数型
可空:N
意思:输入文件大小
- 参数.五:bRewrite
+ 参数.六:bRewrite
In/Out:In
类型:整数型
可空:N
意思:是否允许覆写
- 参数.六:nPosStart
+ 参数.七:nSpeedLimit
+ In/Out:In
+ 类型:整数型
+ 可空:Y
+ 意思:输入上传限速速率
+ 参数.八:nPosStart
In/Out:In
类型:整数型
可空:Y
意思:输入起始位置
- 参数.七:nPostEnd
+ 参数.九:nPostEnd
In/Out:In
类型:整数型
可空:Y
@@ -107,7 +117,7 @@ bool CSession_UPStroage::Session_UPStroage_Destory()
意思:是否成功
备注:
*********************************************************************/
-bool CSession_UPStroage::Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, __int64x nFileSize, bool bRewrite, int nPosStart /* = 0 */, int nPostEnd /* = 0 */)
+bool CSession_UPStroage::Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, XHANDLE xhSpeed, __int64x nFileSize, bool bRewrite, int nSpeedLimit, int nPosStart , int nPostEnd )
{
Session_IsErrorOccur = false;
@@ -132,9 +142,11 @@ bool CSession_UPStroage::Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXST
SESSION_STORAGEUPLOADER st_Client;
memset(&st_Client, '\0', sizeof(SESSION_STORAGEUPLOADER));
//填充下载信息
+ st_Client.xhSpeed = xhSpeed;
st_Client.st_StorageInfo.ullPosStart = nPosStart;
st_Client.st_StorageInfo.ullPosEnd = nPostEnd;
st_Client.st_StorageInfo.ullCount = nFileSize;
+ st_Client.st_StorageInfo.nLimit = nSpeedLimit;
_tcsxcpy(st_Client.st_StorageInfo.tszBuckKey, lpszBuckKey);
_tcsxcpy(st_Client.st_StorageInfo.tszFileDir, lpszFileDir);
_tcsxcpy(st_Client.st_StorageInfo.tszClientAddr, lpszClientAddr);
@@ -234,6 +246,43 @@ bool CSession_UPStroage::Session_UPStroage_GetInfo(LPCXSTR lpszClientAddr, SESSI
return true;
}
/********************************************************************
+函数名称:Session_UPStroage_GetSpeed
+函数功能:获得速率限制句柄
+ 参数.一:lpszClientAddr
+ In/Out:In
+ 类型:常量字符指针
+ 可空:N
+ 意思:输入要操作的客户端
+返回值
+ 类型:句柄
+ 意思:返回速率句柄
+备注:
+*********************************************************************/
+XHANDLE CSession_UPStroage::Session_UPStroage_GetSpeed(LPCXSTR lpszClientAddr)
+{
+ Session_IsErrorOccur = false;
+
+ if ((NULL == lpszClientAddr))
+ {
+ Session_IsErrorOccur = true;
+ Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PARAMENT;
+ return NULL;
+ }
+
+ st_Locker.lock_shared();
+ unordered_map::iterator stl_MapIterator = stl_MapStroage.find(lpszClientAddr);
+ if (stl_MapIterator == stl_MapStroage.end())
+ {
+ Session_IsErrorOccur = true;
+ Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_NOTFOUND;
+ st_Locker.unlock_shared();
+ return NULL;
+ }
+ XHANDLE xhSpeed = stl_MapIterator->second.xhSpeed;;
+ st_Locker.unlock_shared();
+ return xhSpeed;
+}
+/********************************************************************
函数名称:Session_UPStroage_Write
函数功能:写入数据到文件
参数.一:lpszClientAddr
diff --git a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.h b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.h
index 70ad499..5bcff1b 100644
--- a/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.h
+++ b/XEngine_Source/StorageModule_Session/Session_Stroage/Session_UPStroage.h
@@ -14,6 +14,7 @@ typedef struct
{
time_t nTimeStart;
SESSION_STORAGEINFO st_StorageInfo;
+ XHANDLE xhSpeed;
}SESSION_STORAGEUPLOADER;
class CSession_UPStroage
@@ -24,8 +25,9 @@ class CSession_UPStroage
public:
bool Session_UPStroage_Init(int nMaxConnect, bool bUPResume = false);
bool Session_UPStroage_Destory();
- bool Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, __int64x nFileSize, bool bRewrite, int nPosStart = 0, int nPostEnd = 0);
+ bool Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, XHANDLE xhSpeed, __int64x nFileSize, bool bRewrite, int nSpeedLimit = 0, int nPosStart = 0, int nPostEnd = 0);
bool Session_UPStroage_GetInfo(LPCXSTR lpszClientAddr, SESSION_STORAGEINFO* pSt_StorageInfo);
+ XHANDLE Session_UPStroage_GetSpeed(LPCXSTR lpszClientAddr);
bool Session_UPStroage_Write(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen);
bool Session_UPStroage_Exist(LPCXSTR lpszClientAddr);
bool Session_UPStorage_GetAll(SESSION_STORAGEINFO*** pppSt_StorageInfo, int* pInt_ListCount);
diff --git a/XEngine_Source/StorageModule_Session/Session_User/Session_User.cpp b/XEngine_Source/StorageModule_Session/Session_User/Session_User.cpp
deleted file mode 100644
index acfa388..0000000
--- a/XEngine_Source/StorageModule_Session/Session_User/Session_User.cpp
+++ /dev/null
@@ -1,155 +0,0 @@
-#include "pch.h"
-#include "Session_User.h"
-/********************************************************************
-// Created: 2021/06/18 15:01:25
-// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_Session\Session_User\Session_User.cpp
-// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_Session\Session_User
-// File Base: Session_User
-// File Ext: cpp
-// Project: XEngine(网络通信引擎)
-// Author: qyt
-// Purpose: 存储用户管理
-// History:
-*********************************************************************/
-CSession_User::CSession_User()
-{
-}
-CSession_User::~CSession_User()
-{
-}
-//////////////////////////////////////////////////////////////////////////
-// 公有函数
-//////////////////////////////////////////////////////////////////////////
-/********************************************************************
-函数名称:Session_User_Init
-函数功能:初始化用户管理器
- 参数.一:lpszUserFile
- In/Out:In
- 类型:常量字符指针
- 可空:N
- 意思:输入用户文件地址
-返回值
- 类型:逻辑型
- 意思:是否成功
-备注:
-*********************************************************************/
-bool CSession_User::Session_User_Init(LPCXSTR lpszUserFile)
-{
- Session_IsErrorOccur = false;
-
- FILE* pSt_File = _xtfopen(lpszUserFile, _X("rb"));
- if (NULL == pSt_File)
- {
- Session_IsErrorOccur = true;
- Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_OPENFILE;
- return false;
- }
- int nCount = 0;
- XCHAR tszMsgBuffer[4096];
- memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
-
- while (true)
- {
- int nRet = fread(tszMsgBuffer + nCount, 1, 1024, pSt_File);
- if (nRet <= 0)
- {
- break;
- }
- nCount += nRet;
- }
- fclose(pSt_File);
-
- LPCXSTR lpszLineStr = _X("\r\n");
- XCHAR* ptszTokStr = _tcsxtok(tszMsgBuffer, lpszLineStr);
- while (1)
- {
- if (NULL == ptszTokStr)
- {
- break;
- }
- SESSION_USERINFO st_UserInfo;
- memset(&st_UserInfo, '\0', sizeof(SESSION_USERINFO));
-
- _stxscanf(ptszTokStr, _X("%s %s %s"), st_UserInfo.tszUserName, st_UserInfo.tszUserPass, st_UserInfo.tszUserLimit);
- stl_MapUser.insert(make_pair(st_UserInfo.tszUserName, st_UserInfo));
-
- ptszTokStr = _tcsxtok(NULL, lpszLineStr);
- }
- return true;
-}
-/********************************************************************
-函数名称:Session_User_Destory
-函数功能:销毁管理器
-返回值
- 类型:逻辑型
- 意思:是否成功
-备注:
-*********************************************************************/
-bool CSession_User::Session_User_Destory()
-{
- Session_IsErrorOccur = false;
-
- st_Locker.lock();
- stl_MapUser.clear();
- st_Locker.unlock();
-
- return true;
-}
-/********************************************************************
-函数名称:Session_User_Exist
-函数功能:用户名和密码是否存在
- 参数.一:lpszUser
- In/Out:In
- 类型:常量字符指针
- 可空:N
- 意思:输入要判断的用户名
- 参数.二:lpszPass
- In/Out:In
- 类型:常量字符指针
- 可空:N
- 意思:输入要判断的密码
- 参数.三:pInt_Limit
- In/Out:Out
- 类型:整数型指针
- 可空:Y
- 意思:输出获取到的限速
-返回值
- 类型:逻辑型
- 意思:是否成功
-备注:
-*********************************************************************/
-bool CSession_User::Session_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass, int* pInt_Limit /* = NULL */)
-{
- Session_IsErrorOccur = false;
-
- st_Locker.lock_shared();
- unordered_map::const_iterator stl_MapIterator = stl_MapUser.find(lpszUser);
- if (stl_MapIterator == stl_MapUser.end())
- {
- Session_IsErrorOccur = true;
- Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_NOTFOUND;
- st_Locker.unlock_shared();
- return false;
- }
-
- if (_tcsxlen(lpszPass) != _tcsxlen(stl_MapIterator->second.tszUserPass))
- {
- Session_IsErrorOccur = true;
- Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PASSWORD;
- st_Locker.unlock_shared();
- return false;
- }
- if (0 != _tcsxncmp(lpszPass, stl_MapIterator->second.tszUserPass, _tcsxlen(lpszPass)))
- {
- Session_IsErrorOccur = true;
- Session_dwErrorCode = ERROR_STORAGE_MODULE_SESSION_PASSWORD;
- st_Locker.unlock_shared();
- return false;
- }
- if (NULL != pInt_Limit)
- {
- *pInt_Limit = _ttxoi(stl_MapIterator->second.tszUserLimit);
- }
- st_Locker.unlock_shared();
- return true;
-}
\ No newline at end of file
diff --git a/XEngine_Source/StorageModule_Session/Session_User/Session_User.h b/XEngine_Source/StorageModule_Session/Session_User/Session_User.h
deleted file mode 100644
index 56e3b6f..0000000
--- a/XEngine_Source/StorageModule_Session/Session_User/Session_User.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-/********************************************************************
-// Created: 2021/06/18 14:59:38
-// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_Session\Session_User\Session_User.h
-// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_Session\Session_User
-// File Base: Session_User
-// File Ext: h
-// Project: XEngine(网络通信引擎)
-// Author: qyt
-// Purpose: 存储用户管理
-// History:
-*********************************************************************/
-
-typedef struct
-{
- XCHAR tszUserName[128];
- XCHAR tszUserPass[128];
- XCHAR tszUserLimit[128];
-}SESSION_USERINFO;
-
-class CSession_User
-{
-public:
- CSession_User();
- ~CSession_User();
-public:
- bool Session_User_Init(LPCXSTR lpszUserFile);
- bool Session_User_Destory();
- bool Session_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass, int* pInt_Limit = NULL);
-private:
- shared_mutex st_Locker;
-private:
- unordered_map stl_MapUser;
-};
diff --git a/XEngine_Source/StorageModule_Session/StorageModule_Session.def b/XEngine_Source/StorageModule_Session/StorageModule_Session.def
index 829b2c6..5d442f0 100644
--- a/XEngine_Source/StorageModule_Session/StorageModule_Session.def
+++ b/XEngine_Source/StorageModule_Session/StorageModule_Session.def
@@ -3,10 +3,6 @@ LIBRARY
EXPORTS
Session_GetLastError
- Session_User_Init
- Session_User_Destory
- Session_User_Exist
-
Session_DLStroage_Init
Session_DLStroage_Destory
Session_DLStroage_Insert
@@ -22,6 +18,7 @@ EXPORTS
Session_UPStroage_Destory
Session_UPStroage_Insert
Session_UPStroage_GetInfo
+ Session_UPStroage_GetSpeed
Session_UPStroage_Write
Session_UPStroage_Exist
Session_UPStorage_GetAll
diff --git a/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj b/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj
index 79d6371..9e066c2 100644
--- a/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj
+++ b/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj
@@ -174,7 +174,6 @@
-
@@ -188,7 +187,6 @@
-
diff --git a/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj.filters b/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj.filters
index f293871..b9bc978 100644
--- a/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj.filters
+++ b/XEngine_Source/StorageModule_Session/StorageModule_Session.vcxproj.filters
@@ -19,12 +19,6 @@
{b0b7eb76-2bec-46b1-8226-fc362b960454}
-
- {6b277f3a-fbd4-4847-a386-376dd775da0e}
-
-
- {032cbde1-12f2-4e52-ab1d-81799538579f}
-
{e950cfee-ded9-4200-a23c-3926b448090d}
@@ -57,9 +51,6 @@
头文件\Session_Stroage
-
- 头文件\Session_User
-
头文件\Session_Action
@@ -80,9 +71,6 @@
源文件\Session_Stroage
-
- 源文件\Session_User
-
源文件\Session_Action
diff --git a/XEngine_Source/StorageModule_Session/pch.cpp b/XEngine_Source/StorageModule_Session/pch.cpp
index 0f07a4b..e9eb29c 100644
--- a/XEngine_Source/StorageModule_Session/pch.cpp
+++ b/XEngine_Source/StorageModule_Session/pch.cpp
@@ -1,7 +1,6 @@
#include "pch.h"
#include "Session_Stroage/Session_DLStroage.h"
#include "Session_Stroage/Session_UPStroage.h"
-#include "Session_User/Session_User.h"
#include "Session_Action/Session_Action.h"
#include "Session_Webdav/Session_Webdav.h"
/********************************************************************
@@ -20,7 +19,6 @@ XLONG Session_dwErrorCode = 0;
//////////////////////////////////////////////////////////////////////////
CSession_DLStroage m_DLStorage;
CSession_UPStroage m_UPStorage;
-CSession_User m_User;
CSession_Action m_Action;
CSession_Webdav m_Webdav;
//////////////////////////////////////////////////////////////////////////
@@ -35,21 +33,6 @@ extern "C" XLONG Session_GetLastError(int* pInt_SysError)
return Session_dwErrorCode;
}
/************************************************************************/
-/* 用户管理导出的函数 */
-/************************************************************************/
-extern "C" bool Session_User_Init(LPCXSTR lpszUserFile)
-{
- return m_User.Session_User_Init(lpszUserFile);
-}
-extern "C" bool Session_User_Destory()
-{
- return m_User.Session_User_Destory();
-}
-extern "C" bool Session_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass, int* pInt_Limit)
-{
- return m_User.Session_User_Exist(lpszUser, lpszPass, pInt_Limit);
-}
-/************************************************************************/
/* 存储会话导出的函数 */
/************************************************************************/
extern "C" bool Session_DLStroage_Init(int nMaxConnect)
@@ -100,14 +83,18 @@ extern "C" bool Session_UPStroage_Destory()
{
return m_UPStorage.Session_UPStroage_Destory();
}
-extern "C" bool Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, __int64x nFileSize, bool bRewrite, int nPosStart, int nPostEnd)
+extern "C" bool Session_UPStroage_Insert(LPCXSTR lpszClientAddr, LPCXSTR lpszBuckKey, LPCXSTR lpszFileDir, XHANDLE xhSpeed, __int64x nFileSize, bool bRewrite, int nSpeedLimit, int nPosStart, int nPostEnd)
{
- return m_UPStorage.Session_UPStroage_Insert(lpszClientAddr, lpszBuckKey, lpszFileDir, nFileSize, bRewrite, nPosStart, nPostEnd);
+ return m_UPStorage.Session_UPStroage_Insert(lpszClientAddr, lpszBuckKey, lpszFileDir, xhSpeed, nFileSize, bRewrite, nSpeedLimit, nPosStart, nPostEnd);
}
extern "C" bool Session_UPStroage_GetInfo(LPCXSTR lpszClientAddr, SESSION_STORAGEINFO * pSt_StorageInfo)
{
return m_UPStorage.Session_UPStroage_GetInfo(lpszClientAddr, pSt_StorageInfo);
}
+extern "C" XHANDLE Session_UPStroage_GetSpeed(LPCXSTR lpszClientAddr)
+{
+ return m_UPStorage.Session_UPStroage_GetSpeed(lpszClientAddr);
+}
extern "C" bool Session_UPStroage_Write(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen)
{
return m_UPStorage.Session_UPStroage_Write(lpszClientAddr, lpszMsgBuffer, nMsgLen);
diff --git a/XEngine_Source/XEngine_Depend b/XEngine_Source/XEngine_Depend
index 71debf9..d1d1ee7 160000
--- a/XEngine_Source/XEngine_Depend
+++ b/XEngine_Source/XEngine_Depend
@@ -1 +1 @@
-Subproject commit 71debf9e6f9574d656bf8aa8e576fe1b0d5fb37c
+Subproject commit d1d1ee7952a0a93a1beb183a8dee281d9231ff3d
diff --git a/XEngine_Source/XEngine_StorageApp.sln b/XEngine_Source/XEngine_StorageApp.sln
index 97af25c..6a106a4 100644
--- a/XEngine_Source/XEngine_StorageApp.sln
+++ b/XEngine_Source/XEngine_StorageApp.sln
@@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_StorageApp", "XEngine_StorageApp\XEngine_StorageApp.vcxproj", "{0F90944D-3817-444A-9A4D-A25362DC0AB5}"
ProjectSection(ProjectDependencies) = postProject
{427DADD2-908A-464E-8CC7-D7A3DC518332} = {427DADD2-908A-464E-8CC7-D7A3DC518332}
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
{782538C0-67CB-4395-83AF-439C2DD38EEB} = {782538C0-67CB-4395-83AF-439C2DD38EEB}
{8B90FA35-1D93-4174-BF1C-926D52F0C67F} = {8B90FA35-1D93-4174-BF1C-926D52F0C67F}
{D8C24395-605F-4C73-AA50-ABA6B7CD84D6} = {D8C24395-605F-4C73-AA50-ABA6B7CD84D6}
@@ -16,14 +17,20 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_StorageApp", "XEngi
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_Session", "StorageModule_Session\StorageModule_Session.vcxproj", "{E858E3E8-8552-4AE5-A640-D6BDDC6572C5}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
+ {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_Config", "StorageModule_Config\StorageModule_Config.vcxproj", "{782538C0-67CB-4395-83AF-439C2DD38EEB}"
ProjectSection(ProjectDependencies) = postProject
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
{F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_APIHelp", "StorageModule_APIHelp\StorageModule_APIHelp.vcxproj", "{D8C24395-605F-4C73-AA50-ABA6B7CD84D6}"
ProjectSection(ProjectDependencies) = postProject
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
{F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}
EndProjectSection
EndProject
@@ -35,12 +42,23 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "XStorage_Include", "XStorag
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_Protocol", "StorageModule_Protocol\StorageModule_Protocol.vcxproj", "{427DADD2-908A-464E-8CC7-D7A3DC518332}"
ProjectSection(ProjectDependencies) = postProject
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
+ {D8C24395-605F-4C73-AA50-ABA6B7CD84D6} = {D8C24395-605F-4C73-AA50-ABA6B7CD84D6}
+ {E858E3E8-8552-4AE5-A640-D6BDDC6572C5} = {E858E3E8-8552-4AE5-A640-D6BDDC6572C5}
{F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_Database", "StorageModule_Database\StorageModule_Database.vcxproj", "{8B90FA35-1D93-4174-BF1C-926D52F0C67F}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
+ {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}
+ EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_BTorrent", "StorageModule_BTorrent\StorageModule_BTorrent.vcxproj", "{FFBC453D-B12C-4C3F-86EA-FC569E0566E7}"
+ ProjectSection(ProjectDependencies) = postProject
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
+ {F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "XEngine_Depend", "XEngine_Depend", "{E456F23F-1E72-4ABD-AAA9-051B2F7FD728}"
EndProject
@@ -48,6 +66,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsoncpp", "XEngine_Depend\X
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_InfoReport", "XEngine_Depend\XEngine_Module\XEngine_InfoReport\XEngine_InfoReport.vcxproj", "{F6520D2C-BB8E-45BB-964B-F5D6A4318A89}"
ProjectSection(ProjectDependencies) = postProject
+ {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A} = {4BF7CA78-A1DD-4C6A-8AC7-C3AEB528115A}
{F1736B3F-03A2-4FC7-B045-A12BA8D724FB} = {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}
EndProjectSection
EndProject
diff --git a/XEngine_Source/XEngine_StorageApp/Makefile b/XEngine_Source/XEngine_StorageApp/Makefile
index 3849336..14c29cb 100644
--- a/XEngine_Source/XEngine_StorageApp/Makefile
+++ b/XEngine_Source/XEngine_StorageApp/Makefile
@@ -1,4 +1,4 @@
-CC = g++ -Wall -std=c++17 -fPIC -Wformat-overflow=0
+CC = g++ -Wall -std=c++17 -fPIC
PLATFORM = linux
PLATVER =
PLATDIR =
@@ -6,7 +6,7 @@ RELEASE = 0
UNICODE = 0
LOADHDR = -I ./
LOADSO = -L ../XEngine_Depend/XEngine_Module/jsoncpp -L ../XEngine_Depend/XEngine_Module/tinyxml2 -L ../XEngine_Depend/XEngine_Module/XEngine_InfoReport \
- -L ../StorageModule_Database -L ../StorageModule_Config -L ../StorageModule_Session -L ../StorageModule_APIHelp -L ../StorageModule_Protocol -L ../StorageModule_BTorrent -L ../StorageModule_InfoReport
+ -L ../StorageModule_Database -L ../StorageModule_Config -L ../StorageModule_Session -L ../StorageModule_APIHelp -L ../StorageModule_Protocol -L ../StorageModule_BTorrent
LIB = -lXEngine_BaseLib -lXEngine_Algorithm -lXEngine_Core -lXEngine_ManagePool -lXEngine_OPenSsl -lXClient_APIHelp -lXEngine_ProcFile -lXEngine_SystemApi -lHelpComponents_XLog -lHelpComponents_Packets -lRfcComponents_HttpProtocol \
-lStorageModule_Database -lStorageModule_Config -lStorageModule_Session -lStorageModule_APIHelp -lStorageModule_Protocol -lStorageModule_BTorrent \
-ljsoncpp -ltinyxml2 -lXEngine_InfoReport
@@ -18,8 +18,13 @@ ifeq ($(RELEASE),1)
FLAGS = -c
DEBUG =
else
-FLAGS = -c -lc_p
-DEBUG = -g -pg
+ ifeq ($(PLATFORM),mac)
+ FLAGS = -c
+ DEBUG = -g
+ else
+ FLAGS = -c -lc_p
+ DEBUG = -g -pg
+ endif
endif
ifeq ($(UNICODE),1)
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp
index 88f311a..ef86845 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Center.cpp
@@ -58,7 +58,7 @@ bool XEngine_Task_HttpCenter(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int
LPCXSTR lpszMethodPost = _X("POST");
LPCXSTR lpszMethodOption = _X("OPTIONS");
- if (st_ServiceCfg.st_XAuth.bCHAuth)
+ if (st_ServiceCfg.st_XProxy.bAuthPass)
{
XCHAR tszUserName[64];
XCHAR tszUserPass[64];
@@ -76,41 +76,23 @@ bool XEngine_Task_HttpCenter(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("业务客户端:%s,用户验证失败,错误:%lX"), lpszClientAddr, StorageHelp_GetLastError());
return false;
}
- if (st_ServiceCfg.st_XProxy.bAuthPass)
- {
- int nResponseCode = 0;
- XCHAR* ptszBody = NULL;
-
- Protocol_StoragePacket_BasicAuth(pSt_HTTPParam->tszHttpMethod, pSt_HTTPParam->tszHttpUri, lpszClientAddr, tszUserName, tszUserPass, tszSDBuffer, &nSDLen);
- APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XProxy.tszAuthPass, tszSDBuffer, &nResponseCode, &ptszBody, &nSDLen);
- if (200 != nResponseCode)
- {
- st_HDRParam.bIsClose = true;
- st_HDRParam.bAuth = true;
- st_HDRParam.nHttpCode = nResponseCode;
+ int nResponseCode = 0;
+ XCHAR* ptszBody = NULL;
- HttpProtocol_Server_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
- XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("业务客户端:%s,用户验证失败,用户名:%s,密码:%s,错误码:%d,错误内容:%s"), tszUserName, tszUserPass, tszUserPass, nResponseCode, ptszBody);
- }
- BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszBody);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("业务客户端:%s,代理服务:%s 验证通过,用户名:%s,密码:%s"), lpszClientAddr, st_ServiceCfg.st_XProxy.tszAuthPass, tszUserName, tszUserPass);
- }
- else
+ Protocol_StoragePacket_BasicAuth(pSt_HTTPParam->tszHttpMethod, pSt_HTTPParam->tszHttpUri, lpszClientAddr, tszUserName, tszUserPass, tszSDBuffer, &nSDLen);
+ APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XProxy.tszAuthPass, tszSDBuffer, &nResponseCode, &ptszBody, &nSDLen);
+ if (200 != nResponseCode)
{
- if (!Session_User_Exist(tszUserName, tszUserPass))
- {
- st_HDRParam.bIsClose = true;
- st_HDRParam.bAuth = true;
- st_HDRParam.nHttpCode = 401;
+ st_HDRParam.bIsClose = true;
+ st_HDRParam.bAuth = true;
+ st_HDRParam.nHttpCode = nResponseCode;
- HttpProtocol_Server_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
- XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("业务客户端:%s,验证用户失败,无法继续"), lpszClientAddr);
- return false;
- }
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("业务客户端:%s,本地验证用户验证通过,用户名:%s,密码:%s"), lpszClientAddr, tszUserName, tszUserPass);
+ HttpProtocol_Server_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
+ XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("业务客户端:%s,用户验证失败,用户名:%s,密码:%s,错误码:%d,错误内容:%s"), tszUserName, tszUserPass, tszUserPass, nResponseCode, ptszBody);
}
+ BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszBody);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("业务客户端:%s,代理服务:%s 验证通过,用户名:%s,密码:%s"), lpszClientAddr, st_ServiceCfg.st_XProxy.tszAuthPass, tszUserName, tszUserPass);
st_HDRParam.bAuth = true;
}
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Config.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Config.cpp
index a140a4f..321b51b 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_Config.cpp
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Config.cpp
@@ -61,11 +61,11 @@ bool StorageApp_Config_Parament(int argc,char **argv)
}
else if (0 == _tcsxcmp("-l",argv[i]))
{
- st_ServiceCfg.st_XLog.nLogLeave = _ttxoi(argv[i + 1]);
+ st_ServiceCfg.st_XLog.nLogLeave = _ttxoi(argv[++i]);
}
else if (0 == _tcsxcmp("-d",argv[i]))
{
- st_ServiceCfg.bDeamon = _ttxoi(argv[i + 1]);
+ st_ServiceCfg.bDeamon = _ttxoi(argv[++i]);
}
else if (0 == _tcsxcmp("-r", argv[i]))
{
@@ -75,6 +75,10 @@ bool StorageApp_Config_Parament(int argc,char **argv)
{
st_ServiceCfg.bReuseraddr = true;
}
+ else if (0 == _tcsxcmp("-t", argv[i]))
+ {
+ bIsTest = true;
+ }
}
return true;
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp
index d4e05e4..c902410 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Download.cpp
@@ -156,7 +156,7 @@ bool XEngine_Task_HttpDownload(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
}
}
//验证用户
- if (st_ServiceCfg.st_XAuth.bDLAuth)
+ if (st_ServiceCfg.st_XProxy.bDLPass)
{
XCHAR tszUserName[64];
XCHAR tszUserPass[64];
@@ -174,43 +174,25 @@ bool XEngine_Task_HttpDownload(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("下载客户端:%s,用户验证失败,错误:%lX"), lpszClientAddr, StorageHelp_GetLastError());
return false;
}
- if (st_ServiceCfg.st_XProxy.bAuthPass)
- {
- int nCode = 0;
- int nResponseCode = 0;
- XCHAR* ptszBody = NULL;
-
- Protocol_StoragePacket_BasicAuth(pSt_HTTPParam->tszHttpMethod, pSt_HTTPParam->tszHttpUri, lpszClientAddr, tszUserName, tszUserPass, tszSDBuffer, &nSDLen);
- APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XProxy.tszAuthPass, tszSDBuffer, &nResponseCode, &ptszBody, &nSDLen);
- if (200 != nResponseCode)
- {
- st_HDRParam.bIsClose = true;
- st_HDRParam.bAuth = true;
- st_HDRParam.nHttpCode = nResponseCode;
+ int nCode = 0;
+ int nResponseCode = 0;
+ XCHAR* ptszBody = NULL;
- HttpProtocol_Server_SendMsgEx(xhDLHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
- XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPDOWNLOAD);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("下载客户端:%s,用户验证失败,用户名:%s,密码:%s,错误码:%d,错误内容:%s"), tszUserName, tszUserPass, tszUserPass, nResponseCode, ptszBody);
- }
- Protocol_StorageParse_SpeedLimit(ptszBody, nSDLen, &nCode, &nLimit);
- BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszBody);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("下载客户端:%s,代理服务:%s 验证通过,用户名:%s,密码:%s,值:%d"), lpszClientAddr, st_ServiceCfg.st_XProxy.tszAuthPass, tszUserName, tszUserPass, nCode);
- }
- else
+ Protocol_StoragePacket_BasicAuth(pSt_HTTPParam->tszHttpMethod, pSt_HTTPParam->tszHttpUri, lpszClientAddr, tszUserName, tszUserPass, tszSDBuffer, &nSDLen);
+ APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XProxy.tszAuthPass, tszSDBuffer, &nResponseCode, &ptszBody, &nSDLen);
+ if (200 != nResponseCode)
{
- if (!Session_User_Exist(tszUserName, tszUserPass, &nLimit))
- {
- st_HDRParam.bIsClose = true;
- st_HDRParam.bAuth = true;
- st_HDRParam.nHttpCode = 401;
+ st_HDRParam.bIsClose = true;
+ st_HDRParam.bAuth = true;
+ st_HDRParam.nHttpCode = nResponseCode;
- HttpProtocol_Server_SendMsgEx(xhDLHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
- XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPDOWNLOAD);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("下载客户端:%s,验证用户失败,无法继续"), lpszClientAddr);
- return false;
- }
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("下载客户端:%s,本地验证用户验证通过,用户名:%s,密码:%s"), lpszClientAddr, tszUserName, tszUserPass);
+ HttpProtocol_Server_SendMsgEx(xhDLHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
+ XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPDOWNLOAD);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("下载客户端:%s,用户验证失败,用户名:%s,密码:%s,错误码:%d,错误内容:%s"), tszUserName, tszUserPass, tszUserPass, nResponseCode, ptszBody);
}
+ Protocol_StorageParse_SpeedLimit(ptszBody, nSDLen, &nCode, &nLimit);
+ BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszBody);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("下载客户端:%s,代理服务:%s 验证通过,用户名:%s,密码:%s,值:%d"), lpszClientAddr, st_ServiceCfg.st_XProxy.tszAuthPass, tszUserName, tszUserPass, nCode);
st_HDRParam.bAuth = true;
}
//使用重定向,这是分布式重定向实现
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h b/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h
index e19fc43..4c8d5ad 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Hdr.h
@@ -15,6 +15,7 @@
#include
#include
#include
+#include
#else
#include
#include
@@ -74,6 +75,7 @@ using namespace std;
#define STORAGE_NETTYPE_HTTPWEBDAV 4
extern bool bIsRun;
+extern bool bIsTest;
extern XHANDLE xhLog;
extern XHANDLE xhHBDownload;
@@ -122,6 +124,7 @@ extern XENGINE_LBCONFIG st_LoadbalanceCfg;
#ifdef _MSC_BUILD
#pragma comment(lib,"Ws2_32.lib")
+#pragma comment(lib,"Dbghelp.lib")
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib.lib")
#pragma comment(lib,"XEngine_BaseLib/XEngine_Algorithm.lib")
#pragma comment(lib,"XEngine_Core/XEngine_Core.lib")
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp
index 17b29d5..4e383b4 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Network.cpp
@@ -76,12 +76,6 @@ void CALLBACK XEngine_Callback_UPLoaderRecv(LPCXSTR lpszClientAddr, XSOCKET hSoc
}
}
SocketOpt_HeartBeat_ActiveAddrEx(xhHBUPLoader, lpszClientAddr);
-
- int nCount = 0;
- __int64u nTimeWait = 0;
- Session_UPStorage_GetAll(NULL, &nCount);
- Algorithm_Calculation_SleepFlow(xhLimit, &nTimeWait, st_ServiceCfg.st_XLimit.nMaxUPLoader, nCount, nMsgLen);
- std::this_thread::sleep_for(std::chrono::microseconds(nTimeWait));
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("上传客户端:%s,投递包成功,大小:%d"), lpszClientAddr, nMsgLen);
}
void CALLBACK XEngine_Callback_UPLoaderLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam)
@@ -212,6 +206,8 @@ bool XEngine_Net_CloseClient(LPCXSTR lpszClientAddr, int nLeaveType, int nClient
NetCore_TCPXCore_CloseForClientEx(xhNetUPLoader, lpszClientAddr);
SocketOpt_HeartBeat_DeleteAddrEx(xhHBUPLoader, lpszClientAddr);
}
+ Algorithm_Calculation_PassiveClose(Session_UPStroage_GetSpeed(lpszClientAddr), true);
+ Algorithm_Calculation_Close(Session_UPStroage_GetSpeed(lpszClientAddr));
Session_UPStroage_Delete(lpszClientAddr);
HttpProtocol_Server_CloseClinetEx(xhUPHttp, lpszClientAddr);
OPenSsl_Server_CloseClientEx(xhUPSsl, lpszClientAddr);
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp
index e6408c9..daa5b4c 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.cpp
@@ -39,9 +39,24 @@ XHTHREAD CALLBACK XEngine_UPLoader_HTTPThread(XPVOID lParam)
}
return 0;
}
+void CALLBACK XEngine_UPLoader_UPFlow(XHANDLE xhToken, bool bSDFlow, bool bRVFlow, bool bTime, __int64u nSDFlow, __int64u nRVFlow, __int64u nTimeFlow, XPVOID lParam)
+{
+ XCHAR tszIPAddr[128] = {};
+ _tcsxcpy(tszIPAddr, (LPCXSTR)lParam);
+ if (bSDFlow)
+ {
+ NetCore_TCPXCore_PasueRecvEx(xhNetUPLoader, tszIPAddr, false);
+ }
+ else
+ {
+ NetCore_TCPXCore_PasueRecvEx(xhNetUPLoader, tszIPAddr, true);
+ }
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("上传客户端:%s,接受数据标志:%d,当前平均流量:%llu"), tszIPAddr, bSDFlow, nSDFlow);
+}
bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, XCHAR** pptszListHdr, int nHdrCount)
{
int nSDLen = 2048;
+ int nLimit = 0;
XCHAR tszSDBuffer[2048];
XCHAR tszFileDir[1024];
RFCCOMPONENTS_HTTP_HDRPARAM st_HDRParam;
@@ -78,7 +93,7 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
}
}
//用户验证
- if (st_ServiceCfg.st_XAuth.bUPAuth)
+ if (st_ServiceCfg.st_XProxy.bUPPass)
{
XCHAR tszUserName[64];
XCHAR tszUserPass[64];
@@ -96,41 +111,25 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("上传客户端:%s,用户验证失败,错误:%lX"), lpszClientAddr, StorageHelp_GetLastError());
return false;
}
- if (st_ServiceCfg.st_XProxy.bAuthPass)
- {
- int nResponseCode = 0;
- XCHAR* ptszBody = NULL;
-
- Protocol_StoragePacket_BasicAuth(pSt_HTTPParam->tszHttpMethod, pSt_HTTPParam->tszHttpUri, lpszClientAddr, tszUserName, tszUserPass, tszSDBuffer, &nSDLen);
- APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XProxy.tszAuthPass, tszSDBuffer, &nResponseCode, &ptszBody, &nSDLen);
- if (200 != nResponseCode)
- {
- st_HDRParam.bIsClose = true;
- st_HDRParam.bAuth = true;
- st_HDRParam.nHttpCode = nResponseCode;
+ int nCode = 0;
+ int nResponseCode = 0;
+ XCHAR* ptszBody = NULL;
- HttpProtocol_Server_SendMsgEx(xhUPHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
- XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPUPLOADER);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("上传客户端:%s,用户验证失败,用户名:%s,密码:%s,错误码:%d,错误内容:%s"), tszUserName, tszUserPass, tszUserPass, nResponseCode, ptszBody);
- }
- BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszBody);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("上传客户端:%s,代理服务:%s 验证通过,用户名:%s,密码:%s"), lpszClientAddr, st_ServiceCfg.st_XProxy.tszAuthPass, tszUserName, tszUserPass);
- }
- else
+ Protocol_StoragePacket_BasicAuth(pSt_HTTPParam->tszHttpMethod, pSt_HTTPParam->tszHttpUri, lpszClientAddr, tszUserName, tszUserPass, tszSDBuffer, &nSDLen);
+ APIClient_Http_Request(_X("POST"), st_ServiceCfg.st_XProxy.tszAuthPass, tszSDBuffer, &nResponseCode, &ptszBody, &nSDLen);
+ if (200 != nResponseCode)
{
- if (!Session_User_Exist(tszUserName, tszUserPass))
- {
- st_HDRParam.bIsClose = true;
- st_HDRParam.bAuth = true;
- st_HDRParam.nHttpCode = 401;
+ st_HDRParam.bIsClose = true;
+ st_HDRParam.bAuth = true;
+ st_HDRParam.nHttpCode = nResponseCode;
- HttpProtocol_Server_SendMsgEx(xhUPHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
- XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPUPLOADER);
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("上传客户端:%s,验证用户失败,无法继续"), lpszClientAddr);
- return false;
- }
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("上传客户端:%s,本地验证用户验证通过,用户名:%s,密码:%s"), lpszClientAddr, tszUserName, tszUserPass);
+ HttpProtocol_Server_SendMsgEx(xhUPHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
+ XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPUPLOADER);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("上传客户端:%s,用户验证失败,用户名:%s,密码:%s,错误码:%d,错误内容:%s"), tszUserName, tszUserPass, tszUserPass, nResponseCode, ptszBody);
}
+ Protocol_StorageParse_SpeedLimit(ptszBody, nSDLen, &nCode, &nLimit);
+ BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszBody);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("上传客户端:%s,代理服务:%s 验证通过,用户名:%s,密码:%s"), lpszClientAddr, st_ServiceCfg.st_XProxy.tszAuthPass, tszUserName, tszUserPass);
st_HDRParam.bAuth = true;
}
//使用重定向?
@@ -307,7 +306,31 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
}
SystemApi_File_CreateMutilFolder(tszTmpPath);
}
- if (!Session_UPStroage_Insert(lpszClientAddr, st_StorageBucket.tszBuckKey, tszFileDir, nPosCount, st_StorageBucket.st_PermissionFlags.bRewrite, nPosStart, nPosEnd))
+ XHANDLE xhUPSpeed = NULL;
+ if (nLimit > 0 || (st_ServiceCfg.st_XLimit.bLimitMode && st_ServiceCfg.st_XLimit.nMaxUPLoader > 0))
+ {
+ //处理限速情况
+ XCHAR* ptszIPClient = (XCHAR*)malloc(MAX_PATH);
+ if (NULL == ptszIPClient)
+ {
+ st_HDRParam.bIsClose = true;
+ st_HDRParam.nHttpCode = 500;
+
+ HttpProtocol_Server_SendMsgEx(xhUPHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
+ XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPUPLOADER);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("上传客户端:%s,插入用户请求失败,文件:%s,内存申请失败,服务器错误"), lpszClientAddr, tszFileDir);
+ return false;
+ }
+ memset(ptszIPClient, '\0', MAX_PATH);
+ _tcsxcpy(ptszIPClient, lpszClientAddr);
+
+ nLimit = nLimit == 0 ? st_ServiceCfg.st_XLimit.nMaxUPLoader : nLimit;
+ xhUPSpeed = Algorithm_Calculation_Create();
+ Algorithm_Calculation_PassiveOPen(xhUPSpeed, XEngine_UPLoader_UPFlow, nLimit, 0, 0, false, ptszIPClient);
+ NetCore_TCPXCore_PasueRecvEx(xhNetUPLoader, lpszClientAddr, false);
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("上传客户端:%s,上传限速被启用,文件:%s,限速:%d"), lpszClientAddr, tszFileDir, nLimit);
+ }
+ if (!Session_UPStroage_Insert(lpszClientAddr, st_StorageBucket.tszBuckKey, tszFileDir, xhUPSpeed, nPosCount, st_StorageBucket.st_PermissionFlags.bRewrite, nLimit, nPosStart, nPosEnd))
{
st_HDRParam.bIsClose = true;
st_HDRParam.nHttpCode = 500;
@@ -369,6 +392,7 @@ bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in
{
Session_UPStroage_Write(lpszClientAddr, lpszMsgBuffer, nMsgLen);
}
+ Algorithm_Calculation_ADDSDFlow(Session_UPStroage_GetSpeed(lpszClientAddr), nMsgLen);
HttpProtocol_Server_GetRecvModeEx(xhUPHttp, lpszClientAddr, &nRVMode, &nRVCount, &nHDSize);
if (nHDSize >= nRVCount)
{
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.h b/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.h
index 49d0617..67f18a9 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.h
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_UPLoader.h
@@ -1,4 +1,5 @@
#pragma once
XHTHREAD CALLBACK XEngine_UPLoader_HTTPThread(XPVOID lParam);
+void CALLBACK XEngine_UPLoader_UPFlow(XHANDLE xhToken, bool bSDFlow, bool bRVFlow, bool bTime, XPVOID lParam);
bool XEngine_Task_HttpUPLoader(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, RFCCOMPONENTS_HTTP_REQPARAM* pSt_HTTPParam, XCHAR** pptszListHdr, int nHdrCount);
\ No newline at end of file
diff --git a/XEngine_Source/XEngine_StorageApp/StorageApp_Webdav.cpp b/XEngine_Source/XEngine_StorageApp/StorageApp_Webdav.cpp
index a0f1af8..8f99701 100644
--- a/XEngine_Source/XEngine_StorageApp/StorageApp_Webdav.cpp
+++ b/XEngine_Source/XEngine_StorageApp/StorageApp_Webdav.cpp
@@ -91,6 +91,8 @@ bool XEngine_Task_HttpWebdav(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("WEBDAV客户端:%s,处理WEBDAV协议PROPFIND方法失败,URL:%s"), lpszClientAddr, pSt_HTTPParam->tszHttpUri);
return false;
}
+ int nListCount = 0;
+ XCHAR** pptszListFile;
XCHAR tszFindStr[MAX_PATH] = {};
//得到是否是文件
if (APIHelp_Api_UrlStr(st_StorageBucket.tszBuckKey, pSt_HTTPParam->tszHttpUri))
@@ -98,6 +100,10 @@ bool XEngine_Task_HttpWebdav(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int
int nALen = 0;
_tcsxcpy(tszFindStr, pSt_HTTPParam->tszHttpUri + 1);
BaseLib_OperatorString_Replace(tszFindStr, &nALen, st_StorageBucket.tszBuckKey, st_StorageBucket.tszFilePath, true);
+ //如果是文件
+ nListCount = 1;
+ BaseLib_OperatorMemory_Malloc((XPPPMEM)&pptszListFile, nListCount, MAX_PATH);
+ _tcsxcpy(pptszListFile[0], tszFindStr);
}
else
{
@@ -106,17 +112,14 @@ bool XEngine_Task_HttpWebdav(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int
HttpProtocol_ServerHelp_GetField(&pptszListHdr, nHdrCount, _X("Depth"), tszVluStr);
if (1 == _ttxoi(tszVluStr))
{
- _xstprintf(tszFindStr, _X("%s/*"), st_StorageBucket.tszFilePath);
+ SystemApi_File_EnumFile(tszFindStr, &pptszListFile, &nListCount, false, 3);
}
else
{
- _tcsxcpy(tszFindStr, st_StorageBucket.tszFilePath);
+ SystemApi_File_EnumFile(tszFindStr, &pptszListFile, &nListCount);
}
}
//枚举文件
- int nListCount = 0;
- XCHAR** pptszListFile;
- SystemApi_File_EnumFile(tszFindStr, &pptszListFile, &nListCount);
if (0 == nListCount)
{
st_HDRParam.nHttpCode = 404;
diff --git a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp
index 6c0f2b3..a5b521c 100644
--- a/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp
+++ b/XEngine_Source/XEngine_StorageApp/Storage_APPTask/Storage_TaskManage.cpp
@@ -311,20 +311,6 @@ bool XEngine_Task_Manage(LPCXSTR lpszAPIName, LPCXSTR lpszClientAddr, LPCXSTR lp
if (0 == nOPCode)
{
//处理路径格式
- if (tszRealDir[_tcsxlen(tszRealDir) - 1] != '*')
- {
- int nPathType = 0;
- BaseLib_OperatorString_GetPath(tszRealDir, &nPathType);
- //判断是绝对路径还是相对路径
- if (1 == nPathType)
- {
- _tcsxcat(tszRealDir, _X("\\*"));
- }
- else if (2 == nPathType)
- {
- _tcsxcat(tszRealDir, _X("/*"));
- }
- }
if (!SystemApi_File_EnumFile(tszRealDir, &ppszListDir, &nListCount, true, 2))
{
st_HDRParam.bIsClose = true;
diff --git a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp
index b6dd6e0..9f600ed 100644
--- a/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp
+++ b/XEngine_Source/XEngine_StorageApp/XEngine_StorageApp.cpp
@@ -1,6 +1,7 @@
#include "StorageApp_Hdr.h"
bool bIsRun = false;
+bool bIsTest = false;
XHANDLE xhLog = NULL;
XHANDLE xhHBDownload = NULL;
@@ -71,7 +72,6 @@ void ServiceApp_Stop(int signo)
Algorithm_Calculation_Close(xhLimit);
HelpComponents_XLog_Destroy(xhLog);
- Session_User_Destory();
Session_DLStroage_Destory();
Session_UPStroage_Destory();
Database_File_Destory();
@@ -119,15 +119,42 @@ static int ServiceApp_Deamon(int wait)
#endif
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 _MSC_BUILD
WSADATA st_WSAData;
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
+
+ SetUnhandledExceptionFilter(Coredump_ExceptionFilter);
#endif
bIsRun = true;
- string m_StrVersion;
+ int nRet = -1;
LPCXSTR lpszHTTPMime = _X("./XEngine_Config/HttpMime.types");
LPCXSTR lpszHTTPCode = _X("./XEngine_Config/HttpCode.types");
HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig;
@@ -240,12 +267,7 @@ int main(int argc, char** argv)
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,初始化数据库失败,数据库被设置为禁用,相关功能已经被禁止使用!"));
}
- if (!Session_User_Init(st_ServiceCfg.st_XAuth.tszUserList))
- {
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动用户管理服务失败,错误:%lX"), Session_GetLastError());
- goto XENGINE_EXITAPP;
- }
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动用户管理服务成功"));
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,验证服务启动标志:API:%d,上传:%d,下载:%d"), st_ServiceCfg.st_XProxy.bAuthPass, st_ServiceCfg.st_XProxy.bDLPass, st_ServiceCfg.st_XProxy.bUPPass);
//启动下载服务
if (st_ServiceCfg.nStorageDLPort > 0)
{
@@ -544,7 +566,7 @@ int main(int argc, char** argv)
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,转录动作没有启用"));
}
//发送信息报告
- if (st_ServiceCfg.st_XReport.bEnable)
+ if (st_ServiceCfg.st_XReport.bEnable && !bIsTest)
{
if (InfoReport_APIMachine_Send(st_ServiceCfg.st_XReport.tszAPIUrl, st_ServiceCfg.st_XReport.tszServiceName))
{
@@ -566,6 +588,11 @@ int main(int argc, char** argv)
while (true)
{
+ if (bIsTest)
+ {
+ nRet = 0;
+ break;
+ }
std::this_thread::sleep_for(std::chrono::seconds(1));
}
@@ -573,9 +600,15 @@ int main(int argc, char** argv)
if (bIsRun)
{
- XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("存储中心服务关闭,服务器退出..."));
bIsRun = false;
-
+ if (bIsTest && 0 == nRet)
+ {
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("存储中心服务关闭,测试程序退出..."));
+ }
+ else
+ {
+ XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("存储中心服务关闭,服务器退出..."));
+ }
HttpProtocol_Server_DestroyEx(xhUPHttp);
HttpProtocol_Server_DestroyEx(xhDLHttp);
HttpProtocol_Server_DestroyEx(xhCenterHttp);
@@ -604,7 +637,6 @@ int main(int argc, char** argv)
Algorithm_Calculation_Close(xhLimit);
HelpComponents_XLog_Destroy(xhLog);
- Session_User_Destory();
Session_DLStroage_Destory();
Session_UPStroage_Destory();
Database_File_Destory();
@@ -623,5 +655,5 @@ int main(int argc, char** argv)
#ifdef _MSC_BUILD
WSACleanup();
#endif
- return 0;
+ return nRet;
}