Skip to content

Commit dc6c7eb

Browse files
authored
Merge pull request #6 from libxengine/develop
V2.4.0.1001 Merge
2 parents 0dd1d41 + 080ba6b commit dc6c7eb

File tree

56 files changed

+1888
-144
lines changed

Some content is hidden

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

56 files changed

+1888
-144
lines changed

CHANGELOG

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
XEngine_APIService V2.4.0.1001
2+
3+
添加:分布式锁
4+
添加:cdkey授权功能支持
5+
修改:插件文件名支持自适应了
6+
修改:linux和macos的程序名称
7+
修改:p2pcomm函数为comm公用函数
8+
修改:密码函数类型支持整数和字母了
9+
修复:提交方法没有释放头列表内存的问题
10+
11+
added:Distributed lock
12+
added:cdkey create function
13+
modify:plugin file name was support adaptive
14+
modify:linux and macos app name
15+
modify:p2pcomm function to comm
16+
modify:Password types support int and words
17+
fixed:post method does not free header list memory
18+
======================================================================================
119
XEngine_APIService V2.3.0.1001
220

321
添加:服务器能力查询接口函数

README.en.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ Support privatization deployment, free, safe, open source, controllable
3838
18. Twenty-four solar terms (planned)
3939
19. Xinhua Dictionary
4040
20. Metering Conversion
41-
21. CDKey Creator (planned)
42-
22. Distributed lock (planned)
41+
21. CDKey Creator
42+
22. Distributed lock
4343

4444
## install
4545

@@ -200,6 +200,40 @@ api:http://app.xyry.org:5501/api?function=translation&params1=中国&params2=0&p
200200
"msg":"success"
201201
}
202202
```
203+
Authorize CDKey
204+
Api:http://app.xyry.org:5501/api?function=cdkey&params1=0
205+
```json
206+
{
207+
"tszAddr":"服务器地址",
208+
"nPort":5000,
209+
"st_AuthAppInfo":{
210+
"tszAppName":"自定义名称",
211+
"tszAppVer":"自定义版本"
212+
},
213+
"st_AuthRegInfo":{
214+
"tszHardware":"硬件吗",
215+
"enSerialType":1,
216+
"enRegType":1,
217+
"enHWType":1
218+
},
219+
"st_AuthUserInfo":{
220+
"tszUserName":"注册的用户名",
221+
"tszUserContact":"联系方式",
222+
"tszCustom":"自定义,可选参数"
223+
}
224+
}
225+
```
226+
Distributed Lock
227+
Api:http://app.xyry.org:5501/api?function=lock&params1=1000154321&params2=1
228+
```json
229+
{
230+
"code":0,
231+
"data":{
232+
"xhToken":1000154321
233+
},
234+
"msg":"success"
235+
}
236+
```
203237
## Participate in contribution
204238
I hope you will submit more code to participate in the contribution
205239

README.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ c c++ interface api service
3838
18. 二十四节气(计划中)
3939
19. 新华词典
4040
20. 计量转换(计划中)
41-
21. CDKey创建支持(计划中)
42-
22. 分布式锁API(计划中)
41+
21. CDKey创建支持
42+
22. 分布式锁API
4343

4444
## 安装教程
4545

@@ -198,6 +198,40 @@ IP地址查询
198198
"msg":"success"
199199
}
200200
```
201+
CDKey授权
202+
接口:http://app.xyry.org:5501/api?function=cdkey&params1=0
203+
```json
204+
{
205+
"tszAddr":"服务器地址",
206+
"nPort":5000,
207+
"st_AuthAppInfo":{
208+
"tszAppName":"自定义名称",
209+
"tszAppVer":"自定义版本"
210+
},
211+
"st_AuthRegInfo":{
212+
"tszHardware":"硬件吗",
213+
"enSerialType":1,
214+
"enRegType":1,
215+
"enHWType":1
216+
},
217+
"st_AuthUserInfo":{
218+
"tszUserName":"注册的用户名",
219+
"tszUserContact":"联系方式",
220+
"tszCustom":"自定义,可选参数"
221+
}
222+
}
223+
```
224+
分布式锁
225+
接口:http://app.xyry.org:5501/api?function=lock&params1=1000154321&params2=1
226+
```json
227+
{
228+
"code":0,
229+
"data":{
230+
"xhToken":1000154321
231+
},
232+
"msg":"success"
233+
}
234+
```
201235
## 参与贡献
202236
希望大家多多提交代码参与贡献
203237

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#ifdef _MSC_BUILD
2+
#include <Windows.h>
3+
#include <tchar.h>
4+
#pragma comment(lib,"Ws2_32")
5+
#pragma comment(lib,"jsoncpp")
6+
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib")
7+
#pragma comment(lib,"XEngine_Core/XEngine_OPenSsl")
8+
#pragma comment(lib,"XEngine_NetHelp/NetHelp_APIHelp")
9+
#pragma comment(lib,"XEngine_HelpComponents/HelpComponents_Authorize")
10+
#endif
11+
#include <stdio.h>
12+
#include <stdlib.h>
13+
#include <string.h>
14+
#include <inttypes.h>
15+
#include <json/json.h>
16+
#include <XEngine_Include/XEngine_CommHdr.h>
17+
#include <XEngine_Include/XEngine_ProtocolHdr.h>
18+
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
19+
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
20+
#include <XEngine_Include/XEngine_Core/OPenSsl_Define.h>
21+
#include <XEngine_Include/XEngine_Core/OPenSsl_Error.h>
22+
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Define.h>
23+
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Error.h>
24+
#include <XEngine_Include/XEngine_HelpComponents/Authorize_Define.h>
25+
#include <XEngine_Include/XEngine_HelpComponents/Authorize_Error.h>
26+
27+
//需要优先配置XEngine
28+
//WINDOWS支持VS2022 x64 debug 编译调试
29+
//linux::g++ -std=c++17 -Wall -g APPClient_CDKeyExample.cpp -o APPClient_CDKeyExample.exe -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_NetHelp -L /usr/local/lib/XEngine_Release/XEngine_HelpComponents -lXEngine_BaseLib -lXEngine_OPenSsl -lNetHelp_APIHelp -lHelpComponents_Authorize
30+
//macos::g++ -std=c++17 -Wall -g APPClient_CDKeyExample.cpp -o APPClient_CDKeyExample.exe -lXEngine_BaseLib -lXEngine_OPenSsl -lNetHelp_APIHelp -lHelpComponents_Authorize
31+
32+
int main()
33+
{
34+
#ifdef _MSC_BUILD
35+
WSADATA st_WSAData;
36+
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
37+
#endif
38+
int nLen = 0;
39+
int nCode = 0;
40+
LPCTSTR lpszCreateUrl = _T("http://127.0.0.1:5501/api?function=cdkey&params1=0");
41+
42+
Json::Value st_JsonRoot;
43+
Json::Value st_JsonAPPInfo;
44+
Json::Value st_JsonREGInfo;
45+
Json::Value st_JsonUserInfo;
46+
st_JsonRoot["tszAddr"] = "http://app.xyry.org";
47+
st_JsonRoot["nPort"] = 5501;
48+
49+
st_JsonAPPInfo["tszAppName"] = "XEngine";
50+
st_JsonAPPInfo["tszAppVer"] = "1.0.0.1001";
51+
52+
st_JsonREGInfo["tszHardware"] = "5501012NE21N";
53+
st_JsonREGInfo["enSerialType"] = 3;
54+
st_JsonREGInfo["enRegType"] = 2;
55+
st_JsonREGInfo["enHWType"] = 1;
56+
57+
st_JsonUserInfo["tszUserName"] = "qyt";
58+
st_JsonUserInfo["tszUserContact"] = "[email protected]";
59+
60+
st_JsonRoot["st_AuthAppInfo"] = st_JsonAPPInfo;
61+
st_JsonRoot["st_AuthRegInfo"] = st_JsonREGInfo;
62+
st_JsonRoot["st_AuthUserInfo"] = st_JsonUserInfo;
63+
64+
TCHAR* ptszCreateBuffer = NULL;
65+
TCHAR* ptszAuthBuffer = NULL;
66+
if (!APIHelp_HttpRequest_Post(lpszCreateUrl, st_JsonRoot.toStyledString().c_str(), &nCode, &ptszCreateBuffer, &nLen))
67+
{
68+
printf("发送投递失败!\n");
69+
return 0;
70+
}
71+
printf("接受到数据,大小:%d,内容:%s\n", nLen, ptszCreateBuffer);
72+
73+
TCHAR tszMsgBuffer[4096];
74+
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
75+
//你也可以通过授权模块的API函数来读内存,都一回事,这里为了方便直接写了,请求分钟卡,拥有10分钟,也可以写自定义时间格式
76+
BaseLib_OperatorFile_WriteProfileFromMemory(ptszCreateBuffer, nLen, "AuthReg", "tszLeftTime", "10", tszMsgBuffer, &nLen);
77+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszCreateBuffer);
78+
79+
LPCTSTR lpszAuthUrl = _T("http://127.0.0.1:5501/api?function=cdkey&params1=1&params2=123123");
80+
if (!APIHelp_HttpRequest_Post(lpszAuthUrl, tszMsgBuffer, &nCode, &ptszAuthBuffer, &nLen))
81+
{
82+
printf("发送投递失败!\n");
83+
return 0;
84+
}
85+
//ptszAuthBuffer 写文件,然后验证即可.如下所示
86+
//step 1.解密
87+
CHAR tszCodecBuffer[4096];
88+
memset(tszCodecBuffer, '\0', sizeof(tszCodecBuffer));
89+
OPenSsl_XCrypto_Decoder(ptszAuthBuffer, &nLen, tszCodecBuffer, "123123");
90+
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszAuthBuffer);
91+
printf("接受到数据,大小:%d,内容:\n%s\n", nLen, tszCodecBuffer);
92+
//step 2.转换格式
93+
XENGINE_AUTHORIZE_LOCAL st_Authorize;
94+
memset(&st_Authorize, '\0', sizeof(XENGINE_AUTHORIZE_LOCAL));
95+
96+
Authorize_Local_ReadMemory(tszCodecBuffer, nLen, &st_Authorize);
97+
//step 3.判断您是否超时
98+
if (Authorize_Local_GetLeftTimer(&st_Authorize))
99+
{
100+
printf("ok\n");
101+
}
102+
else
103+
{
104+
printf("timeout\n");
105+
}
106+
#ifdef _MSC_BUILD
107+
WSACleanup();
108+
#endif
109+
return 0;
110+
}
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{155b430d-7cda-488c-b3ae-333d179d1943}</ProjectGuid>
25+
<RootNamespace>APPClientCDKeyExample</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v143</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v143</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v143</PlatformToolset>
46+
<CharacterSet>MultiByte</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v143</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
74+
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
75+
<LibraryPath>$(XEngine_Lib64);../../XEngine_Source/x64/Debug;$(LibraryPath)</LibraryPath>
76+
</PropertyGroup>
77+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
78+
<ClCompile>
79+
<WarningLevel>Level3</WarningLevel>
80+
<SDLCheck>true</SDLCheck>
81+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
82+
<ConformanceMode>true</ConformanceMode>
83+
</ClCompile>
84+
<Link>
85+
<SubSystem>Console</SubSystem>
86+
<GenerateDebugInformation>true</GenerateDebugInformation>
87+
</Link>
88+
</ItemDefinitionGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
90+
<ClCompile>
91+
<WarningLevel>Level3</WarningLevel>
92+
<FunctionLevelLinking>true</FunctionLevelLinking>
93+
<IntrinsicFunctions>true</IntrinsicFunctions>
94+
<SDLCheck>true</SDLCheck>
95+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
96+
<ConformanceMode>true</ConformanceMode>
97+
</ClCompile>
98+
<Link>
99+
<SubSystem>Console</SubSystem>
100+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
101+
<OptimizeReferences>true</OptimizeReferences>
102+
<GenerateDebugInformation>true</GenerateDebugInformation>
103+
</Link>
104+
</ItemDefinitionGroup>
105+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
106+
<ClCompile>
107+
<WarningLevel>Level3</WarningLevel>
108+
<SDLCheck>true</SDLCheck>
109+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
110+
<ConformanceMode>true</ConformanceMode>
111+
</ClCompile>
112+
<Link>
113+
<SubSystem>Console</SubSystem>
114+
<GenerateDebugInformation>true</GenerateDebugInformation>
115+
</Link>
116+
</ItemDefinitionGroup>
117+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
118+
<ClCompile>
119+
<WarningLevel>Level3</WarningLevel>
120+
<FunctionLevelLinking>true</FunctionLevelLinking>
121+
<IntrinsicFunctions>true</IntrinsicFunctions>
122+
<SDLCheck>true</SDLCheck>
123+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
124+
<ConformanceMode>true</ConformanceMode>
125+
</ClCompile>
126+
<Link>
127+
<SubSystem>Console</SubSystem>
128+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
129+
<OptimizeReferences>true</OptimizeReferences>
130+
<GenerateDebugInformation>true</GenerateDebugInformation>
131+
</Link>
132+
</ItemDefinitionGroup>
133+
<ItemGroup>
134+
<ClCompile Include="APPClient_CDKeyExample.cpp" />
135+
</ItemGroup>
136+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
137+
<ImportGroup Label="ExtensionTargets">
138+
</ImportGroup>
139+
</Project>

0 commit comments

Comments
 (0)