Skip to content

Commit df568ba

Browse files
authored
Merge pull request #22 from libxengine/develop
V3.6.0.1001 Merge
2 parents 57f749c + 28bde63 commit df568ba

File tree

73 files changed

+1881
-1737
lines changed

Some content is hidden

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

73 files changed

+1881
-1737
lines changed

CHANGELOG

Lines changed: 414 additions & 0 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
author by:qyt [email protected]
2+
3+
## 贡献准则(Contribution Guidelines)
4+
5+
此服务是一个尝试由社区驱动,你的共享价值将不可估量!
6+
the service is an attempt to be driven by the community, your shared value will be immeasurable!
7+
8+
## 提交代码(Submit code)
9+
10+
想要贡献代码,你需要按照我们的风格来提交代码.
11+
To contribute code, you need to submit code in our style
12+
13+
## 法律声明(Legal Notice)
14+
15+
如果你的提交的请求有依赖其他库,请注意库的版权.你的提交代码将被允许被我们随意复制,分发,删除,修改
16+
If your submitted request depends on other libraries, please pay attention to the copyright of the library. Your submitted code will be allowed to be copied, distributed, deleted, and modified by us at will

COPYRIGHT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
the open source software depend on the following libraries, please note the copyright
2+
XEngine:https://gitee.com/xyry/libxengine or https://github.com/libxengine/xengine
3+
jsoncpp:https://github.com/open-source-parsers/jsoncpp

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ P2P分布式下载与其他下载工具的超线程下载一样,原理是使用H
8080

8181
## 当前任务
8282
P2P广域网文件查找与下载支持
83+
分布式数据库存储
8384

8485
## 其他问题
8586
你可以参考docment目录下的文档.里面包含了API协议和服务说明.

XEngine_APPClient/APPClient_Download/APPClient_Download.cpp

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
//P2P Distributed(Hyper-Threading download sample code),only supports LAN,The example code is just to demonstrate how to implement it, and it needs to be adjusted for business
33
//你可以使用libcurl实现HTTP下载功能,主要是利用了Range字段实现分块下载
44
//You can use libcurl to implement the HTTP download, mainly using the Range field to achieve block download
5-
#ifdef _WINDOWS
5+
#ifdef _MSC_BUILD
66
#include <windows.h>
77
#include <tchar.h>
8+
#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib")
9+
#pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIHelp")
10+
#pragma comment(lib,"x86/XEngine_DownLoad/XEngine_DownLoad")
11+
#pragma comment(lib,"x86/XEngine_SystemSdk/XEngine_SystemApi")
12+
#pragma comment(lib,"Ws2_32")
13+
#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")
814
#else
915
#endif
1016
#include <list>
17+
#include <thread>
1118
#include <json/json.h>
1219
#include <XEngine_Include/XEngine_CommHdr.h>
1320
#include <XEngine_Include/XEngine_Types.h>
@@ -24,11 +31,10 @@
2431
#include "../../XEngine_Source/XStorage_Protocol.h"
2532
using namespace std;
2633

27-
#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib")
28-
#pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIHelp")
29-
#pragma comment(lib,"x86/XEngine_DownLoad/XEngine_DownLoad")
30-
#pragma comment(lib,"x86/XEngine_SystemSdk/XEngine_SystemApi")
31-
#pragma comment(lib,"Ws2_32")
34+
//需要优先配置XEngine
35+
//WINDOWS使用VS2022 x86 debug 编译
36+
//linux使用下面的命令编译
37+
//g++ -std=c++17 -Wall -g APPClient_Download.cpp -o APPClient_Download.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L /usr/local/lib/XEngine_Release/XEngine_DownLoad -L /usr/local/lib/XEngine_Release/XEngine_SystemSdk -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIHelp -lXEngine_Download -lXEngine_SystemApi -ljsoncpp
3238

3339
typedef struct
3440
{
@@ -88,15 +94,15 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
8894
list<P2PFILE_INFO>::const_iterator stl_ListIterator = pStl_ListFile->begin();
8995
for (int i = 0; stl_ListIterator != pStl_ListFile->end(); stl_ListIterator++, i++)
9096
{
91-
TCHAR tszDLUrl[MAX_PATH];
97+
TCHAR tszDLUrl[1024];
9298
TCHAR tszRange[128];
9399

94-
memset(tszDLUrl, '\0', MAX_PATH);
100+
memset(tszDLUrl, '\0', sizeof(tszDLUrl));
95101
memset(tszRange, '\0', sizeof(tszRange));
96102

97103
_stprintf(tszDLUrl, _T("%s/%s/%s"), stl_ListIterator->tszIPAddr, stl_ListIterator->st_ProtocolFile.tszFilePath + 2, stl_ListIterator->st_ProtocolFile.tszFileName);
98104
//是否是最后一块
99-
if (pStl_ListFile->size() == (i + 1))
105+
if ((int)pStl_ListFile->size() == (i + 1))
100106
{
101107
pSt_P2PFile[i].nPosStart = nPos;
102108
pSt_P2PFile[i].nPosEnd = 0;
@@ -112,7 +118,7 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
112118

113119
if (!DownLoad_Http_Create(&pSt_P2PFile[i].xhToken, tszDLUrl, lpszFile, tszRange, NULL, NULL, NULL))
114120
{
115-
printf("create download task is failed:%lX\n", Download_GetLastError());
121+
printf("create download task is failed:%X\n", Download_GetLastError());
116122
}
117123
}
118124
//直到所有完成
@@ -135,7 +141,7 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
135141
{
136142
break;
137143
}
138-
Sleep(500);
144+
std::this_thread::sleep_for(std::chrono::seconds(1));
139145
}
140146

141147
for (unsigned int i = 0; i < pStl_ListFile->size(); i++)
@@ -148,8 +154,10 @@ void P2PFile_Create(list<P2PFILE_INFO>* pStl_ListFile, LPCTSTR lpszFile)
148154

149155
int main()
150156
{
157+
#ifdef _MSC_BUILD
151158
WSADATA st_WSAData;
152159
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
160+
#endif
153161

154162
int nHTTPCode = 0;
155163
int nBodyLen = 2048;
@@ -179,6 +187,9 @@ int main()
179187
P2PFile_Create(&stl_ListFile, lpszFile);
180188

181189
BaseLib_OperatorMemory_FreeCStyle((VOID**)&ptszMsgBody);
190+
191+
#ifdef _MSC_BUILD
182192
WSACleanup();
193+
#endif
183194
return 0;
184195
}

XEngine_APPClient/APPClient_Download/APPClient_Download.vcxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@
2929
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
3030
<ConfigurationType>Application</ConfigurationType>
3131
<UseDebugLibraries>true</UseDebugLibraries>
32-
<PlatformToolset>v142</PlatformToolset>
32+
<PlatformToolset>v143</PlatformToolset>
3333
<CharacterSet>MultiByte</CharacterSet>
3434
</PropertyGroup>
3535
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
3636
<ConfigurationType>Application</ConfigurationType>
3737
<UseDebugLibraries>false</UseDebugLibraries>
38-
<PlatformToolset>v142</PlatformToolset>
38+
<PlatformToolset>v143</PlatformToolset>
3939
<WholeProgramOptimization>true</WholeProgramOptimization>
4040
<CharacterSet>Unicode</CharacterSet>
4141
</PropertyGroup>
4242
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
4343
<ConfigurationType>Application</ConfigurationType>
4444
<UseDebugLibraries>true</UseDebugLibraries>
45-
<PlatformToolset>v142</PlatformToolset>
45+
<PlatformToolset>v143</PlatformToolset>
4646
<CharacterSet>Unicode</CharacterSet>
4747
</PropertyGroup>
4848
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
4949
<ConfigurationType>Application</ConfigurationType>
5050
<UseDebugLibraries>false</UseDebugLibraries>
51-
<PlatformToolset>v142</PlatformToolset>
51+
<PlatformToolset>v143</PlatformToolset>
5252
<WholeProgramOptimization>true</WholeProgramOptimization>
5353
<CharacterSet>Unicode</CharacterSet>
5454
</PropertyGroup>
@@ -72,7 +72,7 @@
7272
<PropertyGroup Label="UserMacros" />
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7474
<LinkIncremental>true</LinkIncremental>
75-
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
75+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
7676
<LibraryPath>$(XEngine_Library);$(LibraryPath)</LibraryPath>
7777
</PropertyGroup>
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

XEngine_APPClient/APPClient_P2XPClient/APPClient_P2XPClient.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
#ifdef _WINDOWS
1+
#ifdef _MSC_BUILD
22
#include <windows.h>
33
#include <tchar.h>
4+
#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib")
5+
#pragma comment(lib,"x86/XEngine_Client/XClient_Socket")
6+
#pragma comment(lib,"x86/XEngine_Core/XEngine_NetXApi")
7+
#pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIHelp")
8+
#pragma comment(lib,"Ws2_32")
9+
#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")
410
#else
11+
#include <sys/types.h>
12+
#include <sys/socket.h>
513
#endif
614
#include <json/json.h>
715
#include <XEngine_Include/XEngine_CommHdr.h>
@@ -16,14 +24,13 @@
1624
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Error.h>
1725
#include "../../XEngine_Source/XStorage_Protocol.h"
1826

19-
#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib")
20-
#pragma comment(lib,"x86/XEngine_Client/XClient_Socket")
21-
#pragma comment(lib,"x86/XEngine_Core/XEngine_NetXApi")
22-
#pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIHelp")
23-
#pragma comment(lib,"Ws2_32")
27+
//需要优先配置XEngine
28+
//WINDOWS使用VS2022 x86 debug 编译
29+
//linux使用下面的命令编译
30+
//g++ -std=c++17 -Wall -g APPClient_P2XPClient.cpp -o APPClient_P2XPClient.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_Client -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lXEngine_OPenSsl -lXEngine_NetXApi -lXClient_Socket -lNetHelp_APIHelp -ljsoncpp
2431

2532
LPCTSTR lpszUserName = _T("123123aa");
26-
LPCTSTR lpszAddr = _T("192.168.1.7");
33+
LPCTSTR lpszAddr = _T("192.168.1.8");
2734

2835
TCHAR tszPublicAddr[128];
2936
TCHAR tszPrivateAddr[128];
@@ -55,16 +62,15 @@ int APPClient_P2XPLogin()
5562
return -1;
5663
}
5764
int nListCount = 0;
58-
APIHELP_NETCARD** ppSt_APICard;
59-
if (!APIHelp_NetWork_GetIPAddr(&ppSt_APICard, &nListCount, TRUE, tszPublicAddr))
60-
{
61-
return -1;
62-
}
65+
NETXAPI_CARDINFO** ppSt_APICard;
66+
NetXApi_Socket_GetCardInfo(&ppSt_APICard, &nListCount, AF_INET);
67+
APIHelp_NetWork_GetIPNet(tszPublicAddr);
6368
if (nListCount <= 0)
6469
{
6570
return -1;
6671
}
67-
_tcscpy(tszPrivateAddr, ppSt_APICard[0]->tszIPAddr);
72+
//得到IP地址
73+
strcpy(tszPrivateAddr, ppSt_APICard[0]->tszIPAddr);
6874
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_APICard, nListCount);
6975

7076
st_JsonRoot["tszUserName"] = lpszUserName;
@@ -203,8 +209,10 @@ int APPClient_P2XPConnect()
203209

204210
int main()
205211
{
212+
#ifdef _MSC_BUILD
206213
WSADATA st_WSAData;
207214
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
215+
#endif
208216

209217
if (!XClient_TCPSelect_Create(&m_hSocket, lpszAddr, nPort))
210218
{
@@ -216,6 +224,9 @@ int main()
216224
APPClient_P2XPConnect();
217225

218226
XClient_TCPSelect_Close(m_hSocket);
227+
228+
#ifdef _MSC_BUILD
219229
WSACleanup();
230+
#endif
220231
return 0;
221232
}

XEngine_APPClient/APPClient_P2XPClient/APPClient_P2XPClient.vcxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@
2929
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
3030
<ConfigurationType>Application</ConfigurationType>
3131
<UseDebugLibraries>true</UseDebugLibraries>
32-
<PlatformToolset>v142</PlatformToolset>
32+
<PlatformToolset>v143</PlatformToolset>
3333
<CharacterSet>MultiByte</CharacterSet>
3434
</PropertyGroup>
3535
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
3636
<ConfigurationType>Application</ConfigurationType>
3737
<UseDebugLibraries>false</UseDebugLibraries>
38-
<PlatformToolset>v142</PlatformToolset>
38+
<PlatformToolset>v143</PlatformToolset>
3939
<WholeProgramOptimization>true</WholeProgramOptimization>
4040
<CharacterSet>Unicode</CharacterSet>
4141
</PropertyGroup>
4242
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
4343
<ConfigurationType>Application</ConfigurationType>
4444
<UseDebugLibraries>true</UseDebugLibraries>
45-
<PlatformToolset>v142</PlatformToolset>
45+
<PlatformToolset>v143</PlatformToolset>
4646
<CharacterSet>Unicode</CharacterSet>
4747
</PropertyGroup>
4848
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
4949
<ConfigurationType>Application</ConfigurationType>
5050
<UseDebugLibraries>false</UseDebugLibraries>
51-
<PlatformToolset>v142</PlatformToolset>
51+
<PlatformToolset>v143</PlatformToolset>
5252
<WholeProgramOptimization>true</WholeProgramOptimization>
5353
<CharacterSet>Unicode</CharacterSet>
5454
</PropertyGroup>
@@ -72,7 +72,7 @@
7272
<PropertyGroup Label="UserMacros" />
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7474
<LinkIncremental>true</LinkIncremental>
75-
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
75+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
7676
<LibraryPath>$(XEngine_Library);$(LibraryPath)</LibraryPath>
7777
</PropertyGroup>
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

XEngine_APPClient/APPClient_RestApi/APPClient_RestApi.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
#ifdef _WINDOWS
1+
#ifdef _MSC_BUILD
22
#include <windows.h>
33
#include <tchar.h>
4-
#include <json/json.h>
4+
#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")
55
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
66
#pragma comment(lib,"XEngine_NetHelp/NetHelp_APIHelp")
77
#pragma comment(lib,"Ws2_32")
8-
#else
9-
#ifdef _CENTOS
10-
#include <json/json.h>
11-
#else
12-
#include <jsoncpp/json/json.h>
13-
#endif
148
#endif
159
#include <stdio.h>
1610
#include <string.h>
1711
#include <time.h>
1812
#include <list>
13+
#include <json/json.h>
1914
#include <XEngine_Include/XEngine_CommHdr.h>
2015
#include <XEngine_Include/XEngine_Types.h>
2116
#include <XEngine_Include/XEngine_ProtocolHdr.h>
@@ -26,6 +21,10 @@
2621
using namespace std;
2722

2823
//g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib -L ../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp -lXEngine_BaseLib -lNetHelp_APIHelp -ljsoncpp -Wl,-rpath=../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_BaseLib:../../../XEngine/XEngine_Release/XEngine_Linux/Ubuntu/XEngine_NetHelp,--disable-new-dtags
24+
//需要优先配置XEngine
25+
//WINDOWS使用VS2022 x86 debug 编译
26+
//linux使用下面的命令编译
27+
//g++ -std=c++17 -Wall -g APPClient_RestApi.cpp -o APPClient_RestApi.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lNetHelp_APIHelp -ljsoncpp
2928

3029
//查询
3130
void API_Manage_Query()

XEngine_APPClient/APPClient_RestApi/APPClient_RestApi.vcxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@
2929
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
3030
<ConfigurationType>Application</ConfigurationType>
3131
<UseDebugLibraries>true</UseDebugLibraries>
32-
<PlatformToolset>v142</PlatformToolset>
32+
<PlatformToolset>v143</PlatformToolset>
3333
<CharacterSet>MultiByte</CharacterSet>
3434
</PropertyGroup>
3535
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
3636
<ConfigurationType>Application</ConfigurationType>
3737
<UseDebugLibraries>false</UseDebugLibraries>
38-
<PlatformToolset>v142</PlatformToolset>
38+
<PlatformToolset>v143</PlatformToolset>
3939
<WholeProgramOptimization>true</WholeProgramOptimization>
4040
<CharacterSet>Unicode</CharacterSet>
4141
</PropertyGroup>
4242
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
4343
<ConfigurationType>Application</ConfigurationType>
4444
<UseDebugLibraries>true</UseDebugLibraries>
45-
<PlatformToolset>v142</PlatformToolset>
45+
<PlatformToolset>v143</PlatformToolset>
4646
<CharacterSet>Unicode</CharacterSet>
4747
</PropertyGroup>
4848
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
4949
<ConfigurationType>Application</ConfigurationType>
5050
<UseDebugLibraries>false</UseDebugLibraries>
51-
<PlatformToolset>v142</PlatformToolset>
51+
<PlatformToolset>v143</PlatformToolset>
5252
<WholeProgramOptimization>true</WholeProgramOptimization>
5353
<CharacterSet>Unicode</CharacterSet>
5454
</PropertyGroup>
@@ -72,7 +72,7 @@
7272
<PropertyGroup Label="UserMacros" />
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7474
<LinkIncremental>true</LinkIncremental>
75-
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
75+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
7676
<LibraryPath>$(XEngine_Lib32);$(LibraryPath)</LibraryPath>
7777
</PropertyGroup>
7878
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">

0 commit comments

Comments
 (0)