未验证 提交 1ecd4113 编写于 作者: xengine-qyt's avatar xengine-qyt 提交者: Gitee

!22 V3.7.0.1001 Merge

Merge pull request !22 from qyt/develop
XEngine_Storage V3.7.0.1001
优化:关闭广播
修改:Protocol_P2XPPacket_QueryFile函数名为Protocol_StoragePacket_REQFile
修改:程序启动会打印XEngine版本了
修正:动态重载配置文件不正确
修正:客户离开类型日志打印问题
删除:p2p相关文件和代码
improved:close broadcast
modify:Protocol_P2XPPacket_QueryFile function name to Protocol_StoragePacket_REQFile function name
modify:print xengine version when start program
fixed:reload configure file is incorrent
fixed:print problem that client leave type
delete:p2xp about file and code
======================================================================================
XEngine_Storage V3.6.0.1001
添加:在Protocol_StorageParse_QueryFile函数中添加模式参数
......
[中文](README.md) || [English](README.en.md)
# XEngine_Storage
This repository has a development and master branch. If you want to use it, please use the master branch
As long as the repository is not in a suspended state, someone will maintain and develop it all the time, please use it with confidence
## Introduction
c c++ 存储服务 c c++ 文件存储服务
......
[中文](README.md) || [English](README.en.md)
# XEngine_Storage
本仓库有开发和主分支,如果要使用,请使用master分支下的代码
只要仓库不是在暂停状态,那么就会有人一直维护和开发,请放心使用
## 介绍
c c++ 存储服务 c c++ 文件存储服务
......@@ -79,6 +80,7 @@ P2P分布式下载已经支持,不过目前只能在局域网中,暂时不支持
P2P分布式下载与其他下载工具的超线程下载一样,原理是使用HTTP RANGE字段实现.各位可以通过libcurl等库实现此功能.
## 当前任务
管理接口调试
P2P广域网文件查找与下载支持
分布式数据库存储
......
......@@ -163,12 +163,13 @@ int main()
int nBodyLen = 2048;
TCHAR *ptszMsgBody = NULL;
//请求分布式存储文件所有位置
LPCTSTR lpszUrl = _T("http://127.0.0.1:5100/Api/Manage/P2P");
LPCTSTR lpszUrl = _T("http://127.0.0.1:5100/Api/Manage/Query");
LPCTSTR lpszFile = _T("D:\\XEngine_Storage\\XEngine_APPClient\\Debug\\qq.exe");
Json::Value st_JsonRoot;
st_JsonRoot["nMode"] = 1; //使用P2P下载
st_JsonRoot["lpszBuckKey"] = "storagekey2";
st_JsonRoot["lpszFileHash"] = "781E5E245D69B566979B86E28D23F2C7";
st_JsonRoot["lpszFileName"] = "qq.exe";
if (!APIHelp_HttpRequest_Post(lpszUrl, st_JsonRoot.toStyledString().c_str(), &nHTTPCode, &ptszMsgBody, &nBodyLen))
{
......
#ifdef _MSC_BUILD
#include <windows.h>
#include <tchar.h>
#pragma comment(lib,"x86/XEngine_BaseLib/XEngine_BaseLib")
#pragma comment(lib,"x86/XEngine_Client/XClient_Socket")
#pragma comment(lib,"x86/XEngine_Core/XEngine_NetXApi")
#pragma comment(lib,"x86/XEngine_NetHelp/NetHelp_APIHelp")
#pragma comment(lib,"Ws2_32")
#pragma comment(lib,"../../XEngine_Source/Debug/jsoncpp")
#else
#include <sys/types.h>
#include <sys/socket.h>
#endif
#include <json/json.h>
#include <XEngine_Include/XEngine_CommHdr.h>
#include <XEngine_Include/XEngine_ProtocolHdr.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
#include <XEngine_Include/XEngine_Client/XClient_Define.h>
#include <XEngine_Include/XEngine_Client/XClient_Error.h>
#include <XEngine_Include/XEngine_Core/NetXApi_Define.h>
#include <XEngine_Include/XEngine_Core/NetXApi_Error.h>
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Define.h>
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Error.h>
#include "../../XEngine_Source/XStorage_Protocol.h"
//需要优先配置XEngine
//WINDOWS使用VS2022 x86 debug 编译
//linux使用下面的命令编译
//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
LPCTSTR lpszUserName = _T("123123aa");
LPCTSTR lpszAddr = _T("192.168.1.8");
TCHAR tszPublicAddr[128];
TCHAR tszPrivateAddr[128];
int nPort = 5103;
SOCKET m_hSocket;
int APPClient_P2XPLogin()
{
Json::Value st_JsonRoot;
TCHAR tszMsgBuffer[2048];
XENGINE_PROTOCOLHDR st_ProtocolHdr;
ENUM_XENGINE_NETXAPI_SOCKET_CONNECTTYPE dwNetType;
memset(tszPublicAddr, '\0', sizeof(tszPublicAddr));
memset(tszPrivateAddr, '\0', sizeof(tszPrivateAddr));
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_P2XP;
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQLOGIN;
st_ProtocolHdr.byVersion = 2;
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
//获取网络连接类型
if (!NetXApi_Socket_GetNetConnectType(&dwNetType))
{
return -1;
}
int nListCount = 0;
NETXAPI_CARDINFO** ppSt_APICard;
NetXApi_Socket_GetCardInfo(&ppSt_APICard, &nListCount, AF_INET);
APIHelp_NetWork_GetIPNet(tszPublicAddr);
if (nListCount <= 0)
{
return -1;
}
//得到IP地址
strcpy(tszPrivateAddr, ppSt_APICard[0]->tszIPAddr);
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_APICard, nListCount);
st_JsonRoot["tszUserName"] = lpszUserName;
st_JsonRoot["tszPrivateAddr"] = tszPrivateAddr;
st_JsonRoot["tszPublicAddr"] = tszPublicAddr;
st_JsonRoot["dwConnectType"] = (Json::Value::UInt)dwNetType;
st_JsonRoot["dwPeerType"] = 0;
st_ProtocolHdr.unPacketSize = st_JsonRoot.toStyledString().length();
int nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), st_ProtocolHdr.unPacketSize);
if (!XClient_TCPSelect_SendMsg(m_hSocket, tszMsgBuffer, nMsgLen))
{
return -1;
}
nMsgLen = sizeof(tszMsgBuffer);
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
XClient_TCPSelect_RecvMsg(m_hSocket, tszMsgBuffer, &nMsgLen, FALSE);
printf("APPClient_P2XPLogin:%s\n", tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR));
return 0;
}
int APPClient_P2XPList()
{
Json::Value st_JsonRoot;
TCHAR tszMsgBuffer[2048];
XENGINE_PROTOCOLHDR st_ProtocolHdr;
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_P2XP;
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQLANLIST;
st_ProtocolHdr.byVersion = 2;
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
st_JsonRoot["tszPublicAddr"] = tszPublicAddr;
st_JsonRoot["tszPrivateAddr"] = tszPrivateAddr;
st_ProtocolHdr.unPacketSize = st_JsonRoot.toStyledString().length();
int nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), st_ProtocolHdr.unPacketSize);
if (!XClient_TCPSelect_SendMsg(m_hSocket, tszMsgBuffer, nMsgLen))
{
return -1;
}
nMsgLen = sizeof(tszMsgBuffer);
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
XClient_TCPSelect_RecvMsg(m_hSocket, tszMsgBuffer, &nMsgLen, FALSE);
printf("APPClient_P2XPList:%s\n", tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR));
return 0;
}
int APPClient_P2XPGetUser()
{
Json::Value st_JsonRoot;
TCHAR tszMsgBuffer[2048];
XENGINE_PROTOCOLHDR st_ProtocolHdr;
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_P2XP;
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQUSERQUERY;
st_ProtocolHdr.byVersion = 2;
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
st_JsonRoot["tszUserName"] = lpszUserName;
st_ProtocolHdr.unPacketSize = st_JsonRoot.toStyledString().length();
int nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), st_ProtocolHdr.unPacketSize);
if (!XClient_TCPSelect_SendMsg(m_hSocket, tszMsgBuffer, nMsgLen))
{
return -1;
}
nMsgLen = sizeof(tszMsgBuffer);
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
XClient_TCPSelect_RecvMsg(m_hSocket, tszMsgBuffer, &nMsgLen, FALSE);
printf("APPClient_P2XPGetUser:%s\n", tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR));
return 0;
}
int APPClient_P2XPConnect()
{
Json::Value st_JsonRoot;
TCHAR tszMsgBuffer[2048];
XENGINE_PROTOCOLHDR st_ProtocolHdr;
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
st_ProtocolHdr.wHeader = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER;
st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_P2XP;
st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQCONNECT;
st_ProtocolHdr.byVersion = 2;
st_ProtocolHdr.wTail = XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL;
st_JsonRoot["tszPublicAddr"] = tszPublicAddr;
st_JsonRoot["tszPrivateAddr"] = tszPrivateAddr;
st_ProtocolHdr.unPacketSize = st_JsonRoot.toStyledString().length();
int nMsgLen = sizeof(XENGINE_PROTOCOLHDR) + st_ProtocolHdr.unPacketSize;
memcpy(tszMsgBuffer, &st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), st_ProtocolHdr.unPacketSize);
if (!XClient_TCPSelect_SendMsg(m_hSocket, tszMsgBuffer, nMsgLen))
{
return -1;
}
nMsgLen = sizeof(tszMsgBuffer);
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
XClient_TCPSelect_RecvMsg(m_hSocket, tszMsgBuffer, &nMsgLen, FALSE);
printf("%s\n", tszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR));
return 0;
}
int main()
{
#ifdef _MSC_BUILD
WSADATA st_WSAData;
WSAStartup(MAKEWORD(2, 2), &st_WSAData);
#endif
if (!XClient_TCPSelect_Create(&m_hSocket, lpszAddr, nPort))
{
return -1;
}
APPClient_P2XPLogin();
APPClient_P2XPList();
APPClient_P2XPGetUser();
APPClient_P2XPConnect();
XClient_TCPSelect_Close(m_hSocket);
#ifdef _MSC_BUILD
WSACleanup();
#endif
return 0;
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{6a38a644-ab6e-43d1-adff-dd963239ed39}</ProjectGuid>
<RootNamespace>APPClientP2XPClient</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(XEngine_Include);../../XEngine_Source/XEngine_ThirdPart/jsoncpp;$(IncludePath)</IncludePath>
<LibraryPath>$(XEngine_Library);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="APPClient_P2XPClient.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="APPClient_P2XPClient.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31410.357
# Visual Studio Version 17
VisualStudioVersion = 17.2.32526.322
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APPClient_P2XPClient", "APPClient_P2XPClient\APPClient_P2XPClient.vcxproj", "{6A38A644-AB6E-43D1-ADFF-DD963239ED39}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APPClient_Download", "APPClient_Download\APPClient_Download.vcxproj", "{16608D17-1839-48D8-A455-21AAF0257E36}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "APPClient_UPDownload", "APPClient_UPDownload\APPClient_UPDownload.vcxproj", "{01470EBD-47EC-4AC1-BA0D-C75926DD1E60}"
......@@ -19,14 +17,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Debug|x64.ActiveCfg = Debug|x64
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Debug|x64.Build.0 = Debug|x64
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Debug|x86.ActiveCfg = Debug|Win32
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Debug|x86.Build.0 = Debug|Win32
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Release|x64.ActiveCfg = Release|x64
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Release|x64.Build.0 = Release|x64
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Release|x86.ActiveCfg = Release|Win32
{6A38A644-AB6E-43D1-ADFF-DD963239ED39}.Release|x86.Build.0 = Release|Win32
{16608D17-1839-48D8-A455-21AAF0257E36}.Debug|x64.ActiveCfg = Debug|x64
{16608D17-1839-48D8-A455-21AAF0257E36}.Debug|x64.Build.0 = Debug|x64
{16608D17-1839-48D8-A455-21AAF0257E36}.Debug|x86.ActiveCfg = Debug|Win32
......
......@@ -56,7 +56,7 @@
"XLimit":{
"nDLTry":10,
"nMaxUPLoad":4096000,
"nMaxDNLoad":4096000
"nMaxDNLoad":40960000
},
"XP2xp":{
"nTime":2,
......
......@@ -5,9 +5,7 @@ FLAGS = RELEASE=$(RELEASE)
THIRD_JSONCPP_PATH = ./XEngine_ThirdPart/jsoncpp
STORAGE_SQL_PATH = ./StorageModule_Database
STORAGE_P2XP_PATH = ./StorageModule_P2XPPeer
BASE_SQL_PATH = ./StorageModule_Database
BASE_CONFIG_PATH = ./StorageModule_Config
BASE_SESSION_PATH = ./StorageModule_Session
BASE_APIHELP_PATH = ./StorageModule_APIHelp
......@@ -16,9 +14,8 @@ BASE_PROTOCOL_PATH = ./StorageModule_Protocol
APPSERVICE_STORAGE_PATH = ./XEngine_StorageApp
NETENGINE_LIB = libjsoncpp.so \
libStorageModule_Database.so libStorageModule_P2XPPeer.so \
libStorageModule_Config.so libStorageModule_Session.so libStorageModule_APIHelp.so libStorageModule_Protocol.so \
XEngine_StorageApp.exe
libStorageModule_Database.so libStorageModule_Config.so libStorageModule_Session.so libStorageModule_APIHelp.so libStorageModule_Protocol.so \
XEngine_StorageApp.exe
.PHONY:MakeAll
MakeAll:$(NETENGINE_LIB)
......@@ -27,10 +24,7 @@ libjsoncpp.so:
make -C $(THIRD_JSONCPP_PATH) $(FLAGS)
libStorageModule_Database.so:
make -C $(STORAGE_SQL_PATH) $(FLAGS)
libStorageModule_P2XPPeer.so:
make -C $(STORAGE_P2XP_PATH) $(FLAGS)
make -C $(BASE_SQL_PATH) $(FLAGS)
libStorageModule_Config.so:
make -C $(BASE_CONFIG_PATH) $(FLAGS)
libStorageModule_Session.so:
......
......@@ -21,7 +21,6 @@ typedef struct tag_XEngine_ServerConfig
int nCenterPort;
int nStorageDLPort;
int nStorageUPPort;
int nP2XPPort;
struct
{
BOOL bReload;
......@@ -34,7 +33,6 @@ typedef struct tag_XEngine_ServerConfig
int nCenterThread;
int nStorageDLThread;
int nStorageUPThread;
int nP2XPThread;
}st_XMax;
struct
{
......@@ -43,7 +41,6 @@ typedef struct tag_XEngine_ServerConfig
int nTimeCheck;
int nCenterTimeOut;
int nStorageTimeOut;
int nP2XPTimeOut;
}st_XTime;
struct
{
......@@ -94,7 +91,6 @@ typedef struct tag_XEngine_ServerConfig
int nTime;
int nSDPort;
int nRVPort;
TCHAR tszQQWryFile[MAX_PATH];
}st_P2xp;
struct
{
......
......@@ -86,9 +86,8 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVERCONFIG
pSt_ServerConfig->nCenterPort = st_JsonRoot["nCenterPort"].asInt();
pSt_ServerConfig->nStorageDLPort = st_JsonRoot["nStorageDLPort"].asInt();
pSt_ServerConfig->nStorageUPPort = st_JsonRoot["nStorageUPPort"].asInt();
pSt_ServerConfig->nP2XPPort = st_JsonRoot["nP2XPPort"].asInt();
if (st_JsonRoot["XMax"].empty() || (7 != st_JsonRoot["XMax"].size()))
if (st_JsonRoot["XMax"].empty() || (6 != st_JsonRoot["XMax"].size()))
{
Config_IsErrorOccur = TRUE;
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_XMAX;
......@@ -101,9 +100,8 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVERCONFIG
pSt_ServerConfig->st_XMax.nCenterThread = st_JsonXMax["CenterThread"].asInt();
pSt_ServerConfig->st_XMax.nStorageUPThread = st_JsonXMax["nStorageUPThread"].asInt();
pSt_ServerConfig->st_XMax.nStorageDLThread = st_JsonXMax["nStorageDLThread"].asInt();
pSt_ServerConfig->st_XMax.nP2XPThread = st_JsonXMax["nP2XPThread"].asInt();
if (st_JsonRoot["XTime"].empty() || (6 != st_JsonRoot["XTime"].size()))
if (st_JsonRoot["XTime"].empty() || (5 != st_JsonRoot["XTime"].size()))
{
Config_IsErrorOccur = TRUE;
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_XTIME;
......@@ -115,7 +113,6 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVERCONFIG
pSt_ServerConfig->st_XTime.nTimeCheck = st_JsonXTime["nTimeCheck"].asInt();
pSt_ServerConfig->st_XTime.nCenterTimeOut = st_JsonXTime["nCenterTimeOut"].asInt();
pSt_ServerConfig->st_XTime.nStorageTimeOut = st_JsonXTime["nStorageTimeOut"].asInt();
pSt_ServerConfig->st_XTime.nP2XPTimeOut = st_JsonXTime["nP2XPTimeOut"].asInt();
if (st_JsonRoot["XLog"].empty() || (3 != st_JsonRoot["XLog"].size()))
{
......@@ -184,7 +181,7 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVERCONFIG
pSt_ServerConfig->st_XLimit.nMaxDNLoader = st_JsonXLimit["nMaxDNLoad"].asInt64();
pSt_ServerConfig->st_XLimit.nMaxUPLoader = st_JsonXLimit["nMaxUPLoad"].asInt64();
if (st_JsonRoot["XP2xp"].empty() || (4 != st_JsonRoot["XP2xp"].size()))
if (st_JsonRoot["XP2xp"].empty() || (3 != st_JsonRoot["XP2xp"].size()))
{
Config_IsErrorOccur = TRUE;
Config_dwErrorCode = ERROR_XENGINE_BLOGIC_CONFIG_JSON_P2XP;
......@@ -194,7 +191,6 @@ BOOL CConfig_Json::Config_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVERCONFIG
pSt_ServerConfig->st_P2xp.nTime = st_JsonP2xp["nTime"].asInt();
pSt_ServerConfig->st_P2xp.nRVPort = st_JsonP2xp["nRVPort"].asInt();
pSt_ServerConfig->st_P2xp.nSDPort = st_JsonP2xp["nSDPort"].asInt();
_tcscpy(pSt_ServerConfig->st_P2xp.tszQQWryFile, st_JsonP2xp["tszQQWryFile"].asCString());
if (st_JsonRoot["XCert"].empty() || (6 != st_JsonRoot["XCert"].size()))
{
......
CC = g++ -Wall -std=c++17 -fPIC
RELEASE = 0
UNICODE = 0
INCLUDE = -I ./
FILECENTOS = /etc/redhat-release
LOADBIN = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib
LIB = -lXEngine_BaseLib
LIBEX = -static-libgcc -lrt -ldl -lpthread
LOADSO = -Wl,-rpath=./,--disable-new-dtags
LIBINCLUDE = P2XPPeer_Manage.o pch.o
ifeq ($(RELEASE),1)
FLAGS = -c -O2
DEBUG =
else
FLAGS = -c -lc_p
DEBUG = -g -pg
endif
ifeq ($(UNICODE),1)
UNICODE = -D _UNICODE
else
UNICODE =
endif
all:$(LIBINCLUDE)
$(CC) $(DEBUG) $(LIBINCLUDE) -o libStorageModule_P2XPPeer.so -shared -fPIC $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO)
P2XPPeer_Manage.o:./P2XPPeer_Manage/P2XPPeer_Manage.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./P2XPPeer_Manage/P2XPPeer_Manage.cpp
pch.o:pch.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) pch.cpp
InstallAll:InstallSo
InstallSo:./libStorageModule_P2XPPeer.so
cp ./libStorageModule_P2XPPeer.so ../../XEngine_Release/libStorageModule_P2XPPeer.so
CleanAll:CleanObj CleanMk
CleanObj:
rm *.o
CleanMk:
rm *.so
#pragma once
/********************************************************************
// Created: 2022/03/29 14:31:05
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer\P2XPPeer_Define.h
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer
// File Base: P2XPPeer_Define
// File Ext: h
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: 节点管理器导出定义
// History:
*********************************************************************/
//////////////////////////////////////////////////////////////////////////
// 导出数据结构
//////////////////////////////////////////////////////////////////////////
//计时器
typedef struct tag_P2XP_Timer_Information
{
__int64x dwUserTime; //用户存在时间
__int64x dwPacketTime; //包时间,拿到包后的存活时间
__int64x dwKeepAlive; //保活计时器时间,经过网络时间
unsigned short int usTTL : 1; //路由数
}P2XP_TIMER_INFOMATION, *LPP2XP_TIMER_INFOMATION;
//一个节点信息
typedef struct tag_NetEngine_P2XPPeer_Info
{
XENGINE_P2XPPEER_PROTOCOL st_PeerAddr; //P2P通信的时候使用的地址(客户方使用)
P2XP_TIMER_INFOMATION st_PeerTimer; //节点时间信息
XENGINE_IPADDRINFO st_IPAddrInfo; //IP地址信息
BOOL bIsLogin;
}XENGINE_P2XP_PEERINFO,*LPNETENGINE_P2XP_PEERINFO;
//////////////////////////////////////////////////////////////////////////
// 导出函数
//////////////////////////////////////////////////////////////////////////
extern "C" DWORD P2XPPeer_GetLastError(int *pInt_ErrorCode = NULL);
/************************************************************************/
/* 节点管理器导出函数 */
/************************************************************************/
/********************************************************************
函数名称:P2XPPeer_Manage_Add
函数功能:添加一个客户到一个节点信息
参数.一:pSt_PeerInfo
In/Out:In
类型:结构体指针
可空:N
意思:要添加的节点信息
返回值
类型:逻辑型
意思:是否添加成功
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_Add(XENGINE_P2XP_PEERINFO st_PeerInfo);
/********************************************************************
函数名称:P2XPPeer_Manage_Get
函数功能:获取P2P节点对应信息
参数.一:lpszAddr
In/Out:In
类型:常量字符指针
可空:N
意思:要查询的地址
参数.二:pSt_PeerInfo
In/Out:Out
类型:数据结构指针
可空:Y
意思:如果为空将不导出对应的数据
返回值
类型:逻辑型
意思:是否查找成功
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_Get(LPCSTR lpszAddr,XENGINE_P2XP_PEERINFO *pSt_PeerInfo = NULL);
/********************************************************************
函数名称:P2XPPeer_Manage_GetUser
函数功能:通过用户名获取节点信息
参数.一:lpszUser
In/Out:In
类型:常量字符指针
可空:N
意思:要搜索的用户的 标识符
参数.二:pSt_PeerInfo
In/Out:Out
类型:数据结构指针
可空:Y
意思:导出获取到的信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_GetUser(LPCSTR lpszUser, XENGINE_P2XP_PEERINFO *pSt_PeerInfo = NULL);
/********************************************************************
函数名称:P2XPPeer_Manage_GetLan
函数功能:获取局域网IP地址列表
参数.一:lpszPubAddr
In/Out:In
类型:常量字符指针
可空:N
意思:要查找的局域网相同公网的IP地址
参数.二:lpszPriAddr
In/Out:In
类型:常量字符指针
可空:N
意思:输入要获取同一公网下不同私有网段的IP列表
参数.三:pppSt_P2XPClient
In/Out:Out
类型:三级指针
可空:N
意思:导出局域网IP地址列表
参数.四:pInt_ListCount
In/Out:Out
类型:整数型指针
可空:N
意思:输出地址列表个数
返回值
类型:逻辑型
意思:是否成功
备注:参数三需要调用基础库的BaseLib_OperatorMemory_Free函数进行内存释放
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_GetLan(LPCSTR lpszPubAddr, LPCSTR lpszPriAddr, XENGINE_P2XPPEER_PROTOCOL * **pppSt_P2XPClient, int* pInt_ListCount);
/********************************************************************
函数名称:P2XPPeer_Manage_GetLList
函数功能:获取同一公网下所有局域网主IP列表
参数.一:lpszPubAddr
In/Out:In
类型:常量字符指针
可空:N
意思:输入要获取的IP地址
参数.二:pppszP2XPClient
In/Out:Out
类型:三级指针
可空:N
意思:输出内网主IP地址列表
参数.三:pInt_ListCount
In/Out:Out
类型:整数型指针
可空:N
意思:输出列表个数
返回值
类型:逻辑型
意思:是否成功
备注:参数二需要调用基础库的BaseLib_OperatorMemory_Free函数进行内存释放
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_GetLList(LPCSTR lpszPubAddr, CHAR*** pppszP2XPClient, int* pInt_ListCount);
/********************************************************************
函数名称:P2XPPeer_Manage_GetWList
函数功能:获取所有连接到的公网地址列表
参数.一:pppszP2XPClient
In/Out:Out
类型:三级指针
可空:N
意思:输出地址列表
参数.二:pInt_ListCount
In/Out:Out
类型:整数型指针
可空:N
意思:输出列表个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_GetWList(CHAR*** pppszP2XPClient, int* pInt_ListCount);
/********************************************************************
函数名称:P2XPPeer_Manage_GetAllList
函数功能:获取所有客户端
参数.一:pppszP2XPClient
In/Out:Out
类型:三级指针
可空:N
意思:输出客户端列表
参数.二:pInt_ListCount
In/Out:Out
类型:整数型指针
可空:N
意思:输出客户端个数
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_GetAllList(TCHAR*** pppszP2XPClient, int* pInt_ListCount);
/********************************************************************
函数名称:P2XPPeer_Manage_Set
函数功能:设置指定客户的节点信息
参数.一:lpszAddr
In/Out:In
类型:常量字符指针
可空:N
意思:要设置的客户
参数.二:st_PeerInfo
In/Out:In
类型:结构体
可空:N
意思:要设置的节点信息
返回值
类型:逻辑型
意思:是否设置成功
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_Set(LPCSTR lpszAddr,XENGINE_P2XP_PEERINFO st_PeerInfo);
/********************************************************************
函数名称:P2XPPeer_Manage_Delete
函数功能:删除一个指定的节点
参数.一:pszUserName
In/Out:In
类型:字符串指针
可空:N
意思:要删除的节点名称
返回值
类型:逻辑型
意思:是否成功删除
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_Delete(LPCSTR lpszUserName);
/********************************************************************
函数名称:P2XPPeer_Manage_DelAll
函数功能:清空节点列表数据
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_DelAll();
/********************************************************************
函数名称:P2XPPeer_Manage_GetCount
函数功能:获取节点个数
参数.一:pInt_PeerCount
In/Out:Out
类型:整数型指针
可空:N
意思:导出获取到的个数
返回值
类型:逻辑型
意思:是否成功获取到节点个数
备注:
*********************************************************************/
extern "C" BOOL P2XPPeer_Manage_GetCount(int *pInt_PeerCount);
\ No newline at end of file
#pragma once
/********************************************************************
// Created: 2022/03/29 14:31:13
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer\P2XPPeer_Error.h
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer
// File Base: P2XPPeer_Error
// File Ext: h
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: P2P节点管理器导出错误
// History:
*********************************************************************/
/************************************************************************/
/* 节点管理器错误 */
/************************************************************************/
#define ERROR_XENGINE_P2XP_PEER_MANAGE_ADD_ISEXIST 0xB0E0001 //用户已经存在
#define ERROR_XENGINE_P2XP_PEER_MANAGE_ADD_MALLOC 0xB0E0002 //申请内存失败
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GET_PARAMENT 0xB0E0010 //获取用户信息失败,参数错误
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GET_NOTFOUND 0xB0E0011 //没有找到用户
#define ERROR_XENGINE_P2XP_PEER_MANAGE_SET_PARAMENT 0xB0E0020 //参数错误
#define ERROR_XENGINE_P2XP_PEER_MANAGE_SET_NOTFOUND 0xB0E0021 //没有找到用户
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETWLIST_PARAMENT 0xB0E0030 //参数错误
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETWLIST_NOTFOUND 0xB0E0031 //没有找到
#define ERROR_XENGINE_P2XP_PEER_MANAGE_DELETE_PARAMENT 0xB0E0040 //参数错误
#define ERROR_XENGINE_P2XP_PEER_MANAGE_DELETE_NOTFOUND 0xB0E0041 //没有找到用户
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETLAN_PARAMENT 0xB0E0050 //参数错误
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETLAN_NOTPUBADDRR 0xB0E0051 //公网IP地址没有找到
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETLAN_NOTPRIADDR 0xB0E0052 //私有网络IP地址没有找到
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETLAN_NOLIST 0xB0E0053 //没有数据存在
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETLAN_NOTFOUND 0xB0E0054 //没有找到链接地址
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETUSER_PARAMENT 0xB0E0060 //参数错误
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETUSER_NOTFOUND 0xB0E0061 //没有找到
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETLLIST_PARAMENT 0xB0E0070 //获取列表失败,参数错误
#define ERROR_XENGINE_P2XP_PEER_MANAGE_GETLLIST_NOTFOUND 0xB0E0071 //没有找到指定列表
#pragma once
/********************************************************************
// Created: 2022/03/29 14:30:57
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer\P2XPPeer_Manage\P2XPPeer_Manage.h
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer\P2XPPeer_Manage
// File Base: P2XPPeer_Manage
// File Ext: h
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: P2P节点管理器
// History:
*********************************************************************/
class CP2XPPeer_Manage
{
public:
CP2XPPeer_Manage();
~CP2XPPeer_Manage();
public:
BOOL P2XPPeer_Manage_Add(XENGINE_P2XP_PEERINFO st_PeerInfo); //向列表中添加一个节点
BOOL P2XPPeer_Manage_Get(LPCTSTR lpszAddr, XENGINE_P2XP_PEERINFO* pSt_PeerInfo = NULL); //查找指定用户名对应的节点
BOOL P2XPPeer_Manage_GetUser(LPCTSTR lpszUser, XENGINE_P2XP_PEERINFO* pSt_PeerInfo = NULL); //查找指定用户名对应的节点
BOOL P2XPPeer_Manage_GetLan(LPCTSTR lpszPubAddr, LPCTSTR lpszPriAddr, XENGINE_P2XPPEER_PROTOCOL*** pppSt_P2XPClient, int* pInt_ListCount); //获取公网下的局域网IP地址列表
BOOL P2XPPeer_Manage_GetLList(LPCTSTR lpszPubAddr, TCHAR*** pppszP2XPClient, int* pInt_ListCount);
BOOL P2XPPeer_Manage_GetWList(TCHAR*** pppszP2XPClient, int* pInt_ListCount);
BOOL P2XPPeer_Manage_GetAllList(TCHAR*** pppszP2XPClient, int* pInt_ListCount);
BOOL P2XPPeer_Manage_Set(LPCTSTR lpszAddr,XENGINE_P2XP_PEERINFO st_PeerInfo); //设置指定客户的节点信息
BOOL P2XPPeer_Manage_Delete(LPCTSTR lpszUserName); //从列表中删除一个节点
BOOL P2XPPeer_Manage_DelAll(); //清空节点列表
BOOL P2XPPeer_Manage_GetCount(int *pInt_PeerCount); //获取有多少个节点
protected:
BOOL P2XPPeer_Manage_AddLan(XENGINE_P2XPPEER_PROTOCOL st_ClientAddr); //添加到局域网节点列表
BOOL P2XPPeer_Manage_DelLan(XENGINE_P2XPPEER_PROTOCOL st_ClientAddr); //从列表中删除一个节点
private:
shared_mutex st_rwLocker; //节点读写保护区
private:
unordered_map<string,LPNETENGINE_P2XP_PEERINFO> stl_MapPeerAddr; //链接地址管理
unordered_map<string, unordered_map<string, list<XENGINE_P2XPPEER_PROTOCOL> > > stl_MapClients;
};
LIBRARY
EXPORTS
P2XPPeer_GetLastError
P2XPPeer_Manage_Add
P2XPPeer_Manage_Get
P2XPPeer_Manage_GetUser
P2XPPeer_Manage_GetLan
P2XPPeer_Manage_GetLList
P2XPPeer_Manage_GetWList
P2XPPeer_Manage_GetAllList
P2XPPeer_Manage_Set
P2XPPeer_Manage_Delete
P2XPPeer_Manage_DelAll
P2XPPeer_Manage_GetCount
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{91bb60c1-34b4-4d1f-92eb-53f8cc8b51c3}</ProjectGuid>
<RootNamespace>StorageModuleP2XPPeer</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
<LibraryPath>$(XEngine_Lib32);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
<LibraryPath>$(XEngine_Lib32);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
<LibraryPath>$(XEngine_Lib64);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(XEngine_Include);$(IncludePath)</IncludePath>
<LibraryPath>$(XEngine_Lib64);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;STORAGEMODULEP2XPPEER_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>StorageModule_P2XPPeer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;STORAGEMODULEP2XPPEER_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>StorageModule_P2XPPeer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;STORAGEMODULEP2XPPEER_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>StorageModule_P2XPPeer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;STORAGEMODULEP2XPPEER_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<ModuleDefinitionFile>StorageModule_P2XPPeer.def</ModuleDefinitionFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="P2XPPeer_Define.h" />
<ClInclude Include="P2XPPeer_Error.h" />
<ClInclude Include="P2XPPeer_Manage\P2XPPeer_Manage.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="P2XPPeer_Manage\P2XPPeer_Manage.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="StorageModule_P2XPPeer.def" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="头文件\P2XPPeer_Manage">
<UniqueIdentifier>{1da12ece-16c3-4c42-a41e-f92dacbc766e}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\P2XPPeer_Manage">
<UniqueIdentifier>{175784f0-cef5-4663-a199-4307a3f8de63}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="P2XPPeer_Manage\P2XPPeer_Manage.h">
<Filter>头文件\P2XPPeer_Manage</Filter>
</ClInclude>
<ClInclude Include="P2XPPeer_Define.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="P2XPPeer_Error.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="P2XPPeer_Manage\P2XPPeer_Manage.cpp">
<Filter>源文件\P2XPPeer_Manage</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="StorageModule_P2XPPeer.def">
<Filter>源文件</Filter>
</None>
</ItemGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
\ No newline at end of file
// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
#pragma once
#define WIN32_LEAN_AND_MEAN // 从 Windows 头文件中排除极少使用的内容
// Windows 头文件
#include <windows.h>
#include "pch.h"
#include "P2XPPeer_Manage/P2XPPeer_Manage.h"
/********************************************************************
// Created: 2022/03/29 14:32:06
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer\pch.cpp
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer
// File Base: pch
// File Ext: cpp
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: P2P节点管理器导出函数实现
// History:
*********************************************************************/
BOOL PeerManage_IsErrorOccur = FALSE;
DWORD PeerManage_dwErrorCode = 0;
//////////////////////////////////////////////////////////////////////////
CP2XPPeer_Manage m_P2PPeerManage;
//////////////////////////////////////////////////////////////////////////
extern "C" DWORD P2XPPeer_GetLastError(int* pInt_ErrorCode)
{
if (NULL != pInt_ErrorCode)
{
*pInt_ErrorCode = errno;
}
return PeerManage_dwErrorCode;
}
//////////////////////////////////////////////////////////////////////////
extern "C" BOOL P2XPPeer_Manage_Add(XENGINE_P2XP_PEERINFO st_PeerInfo)
{
return m_P2PPeerManage.P2XPPeer_Manage_Add(st_PeerInfo);
}
extern "C" BOOL P2XPPeer_Manage_Get(LPCTSTR lpszAddr, XENGINE_P2XP_PEERINFO * pSt_PeerInfo /* = NULL */)
{
return m_P2PPeerManage.P2XPPeer_Manage_Get(lpszAddr, pSt_PeerInfo);
}
extern "C" BOOL P2XPPeer_Manage_GetUser(LPCTSTR lpszUser, XENGINE_P2XP_PEERINFO * pSt_PeerInfo)
{
return m_P2PPeerManage.P2XPPeer_Manage_GetUser(lpszUser, pSt_PeerInfo);
}
extern "C" BOOL P2XPPeer_Manage_GetLan(LPCTSTR lpszPubAddr, LPCTSTR lpszPriAddr, XENGINE_P2XPPEER_PROTOCOL * **pppSt_P2XPClient, int* pInt_ListCount)
{
return m_P2PPeerManage.P2XPPeer_Manage_GetLan(lpszPubAddr, lpszPriAddr, pppSt_P2XPClient, pInt_ListCount);
}
extern "C" BOOL P2XPPeer_Manage_GetLList(LPCTSTR lpszPubAddr, TCHAR * **pppszP2XPClient, int* pInt_ListCount)
{
return m_P2PPeerManage.P2XPPeer_Manage_GetLList(lpszPubAddr, pppszP2XPClient, pInt_ListCount);
}
extern "C" BOOL P2XPPeer_Manage_GetWList(TCHAR * **pppszP2XPClient, int* pInt_ListCount)
{
return m_P2PPeerManage.P2XPPeer_Manage_GetWList(pppszP2XPClient, pInt_ListCount);
}
extern "C" BOOL P2XPPeer_Manage_GetAllList(TCHAR * **pppszP2XPClient, int* pInt_ListCount)
{
return m_P2PPeerManage.P2XPPeer_Manage_GetAllList(pppszP2XPClient, pInt_ListCount);
}
extern "C" BOOL P2XPPeer_Manage_Set(LPCTSTR lpszAddr, XENGINE_P2XP_PEERINFO st_PeerInfo)
{
return m_P2PPeerManage.P2XPPeer_Manage_Set(lpszAddr, st_PeerInfo);
}
extern "C" BOOL P2XPPeer_Manage_Delete(LPCTSTR lpszUserName)
{
return m_P2PPeerManage.P2XPPeer_Manage_Delete(lpszUserName);
}
extern "C" BOOL P2XPPeer_Manage_DelAll()
{
return m_P2PPeerManage.P2XPPeer_Manage_DelAll();
}
extern "C" BOOL P2XPPeer_Manage_GetCount(int* pInt_PeerCount)
{
return m_P2PPeerManage.P2XPPeer_Manage_GetCount(pInt_PeerCount);
}
\ No newline at end of file
// pch.h: 这是预编译标头文件。
// 下方列出的文件仅编译一次,提高了将来生成的生成性能。
// 这还将影响 IntelliSense 性能,包括代码完成和许多代码浏览功能。
// 但是,如果此处列出的文件中的任何一个在生成之间有更新,它们全部都将被重新编译。
// 请勿在此处添加要频繁更新的文件,这将使得性能优势无效。
#ifndef PCH_H
#define PCH_H
#ifdef _WINDOWS
// 添加要在此处预编译的标头
#include "framework.h"
#include <tchar.h>
#else
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <pthread.h>
#endif
#endif //PCH_H
#include <list>
#include <shared_mutex>
#include <unordered_map>
using namespace std;
#include <XEngine_Include/XEngine_CommHdr.h>
#include <XEngine_Include/XEngine_Types.h>
#include <XEngine_Include/XEngine_ProtocolHdr.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Define.h>
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
#include "../XStorage_Protocol.h"
#include "P2XPPeer_Define.h"
#include "P2XPPeer_Error.h"
/********************************************************************
// Created: 2022/03/29 14:31:31
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer\pch.h
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_P2XPPeer
// File Base: pch
// File Ext: h
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: P2XP节点管理器模块公用头
// History:
*********************************************************************/
extern BOOL PeerManage_IsErrorOccur;
extern DWORD PeerManage_dwErrorCode;
#ifdef _WINDOWS
#pragma comment(lib,"XEngine_BaseLib/XEngine_BaseLib.lib")
#endif
......@@ -7,7 +7,7 @@ LOADBIN = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L ../XEngine_ThirdP
LIB = -lXEngine_BaseLib -ljsoncpp
LIBEX = -static-libgcc -lrt -ldl
LOADSO = -Wl,-rpath=./,--disable-new-dtags
LIBINCLUDE = Protocol_P2XPPacket.o Protocol_StoragePacket.o Protocol_P2XPParse.o Protocol_StorageParse.o pch.o
LIBINCLUDE = Protocol_StoragePacket.o Protocol_StorageParse.o pch.o
ifeq ($(RELEASE),1)
FLAGS = -c -O2
......@@ -32,12 +32,8 @@ endif
all:$(LIBINCLUDE)
$(CC) $(DEBUG) $(LIBINCLUDE) -o libStorageModule_Protocol.so -shared $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO)
Protocol_P2XPPacket.o:./Protocol_Packet/Protocol_P2XPPacket.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./Protocol_Packet/Protocol_P2XPPacket.cpp
Protocol_StoragePacket.o:./Protocol_Packet/Protocol_StoragePacket.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./Protocol_Packet/Protocol_StoragePacket.cpp
Protocol_P2XPParse.o:./Protocol_Parse/Protocol_P2XPParse.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./Protocol_Parse/Protocol_P2XPParse.cpp
Protocol_StorageParse.o:./Protocol_Parse/Protocol_StorageParse.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./Protocol_Parse/Protocol_StorageParse.cpp
......
#include "pch.h"
#include "Protocol_P2XPPacket.h"
/********************************************************************
// Created: 2021/10/25 14:35:17
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Packet\Protocol_P2XPPacket.cpp
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Packet
// File Base: Protocol_P2XPPacket
// File Ext: cpp
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: 打包类
// History:
*********************************************************************/
CProtocol_P2XPPacket::CProtocol_P2XPPacket()
{
}
CProtocol_P2XPPacket::~CProtocol_P2XPPacket()
{
}
//////////////////////////////////////////////////////////////////////////
// 公有函数
//////////////////////////////////////////////////////////////////////////
/********************************************************************
函数名称:Protocol_P2XPPacket_Common
函数功能:P2XP公用协议打包函数
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打好包的缓冲区
参数.三:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出缓冲区大小
参数.四:nCode
In/Out:In
类型:整数型
可空:Y
意思:输入返回的值
参数.五:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要打包的后续内容
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPPacket::Protocol_P2XPPacket_Common(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode /* = 0 */, LPCTSTR lpszMsgBuffer /* = NULL */)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
st_JsonRoot["nCode"] = 0;
if (NULL != lpszMsgBuffer)
{
st_JsonRoot["lpszMsgBuffer"] = lpszMsgBuffer;
}
if (NULL == pSt_ProtocolHdr)
{
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen);
}
else
{
pSt_ProtocolHdr->unPacketSize = st_JsonRoot.toStyledString().length();
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + pSt_ProtocolHdr->unPacketSize;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), pSt_ProtocolHdr->unPacketSize);
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPPacket_Lan
函数功能:响应同步局域网地址列表
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pppSt_ListClients
In/Out:In
类型:三级指针
可空:N
意思:输入局域网地址信息列表
参数.三:nListCount
In/Out:In
类型:整数型
可空:N
意思:局域网地址列表个数
参数.四:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.五:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPPacket::Protocol_P2XPPacket_Lan(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL*** pppSt_ListClients, int nListCount, TCHAR* ptszMsgBuffer, int* pInt_MsgLen)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == pppSt_ListClients) || (NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = FALSE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
Json::Value st_JsonArray;
for (int i = 0; i < nListCount; i++)
{
Json::Value st_JsonObject;
st_JsonObject["ClientUser"] = (*pppSt_ListClients)[i]->tszUserName;
st_JsonObject["ClientAddr"] = (*pppSt_ListClients)[i]->tszPrivateAddr;
st_JsonArray.append(st_JsonObject);
}
st_JsonRoot["nCode"] = 0;
st_JsonRoot["lpszMsgBuffer"] = "sucess";
st_JsonRoot["ClientArray"] = st_JsonArray;
st_JsonRoot["ClientCount"] = nListCount;
if (NULL == pSt_ProtocolHdr)
{
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen);
}
else
{
pSt_ProtocolHdr->unPacketSize = st_JsonRoot.toStyledString().length();
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + pSt_ProtocolHdr->unPacketSize;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), pSt_ProtocolHdr->unPacketSize);
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPPacket_WLan
函数功能:响应同步局域网所有地址列表
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pStl_ListClients
In/Out:In
类型:容器指针
可空:N
意思:客户端列表
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.四:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPPacket::Protocol_P2XPPacket_WLan(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, list<XENGINE_P2XPPEER_PROTOCOL>* pStl_ListClients, TCHAR* ptszMsgBuffer, int* pInt_MsgLen)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == pStl_ListClients) || (NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = FALSE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
unordered_map<string, list<P2XPPROTOCOL_LANPACKET>> stl_MapClient;
//首先处理公网下的局域网网段列表
for (auto stl_ListIterator = pStl_ListClients->begin(); stl_ListIterator != pStl_ListClients->end(); stl_ListIterator++)
{
TCHAR tszClientAddr[128];
XENGINE_LIBADDR st_LibAddr;
P2XPPROTOCOL_LANPACKET st_LANPacket;
memset(tszClientAddr, '\0', sizeof(tszClientAddr));
memset(&st_LibAddr, '\0', sizeof(XENGINE_LIBADDR));
memset(&st_LANPacket, '\0', sizeof(P2XPPROTOCOL_LANPACKET));
//分割
BaseLib_OperatorIPAddr_IsIPV4Addr(stl_ListIterator->tszPrivateAddr, &st_LibAddr);
_stprintf(tszClientAddr, _T("%d.%d.%d"), st_LibAddr.nIPAddr1, st_LibAddr.nIPAddr2, st_LibAddr.nIPAddr3);
//赋值
_tcscpy(st_LANPacket.tszUsername, stl_ListIterator->tszUserName);
_tcscpy(st_LANPacket.tszClientAddr, stl_ListIterator->tszPrivateAddr);
//判断是否存在
unordered_map<string, list<P2XPPROTOCOL_LANPACKET>>::iterator stl_MapIterator = stl_MapClient.find(tszClientAddr);
if (stl_MapIterator == stl_MapClient.end())
{
list<P2XPPROTOCOL_LANPACKET> stl_ListClient;
stl_ListClient.push_back(st_LANPacket);
stl_MapClient.insert(make_pair(tszClientAddr, stl_ListClient));
}
else
{
stl_MapIterator->second.push_back(st_LANPacket);
}
}
//打包成JSON数据
int nCount = 0;
Json::Value st_JsonRoot;
Json::Value st_JsonArray;
for (auto stl_MapIterator = stl_MapClient.begin(); stl_MapIterator != stl_MapClient.end(); stl_MapIterator++)
{
Json::Value st_JsonList;
for (auto stl_ListIterator = stl_MapIterator->second.begin(); stl_ListIterator != stl_MapIterator->second.end(); stl_ListIterator++)
{
Json::Value st_JsonObject;
nCount++;
st_JsonObject["ClientUser"] = stl_ListIterator->tszUsername;
st_JsonObject["ClientAddr"] = stl_ListIterator->tszClientAddr;
st_JsonList.append(st_JsonObject);
}
st_JsonArray["tszLANAddr"] = stl_MapIterator->first.c_str();
st_JsonArray["tszLANList"] = st_JsonList;
}
st_JsonRoot["nCode"] = 0;
st_JsonRoot["lpszMsgBuffer"] = "sucess";
st_JsonRoot["ClientArray"] = st_JsonArray;
st_JsonRoot["ClientCount"] = nCount;
if (NULL == pSt_ProtocolHdr)
{
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen);
}
else
{
pSt_ProtocolHdr->unPacketSize = st_JsonRoot.toStyledString().length();
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + pSt_ProtocolHdr->unPacketSize;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), pSt_ProtocolHdr->unPacketSize);
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPPacket_User
函数功能:响应用户查询用户信息的请求协议封包函数
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pSt_PeerInfo
In/Out:In
类型:数据结构指针
可空:N
意思:输入获取到的用户信息
参数.三:pSt_AddrInfo
In/Out:In
类型:数据结构指针
可空:N
意思:IP地址信息
参数.四:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.五:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPPacket::Protocol_P2XPPacket_User(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL* pSt_PeerInfo, XENGINE_IPADDRINFO* pSt_AddrInfo, TCHAR* ptszMsgBuffer, int* pInt_MsgLen)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == pSt_PeerInfo) || (NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = FALSE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
Json::Value st_JsonAddr;
Json::StreamWriterBuilder st_JsonBuilder;
st_JsonRoot["Code"] = 0;
st_JsonRoot["lpszMsgBuffer"] = "sucess";
st_JsonRoot["dwConnectType"] = (Json::Value::UInt)pSt_PeerInfo->dwConnectType;
st_JsonRoot["dwPeerType"] = pSt_PeerInfo->dwPeerType;
st_JsonRoot["tszConnectAddr"] = pSt_PeerInfo->tszConnectAddr;
st_JsonRoot["tszPrivateAddr"] = pSt_PeerInfo->tszPrivateAddr;
st_JsonRoot["tszPublicAddr"] = pSt_PeerInfo->tszPublicAddr;
st_JsonRoot["tszUserName"] = pSt_PeerInfo->tszUserName;
st_JsonAddr["tszIPCountry"] = pSt_AddrInfo->tszIPCountry;
st_JsonAddr["tszIPProvince"] = pSt_AddrInfo->tszIPProvince;
st_JsonAddr["tszIPCity"] = pSt_AddrInfo->tszIPCity;
st_JsonAddr["tszIPCounty"] = pSt_AddrInfo->tszIPCounty;
st_JsonAddr["tszIPISP"] = pSt_AddrInfo->tszIPISP;
st_JsonRoot["st_AddrInfo"] = st_JsonAddr;
st_JsonBuilder["emitUTF8"] = true;
if (NULL == pSt_ProtocolHdr)
{
*pInt_MsgLen = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
memcpy(ptszMsgBuffer, Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), *pInt_MsgLen);
}
else
{
pSt_ProtocolHdr->unPacketSize = Json::writeString(st_JsonBuilder, st_JsonRoot).length();
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + pSt_ProtocolHdr->unPacketSize;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), Json::writeString(st_JsonBuilder, st_JsonRoot).c_str(), pSt_ProtocolHdr->unPacketSize);
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPPacket_Connect
函数功能:请求连接打包函数
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pSt_IOProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:输入连接信息
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.四:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPPacket::Protocol_P2XPPacket_Connect(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_P2XPIO_PROTOCOL* pSt_IOProtocol, TCHAR* ptszMsgBuffer, int* pInt_MsgLen)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = FALSE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
st_JsonRoot["tszSourceUser"] = pSt_IOProtocol->tszSourceUser;
st_JsonRoot["tszDestUser"] = pSt_IOProtocol->tszDestUser;
st_JsonRoot["tszConnectAddr"] = pSt_IOProtocol->tszConnectAddr;
st_JsonRoot["nDestPort"] = pSt_IOProtocol->nDestPort;
st_JsonRoot["bIsTcp"] = pSt_IOProtocol->bIsTcp;
if (NULL == pSt_ProtocolHdr)
{
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen);
}
else
{
pSt_ProtocolHdr->unPacketSize = st_JsonRoot.toStyledString().length();
*pInt_MsgLen = sizeof(XENGINE_PROTOCOLHDR) + pSt_ProtocolHdr->unPacketSize;
memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR));
memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), pSt_ProtocolHdr->unPacketSize);
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPPacket_QueryFile
函数功能:查询P2P文件请求函数
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出组好包的请求缓冲区
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出缓冲区大小
参数.三:lpszFileName
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件名
参数.四:lpszFileHash
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件MD5
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPPacket::Protocol_P2XPPacket_QueryFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName /* = NULL */, LPCTSTR lpszFileHash /* = NULL */)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
if (NULL != lpszFileName)
{
st_JsonRoot["lpszFileName"] = lpszFileName;
}
if (NULL != lpszFileHash)
{
st_JsonRoot["lpszFileHash"] = lpszFileHash;
}
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_STORAGE;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_STORAGE_REQQUERY;
//打包输出信息
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen);
return TRUE;
}
\ No newline at end of file
#pragma once
/********************************************************************
// Created: 2021/10/25 14:34:34
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Packet\Protocol_P2XPPacket.h
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Packet
// File Base: Protocol_P2XPPacket
// File Ext: h
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: 打包类
// History:
*********************************************************************/
typedef struct
{
TCHAR tszUsername[MAX_PATH];
TCHAR tszClientAddr[128];
}P2XPPROTOCOL_LANPACKET;
class CProtocol_P2XPPacket
{
public:
CProtocol_P2XPPacket();
~CProtocol_P2XPPacket();
public:
BOOL Protocol_P2XPPacket_Common(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
BOOL Protocol_P2XPPacket_Lan(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL*** pppSt_ListClients, int nListCount, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
BOOL Protocol_P2XPPacket_WLan(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, list<XENGINE_P2XPPEER_PROTOCOL>* pStl_ListClients, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
BOOL Protocol_P2XPPacket_User(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL* pSt_PeerInfo, XENGINE_IPADDRINFO* pSt_AddrInfo, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
BOOL Protocol_P2XPPacket_Connect(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_P2XPIO_PROTOCOL* pSt_IOProtocol, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
BOOL Protocol_P2XPPacket_QueryFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName = NULL, LPCTSTR lpszFileHash = NULL);
protected:
private:
};
\ No newline at end of file
......@@ -397,4 +397,58 @@ BOOL CProtocol_StoragePacket::Protocol_StoragePacket_UPDown(TCHAR* ptszMsgBuffer
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
_tcscpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str());
return TRUE;
}
/********************************************************************
函数名称:Protocol_StoragePacket_REQFile
函数功能:查询文件请求函数
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出组好包的请求缓冲区
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出缓冲区大小
参数.三:lpszFileName
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件名
参数.四:lpszFileHash
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件MD5
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_StoragePacket::Protocol_StoragePacket_REQFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName /* = NULL */, LPCTSTR lpszFileHash /* = NULL */)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == ptszMsgBuffer) || (NULL == pInt_MsgLen))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
if (NULL != lpszFileName)
{
st_JsonRoot["lpszFileName"] = lpszFileName;
}
if (NULL != lpszFileHash)
{
st_JsonRoot["lpszFileHash"] = lpszFileHash;
}
st_JsonRoot["unOperatorType"] = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_STORAGE;
st_JsonRoot["unOperatorCode"] = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_STORAGE_REQQUERY;
//打包输出信息
*pInt_MsgLen = st_JsonRoot.toStyledString().length();
memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_MsgLen);
return TRUE;
}
\ No newline at end of file
......@@ -22,4 +22,5 @@ public:
BOOL Protocol_StoragePacket_DirOperator(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, TCHAR*** pppszListEnum, int nListCount);
BOOL Protocol_StoragePacket_BasicAuth(LPCTSTR lpszMethod, LPCTSTR lpszPostUrl, LPCTSTR lpszClientAddr, LPCTSTR lpszUser, LPCTSTR lpszPass, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
BOOL Protocol_StoragePacket_UPDown(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszBuckKey, LPCTSTR lpszFileName, LPCTSTR lpszClientAddr, __int64x nFileSize, BOOL bDown, LPCTSTR lpszFileHash = NULL);
BOOL Protocol_StoragePacket_REQFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName = NULL, LPCTSTR lpszFileHash = NULL);
};
#include "pch.h"
#include "Protocol_P2XPParse.h"
/********************************************************************
// Created: 2021/10/25 14:35:33
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Parse\Protocol_P2XPParse.cpp
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Parse
// File Base: Protocol_P2XPParse
// File Ext: cpp
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: 解析类
// History:
*********************************************************************/
CProtocol_P2XPParse::CProtocol_P2XPParse()
{
}
CProtocol_P2XPParse::~CProtocol_P2XPParse()
{
}
//////////////////////////////////////////////////////////////////////////
// 公有函数
//////////////////////////////////////////////////////////////////////////
/********************************************************************
函数名称:Protocol_P2XPParse_Login
函数功能:登录解析函数
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:pSt_P2XPPeer
In/Out:In
类型:数据结构指针
可空:N
意思:输出解析后的节点信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPParse::Protocol_P2XPParse_Login(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPPEER_PROTOCOL *pSt_P2XPPeer)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == lpszMsgBuffer) || (NULL == pSt_P2XPPeer))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
Json::CharReaderBuilder st_JsonBuild;
Json::CharReader* pSt_JsonReader(st_JsonBuild.newCharReader());
JSONCPP_STRING st_JsonError;
//解析JSON
if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARSE;
return FALSE;
}
delete pSt_JsonReader;
pSt_JsonReader = NULL;
if (!st_JsonRoot["tszUserName"].isNull())
{
_tcscpy(pSt_P2XPPeer->tszUserName, st_JsonRoot["tszUserName"].asCString());
}
if (!st_JsonRoot["tszPrivateAddr"].isNull())
{
_tcscpy(pSt_P2XPPeer->tszPrivateAddr, st_JsonRoot["tszPrivateAddr"].asCString());
}
if (!st_JsonRoot["tszPublicAddr"].isNull())
{
_tcscpy(pSt_P2XPPeer->tszPublicAddr, st_JsonRoot["tszPublicAddr"].asCString());
}
if (!st_JsonRoot["dwConnectType"].isNull())
{
pSt_P2XPPeer->dwConnectType = st_JsonRoot["dwConnectType"].asInt();
}
if (!st_JsonRoot["dwPeerType"].isNull())
{
pSt_P2XPPeer->dwPeerType = st_JsonRoot["dwPeerType"].asInt();
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPParse_List
函数功能:解析列表请求
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:ptszPubAddr
In/Out:Out
类型:字符指针
可空:N
意思:输出公有地址
参数.四:ptszPriAddr
In/Out:Out
类型:字符指针
可空:N
意思:输出私有地址
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPParse::Protocol_P2XPParse_List(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszPubAddr, TCHAR* ptszPriAddr)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == lpszMsgBuffer) || (NULL == ptszPubAddr) || (NULL == ptszPriAddr))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
Json::CharReaderBuilder st_JsonBuild;
Json::CharReader* pSt_JsonReader(st_JsonBuild.newCharReader());
JSONCPP_STRING st_JsonError;
//解析JSON
if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARSE;
return FALSE;
}
delete pSt_JsonReader;
pSt_JsonReader = NULL;
if (!st_JsonRoot["tszPublicAddr"].isNull())
{
_tcscpy(ptszPubAddr, st_JsonRoot["tszPublicAddr"].asCString());
}
if (!st_JsonRoot["tszPrivateAddr"].isNull())
{
_tcscpy(ptszPriAddr, st_JsonRoot["tszPrivateAddr"].asCString());
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPParse_List
函数功能:解析列表请求
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:ptszUserName
In/Out:Out
类型:字符指针
可空:N
意思:输出查询的用户名
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPParse::Protocol_P2XPParse_User(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszUserName)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == lpszMsgBuffer) || (NULL == ptszUserName))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
Json::CharReaderBuilder st_JsonBuild;
Json::CharReader* pSt_JsonReader(st_JsonBuild.newCharReader());
JSONCPP_STRING st_JsonError;
//解析JSON
if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARSE;
return FALSE;
}
delete pSt_JsonReader;
pSt_JsonReader = NULL;
if (!st_JsonRoot["tszUserName"].isNull())
{
_tcscpy(ptszUserName, st_JsonRoot["tszUserName"].asCString());
}
return TRUE;
}
/********************************************************************
函数名称:Protocol_P2XPParse_Connect
函数功能:请求连接到指定地址
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:pSt_P2XPPeer
In/Out:In
类型:数据结构指针
可空:N
意思:输出解析后的节点信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
BOOL CProtocol_P2XPParse::Protocol_P2XPParse_Connect(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPIO_PROTOCOL* pSt_IOProtocol)
{
Protocol_IsErrorOccur = FALSE;
if ((NULL == lpszMsgBuffer) || (NULL == pSt_IOProtocol))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARAMENT;
return FALSE;
}
Json::Value st_JsonRoot;
Json::CharReaderBuilder st_JsonBuild;
Json::CharReader* pSt_JsonReader(st_JsonBuild.newCharReader());
JSONCPP_STRING st_JsonError;
//解析JSON
if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError))
{
Protocol_IsErrorOccur = TRUE;
Protocol_dwErrorCode = ERROR_XENGINE_STORAGE_PROTOCOL_PARSE;
return FALSE;
}
delete pSt_JsonReader;
pSt_JsonReader = NULL;
if (!st_JsonRoot["tszSourceUser"].isNull())
{
_tcscpy(pSt_IOProtocol->tszSourceUser, st_JsonRoot["tszSourceUser"].asCString());
}
if (!st_JsonRoot["tszDestUser"].isNull())
{
_tcscpy(pSt_IOProtocol->tszDestUser, st_JsonRoot["tszDestUser"].asCString());
}
if (!st_JsonRoot["tszConnectAddr"].isNull())
{
_tcscpy(pSt_IOProtocol->tszConnectAddr, st_JsonRoot["tszConnectAddr"].asCString());
}
if (!st_JsonRoot["nDestPort"].isNull())
{
pSt_IOProtocol->nDestPort = st_JsonRoot["nDestPort"].asInt();
}
if (!st_JsonRoot["bIsTcp"].isNull())
{
pSt_IOProtocol->bIsTcp = st_JsonRoot["bIsTcp"].asInt();
}
return TRUE;
}
\ No newline at end of file
#pragma once
/********************************************************************
// Created: 2021/10/25 14:32:41
// File Name: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Parse\Protocol_P2XPParse.h
// File Path: D:\XEngine_Storage\XEngine_Source\StorageModule_Protocol\Protocol_Parse
// File Base: Protocol_P2XPParse
// File Ext: h
// Project: XEngine(网络通信引擎)
// Author: qyt
// Purpose: 解析类
// History:
*********************************************************************/
class CProtocol_P2XPParse
{
public:
CProtocol_P2XPParse();
~CProtocol_P2XPParse();
public:
BOOL Protocol_P2XPParse_Login(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPPEER_PROTOCOL* pSt_P2XPPeer);
BOOL Protocol_P2XPParse_List(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszPubAddr, TCHAR* ptszPriAddr);
BOOL Protocol_P2XPParse_User(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszUserName);
BOOL Protocol_P2XPParse_Connect(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPIO_PROTOCOL* pSt_IOProtocol);
protected:
private:
};
......@@ -4,25 +4,14 @@ LIBRARY
EXPORTS
Protocol_GetLastError
Protocol_P2XPParse_Login
Protocol_P2XPParse_List
Protocol_P2XPParse_User
Protocol_P2XPParse_Connect
Protocol_P2XPPacket_QueryFile
Protocol_StorageParse_ProxyNotify
Protocol_StorageParse_QueryFile
Protocol_StorageParse_ReportFile
Protocol_StorageParse_DirOperator
Protocol_P2XPPacket_Common
Protocol_P2XPPacket_Lan
Protocol_P2XPPacket_WLan
Protocol_P2XPPacket_User
Protocol_P2XPPacket_Connect
Protocol_StoragePacket_BasicAuth
Protocol_StoragePacket_UPDown
Protocol_StoragePacket_QueryFile
Protocol_StoragePacket_Info
Protocol_StoragePacket_DirOperator
\ No newline at end of file
Protocol_StoragePacket_DirOperator
Protocol_StoragePacket_REQFile
\ No newline at end of file
......@@ -169,9 +169,7 @@
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="Protocol_Packet\Protocol_P2XPPacket.h" />
<ClInclude Include="Protocol_Packet\Protocol_StoragePacket.h" />
<ClInclude Include="Protocol_Parse\Protocol_P2XPParse.h" />
<ClInclude Include="Protocol_Parse\Protocol_StorageParse.h" />
<ClInclude Include="StorageProtocol_Define.h" />
<ClInclude Include="StorageProtocol_Error.h" />
......@@ -184,9 +182,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Protocol_Packet\Protocol_P2XPPacket.cpp" />
<ClCompile Include="Protocol_Packet\Protocol_StoragePacket.cpp" />
<ClCompile Include="Protocol_Parse\Protocol_P2XPParse.cpp" />
<ClCompile Include="Protocol_Parse\Protocol_StorageParse.cpp" />
</ItemGroup>
<ItemGroup>
......
......@@ -33,12 +33,6 @@
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Protocol_Packet\Protocol_P2XPPacket.h">
<Filter>头文件\Protocol_Packet</Filter>
</ClInclude>
<ClInclude Include="Protocol_Parse\Protocol_P2XPParse.h">
<Filter>头文件\Protocol_Parse</Filter>
</ClInclude>
<ClInclude Include="StorageProtocol_Define.h">
<Filter>头文件</Filter>
</ClInclude>
......@@ -59,12 +53,6 @@
<ClCompile Include="pch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Protocol_Packet\Protocol_P2XPPacket.cpp">
<Filter>源文件\Protocol_Packet</Filter>
</ClCompile>
<ClCompile Include="Protocol_Parse\Protocol_P2XPParse.cpp">
<Filter>源文件\Protocol_Parse</Filter>
</ClCompile>
<ClCompile Include="Protocol_Packet\Protocol_StoragePacket.cpp">
<Filter>源文件\Protocol_Packet</Filter>
</ClCompile>
......
......@@ -18,107 +18,6 @@ extern "C" DWORD Protocol_GetLastError(int *pInt_ErrorCode = NULL);
/* 解析协议导出 */
/************************************************************************/
/********************************************************************
函数名称:Protocol_P2XPParse_Login
函数功能:登录解析函数
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:pSt_P2XPPeer
In/Out:In
类型:数据结构指针
可空:N
意思:输出解析后的节点信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPParse_Login(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPPEER_PROTOCOL* pSt_P2XPPeer);
/********************************************************************
函数名称:Protocol_P2XPParse_List
函数功能:解析列表请求
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:ptszPubAddr
In/Out:Out
类型:字符指针
可空:N
意思:输出公有地址
参数.四:ptszPriAddr
In/Out:Out
类型:字符指针
可空:N
意思:输出私有地址
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPParse_List(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszPubAddr, TCHAR* ptszPriAddr);
/********************************************************************
函数名称:Protocol_P2XPParse_List
函数功能:解析列表请求
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:ptszUserName
In/Out:Out
类型:字符指针
可空:N
意思:输出查询的用户名
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPParse_User(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszUserName);
/********************************************************************
函数名称:Protocol_P2XPParse_Connect
函数功能:请求连接到指定地址
参数.一:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:N
意思:输入要解析的缓冲区
参数.二:nMsgLen
In/Out:In
类型:整数型
可空:N
意思:输入缓冲区大小
参数.三:pSt_P2XPPeer
In/Out:In
类型:数据结构指针
可空:N
意思:输出解析后的节点信息
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPParse_Connect(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPIO_PROTOCOL* pSt_IOProtocol);
/********************************************************************
函数名称:Protocol_StorageParse_ProxyNotify
函数功能:解析上传下载通知协议
参数.一:lpszMsgBuffer
......@@ -263,195 +162,6 @@ extern "C" BOOL Protocol_StorageParse_DirOperator(LPCSTR lpszMsgBuffer, CHAR * p
/* 打包协议导出 */
/************************************************************************/
/********************************************************************
函数名称:Protocol_P2XPPacket_Common
函数功能:P2XP公用协议打包函数
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出打好包的缓冲区
参数.三:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出缓冲区大小
参数.四:nCode
In/Out:In
类型:整数型
可空:Y
意思:输入返回的值
参数.五:lpszMsgBuffer
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要打包的后续内容
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPPacket_Common(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, TCHAR* ptszMsgBuffer, int* pInt_MsgLen, int nCode = 0, LPCTSTR lpszMsgBuffer = NULL);
/********************************************************************
函数名称:Protocol_P2XPPacket_Lan
函数功能:响应同步局域网地址列表
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pppSt_ListClients
In/Out:In
类型:三级指针
可空:N
意思:输入局域网地址信息列表
参数.三:nListCount
In/Out:In
类型:整数型
可空:N
意思:局域网地址列表个数
参数.四:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.五:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPPacket_Lan(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL*** pppSt_ListClients, int nListCount, TCHAR* ptszMsgBuffer, int* pInt_Len);
/********************************************************************
函数名称:Protocol_P2XPPacket_WLan
函数功能:响应同步局域网所有地址列表
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pStl_ListClients
In/Out:In
类型:容器指针
可空:N
意思:客户端列表
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.四:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPPacket_WLan(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, list<XENGINE_P2XPPEER_PROTOCOL>* pStl_ListClients, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
/********************************************************************
函数名称:Protocol_P2XPPacket_User
函数功能:响应用户查询用户信息的请求协议封包函数
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pSt_PeerInfo
In/Out:In
类型:数据结构指针
可空:N
意思:输入获取到的用户信息
参数.三:pSt_AddrInfo
In/Out:In
类型:数据结构指针
可空:N
意思:IP地址信息
参数.四:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.五:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPPacket_User(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL* pSt_PeerInfo, XENGINE_IPADDRINFO * pSt_AddrInfo, TCHAR* ptszMsgBuffer, int* pInt_Len);
/********************************************************************
函数名称:Protocol_P2XPPacket_Connect
函数功能:请求连接打包函数
参数.一:pSt_ProtocolHdr
In/Out:In
类型:数据结构指针
可空:N
意思:输入要打包的协议头
参数.二:pSt_IOProtocol
In/Out:In
类型:数据结构指针
可空:N
意思:输入连接信息
参数.三:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:导出封装好的缓冲区
参数.四:pInt_MsgLen
In/Out:In/Out
类型:整数型指针
可空:N
意思:输入你的缓冲区大小,输出缓冲区真实大小
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPPacket_Connect(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XENGINE_P2XPIO_PROTOCOL* pSt_IOProtocol, TCHAR* ptszMsgBuffer, int* pInt_MsgLen);
/********************************************************************
函数名称:Protocol_P2XPPacket_QueryFile
函数功能:查询P2P文件请求函数
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出组好包的请求缓冲区
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出缓冲区大小
参数.三:lpszFileName
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件名
参数.四:lpszFileHash
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件MD5
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_P2XPPacket_QueryFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName = NULL, LPCTSTR lpszFileHash = NULL);
/********************************************************************
函数名称:Protocol_StoragePacket_BasicAuth
函数功能:基本验证协议代理转发
参数.一:lpszMethod
......@@ -650,4 +360,33 @@ extern "C" BOOL Protocol_StoragePacket_Info(TCHAR * ptszMsgBuffer, int* pInt_Msg
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_StoragePacket_DirOperator(CHAR * ptszMsgBuffer, int* pInt_MsgLen, CHAR * **pppszListEnum, int nListCount);
\ No newline at end of file
extern "C" BOOL Protocol_StoragePacket_DirOperator(CHAR * ptszMsgBuffer, int* pInt_MsgLen, CHAR * **pppszListEnum, int nListCount);
/********************************************************************
函数名称:Protocol_StoragePacket_REQFile
函数功能:查询文件请求函数
参数.一:ptszMsgBuffer
In/Out:Out
类型:字符指针
可空:N
意思:输出组好包的请求缓冲区
参数.二:pInt_MsgLen
In/Out:Out
类型:整数型指针
可空:N
意思:输出缓冲区大小
参数.三:lpszFileName
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件名
参数.四:lpszFileHash
In/Out:In
类型:常量字符指针
可空:Y
意思:输入要查询的文件MD5
返回值
类型:逻辑型
意思:是否成功
备注:
*********************************************************************/
extern "C" BOOL Protocol_StoragePacket_REQFile(TCHAR* ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName = NULL, LPCTSTR lpszFileHash = NULL);
\ No newline at end of file
#include "pch.h"
#include "Protocol_Parse/Protocol_P2XPParse.h"
#include "Protocol_Parse/Protocol_StorageParse.h"
#include "Protocol_Packet/Protocol_P2XPPacket.h"
#include "Protocol_Packet/Protocol_StoragePacket.h"
/********************************************************************
// Created: 2021/10/25 14:38:54
......@@ -17,8 +15,6 @@
BOOL Protocol_IsErrorOccur = FALSE;
DWORD Protocol_dwErrorCode = 0;
//////////////////////////////////////////////////////////////////////////
CProtocol_P2XPParse m_P2XPParse;
CProtocol_P2XPPacket m_P2XPPacket;
CProtocol_StoragePacket m_StoragePacket;
CProtocol_StorageParse m_StorageParse;
//////////////////////////////////////////////////////////////////////////
......@@ -33,23 +29,6 @@ extern "C" DWORD Protocol_GetLastError(int* pInt_ErrorCode)
/************************************************************************/
/* 解析协议导出 */
/************************************************************************/
extern "C" BOOL Protocol_P2XPParse_Login(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPPEER_PROTOCOL * pSt_P2XPPeer)
{
return m_P2XPParse.Protocol_P2XPParse_Login(lpszMsgBuffer, nMsgLen, pSt_P2XPPeer);
}
extern "C" BOOL Protocol_P2XPParse_List(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR * ptszPubAddr, TCHAR * ptszPriAddr)
{
return m_P2XPParse.Protocol_P2XPParse_List(lpszMsgBuffer, nMsgLen, ptszPubAddr, ptszPriAddr);
}
extern "C" BOOL Protocol_P2XPParse_User(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR * ptszUserName)
{
return m_P2XPParse.Protocol_P2XPParse_User(lpszMsgBuffer, nMsgLen, ptszUserName);
}
extern "C" BOOL Protocol_P2XPParse_Connect(LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_P2XPIO_PROTOCOL * pSt_IOProtocol)
{
return m_P2XPParse.Protocol_P2XPParse_Connect(lpszMsgBuffer, nMsgLen, pSt_IOProtocol);
}
//////////////////////////////////////////////////////////////////////////
extern "C" BOOL Protocol_StorageParse_ProxyNotify(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR * ptszClientAddr, TCHAR * ptszBuckKey, TCHAR * ptszFileName, TCHAR * ptszFileHash, __int64x * pInt_FileSize)
{
return m_StorageParse.Protocol_StorageParse_ProxyNotify(lpszMsgBuffer, nMsgLen, ptszClientAddr, ptszBuckKey, ptszFileName, ptszFileHash, pInt_FileSize);
......@@ -69,31 +48,6 @@ extern "C" BOOL Protocol_StorageParse_DirOperator(LPCTSTR lpszMsgBuffer, TCHAR *
/************************************************************************/
/* 打包协议导出 */
/************************************************************************/
extern "C" BOOL Protocol_P2XPPacket_Common(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, TCHAR * ptszMsgBuffer, int* pInt_MsgLen, int nCode, LPCTSTR lpszMsgBuffer)
{
return m_P2XPPacket.Protocol_P2XPPacket_Common(pSt_ProtocolHdr, ptszMsgBuffer, pInt_MsgLen, nCode, lpszMsgBuffer);
}
extern "C" BOOL Protocol_P2XPPacket_Lan(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL * **pppSt_ListClients, int nListCount, TCHAR * ptszMsgBuffer, int* pInt_Len)
{
return m_P2XPPacket.Protocol_P2XPPacket_Lan(pSt_ProtocolHdr, pppSt_ListClients, nListCount, ptszMsgBuffer, pInt_Len);
}
extern "C" BOOL Protocol_P2XPPacket_WLan(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, list<XENGINE_P2XPPEER_PROTOCOL>*pStl_ListClients, TCHAR * ptszMsgBuffer, int* pInt_MsgLen)
{
return m_P2XPPacket.Protocol_P2XPPacket_WLan(pSt_ProtocolHdr, pStl_ListClients, ptszMsgBuffer, pInt_MsgLen);
}
extern "C" BOOL Protocol_P2XPPacket_User(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XENGINE_P2XPPEER_PROTOCOL * pSt_PeerInfo, XENGINE_IPADDRINFO * pSt_AddrInfo, TCHAR * ptszMsgBuffer, int* pInt_Len)
{
return m_P2XPPacket.Protocol_P2XPPacket_User(pSt_ProtocolHdr, pSt_PeerInfo, pSt_AddrInfo, ptszMsgBuffer, pInt_Len);
}
extern "C" BOOL Protocol_P2XPPacket_Connect(XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XENGINE_P2XPIO_PROTOCOL * pSt_IOProtocol, TCHAR * ptszMsgBuffer, int* pInt_MsgLen)
{
return m_P2XPPacket.Protocol_P2XPPacket_Connect(pSt_ProtocolHdr, pSt_IOProtocol, ptszMsgBuffer, pInt_MsgLen);
}
extern "C" BOOL Protocol_P2XPPacket_QueryFile(TCHAR * ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName, LPCTSTR lpszFileHash)
{
return m_P2XPPacket.Protocol_P2XPPacket_QueryFile(ptszMsgBuffer, pInt_MsgLen, lpszFileName, lpszFileHash);
}
//////////////////////////////////////////////////////////////////////////
extern "C" BOOL Protocol_StoragePacket_BasicAuth(LPCTSTR lpszMethod, LPCTSTR lpszPostUrl, LPCTSTR lpszClientAddr, LPCTSTR lpszUser, LPCTSTR lpszPass, TCHAR * ptszMsgBuffer, int* pInt_MsgLen)
{
return m_StoragePacket.Protocol_StoragePacket_BasicAuth(lpszMethod, lpszPostUrl, lpszClientAddr, lpszUser, lpszPass, ptszMsgBuffer, pInt_MsgLen);
......@@ -113,4 +67,8 @@ extern "C" BOOL Protocol_StoragePacket_Info(TCHAR * ptszMsgBuffer, int* pInt_Msg
extern "C" BOOL Protocol_StoragePacket_DirOperator(TCHAR * ptszMsgBuffer, int* pInt_MsgLen, TCHAR * **pppszListEnum, int nListCount)
{
return m_StoragePacket.Protocol_StoragePacket_DirOperator(ptszMsgBuffer, pInt_MsgLen, pppszListEnum, nListCount);
}
extern "C" BOOL Protocol_StoragePacket_REQFile(TCHAR * ptszMsgBuffer, int* pInt_MsgLen, LPCTSTR lpszFileName, LPCTSTR lpszFileHash)
{
return m_StoragePacket.Protocol_StoragePacket_REQFile(ptszMsgBuffer, pInt_MsgLen, lpszFileName, lpszFileHash);
}
\ No newline at end of file
......@@ -35,8 +35,6 @@ using namespace std;
#include <XEngine_Include/XEngine_BaseLib/BaseLib_Error.h>
#include <XEngine_Include/XEngine_HelpComponents/DataBase_Define.h>
#include <XEngine_Include/XEngine_HelpComponents/DataBase_Error.h>
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Define.h>
#include <XEngine_Include/XEngine_NetHelp/APIHelp_Error.h>
#include "../XStorage_Protocol.h"
#include "../StorageModule_Session/Session_Define.h"
#include "../StorageModule_Database/Database_Define.h"
......
copy /y "%XEngine_Library%\x64\XEngine_BaseLib\XEngine_BaseLib.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_BaseLib\XEngine_Algorithm.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_Core\XEngine_Core.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_Core\XEngine_ManagePool.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_Core\XEngine_OPenSsl.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_BaseLib.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_Algorithm.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_Core.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_ManagePool.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_OPenSsl.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_SystemSdk\XEngine_SystemApi.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\HelpComponents_DataBase.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\HelpComponents_Packets.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\HelpComponents_XLog.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\HelpComponents_DataBase.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\HelpComponents_XLog.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_NetHelp\NetHelp_APIHelp.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_NetHelp\NetHelp_APIHelp.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_RfcComponents\RfcComponents_HttpServer.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_RfcComponents\RfcComponents_HttpServer.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\bson-1.0.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\mongoc-1.0.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\libmariadb.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\libpq.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\sqlite3.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\zlib1.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_HelpComponents\plugin\caching_sha2_password.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_LibEx\libcrypto-1_1.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_LibEx\libssl-1_1.dll" "./"
copy /y "%XEngine_Library%\x64\XEngine_LibEx\libcurl.dll" "./"
\ No newline at end of file
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\bson-1.0.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\mongoc-1.0.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\libmariadb.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\libpq.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\sqlite3.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\zlib1.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_HelpComponents\plugin\caching_sha2_password.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_LibEx\libcrypto-3.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_LibEx\libssl-3.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_LibEx\libcurl.dll" "./"
copy /y "%XEngine_Lib64%\XEngine_LibEx\nghttp2.dll" "./"
\ No newline at end of file
copy /y "%XEngine_Library%\x86\XEngine_BaseLib\XEngine_BaseLib.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_BaseLib\XEngine_Algorithm.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_Core\XEngine_Core.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_Core\XEngine_ManagePool.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_Core\XEngine_OPenSsl.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_BaseLib.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_BaseLib\XEngine_Algorithm.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_Core.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_ManagePool.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_OPenSsl.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_SystemSdk\XEngine_SystemApi.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\HelpComponents_DataBase.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\HelpComponents_Packets.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\HelpComponents_XLog.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\HelpComponents_DataBase.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\HelpComponents_XLog.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_NetHelp\NetHelp_APIHelp.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_NetHelp\NetHelp_APIHelp.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_RfcComponents\RfcComponents_HttpServer.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_RfcComponents\RfcComponents_HttpServer.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\bson-1.0.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\mongoc-1.0.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\libmariadb.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\libpq.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\sqlite3.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\zlib1.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_HelpComponents\plugin\caching_sha2_password.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_LibEx\libcrypto-1_1.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_LibEx\libssl-1_1.dll" "./"
copy /y "%XEngine_Library%\x86\XEngine_LibEx\libcurl.dll" "./"
\ No newline at end of file
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\bson-1.0.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\mongoc-1.0.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\libmariadb.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\libpq.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\sqlite3.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\zlib1.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_HelpComponents\plugin\caching_sha2_password.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_LibEx\libcrypto-3.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_LibEx\libssl-3.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_LibEx\libcurl.dll" "./"
copy /y "%XEngine_Lib32%\XEngine_LibEx\nghttp2.dll" "./"
\ No newline at end of file
......@@ -24,8 +24,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsoncpp", "XEngine_ThirdPar
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_Database", "StorageModule_Database\StorageModule_Database.vcxproj", "{8B90FA35-1D93-4174-BF1C-926D52F0C67F}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StorageModule_P2XPPeer", "StorageModule_P2XPPeer\StorageModule_P2XPPeer.vcxproj", "{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
......@@ -90,14 +88,6 @@ Global
{8B90FA35-1D93-4174-BF1C-926D52F0C67F}.Release|x64.Build.0 = Release|x64
{8B90FA35-1D93-4174-BF1C-926D52F0C67F}.Release|x86.ActiveCfg = Release|Win32
{8B90FA35-1D93-4174-BF1C-926D52F0C67F}.Release|x86.Build.0 = Release|Win32
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Debug|x64.ActiveCfg = Debug|x64
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Debug|x64.Build.0 = Debug|x64
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Debug|x86.ActiveCfg = Debug|Win32
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Debug|x86.Build.0 = Debug|Win32
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Release|x64.ActiveCfg = Release|x64
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Release|x64.Build.0 = Release|x64
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Release|x86.ActiveCfg = Release|Win32
{91BB60C1-34B4-4D1F-92EB-53F8CC8B51C3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -8,7 +8,7 @@ LIB = -lXEngine_BaseLib -lXEngine_Algorithm -lXEngine_Core -lXEngine_ManagePool
-ljsoncpp
LIBEX = -static-libgcc -ldl -lrt -lpthread
LOADSO = -Wl,-rpath=./,--disable-new-dtags
LIBINCLUDE = StorageApp_Config.o StorageApp_Download.o StorageApp_Network.o StorageApp_Center.o StorageApp_UPLoader.o StorageApp_P2XPNet.o Storage_TaskPass.o Storage_TaskManage.o Storage_TaskP2p.o XEngine_StorageApp.o
LIBINCLUDE = StorageApp_Config.o StorageApp_Download.o StorageApp_Network.o StorageApp_Center.o StorageApp_UPLoader.o Storage_TaskPass.o Storage_TaskManage.o Storage_TaskP2p.o XEngine_StorageApp.o
ifeq ($(RELEASE),1)
FLAGS = -c -O2
......@@ -37,8 +37,6 @@ StorageApp_Center.o:./StorageApp_Center.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_Center.cpp
StorageApp_UPLoader.o:./StorageApp_UPLoader.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_UPLoader.cpp
StorageApp_P2XPNet.o:./StorageApp_P2XPNet.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_P2XPNet.cpp
Storage_TaskPass.o:./Storage_APPTask/Storage_TaskPass.cpp
$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskPass.cpp
......
......@@ -163,7 +163,7 @@ BOOL XEngine_Task_HttpCenter(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int
//用于心跳
st_HDRParam.bIsClose = TRUE;
st_HDRParam.nHttpCode = 200;
LPCTSTR lpszHdrBuffer = _T("Allow: POST GET OPTIONS\r\n");
LPCTSTR lpszHdrBuffer = _T("Allow: POST GET PUT OPTIONS\r\n");
RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam, NULL, 0, lpszHdrBuffer);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,请求OPTIONS心跳方法成功"), lpszClientAddr);
......
#pragma once
#define XENGINE_STORAGE_APP_TASK_EVENT _T("Event")
#define XENGINE_STORAGE_APP_TASK_PASS _T("Pass")
#define XENGINE_STORAGE_APP_TASK_MANAGE _T("Manage")
......
......@@ -51,8 +51,6 @@ using namespace std;
#include "../StorageModule_Session/Session_Error.h"
#include "../StorageModule_Database/Database_Define.h"
#include "../StorageModule_Database/Database_Error.h"
#include "../StorageModule_P2XPPeer/P2XPPeer_Define.h"
#include "../StorageModule_P2XPPeer/P2XPPeer_Error.h"
#include "../StorageModule_Protocol/StorageProtocol_Define.h"
#include "../StorageModule_Protocol/StorageProtocol_Error.h"
#include "../StorageModule_Config/Config_Define.h"
......@@ -67,7 +65,6 @@ using namespace std;
#define STORAGE_NETTYPE_HTTPUPLOADER 1
#define STORAGE_NETTYPE_HTTPDOWNLOAD 2
#define STORAGE_NETTYPE_HTTPCENTER 3
#define STORAGE_NETTYPE_TCPP2XP 4
extern BOOL bIsRun;
extern XLOG xhLog;
......@@ -75,17 +72,14 @@ extern XLOG xhLog;
extern XNETHANDLE xhHBDownload;
extern XNETHANDLE xhHBUPLoader;
extern XNETHANDLE xhHBCenter;
extern XNETHANDLE xhHBP2xp;
extern XNETHANDLE xhNetDownload;
extern XNETHANDLE xhNetUPLoader;
extern XNETHANDLE xhNetCenter;
extern XNETHANDLE xhNetP2xp;
extern XNETHANDLE xhUPPool;
extern XNETHANDLE xhDLPool;
extern XNETHANDLE xhCTPool;
extern XNETHANDLE xhP2XPPool;
extern XHANDLE xhDLSsl;
extern XHANDLE xhUPSsl;
......@@ -94,7 +88,6 @@ extern XHANDLE xhLimit;
extern XHANDLE xhUPHttp;
extern XHANDLE xhDLHttp;
extern XHANDLE xhCenterHttp;
extern XHANDLE xhP2XPPacket;
extern SOCKET hBroadSocket;
extern shared_ptr<std::thread> pSTDThread;
......@@ -107,7 +100,6 @@ extern XENGINE_LBCONFIG st_LoadbalanceCfg;
#include "StorageApp_Download.h"
#include "StorageApp_UPLoader.h"
#include "StorageApp_Center.h"
#include "StorageApp_P2XPNet.h"
#include "Storage_APPTask/Storage_TaskPass.h"
#include "Storage_APPTask/Storage_TaskP2p.h"
#include "Storage_APPTask/Storage_TaskManage.h"
......@@ -131,14 +123,12 @@ extern XENGINE_LBCONFIG st_LoadbalanceCfg;
#pragma comment(lib,"../x64/Debug/StorageModule_APIHelp.lib")
#pragma comment(lib,"../x64/Debug/StorageModule_Protocol.lib")
#pragma comment(lib,"../x64/Debug/StorageModule_Database.lib")
#pragma comment(lib,"../x64/Debug/StorageModule_P2XPPeer.lib")
#else
#pragma comment(lib,"../x64/Release/StorageModule_Session.lib")
#pragma comment(lib,"../x64/Release/StorageModule_Config.lib")
#pragma comment(lib,"../x64/Release/StorageModule_APIHelp.lib")
#pragma comment(lib,"../x64/Release/StorageModule_Protocol.lib")
#pragma comment(lib,"../x64/Release/StorageModule_Database.lib")
#pragma comment(lib,"../x64/Release/StorageModule_P2XPPeer.lib")
#endif
#else
#ifdef _DEBUG
......@@ -147,14 +137,12 @@ extern XENGINE_LBCONFIG st_LoadbalanceCfg;
#pragma comment(lib,"../Debug/StorageModule_APIHelp.lib")
#pragma comment(lib,"../Debug/StorageModule_Protocol.lib")
#pragma comment(lib,"../Debug/StorageModule_Database.lib")
#pragma comment(lib,"../Debug/StorageModule_P2XPPeer.lib")
#else
#pragma comment(lib,"../Release/StorageModule_Session.lib")
#pragma comment(lib,"../Release/StorageModule_Config.lib")
#pragma comment(lib,"../Release/StorageModule_APIHelp.lib")
#pragma comment(lib,"../Release/StorageModule_Protocol.lib")
#pragma comment(lib,"../Release/StorageModule_Database.lib")
#pragma comment(lib,"../Release/StorageModule_P2XPPeer.lib")
#endif
#endif
#endif
\ No newline at end of file
......@@ -130,28 +130,6 @@ void CALLBACK XEngine_Callback_CenterLeave(LPCTSTR lpszClientAddr, SOCKET hSocke
XEngine_Net_CloseClient(lpszClientAddr, STORAGE_LEAVETYPE_BYSELF, STORAGE_NETTYPE_HTTPCENTER);
}
//////////////////////////////////////////////////////////////////////////
BOOL CALLBACK XEngine_Callback_P2xpLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam)
{
HelpComponents_Datas_CreateEx(xhP2XPPacket, lpszClientAddr, 0);
SocketOpt_HeartBeat_InsertAddrEx(xhHBP2xp, lpszClientAddr);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("P2XP客户端:%s,进入了服务器"), lpszClientAddr);
return TRUE;
}
void CALLBACK XEngine_Callback_P2xpRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam)
{
if (!HelpComponents_Datas_PostEx(xhP2XPPacket, lpszClientAddr, lpszRecvMsg, nMsgLen))
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,投递数据失败,大小:%d,错误;%lX"), lpszClientAddr, nMsgLen, HttpServer_GetLastError());
return;
}
SocketOpt_HeartBeat_ActiveAddrEx(xhHBP2xp, lpszClientAddr);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _T("P2XP客户端:%s,投递包成功,大小:%d"), lpszClientAddr, nMsgLen);
}
void CALLBACK XEngine_Callback_P2xpLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam)
{
XEngine_Net_CloseClient(lpszClientAddr, STORAGE_LEAVETYPE_BYSELF, STORAGE_NETTYPE_TCPP2XP);
}
//////////////////////////////////////////////////////////////////////////
void CALLBACK XEngine_Callback_HBDownload(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam)
{
XEngine_Net_CloseClient(lpszClientAddr, STORAGE_LEAVETYPE_HEARTBEAT, STORAGE_NETTYPE_HTTPDOWNLOAD);
......@@ -164,14 +142,10 @@ void CALLBACK XEngine_Callback_HBCenter(LPCTSTR lpszClientAddr, SOCKET hSocket,
{
XEngine_Net_CloseClient(lpszClientAddr, STORAGE_LEAVETYPE_HEARTBEAT, STORAGE_NETTYPE_HTTPCENTER);
}
void CALLBACK XEngine_Callback_HBP2xp(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam)
{
XEngine_Net_CloseClient(lpszClientAddr, STORAGE_LEAVETYPE_HEARTBEAT, STORAGE_NETTYPE_TCPP2XP);
}
//////////////////////////////////////////////////////////////////////////
BOOL XEngine_Net_CloseClient(LPCTSTR lpszClientAddr, int nLeaveType, int nClientType)
{
LPCTSTR lpszLeaveMsg;
string m_StrLeaveMsg;
string m_StrClient;
if (STORAGE_NETTYPE_HTTPUPLOADER == nClientType)
......@@ -179,17 +153,17 @@ BOOL XEngine_Net_CloseClient(LPCTSTR lpszClientAddr, int nLeaveType, int nClient
m_StrClient = _T("上传客户端");
if (STORAGE_LEAVETYPE_HEARTBEAT == nLeaveType)
{
lpszLeaveMsg = _T("心跳超时");
m_StrLeaveMsg = _T("心跳超时");
NetCore_TCPXCore_CloseForClientEx(xhNetUPLoader, lpszClientAddr);
}
else if (STORAGE_LEAVETYPE_BYSELF == nLeaveType)
{
lpszLeaveMsg = _T("被动断开");
m_StrLeaveMsg = _T("被动断开");
SocketOpt_HeartBeat_DeleteAddrEx(xhHBUPLoader, lpszClientAddr);
}
else
{
lpszLeaveMsg = _T("主动关闭");
m_StrLeaveMsg = _T("主动关闭");
NetCore_TCPXCore_CloseForClientEx(xhNetUPLoader, lpszClientAddr);
SocketOpt_HeartBeat_DeleteAddrEx(xhHBUPLoader, lpszClientAddr);
}
......@@ -202,17 +176,17 @@ BOOL XEngine_Net_CloseClient(LPCTSTR lpszClientAddr, int nLeaveType, int nClient
m_StrClient = _T("下载客户端");
if (STORAGE_LEAVETYPE_HEARTBEAT == nLeaveType)
{
lpszLeaveMsg = _T("心跳超时");
m_StrLeaveMsg = _T("心跳超时");
NetCore_TCPXCore_CloseForClientEx(xhNetDownload, lpszClientAddr);
}
else if (STORAGE_LEAVETYPE_BYSELF == nLeaveType)
{
lpszLeaveMsg = _T("被动断开");
m_StrLeaveMsg = _T("被动断开");
SocketOpt_HeartBeat_DeleteAddrEx(xhHBDownload, lpszClientAddr);
}
else
{
lpszLeaveMsg = _T("主动关闭");
m_StrLeaveMsg = _T("主动关闭");
NetCore_TCPXCore_CloseForClientEx(xhNetDownload, lpszClientAddr);
SocketOpt_HeartBeat_DeleteAddrEx(xhHBDownload, lpszClientAddr);
}
......@@ -225,17 +199,17 @@ BOOL XEngine_Net_CloseClient(LPCTSTR lpszClientAddr, int nLeaveType, int nClient
m_StrClient = _T("业务客户端");
if (STORAGE_LEAVETYPE_HEARTBEAT == nLeaveType)
{
lpszLeaveMsg = _T("心跳超时");
m_StrLeaveMsg = _T("心跳超时");
NetCore_TCPXCore_CloseForClientEx(xhNetCenter, lpszClientAddr);
}
else if (STORAGE_LEAVETYPE_BYSELF == nLeaveType)
{
lpszLeaveMsg = _T("被动断开");
m_StrLeaveMsg = _T("被动断开");
SocketOpt_HeartBeat_DeleteAddrEx(xhHBCenter, lpszClientAddr);
}
else
{
lpszLeaveMsg = _T("主动关闭");
m_StrLeaveMsg = _T("主动关闭");
NetCore_TCPXCore_CloseForClientEx(xhNetCenter, lpszClientAddr);
SocketOpt_HeartBeat_DeleteAddrEx(xhHBCenter, lpszClientAddr);
......@@ -243,30 +217,7 @@ BOOL XEngine_Net_CloseClient(LPCTSTR lpszClientAddr, int nLeaveType, int nClient
RfcComponents_HttpServer_CloseClinetEx(xhCenterHttp, lpszClientAddr);
OPenSsl_Server_CloseClientEx(xhCHSsl, lpszClientAddr);
}
else
{
m_StrClient = _T("P2XP客户端");
if (STORAGE_LEAVETYPE_HEARTBEAT == nLeaveType)
{
lpszLeaveMsg = _T("心跳超时");
NetCore_TCPXCore_CloseForClientEx(xhNetP2xp, lpszClientAddr);
}
else if (STORAGE_LEAVETYPE_BYSELF == nLeaveType)
{
lpszLeaveMsg = _T("被动断开");
SocketOpt_HeartBeat_DeleteAddrEx(xhHBP2xp, lpszClientAddr);
}
else
{
lpszLeaveMsg = _T("主动关闭");
NetCore_TCPXCore_CloseForClientEx(xhNetP2xp, lpszClientAddr);
SocketOpt_HeartBeat_DeleteAddrEx(xhHBP2xp, lpszClientAddr);
}
HelpComponents_Datas_DeleteEx(xhP2XPPacket, lpszClientAddr);
P2XPPeer_Manage_Delete(lpszClientAddr);
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("%s:%s,与服务器断开,原因:%s"), m_StrClient.c_str(), lpszClientAddr, lpszLeaveMsg);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("%s:%s,与服务器断开,原因:%s"), m_StrClient.c_str(), lpszClientAddr, m_StrLeaveMsg.c_str());
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////////
......@@ -334,14 +285,6 @@ BOOL XEngine_Net_SendMsg(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsg
SocketOpt_HeartBeat_ActiveAddrEx(xhHBCenter, lpszClientAddr);
}
}
else if (STORAGE_NETTYPE_TCPP2XP == nType)
{
bRet = NetCore_TCPXCore_SendEx(xhNetP2xp, lpszClientAddr, lpszMsgBuffer, nMsgLen);
if (bRet && st_ServiceCfg.st_XTime.bHBTime)
{
SocketOpt_HeartBeat_ActiveAddrEx(xhHBP2xp, lpszClientAddr);
}
}
if (!bRet)
{
DWORD dwRet = NetCore_GetLastError();
......
......@@ -9,14 +9,10 @@ void CALLBACK XEngine_Callback_UPLoaderLeave(LPCTSTR lpszClientAddr, SOCKET hSoc
BOOL CALLBACK XEngine_Callback_CenterLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam);
void CALLBACK XEngine_Callback_CenterRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam);
void CALLBACK XEngine_Callback_CenterLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam);
BOOL CALLBACK XEngine_Callback_P2xpLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam);
void CALLBACK XEngine_Callback_P2xpRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam);
void CALLBACK XEngine_Callback_P2xpLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam);
void CALLBACK XEngine_Callback_HBDownload(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam);
void CALLBACK XEngine_Callback_HBUPLoader(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam);
void CALLBACK XEngine_Callback_HBCenter(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam);
void CALLBACK XEngine_Callback_HBP2xp(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam);
BOOL XEngine_Net_CloseClient(LPCTSTR lpszClientAddr, int nLeaveType, int nClientType = STORAGE_NETTYPE_HTTPDOWNLOAD);
BOOL XEngine_Net_SendMsg(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, int nType = STORAGE_NETTYPE_HTTPDOWNLOAD);
\ No newline at end of file
#include "StorageApp_Hdr.h"
XHTHREAD CALLBACK XEngine_P2XP_TCPThread(LPVOID lParam)
{
int nThreadPos = *(int*)lParam;
nThreadPos++;
while (bIsRun)
{
//等待指定线程事件触发
if (HelpComponents_Datas_WaitEventEx(xhP2XPPacket, nThreadPos))
{
int nListCount = 0;
TCHAR tszMsgBuffer[4096];
XENGINE_PROTOCOLHDR st_ProtocolHdr;
HELPCOMPONENT_PACKET_CLIENT** ppSst_ListAddr;
HelpComponents_Datas_GetPoolEx(xhP2XPPacket, nThreadPos, &ppSst_ListAddr, &nListCount);
for (int i = 0; i < nListCount; i++)
{
int nMsgLen = 4096;
memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR));
memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
for (int j = 0; j < ppSst_ListAddr[i]->nPktCount; j++)
{
if (!HelpComponents_Datas_GetEx(xhP2XPPacket, ppSst_ListAddr[i]->tszClientAddr, tszMsgBuffer, &nMsgLen, &st_ProtocolHdr))
{
DWORD dwRet = Packets_GetLastError();
if (ERROR_HELPCOMPONENTS_PACKETS_PROTOCOL_GET_ISNULL == dwRet)
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("获取消息队列协议失败,获取数据包失败,错误:%lX"), dwRet);
}
continue;
}
XEngine_Task_TCPP2xp(&st_ProtocolHdr, ppSst_ListAddr[i]->tszClientAddr, tszMsgBuffer, nMsgLen);
}
}
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSst_ListAddr, nListCount);
}
}
return 0;
}
BOOL XEngine_Task_TCPP2xp(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen)
{
int nSDLen = 4096;
TCHAR tszSDBuffer[4096];
memset(tszSDBuffer, '\0', sizeof(tszSDBuffer));
if (ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_P2XP == pSt_ProtocolHdr->unOperatorType)
{
if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQLOGIN == pSt_ProtocolHdr->unOperatorCode)
{
XENGINE_P2XP_PEERINFO st_ClientPeer;
memset(&st_ClientPeer, '\0', sizeof(XENGINE_P2XP_PEERINFO));
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REPLOGIN;
if (!Protocol_P2XPParse_Login(lpszMsgBuffer, nMsgLen, &st_ClientPeer.st_PeerAddr))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 400, "协议错误");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,处理登录错误,解析协议失败,错误码:%lX"), lpszClientAddr, Protocol_GetLastError());
return FALSE;
}
//如果没有填充公用地址,用他的连接地址代替,外网服务器都可以这样做
if (_tcslen(st_ClientPeer.st_PeerAddr.tszPublicAddr) <= 0)
{
_tcscpy(st_ClientPeer.st_PeerAddr.tszPublicAddr, lpszClientAddr);
BaseLib_OperatorIPAddr_SegAddr(st_ClientPeer.st_PeerAddr.tszPublicAddr, NULL);
}
//获取外网IP所在位置
int nBLen = 0;
TCHAR* ptszBody;
TCHAR tszUrlBuffer[MAX_PATH];
memset(tszUrlBuffer, '\0', MAX_PATH);
_stprintf(tszUrlBuffer, _T("http://app.xyry.org:5501/api?function=ipquery&params1=%s&params2=0"), st_ClientPeer.st_PeerAddr.tszPublicAddr);
APIHelp_HttpRequest_Get(tszUrlBuffer, &ptszBody, &nBLen);
if (nBLen > 0)
{
APIHelp_Api_GetIPInfo(ptszBody, nBLen, &st_ClientPeer.st_IPAddrInfo);
BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszBody);
}
st_ClientPeer.st_PeerTimer.dwUserTime = time(NULL);
st_ClientPeer.st_PeerTimer.dwKeepAlive = time(NULL);
st_ClientPeer.bIsLogin = TRUE;
_tcscpy(st_ClientPeer.st_PeerAddr.tszConnectAddr, lpszClientAddr);
if (!P2XPPeer_Manage_Add(st_ClientPeer))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 500, "协议错误");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,处理登录错误,设置用户信息失败,错误码:%lX"), lpszClientAddr, P2XPPeer_GetLastError());
return FALSE;
}
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("P2XP客户端:%s,处理用户登录请求成功,用户名:%s"), lpszClientAddr, st_ClientPeer.st_PeerAddr.tszUserName);
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQLANLIST == pSt_ProtocolHdr->unOperatorCode)
{
TCHAR tszPubAddr[128];
TCHAR tszPriAddr[128];
memset(tszPubAddr, '\0', sizeof(tszPubAddr));
memset(tszPriAddr, '\0', sizeof(tszPriAddr));
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REPLANLIST;
if (!Protocol_P2XPParse_List(lpszMsgBuffer, nMsgLen, tszPubAddr, tszPriAddr))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 400, "协议错误");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,列表请求失败,协议解析错误,错误码:%lX"), lpszClientAddr, Protocol_GetLastError());
return FALSE;
}
//请求同步列表
if (_tcslen(tszPriAddr) > 0)
{
int nListCount = 0;
XENGINE_P2XPPEER_PROTOCOL** ppSt_ListClients;
if (!P2XPPeer_Manage_GetLan(tszPubAddr, tszPriAddr, &ppSt_ListClients, &nListCount))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 500, "内部处理错误");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,列表请求失败,请求同步局域网列表失败,公有地址:%s,私有地址:%s,错误码:%lX"), lpszClientAddr, tszPubAddr, tszPriAddr, P2XPPeer_GetLastError());
return FALSE;
}
Protocol_P2XPPacket_Lan(pSt_ProtocolHdr, &ppSt_ListClients, nListCount, tszSDBuffer, &nSDLen);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClients, nListCount);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("客户端:%s,请求同步局域网列表成功,公有地址:%s,私有地址:%s"), lpszClientAddr, tszPubAddr, tszPriAddr);
}
else
{
//公网下所有列表
int nListCount = 0;
TCHAR** ppszClientList;
list<XENGINE_P2XPPEER_PROTOCOL> stl_ListClient;
if (P2XPPeer_Manage_GetLList(tszPubAddr, &ppszClientList, &nListCount))
{
for (int i = 0; i < nListCount; i++)
{
int nLanCount = 0;
XENGINE_P2XPPEER_PROTOCOL** ppSt_ListClients;
if (P2XPPeer_Manage_GetLan(tszPubAddr, ppszClientList[i], &ppSt_ListClients, &nLanCount))
{
for (int j = 0; j < nLanCount; j++)
{
stl_ListClient.push_back(*ppSt_ListClients[j]);
}
BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListClients, nLanCount);
}
}
BaseLib_OperatorMemory_Free((XPPPMEM)&ppszClientList, nListCount);
}
Protocol_P2XPPacket_WLan(pSt_ProtocolHdr, &stl_ListClient, tszSDBuffer, &nSDLen);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("客户端:%s,请求同步局域网列表成功,公有地址:%s,私有地址:%s"), lpszClientAddr, tszPubAddr, tszPriAddr);
}
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQCONNECT == pSt_ProtocolHdr->unOperatorCode)
{
TCHAR tszMsgResponse[2048];
XENGINE_P2XPIO_PROTOCOL st_P2XPIONet;
XENGINE_P2XP_PEERINFO st_P2XPDestPeer;
memset(tszMsgResponse, '\0', sizeof(tszMsgResponse));
memset(&st_P2XPIONet, '\0', sizeof(XENGINE_P2XPIO_PROTOCOL));
memset(&st_P2XPDestPeer, '\0', sizeof(XENGINE_P2XP_PEERINFO));
if (!Protocol_P2XPParse_Connect(lpszMsgBuffer, nMsgLen, &st_P2XPIONet))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 400, "协议错误");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,请求连接失败,协议解析错误,错误码:%lX"), lpszClientAddr, Protocol_GetLastError());
return FALSE;
}
if (!P2XPPeer_Manage_GetUser(st_P2XPIONet.tszDestUser, &st_P2XPDestPeer))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 404, "用户不存在");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,请求连接失败,用户不存在,错误码:%lX"), lpszClientAddr, P2XPPeer_GetLastError());
return FALSE;
}
//发送请求给目标客户端
Protocol_P2XPPacket_Connect(pSt_ProtocolHdr, &st_P2XPIONet, tszSDBuffer, &nSDLen);
XEngine_Net_SendMsg(st_P2XPDestPeer.st_PeerAddr.tszConnectAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
//响应请求客户端
memset(tszSDBuffer, '\0', sizeof(tszSDBuffer));
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REPCONNECT;
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("P2XP客户端:%s,用户名:%s,请求查询用户:%s 状态成功"), lpszClientAddr, st_P2XPIONet.tszSourceUser, st_P2XPIONet.tszDestUser);
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REQUSERQUERY == pSt_ProtocolHdr->unOperatorCode)
{
TCHAR tszUserName[128];
XENGINE_P2XP_PEERINFO st_PeerInfo;
memset(tszUserName, '\0', sizeof(tszUserName));
memset(&st_PeerInfo, '\0', sizeof(XENGINE_P2XP_PEERINFO));
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_P2XP_REPUSERQUERY;
if (!Protocol_P2XPParse_User(lpszMsgBuffer, nMsgLen, tszUserName))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 400, "协议错误");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,查询用户失败,协议解析错误,错误码:%lX"), lpszClientAddr, Protocol_GetLastError());
return FALSE;
}
if (!P2XPPeer_Manage_GetUser(tszUserName, &st_PeerInfo))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 500, "获取用户失败");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,查询用户失败,获取用户失败,用户名:%s,错误码:%lX"), lpszClientAddr, tszUserName, P2XPPeer_GetLastError());
return FALSE;
}
Protocol_P2XPPacket_User(pSt_ProtocolHdr, &st_PeerInfo.st_PeerAddr, &st_PeerInfo.st_IPAddrInfo, tszSDBuffer, &nSDLen);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("客户端:%s,请求查询用户:%s 成功"), lpszClientAddr, tszUserName);
}
else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_STORAGE_REQQUERY == pSt_ProtocolHdr->unOperatorCode)
{
TCHAR tszTimeStart[MAX_PATH];
TCHAR tszTimeEnd[MAX_PATH];
TCHAR tszBuckKey[MAX_PATH];
TCHAR tszFileName[MAX_PATH];
TCHAR tszFileHash[MAX_PATH];
memset(tszTimeStart, '\0', MAX_PATH);
memset(tszTimeEnd, '\0', MAX_PATH);
memset(tszBuckKey, '\0', MAX_PATH);
memset(tszFileName, '\0', MAX_PATH);
memset(tszFileHash, '\0', MAX_PATH);
//用于验证协议是否正确
if (!Protocol_StorageParse_QueryFile(lpszMsgBuffer, tszTimeStart, tszTimeEnd, tszBuckKey, tszFileName, tszFileHash))
{
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen, 400, "协议错误");
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("P2XP客户端:%s,查询文件失败,解析协议失败,错误码:%lX"), lpszClientAddr, P2XPPeer_GetLastError());
return FALSE;
}
//确认
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_STORAGE_REPQUERY;
Protocol_P2XPPacket_Common(pSt_ProtocolHdr, tszSDBuffer, &nSDLen);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_TCPP2XP);
//通知
int nListCount = 0;
TCHAR** pppszP2XPClient;
P2XPPeer_Manage_GetAllList(&pppszP2XPClient, &nListCount);
pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_STORAGE_REQQUERY;
for (int i = 0; i < nListCount; i++)
{
//过滤自己
if (0 == _tcsncmp(lpszClientAddr, pppszP2XPClient[i], _tcslen(lpszClientAddr)))
{
continue;
}
XEngine_Net_SendMsg(pppszP2XPClient[i], (LPCTSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), STORAGE_NETTYPE_TCPP2XP);
XEngine_Net_SendMsg(pppszP2XPClient[i], lpszMsgBuffer, nMsgLen, STORAGE_NETTYPE_TCPP2XP);
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("客户端:%s,请求查询Buck:%s 中的文件名:%s,HASH:%s,用户个数:%d"), lpszClientAddr, tszBuckKey, tszFileName, tszFileHash, nListCount);
BaseLib_OperatorMemory_Free((XPPPMEM)&pppszP2XPClient, nListCount);
}
else
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("客户端:%s,请求了一条未知的子协议:%lX"), lpszClientAddr, pSt_ProtocolHdr->unOperatorCode);
}
}
else
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("客户端:%s,请求了一条未知的主协议:%lX"), lpszClientAddr, pSt_ProtocolHdr->unOperatorType);
}
return TRUE;
}
\ No newline at end of file
#pragma once
XHTHREAD CALLBACK XEngine_P2XP_TCPThread(LPVOID lParam);
BOOL XEngine_Task_TCPP2xp(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen);
\ No newline at end of file
......@@ -17,7 +17,7 @@ BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lp
if (0 == _tcsnicmp(XENGINE_STORAGE_APP_METHOD_CONFIG, lpszAPIName, _tcslen(XENGINE_STORAGE_APP_METHOD_CONFIG)))
{
StorageApp_Config_Parament(0, NULL);
RfcComponents_HttpServer_SendMsgEx(xhUPHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
RfcComponents_HttpServer_SendMsgEx(xhCenterHttp, tszSDBuffer, &nSDLen, &st_HDRParam);
XEngine_Net_SendMsg(lpszClientAddr, tszSDBuffer, nSDLen, STORAGE_NETTYPE_HTTPCENTER);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("业务客户端:%s,处理用户重载配置文件成功"), lpszClientAddr);
}
......@@ -83,7 +83,7 @@ BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lp
SOCKET hRVSocket;
list<APIHELP_LBFILEINFO> stl_ListFile;
Protocol_P2XPPacket_QueryFile(tszSDBuffer, &nSDLen, NULL, tszFileHash);
Protocol_StoragePacket_REQFile(tszSDBuffer, &nSDLen, NULL, tszFileHash);
NetCore_BroadCast_SendInit(&hSDSocket, st_ServiceCfg.st_P2xp.nRVPort, st_ServiceCfg.tszIPAddr);
NetCore_BroadCast_RecvInit(&hRVSocket, st_ServiceCfg.st_P2xp.nSDPort);
......@@ -99,7 +99,6 @@ BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lp
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("业务客户端:%s,发送广播请求失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError());
return FALSE;
}
NetCore_BroadCast_Close(hSDSocket);
time_t nTimeStart = time(NULL);
while (1)
......@@ -119,6 +118,7 @@ BOOL XEngine_Task_Manage(LPCTSTR lpszAPIName, LPCTSTR lpszClientAddr, LPCTSTR lp
break;
}
}
NetCore_BroadCast_Close(hSDSocket);
NetCore_BroadCast_Close(hRVSocket);
if (stl_ListFile.empty())
......
......@@ -6,17 +6,14 @@ XLOG xhLog = NULL;
XNETHANDLE xhHBDownload = 0;
XNETHANDLE xhHBUPLoader = 0;
XNETHANDLE xhHBCenter = 0;
XNETHANDLE xhHBP2xp = 0;
XNETHANDLE xhNetDownload = 0;
XNETHANDLE xhNetUPLoader = 0;
XNETHANDLE xhNetCenter = 0;
XNETHANDLE xhNetP2xp = 0;
XNETHANDLE xhUPPool = 0;
XNETHANDLE xhDLPool = 0;
XNETHANDLE xhCTPool = 0;
XNETHANDLE xhP2XPPool = 0;
XHANDLE xhDLSsl = NULL;
XHANDLE xhUPSsl = NULL;
......@@ -25,7 +22,6 @@ XHANDLE xhLimit = NULL;
XHANDLE xhUPHttp = NULL;
XHANDLE xhDLHttp = NULL;
XHANDLE xhCenterHttp = NULL;
XHANDLE xhP2XPPacket = 0;
SOCKET hBroadSocket = 0;
shared_ptr<std::thread> pSTDThread = NULL;
......@@ -43,7 +39,6 @@ void ServiceApp_Stop(int signo)
RfcComponents_HttpServer_DestroyEx(xhUPHttp);
RfcComponents_HttpServer_DestroyEx(xhDLHttp);
RfcComponents_HttpServer_DestroyEx(xhCenterHttp);
HelpComponents_Datas_Destory(xhP2XPPacket);
OPenSsl_Server_StopEx(xhDLSsl);
OPenSsl_Server_StopEx(xhUPSsl);
......@@ -52,17 +47,14 @@ void ServiceApp_Stop(int signo)
NetCore_TCPXCore_DestroyEx(xhNetDownload);
NetCore_TCPXCore_DestroyEx(xhNetUPLoader);
NetCore_TCPXCore_DestroyEx(xhNetCenter);
NetCore_TCPXCore_DestroyEx(xhNetP2xp);
SocketOpt_HeartBeat_DestoryEx(xhHBDownload);
SocketOpt_HeartBeat_DestoryEx(xhHBUPLoader);
SocketOpt_HeartBeat_DestoryEx(xhHBCenter);
SocketOpt_HeartBeat_DestoryEx(xhHBP2xp);
ManagePool_Thread_NQDestroy(xhUPPool);
ManagePool_Thread_NQDestroy(xhDLPool);
ManagePool_Thread_NQDestroy(xhCTPool);
ManagePool_Thread_NQDestroy(xhP2XPPool);
Algorithm_Calculation_Close(xhLimit);
HelpComponents_XLog_Destroy(xhLog);
......@@ -129,7 +121,6 @@ int main(int argc, char** argv)
THREADPOOL_PARAMENT** ppSt_ListUPThread;
THREADPOOL_PARAMENT** ppSt_ListDLThread;
THREADPOOL_PARAMENT** ppSt_ListCTThread;
THREADPOOL_PARAMENT** ppSt_ListP2xpThread;
memset(&st_XLogConfig, '\0', sizeof(HELPCOMPONENTS_XLOG_CONFIGURE));
memset(&st_ServiceCfg, '\0', sizeof(XENGINE_SERVERCONFIG));
......@@ -146,7 +137,7 @@ int main(int argc, char** argv)
TCHAR tszAddr[128];
memset(tszAddr, '\0', sizeof(tszAddr));
_stprintf(tszAddr, _T("Http://127.0.0.1:%d/Api/Event/Config"), st_ServiceCfg.nCenterPort);
_stprintf(tszAddr, _T("Http://127.0.0.1:%d/Api/Manage/Config"), st_ServiceCfg.nCenterPort);
APIHelp_HttpRequest_Post(tszAddr);
return 0;
}
......@@ -204,13 +195,6 @@ int main(int argc, char** argv)
goto XENGINE_EXITAPP;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化业务管理服务成功,句柄:%llu,时间:%d,次数:%d"), xhHBUPLoader, st_ServiceCfg.st_XTime.nCenterTimeOut, st_ServiceCfg.st_XTime.nTimeCheck);
if (!SocketOpt_HeartBeat_InitEx(&xhHBP2xp, st_ServiceCfg.st_XTime.nP2XPTimeOut, st_ServiceCfg.st_XTime.nTimeCheck, XEngine_Callback_HBP2xp))
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化P2XP心跳管理服务失败,错误:%lX"), NetCore_GetLastError());
goto XENGINE_EXITAPP;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化P2XP心跳管理服务成功,句柄:%llu,时间:%d,次数:%d"), xhHBP2xp, st_ServiceCfg.st_XTime.nP2XPTimeOut, st_ServiceCfg.st_XTime.nTimeCheck);
}
else
{
......@@ -409,65 +393,29 @@ int main(int argc, char** argv)
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动HTTP业务任务处理线程池成功,线程池个数:%d"), st_ServiceCfg.st_XMax.nCenterThread);
}
//启动P2P服务
if (st_ServiceCfg.nP2XPPort > 0)
//默认为假才是客户端,才能启用P2P
if (!st_ServiceCfg.st_XSql.bEnable)
{
xhP2XPPacket = HelpComponents_Datas_Init(st_ServiceCfg.st_XMax.nMaxQueue, st_ServiceCfg.st_XMax.nP2XPThread);
if (NULL == xhP2XPPacket)
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化P2XP包管理器失败,错误:%lX"), Packets_GetLastError());
goto XENGINE_EXITAPP;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2XP组包器成功"));
if (!NetCore_TCPXCore_StartEx(&xhNetP2xp, st_ServiceCfg.nP2XPPort, st_ServiceCfg.st_XMax.nMaxClient, st_ServiceCfg.st_XMax.nP2XPThread, FALSE, st_ServiceCfg.bReuseraddr))
if (!NetCore_BroadCast_RecvInit(&hBroadSocket, st_ServiceCfg.st_P2xp.nRVPort))
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2XP网络服务失败,端口:%d,错误:%lX"), st_ServiceCfg.nP2XPPort, NetCore_GetLastError());
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2P存储广播服务失败,错误:%d"), errno);
goto XENGINE_EXITAPP;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2XP网络服务成功,句柄:%llu,端口:%d,IO线程个数:%d"), xhNetP2xp, st_ServiceCfg.nP2XPPort, st_ServiceCfg.st_XMax.nP2XPThread);
NetCore_TCPXCore_RegisterCallBackEx(xhNetP2xp, XEngine_Callback_P2xpLogin, XEngine_Callback_P2xpRecv, XEngine_Callback_P2xpLeave);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,注册P2XP网络服务事件成功!"));
BaseLib_OperatorMemory_Malloc((XPPPMEM)&ppSt_ListP2xpThread, st_ServiceCfg.st_XMax.nP2XPThread, sizeof(THREADPOOL_PARAMENT));
for (int i = 0; i < st_ServiceCfg.st_XMax.nP2XPThread; i++)
{
int* pInt_Pos = new int;
*pInt_Pos = i;
ppSt_ListP2xpThread[i]->lParam = pInt_Pos;
ppSt_ListP2xpThread[i]->fpCall_ThreadsTask = XEngine_P2XP_TCPThread;
}
if (!ManagePool_Thread_NQCreate(&xhP2XPPool, &ppSt_ListP2xpThread, st_ServiceCfg.st_XMax.nP2XPThread))
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2P存储广播服务成功,端口:%d"), st_ServiceCfg.st_P2xp.nRVPort);
pSTDThread = make_shared<std::thread>(XEngine_Task_P2PThread);
if (!pSTDThread->joinable())
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2XP处理线程池失败,错误:%d"), errno);
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2P存储广播服务线程失败,错误:%d"), errno);
goto XENGINE_EXITAPP;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2XP任务处理线程池成功,线程池个数:%d"), st_ServiceCfg.st_XMax.nP2XPThread);
//默认为假才是客户端,才能启用P2P
if (!st_ServiceCfg.st_XSql.bEnable)
{
if (!NetCore_BroadCast_RecvInit(&hBroadSocket, st_ServiceCfg.st_P2xp.nRVPort))
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2P存储广播服务失败,错误:%d"), errno);
goto XENGINE_EXITAPP;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2P存储广播服务成功,端口:%d"), st_ServiceCfg.st_P2xp.nRVPort);
pSTDThread = make_shared<std::thread>(XEngine_Task_P2PThread);
if (!pSTDThread->joinable())
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动P2P存储广播服务线程失败,错误:%d"), errno);
goto XENGINE_EXITAPP;
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2P存储广播服务线程成功"));
}
else
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,P2P存储服务配置为不启动"));
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动P2P存储广播服务线程成功"));
}
else
{
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,P2P存储服务配置为不启动"));
}
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("所有服务成功启动,存储中心服务运行中,发行版本次数:%d,当前运行版本:%s。。。"), st_ServiceCfg.st_XVer.pStl_ListStorage->size(), st_ServiceCfg.st_XVer.pStl_ListStorage->front().c_str());
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("所有服务成功启动,存储中心服务运行中,发行版本次数:%d,XEngine版本:%s 当前运行版本:%s。。。"), st_ServiceCfg.st_XVer.pStl_ListStorage->size(), BaseLib_OperatorVer_XGetStr(), st_ServiceCfg.st_XVer.pStl_ListStorage->front().c_str());
while (bIsRun)
{
......@@ -484,7 +432,6 @@ XENGINE_EXITAPP:
RfcComponents_HttpServer_DestroyEx(xhUPHttp);
RfcComponents_HttpServer_DestroyEx(xhDLHttp);
RfcComponents_HttpServer_DestroyEx(xhCenterHttp);
HelpComponents_Datas_Destory(xhP2XPPacket);
OPenSsl_Server_StopEx(xhDLSsl);
OPenSsl_Server_StopEx(xhUPSsl);
......@@ -493,17 +440,14 @@ XENGINE_EXITAPP:
NetCore_TCPXCore_DestroyEx(xhNetDownload);
NetCore_TCPXCore_DestroyEx(xhNetUPLoader);
NetCore_TCPXCore_DestroyEx(xhNetCenter);
NetCore_TCPXCore_DestroyEx(xhNetP2xp);
SocketOpt_HeartBeat_DestoryEx(xhHBDownload);
SocketOpt_HeartBeat_DestoryEx(xhHBUPLoader);
SocketOpt_HeartBeat_DestoryEx(xhHBCenter);
SocketOpt_HeartBeat_DestoryEx(xhHBP2xp);
ManagePool_Thread_NQDestroy(xhUPPool);
ManagePool_Thread_NQDestroy(xhDLPool);
ManagePool_Thread_NQDestroy(xhCTPool);
ManagePool_Thread_NQDestroy(xhP2XPPool);
Algorithm_Calculation_Close(xhLimit);
HelpComponents_XLog_Destroy(xhLog);
......
......@@ -160,7 +160,6 @@
<ClCompile Include="Storage_APPTask\Storage_TaskManage.cpp" />
<ClCompile Include="Storage_APPTask\Storage_TaskP2p.cpp" />
<ClCompile Include="Storage_APPTask\Storage_TaskPass.cpp" />
<ClCompile Include="StorageApp_P2XPNet.cpp" />
<ClCompile Include="XEngine_StorageApp.cpp" />
</ItemGroup>
<ItemGroup>
......@@ -169,7 +168,6 @@
<ClInclude Include="StorageApp_Download.h" />
<ClInclude Include="StorageApp_Hdr.h" />
<ClInclude Include="StorageApp_Network.h" />
<ClInclude Include="StorageApp_P2XPNet.h" />
<ClInclude Include="StorageApp_UPLoader.h" />
<ClInclude Include="Storage_APPTask\Storage_TaskManage.h" />
<ClInclude Include="Storage_APPTask\Storage_TaskP2p.h" />
......
......@@ -42,9 +42,6 @@
<ClCompile Include="Storage_APPTask\Storage_TaskPass.cpp">
<Filter>源文件\Storage_APPTask</Filter>
</ClCompile>
<ClCompile Include="StorageApp_P2XPNet.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="Storage_APPTask\Storage_TaskP2p.cpp">
<Filter>源文件\Storage_APPTask</Filter>
</ClCompile>
......@@ -74,9 +71,6 @@
<ClInclude Include="Storage_APPTask\Storage_TaskPass.h">
<Filter>头文件\Storage_APPTask</Filter>
</ClInclude>
<ClInclude Include="StorageApp_P2XPNet.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Storage_APPTask\Storage_TaskP2p.h">
<Filter>头文件\Storage_APPTask</Filter>
</ClInclude>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册