Skip to content

Commit 681d65e

Browse files
authored
Merge pull request #25 from libxengine/develop
V3.9.0.1001 Merge
2 parents ff6ed1d + 941e98e commit 681d65e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+487
-235
lines changed

CHANGELOG

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
XEngine_Storage V3.9.0.1001
2+
3+
添加:用户支持单独限速模式了
4+
更新:匹配XEngine V7.42版本
5+
修改:限制模式是逻辑型了
6+
修改:上传会话字段ullFSize修改为ullRWLen
7+
修改:P2P搜索文件可以不使用数据库了
8+
修改:P2P文件搜索必须设置文件HASH值
9+
修改:本地文件没有找到后会返回错误了
10+
优化:删除没有使用的APIHelp_Distributed_UPStorage函数参数
11+
优化:Session_UPStroage_Close函数代码
12+
修正:P2P没有查找没有返回bucket名称的问题
13+
删除:错误重试配置
14+
删除:没有使用的bucket选择模式代码
15+
16+
added:support user speed limit
17+
update:match xengine v7.42
18+
modify:limit mode is boolean
19+
modify:up session changed ullRWLen from ullFSize
20+
modify:p2p search file can be not enable database
21+
modify:p2p file search have to setting hash value
22+
modify:local file search not found file that reply error code
23+
improved:delete unused parament for APIHelp_Distributed_UPStorage function
24+
improved:Session_UPStroage_Close function code
25+
fixed:p2p not reply bucket name
26+
delete:error try time configrue
27+
delete:unused select bucket mode code
28+
======================================================================================
129
XEngine_Storage V3.8.0.1001
230

331
更新:匹配了xengine v7.38

README.en.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ P2P distributed download is the same as the hyper-threaded download of other dow
8787
- XEngine_APPClient client code dir
8888
- XEngine_SQLFile database sql file
8989

90+
## Example
91+
UPLoad File: curl -d 'hello xengine' -X POST "http://192.168.1.8:5102/api?filename=hello.txt&storeagekey=storagekey1"
92+
Download File: curl -X GET "http://192.168.1.8:5101/storagekey1/hello.txt"
93+
9094
## now task
9195
P2P WAN file search and download support
9296

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ make FLAGS=CleanAll 清理编译
7777
- XEngine_APPClient 客户端演示代码
7878
- XEngine_SQLFile 数据库脚本文件
7979

80+
## 示例
81+
上传文件: curl -d 'hello xengine' -X POST "http://192.168.1.8:5102/api?filename=hello.txt&storeagekey=storagekey1"
82+
下载文件: curl -X GET "http://192.168.1.8:5101/storagekey1/hello.txt"
8083

8184
## 秒传实现
8285
秒传的实现不是靠服务器实现的,而是靠客户端实现的.
@@ -88,8 +91,8 @@ P2P分布式下载已经支持,不过目前只能在局域网中,暂时不支持
8891
P2P分布式下载与其他下载工具的超线程下载一样,原理是使用HTTP RANGE字段实现.各位可以通过libcurl等库实现此功能.
8992

9093
## 当前任务
91-
管理接口调试
9294
本地网络接口删除
95+
上传目录控制,防止超过权限的上传动作
9396
客户端连接数限制
9497
P2P广域网文件查找与下载支持
9598
分布式数据库存储

XEngine_APPClient/APPClient_Download/APPClient_Download.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void P2PParse_List(LPCTSTR lpszMsgBuffer, int nMsgLen, list<P2PFILE_INFO>* pStl_
7979
//创建分布式文件下载器
8080
typedef struct
8181
{
82-
XNETHANDLE xhToken; //下载句柄
82+
XHANDLE xhToken; //下载句柄
8383
__int64x nPosStart;
8484
__int64x nPosEnd;
8585
}P2PFILE_PIECE;
@@ -115,8 +115,8 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
115115
nPos += nPiece;
116116
_stprintf(tszRange, _T("%lld-%lld"), pSt_P2PFile[i].nPosStart, pSt_P2PFile[i].nPosEnd);
117117
}
118-
119-
if (!DownLoad_Http_Create(&pSt_P2PFile[i].xhToken, tszDLUrl, lpszFile, tszRange, NULL, NULL, NULL))
118+
pSt_P2PFile[i].xhToken = DownLoad_Http_Create(tszDLUrl, lpszFile, tszRange, NULL, NULL, NULL);
119+
if (NULL == pSt_P2PFile[i].xhToken)
120120
{
121121
printf("create download task is failed:%X\n", Download_GetLastError());
122122
}
@@ -135,7 +135,7 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
135135
{
136136
bComplete = FALSE;
137137
}
138-
printf("DLToken:%lld DLTotal:%lf DLNow:%lf DLStatus:%d\n", pSt_P2PFile[i].xhToken, st_TaskInfo.dlTotal, st_TaskInfo.dlNow, st_TaskInfo.en_DownStatus);
138+
printf("DLToken:%p DLTotal:%lf DLNow:%lf DLStatus:%d\n", pSt_P2PFile[i].xhToken, st_TaskInfo.dlTotal, st_TaskInfo.dlNow, st_TaskInfo.en_DownStatus);
139139
}
140140
if (bComplete)
141141
{
@@ -160,7 +160,7 @@ int main()
160160
#endif
161161

162162
int nHTTPCode = 0;
163-
int nBodyLen = 2048;
163+
int nBodyLen = 0;
164164
TCHAR *ptszMsgBody = NULL;
165165
//请求分布式存储文件所有位置
166166
LPCTSTR lpszUrl = _T("http://127.0.0.1:5100/Api/Manage/Query");
@@ -169,9 +169,10 @@ int main()
169169
Json::Value st_JsonRoot;
170170
st_JsonRoot["nMode"] = 1; //使用P2P下载
171171
st_JsonRoot["lpszBuckKey"] = "storagekey2";
172-
st_JsonRoot["lpszFileName"] = "qq.exe";
172+
//st_JsonRoot["lpszFileName"] = "qq.exe";
173+
st_JsonRoot["lpszFileHash"] = "D41D8CD98F00B204E9801998ECF8427E";
173174

174-
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nHTTPCode, &ptszMsgBody, &nBodyLen))
175+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nHTTPCode, &ptszMsgBody, &nBodyLen))
175176
{
176177
return -1;
177178
}

XEngine_APPClient/APPClient_RestApi/APPClient_RestApi.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void API_Manage_Query()
3838
st_JsonRoot["lpszTimeEnd"];
3939
st_JsonRoot["lpszBuckKey"] = "storagekey2";
4040

41-
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
41+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
4242
{
4343
printf("API_Manage_Query:%lX\n", APIHelp_GetLastError());
4444
return;
@@ -66,7 +66,7 @@ void API_Manage_Insert()
6666
st_JsonRoot["List"] = st_JsonArray;
6767
st_JsonRoot["Count"] = 1;
6868

69-
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
69+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
7070
{
7171
printf("API_Manage_Insert:%lX\n", APIHelp_GetLastError());
7272
return;
@@ -91,7 +91,7 @@ void API_Manage_Delete()
9191
st_JsonRoot["List"] = st_JsonArray;
9292
st_JsonRoot["Count"] = 1;
9393

94-
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
94+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
9595
{
9696
printf("API_Manage_Delete:%lX\n", APIHelp_GetLastError());
9797
return;
@@ -111,7 +111,7 @@ void API_Manage_Dir()
111111
st_JsonRoot["lpszBuckKey"] = "storagekey1";
112112
st_JsonRoot["lpszUserDir"] = "user";
113113
st_JsonRoot["nOPerator"] = 1;
114-
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
114+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
115115
{
116116
printf("API_Manage_Dir:%lX\n", APIHelp_GetLastError());
117117
return;
@@ -123,7 +123,7 @@ void API_Manage_Dir()
123123
st_JsonRoot["lpszBuckKey"] = "storagekey1";
124124
st_JsonRoot["lpszUserDir"];
125125
st_JsonRoot["nOPerator"] = 0;
126-
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
126+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
127127
{
128128
printf("API_Manage_Dir:%lX\n", APIHelp_GetLastError());
129129
return;
@@ -135,7 +135,7 @@ void API_Manage_Dir()
135135
st_JsonRoot["lpszBuckKey"] = "storagekey1";
136136
st_JsonRoot["lpszUserDir"] = "user";
137137
st_JsonRoot["nOPerator"] = 2;
138-
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
138+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszMsgBuffer, &nLen))
139139
{
140140
printf("API_Manage_Dir:%lX\n", APIHelp_GetLastError());
141141
return;
@@ -150,7 +150,7 @@ void API_Manage_Task()
150150
int nLen = 0;
151151
int nCode = 0;
152152
TCHAR* ptszMsgBuffer = NULL;
153-
if (!APIHelp_HttpRequest_Post(lpszUrl, NULL, &nCode, &ptszMsgBuffer, &nLen))
153+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, NULL, &nCode, &ptszMsgBuffer, &nLen))
154154
{
155155
printf("API_Manage_Task:%lX\n", APIHelp_GetLastError());
156156
return;

XEngine_APPClient/APPClient_UPDownload/APPClient_UPDownload.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using namespace std;
3232
//上传文件
3333
void File_UPLoad()
3434
{
35-
LPCTSTR lpszUrl = _T("http://192.168.1.8:5102/2.txt");
35+
LPCTSTR lpszUrl = _T("http://127.0.0.1:5102/api?filename=newfile4.txt&storeagekey=storagekey2");
3636
int nLen = 0;
3737
int nCode = 0;
3838
TCHAR* ptszMsgBuffer = NULL;
@@ -48,7 +48,7 @@ void File_UPLoad()
4848
OPenSsl_Help_BasicEncoder("123123aa", "123123", tszBaseBuffer);
4949

5050
_stprintf(tszHdrBuffer, _T("Range: bytes=0-5/10\r\nAuthorization: %s\r\n"), tszBaseBuffer);
51-
if (!APIHelp_HttpRequest_Post(lpszUrl, lpszMsgBuffer, &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
51+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, lpszMsgBuffer, &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
5252
{
5353
printf("upload failed:%lX\n", APIHelp_GetLastError());
5454
return;
@@ -66,9 +66,10 @@ void File_UPLoad()
6666
printf("upload:%d\n", nCode);
6767
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer);
6868
//断点续传必须指定storagekey
69+
nLen = 0;
6970
memset(tszHdrBuffer, '\0', MAX_PATH);
7071
_stprintf(tszHdrBuffer, _T("Range: bytes=5-9/10\r\nAuthorization: %s\r\nStorageKey: %s\r\n"), tszBaseBuffer, tszKeyBuffer);
71-
if (!APIHelp_HttpRequest_Post(lpszUrl, lpszMsgBuffer2, &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
72+
if (!APIHelp_HttpRequest_Custom(_T("POST"), lpszUrl, lpszMsgBuffer2, &nCode, &ptszMsgBuffer, &nLen, tszHdrBuffer))
7273
{
7374
printf("upload failed:%lX\n", APIHelp_GetLastError());
7475
return;
@@ -79,10 +80,9 @@ void File_UPLoad()
7980
//下载文件
8081
void File_Download()
8182
{
82-
LPCTSTR lpszUrl = _T("http://192.168.1.8:5101/storagekey2/2.txt");
83+
LPCTSTR lpszUrl = _T("http://192.168.1.8:5101/storagekey2/newfile4.txt");
8384

8485
int nLen = 0;
85-
int nCode = 0;
8686
TCHAR* ptszMsgBuffer = NULL;
8787
TCHAR tszBaseBuffer[128];
8888
TCHAR tszHdrBuffer[MAX_PATH];
@@ -92,7 +92,7 @@ void File_Download()
9292
OPenSsl_Help_BasicEncoder("123123aa", "123123", tszBaseBuffer);
9393

9494
_stprintf(tszHdrBuffer, _T("Range: bytes=0-5\r\nAuthorization: %s\r\n"), tszBaseBuffer);
95-
if (!APIHelp_HttpRequest_Get(lpszUrl, &ptszMsgBuffer, &nLen, &nCode, tszHdrBuffer))
95+
if (!APIHelp_HttpRequest_Custom(_T("GET"), lpszUrl, NULL, NULL, &ptszMsgBuffer, &nLen, tszHdrBuffer))
9696
{
9797
printf("download failed:%lX\n", APIHelp_GetLastError());
9898
return;
@@ -102,7 +102,7 @@ void File_Download()
102102

103103
memset(tszHdrBuffer, '\0', MAX_PATH);
104104
_stprintf(tszHdrBuffer, _T("Range: bytes=5-10\r\nAuthorization: %s\r\n"), tszBaseBuffer);
105-
if (!APIHelp_HttpRequest_Get(lpszUrl, &ptszMsgBuffer, &nLen, &nCode, tszHdrBuffer))
105+
if (!APIHelp_HttpRequest_Custom(_T("GET"), lpszUrl, NULL, NULL, &ptszMsgBuffer, &nLen, tszHdrBuffer))
106106
{
107107
printf("download failed:%lX\n", APIHelp_GetLastError());
108108
return;

XEngine_APPClient/VSCopy_x86.bat

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_BaseLib.dll" "./"
2+
copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_Algorithm.dll" "./"
3+
copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_OPenSsl.dll" "./"
4+
copy /y "%XEngine_Lib32%\XEngine_NetHelp\NetHelp_APIHelp.dll" "./"
5+
copy /y "%XEngine_Lib32%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./"
6+
copy /y "%XEngine_Lib32%\XEngine_Download\XEngine_Download.dll" "./"
7+
8+
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\zlib1.dll" "./"
9+
copy /y "%XEngine_Lib32%\XEngine_LibEx\libcrypto-3.dll" "./"
10+
copy /y "%XEngine_Lib32%\XEngine_LibEx\libssl-3.dll" "./"
11+
copy /y "%XEngine_Lib32%\XEngine_LibEx\libcurl.dll" "./"
12+
copy /y "%XEngine_Lib32%\XEngine_LibEx\nghttp2.dll" "./"

XEngine_Docment/Docment_en.docx

206 Bytes
Binary file not shown.

XEngine_Docment/Docment_zh.docx

317 Bytes
Binary file not shown.

XEngine_Source/StorageModule_APIHelp/APIHelp_Api/APIHelp_Api.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,5 +282,73 @@ BOOL CAPIHelp_Api::APIHelp_Api_GetIPInfo(LPCTSTR lpszMsgBuffer, int nMsgLen, XEN
282282
_tcscpy(pSt_IPAddrInfo->tszIPISP, st_JsonObject["tszIPISP"].asCString());
283283
_tcscpy(pSt_IPAddrInfo->tszIPTime, st_JsonObject["tszIPTime"].asCString());
284284

285+
return TRUE;
286+
}
287+
/********************************************************************
288+
函数名称:APIHelp_Api_UrlParse
289+
函数功能:URL参数解析函数
290+
参数.一:ppptszList
291+
In/Out:In
292+
类型:三级指针
293+
可空:N
294+
意思:输入要解析的列表
295+
参数.二:nListCount
296+
In/Out:In
297+
类型:整数型
298+
可空:N
299+
意思:输入列表个数
300+
参数.三:ptszFileName
301+
In/Out:Out
302+
类型:字符指针
303+
可空:N
304+
意思:输出文件名
305+
参数.四:ptszKeyName
306+
In/Out:Out
307+
类型:字符指针
308+
可空:N
309+
意思:输出存储的bucket
310+
返回值
311+
类型:逻辑型
312+
意思:是否成功
313+
备注:
314+
*********************************************************************/
315+
BOOL CAPIHelp_Api::APIHelp_Api_UrlParse(TCHAR*** ppptszList, int nListCount, TCHAR* ptszFileName, TCHAR* ptszKeyName)
316+
{
317+
APIHelp_IsErrorOccur = FALSE;
318+
319+
LPCTSTR lpszHDRFile = _T("filename");
320+
LPCTSTR lpszHDRKey = _T("storeagekey");
321+
LPCTSTR lpszHDRPath = _T("path");
322+
323+
for (int i = 0; i < nListCount; i++)
324+
{
325+
TCHAR tszKey[MAX_PATH];
326+
TCHAR tszValue[MAX_PATH];
327+
328+
memset(tszKey, '\0', MAX_PATH);
329+
memset(tszValue, '\0', MAX_PATH);
330+
331+
BaseLib_OperatorString_GetKeyValue((*ppptszList)[i], _T("="), tszKey, tszValue);
332+
333+
if (0 == _tcsnicmp(lpszHDRFile, tszKey, _tcslen(lpszHDRFile)))
334+
{
335+
//编码格式是utf8,需要转为ansi
336+
#ifdef _MSC_BUILD
337+
TCHAR tszFileName[MAX_PATH];
338+
memset(tszFileName, '\0', MAX_PATH);
339+
340+
OPenSsl_Codec_UrlDeCodec(tszValue, _tcslen(tszValue), tszFileName);
341+
342+
int nLen = _tcslen(tszFileName);
343+
BaseLib_OperatorCharset_UTFToAnsi(tszFileName, ptszFileName, &nLen);
344+
#else
345+
OPenSsl_Codec_UrlDeCodec(tszValue, _tcslen(tszValue), ptszFileName);
346+
#endif
347+
}
348+
else if (0 == _tcsnicmp(lpszHDRKey, tszKey, _tcslen(lpszHDRKey)))
349+
{
350+
_tcscpy(ptszKeyName, tszValue);
351+
}
352+
}
285353
return TRUE;
286354
}

0 commit comments

Comments
 (0)