diff --git a/CHANGELOG b/CHANGELOG index 1c3b59fd6c88ab8bb43293bc1a0a125c0ee1df8f..5010432fb38a2a7635bd2fa7dedbda2107568f3a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,15 @@ +XEngine_ProxyServer V1.5.1.1001 + +更新:匹配XEngine到V8.x版本 +更新:启动打印xengine版本类型了 +修改:启动参数-v现在打印自身版本信息 +删除:xengine版本判断代码 + +update:match xengine v8.x +update:start printf xengine ver type +modify:printf self version info for parament -v +delete:xengine version judgment code +====================================================================================== XEngine_ProxyServer V1.5.0.1001 优化:优化服务器性能和线程个数 diff --git a/LICENSE b/LICENSE index 65c5ca88a67c30becee01c5a8816d964b03862f9..b4ec123c7313a054e56de689760a16051ac745b7 100644 --- a/LICENSE +++ b/LICENSE @@ -1,165 +1,21 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. +MIT License + +Copyright (c) 2023 XEngine:www.xyry.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.en.md b/README.en.md index ec1ff5f5f891f29a74bc4cf1256811e269ec2fe1..4244be25fe61f7b53124a99c5aa608fc3a337908 100644 --- a/README.en.md +++ b/README.en.md @@ -25,7 +25,7 @@ this software support following features ## install #### XEngine Evn -you must install XEngine,need V7.38 or above,install XEngine can be refer to xengine Readme docment +you must install XEngine,need V8.10 or above,install XEngine can be refer to xengine Readme docment GITEE:https://gitee.com/xyry/libxengine GITHUB:https://github.com/libxengine/xengine @@ -40,11 +40,7 @@ use vs open and compile,suport windows 7sp1 and above Just Run it,use XEngine_AuthorizeApp #### Linux -use makefile compile,UBUNTU20.04 x64 or CENTOS8 x64 -Run it on the terminal - -#### Macos -use makefile compile,mac 12 and above +use makefile compile,UBUNTU22.04 x64 or RockyLinux9 x64 Run it on the terminal ##### complie @@ -53,6 +49,13 @@ make complie make FLAGS=InstallAll install make FLAGS=CleanAll clear +#### Macos +use makefile compile,mac 12 and above +Run it on the terminal + +##### complie +Refer to Linux + #### use 1. Switch to the MASTER branch diff --git a/README.md b/README.md index 59f97b49b6dc4f06541f46778e10f9e91ebd9191..3a20df47aae83f723003cef97292666e09007a83 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ c c++ Socks5 Proxy Service,HTTP Tunnel Proxy Service,tcp forward service ## 安装教程 #### XEngine环境 -必须安装XEngine,版本需要V7.38或者以上版本,安装XEngine可以参考其Readme文档 +必须安装XEngine,版本需要V8.10或者以上版本,安装XEngine可以参考其Readme文档 GITEE:https://gitee.com/xyry/libxengine GITHUB:https://github.com/libxengine/xengine @@ -40,11 +40,7 @@ macos执行:./XEngine_LINEnv.sh -i 3 直接运行即可,使用XEngine_AuthorizeApp #### Linux -Linux使用Makefile编译,UBUNTU20.04 x64或者CENTOS8 x64 -在控制台运行 - -#### Macos -使用makefile编译,控制台运行,需要mac 12以及以上版本 +Linux使用Makefile编译,UBUNTU22.04 x64或者RockyLinux9 x64 在控制台运行 ##### 编译命令 @@ -53,6 +49,13 @@ make 编译 make FLAGS=InstallAll 安装库程序 make FLAGS=CleanAll 清理编译 +#### Macos +使用makefile编译,控制台运行,需要mac 13以及以上版本 +在控制台运行 + +##### 编译命令 +参考Linux + #### 使用说明 1. 切换到MASTER分支 @@ -85,6 +88,7 @@ make FLAGS=CleanAll 清理编译 ## 开发计划 透传代理 转发代理支持权限和确认 +支持加密代理 ## 关注我们 如果你觉得这个软件对你有帮助,请你给我们一个START吧 diff --git a/XEngine_APPClient/APPClient_ForwardExample/APPClient_ForwardExample.cpp b/XEngine_APPClient/APPClient_ForwardExample/APPClient_ForwardExample.cpp index f5ba9c4ff7a6829cd8cc15fdd5685011914a801c..2a44da8425e354635e2909aa29deea7c19442112 100644 --- a/XEngine_APPClient/APPClient_ForwardExample/APPClient_ForwardExample.cpp +++ b/XEngine_APPClient/APPClient_ForwardExample/APPClient_ForwardExample.cpp @@ -26,15 +26,16 @@ //需要优先配置XEngine //WINDOWS支持VS2022 x86 debug 编译调试 //linux使用下面的命令编译 -//g++ -std=c++17 -Wall -g APPClient_ForwardExample.cpp -o APPClient_ForwardExample.exe -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Client -L /usr/local/lib/XEngine_Release/XEngine_RfcComponents -lXEngine_BaseLib -lXClient_Socket -lRfcComponents_ProxyProtocol +//g++ -std=c++17 -Wall -g APPClient_ForwardExample.cpp -o APPClient_ForwardExample.exe -I ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Client -L /usr/local/lib/XEngine_Release/XEngine_RfcComponents -L ../../XEngine_Source/XEngine_ThirdPart/jsoncpp -lXEngine_BaseLib -lXClient_Socket -lRfcComponents_ProxyProtocol -ljsoncpp -Wl,-rpath=../../XEngine_Source/XEngine_ThirdPart/jsoncpp,--disable-new-dtags + int main(int argc, char** argv) { #ifdef _MSC_BUILD WSADATA st_WSAData; WSAStartup(MAKEWORD(2, 2), &st_WSAData); #endif - SOCKET m_Socket; - LPCTSTR lpszServiceAddr = _T("127.0.0.1"); + XSOCKET m_Socket; + LPCXSTR lpszServiceAddr = _X("127.0.0.1"); if (!XClient_TCPSelect_Create(&m_Socket, lpszServiceAddr, 5402)) { printf("连接失败!错误:%lX\n", XClient_GetLastError()); @@ -53,14 +54,14 @@ int main(int argc, char** argv) st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH; st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREQ; - if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCTSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR))) + if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCXSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR))) { printf("发送失败!\n"); return 0; } nMsgLen = 0; - TCHAR* ptszMsgBuffer = NULL; + XCHAR* ptszMsgBuffer = NULL; memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR)); if (!XClient_TCPSelect_RecvPkt(m_Socket, &ptszMsgBuffer, &nMsgLen, &st_ProtocolHdr)) { @@ -75,7 +76,7 @@ int main(int argc, char** argv) st_ProtocolHdr.byVersion = 0; st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_USER_FORWARD; st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREQ; - if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCTSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR))) + if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCXSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR))) { printf("发送失败!\n"); return 0; @@ -95,7 +96,7 @@ int main(int argc, char** argv) std::unique_ptr const pSt_JsonReader(st_JsonBuilder.newCharReader()); if (!pSt_JsonReader->parse(ptszMsgBuffer, ptszMsgBuffer + nMsgLen, &st_JsonAddr, &st_JsonError)) { - return FALSE; + return false; } BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); if (st_JsonAddr["Count"].asInt() > 0) @@ -112,7 +113,7 @@ int main(int argc, char** argv) st_ProtocolHdr.unPacketSize = st_JsonRoot.toStyledString().length(); st_ProtocolHdr.unOperatorType = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_USER_FORWARD; st_ProtocolHdr.unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREQ; - if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCTSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR))) + if (!XClient_TCPSelect_SendMsg(m_Socket, (LPCXSTR)&st_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR))) { printf("发送失败!\n"); return 0; @@ -139,14 +140,14 @@ int main(int argc, char** argv) } else { - BOOL bGet = FALSE; + bool bGet = false; while (1) { if (bGet) { //收到转发请求 nMsgLen = 2048; - TCHAR tszMsgBuffer[2048]; + XCHAR tszMsgBuffer[2048]; memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); @@ -162,7 +163,7 @@ int main(int argc, char** argv) //收到转发请求 if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREQ == st_ProtocolHdr.unOperatorCode) { - bGet = TRUE; + bGet = true; printf("get forward\n"); } BaseLib_OperatorMemory_FreeCStyle((XPPMEM)&ptszMsgBuffer); diff --git a/XEngine_APPClient/APPClient_SocksExample/APPClient_SocksExample.cpp b/XEngine_APPClient/APPClient_SocksExample/APPClient_SocksExample.cpp index 004e160898d3c68d328df0a2ea03a598c96e7ba1..9353d167612d6109333cdc31ed7b2baea2b7faf4 100644 --- a/XEngine_APPClient/APPClient_SocksExample/APPClient_SocksExample.cpp +++ b/XEngine_APPClient/APPClient_SocksExample/APPClient_SocksExample.cpp @@ -1,4 +1,4 @@ -#ifdef _WINDOWS +#ifdef _MSC_BUILD #include #include #pragma comment(lib,"Ws2_32.lib") @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -25,12 +26,12 @@ //g++ -std=c++17 -Wall -g APPClient_SocksExample.cpp -o APPClient_SocksExample.exe -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Client -L /usr/local/lib/XEngine_Release/XEngine_RfcComponents -lXEngine_BaseLib -lXClient_Socket -lRfcComponents_ProxyProtocol int main(int argc, char** argv) { -#ifdef _WINDOWS +#ifdef _MSC_BUILD WSADATA st_WSAData; WSAStartup(MAKEWORD(2, 2), &st_WSAData); #endif - SOCKET m_Socket; - LPCTSTR lpszServiceAddr = _T("127.0.0.1"); + XSOCKET m_Socket; + LPCXSTR lpszServiceAddr = _X("127.0.0.1"); if (!XClient_TCPSelect_Create(&m_Socket, lpszServiceAddr, 5400)) { printf("连接失败!错误:%lX\n", XClient_GetLastError()); @@ -39,7 +40,7 @@ int main(int argc, char** argv) printf("连接成功!\n"); int nMsgLen = 2048; - TCHAR tszMsgBuffer[2048]; + XCHAR tszMsgBuffer[2048]; memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); int nCount = 2; @@ -62,28 +63,31 @@ int main(int argc, char** argv) ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH enServerAuth; ProxyProtocol_SocksClient_AuthParse(tszMsgBuffer, &enServerAuth); printf("接受服务器返回数据,内容:%d\n", enServerAuth); - //////////////////////////////////////////////////////////////////////////登录 匿名登录注释下面的代码 - ProxyProtocol_SocksClient_LoginPacket(tszMsgBuffer, &nMsgLen, "123123aa", "123123"); - if (!XClient_TCPSelect_SendMsg(m_Socket, tszMsgBuffer, nMsgLen)) + if (ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH_USERPASS == enServerAuth) { - printf("发送投递失败!\n"); - return 0; - } + //////////////////////////////////////////////////////////////////////////登录 匿名登录注释下面的代码 + ProxyProtocol_SocksClient_LoginPacket(tszMsgBuffer, &nMsgLen, "123123aa", "123123"); + if (!XClient_TCPSelect_SendMsg(m_Socket, tszMsgBuffer, nMsgLen)) + { + printf("发送投递失败!\n"); + return 0; + } - nMsgLen = 2048; - memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); - if (!XClient_TCPSelect_RecvMsg(m_Socket, tszMsgBuffer, &nMsgLen)) - { - printf("接受数据失败!\n"); - return 0; - } - if (ProxyProtocol_SocksClient_LoginParse(tszMsgBuffer)) - { - printf("login ok\n"); - } - else - { - printf("login failed\n"); + nMsgLen = 2048; + memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); + if (!XClient_TCPSelect_RecvMsg(m_Socket, tszMsgBuffer, &nMsgLen)) + { + printf("接受数据失败!\n"); + return 0; + } + if (ProxyProtocol_SocksClient_LoginParse(tszMsgBuffer)) + { + printf("login ok\n"); + } + else + { + printf("login failed\n"); + } } //////////////////////////////////////////////////////////////////////////连接 ProxyProtocol_SocksClient_ConnectPacket(tszMsgBuffer, &nMsgLen, "www.xyry.org", 80, ENUM_RFCCOMPONENTS_PROXYSOCKS_COMMAND_CONNECT, ENUM_RFCCOMPONENTS_PROXYSOCKS_IPADDR_DOMAIN); @@ -102,8 +106,8 @@ int main(int argc, char** argv) int nCode = 0; ProxyProtocol_SocksClient_ConnectParse(tszMsgBuffer, &nCode); //请求 - LPCTSTR lpszGetHttp = _T("GET / HTTP/1.1\r\nHost: www.xyry.org\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36\r\nAccept: text/html\r\n\r\n"); - if (!XClient_TCPSelect_SendMsg(m_Socket, lpszGetHttp, _tcslen(lpszGetHttp))) + LPCXSTR lpszGetHttp = _X("GET / HTTP/1.1\r\nHost: www.xyry.org\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36\r\nAccept: text/html\r\n\r\n"); + if (!XClient_TCPSelect_SendMsg(m_Socket, lpszGetHttp, _tcsxlen(lpszGetHttp))) { printf("发送投递失败!\n"); return 0; @@ -120,7 +124,7 @@ int main(int argc, char** argv) } XClient_TCPSelect_Close(m_Socket); -#ifdef _WINDOWS +#ifdef _MSC_BUILD WSACleanup(); #endif return 0; diff --git a/XEngine_APPClient/APPClient_TunnelExample/APPClient_TunnelExample.cpp b/XEngine_APPClient/APPClient_TunnelExample/APPClient_TunnelExample.cpp index aeceed6756e7e9a9d692662f76e23a9438fcfb4c..be75e3015d0c67f63cd4a9ff5551fa9c31dbf4b1 100644 --- a/XEngine_APPClient/APPClient_TunnelExample/APPClient_TunnelExample.cpp +++ b/XEngine_APPClient/APPClient_TunnelExample/APPClient_TunnelExample.cpp @@ -1,4 +1,4 @@ -#ifdef _WINDOWS +#ifdef _MSC_BUILD #include #include #pragma comment(lib,"Ws2_32.lib") @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -25,12 +26,12 @@ //g++ -std=c++17 -Wall -g APPClient_TunnelExample.cpp -o APPClient_TunnelExample.exe -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Client -L /usr/local/lib/XEngine_Release/XEngine_RfcComponents -lXEngine_BaseLib -lXClient_Socket -lRfcComponents_ProxyProtocol int main(int argc, char** argv) { -#ifdef _WINDOWS +#ifdef _MSC_BUILD WSADATA st_WSAData; WSAStartup(MAKEWORD(2, 2), &st_WSAData); #endif - SOCKET m_Socket; - LPCTSTR lpszServiceAddr = _T("127.0.0.1"); + XSOCKET m_Socket; + LPCXSTR lpszServiceAddr = _X("127.0.0.1"); if (!XClient_TCPSelect_Create(&m_Socket, lpszServiceAddr, 5401)) { @@ -39,7 +40,7 @@ int main(int argc, char** argv) } printf("连接成功!\n"); int nMsgLen = 2048; - TCHAR tszMsgBuffer[2048]; + XCHAR tszMsgBuffer[2048]; memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); ProxyProtocol_TunnelClient_Packet(tszMsgBuffer, &nMsgLen, "www.xyry.org:80", "MTIzMTIzYWE6MTIzMTIz"); @@ -58,8 +59,8 @@ int main(int argc, char** argv) } printf("接受服务器返回数据,内容:%s\n", tszMsgBuffer); - LPCTSTR lpszGetHttp = _T("GET / HTTP/1.1\r\nHost: www.xyry.org\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36\r\nAccept: text/html\r\n\r\n"); - if (!XClient_TCPSelect_SendMsg(m_Socket, lpszGetHttp, _tcslen(lpszGetHttp))) + LPCXSTR lpszGetHttp = _X("GET / HTTP/1.1\r\nHost: www.xyry.org\r\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36\r\nAccept: text/html\r\n\r\n"); + if (!XClient_TCPSelect_SendMsg(m_Socket, lpszGetHttp, _tcsxlen(lpszGetHttp))) { printf("发送投递失败!\n"); return 0; @@ -77,7 +78,7 @@ int main(int argc, char** argv) } XClient_TCPSelect_Close(m_Socket); -#ifdef _WINDOWS +#ifdef _MSC_BUILD WSACleanup(); #endif return 0; diff --git a/XEngine_APPClient/README.md b/XEngine_APPClient/README.md new file mode 100644 index 0000000000000000000000000000000000000000..4b2ff81bf7cb2a99fdf0e4ca189e25cd572915a4 --- /dev/null +++ b/XEngine_APPClient/README.md @@ -0,0 +1,13 @@ +## XEngine_APPClient + +windows:use x86 debug mode complie by vs2022 +linux or macos:g++ command + +#### APPClient_ForwardExample +xengine data forward protocol example + +#### APPClient_SocksExample +socks v4 and v5 proxy forward example + +#### APPClient_TunnelExample +http tunnel example \ No newline at end of file diff --git a/XEngine_Docment/Docment_en.docx b/XEngine_Docment/Docment_en.docx index c9b672c64b35ecc8e821cde87cf9a2c534d73077..300c22efd5f6ee8484f37cd4b9d1dcf358766510 100644 Binary files a/XEngine_Docment/Docment_en.docx and b/XEngine_Docment/Docment_en.docx differ diff --git a/XEngine_Docment/Docment_zh.docx b/XEngine_Docment/Docment_zh.docx index a4512f5bc5397b4b05d4ffd7532fd65cfa455c48..456ab94df0fe5b4f2f74f52503d1f682d7d75a34 100644 Binary files a/XEngine_Docment/Docment_zh.docx and b/XEngine_Docment/Docment_zh.docx differ diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json index 90faf060c0a14d21d6effa79276a092eccfe8cc7..f33e4a685049b3291fbf53d53ff209a4dcdb9a79 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Config.json +++ b/XEngine_Release/XEngine_Config/XEngine_Config.json @@ -27,6 +27,7 @@ "tszAuthFile": "./XEngine_Config/UserList.txt" }, "XVer": [ + "1.5.1.1001 Build20230426", "1.5.0.1001 Build20230202", "1.4.0.1001 Build20221111", "1.3.1.1001 Build20220804", diff --git a/XEngine_Source/Makefile b/XEngine_Source/Makefile index f828b1de0cda64e38a853e161782e01619fe093a..becd2dedfe51abd6be68d6998d5f1f379b0e0b2b 100644 --- a/XEngine_Source/Makefile +++ b/XEngine_Source/Makefile @@ -1,7 +1,7 @@ RELEASE = 0 UNICODE = 0 -#编译的选项参数 -FLAGS = RELEASE=$(RELEASE) +PLATFORM=linux +FLAGS= #要编译的模块 THIRDPART_MODULE_JSONCPP = ./XEngine_ThirdPart/jsoncpp @@ -17,25 +17,16 @@ XENGINE_MODULES = libjsoncpp.so libXEngine_ModuleConfigure.so libXEngine_ModuleA MakeAll:$(XENGINE_MODULES) libjsoncpp.so: - make -C $(THIRDPART_MODULE_JSONCPP) $(FLAGS) + make -C $(THIRDPART_MODULE_JSONCPP) PLATFORM=$(PLATFORM) $(FLAGS) libXEngine_ModuleConfigure.so: - make -C $(MODULE_CONFIGURE_PATH) $(FLAGS) + make -C $(MODULE_CONFIGURE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) libXEngine_ModuleAuthorize.so: - make -C $(MODULE_AUTHORIZE_PATH) $(FLAGS) + make -C $(MODULE_AUTHORIZE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) libXEngine_ModuleProtocol.so: - make -C $(MODULE_PROTOCOL_PATH) $(FLAGS) + make -C $(MODULE_PROTOCOL_PATH) PLATFORM=$(PLATFORM) $(FLAGS) libXEngine_ModuleSession.so: - make -C $(MODULE_SESSION_PATH) $(FLAGS) + make -C $(MODULE_SESSION_PATH) PLATFORM=$(PLATFORM) $(FLAGS) XEngine_ServiceApp.exe: - make -C $(APP_SERVICE_PATH) $(FLAGS) - - -SetFlags_Install: - export FLAGS=InstallAll -InstallAll:SetFlags_Install $(NETENGINE_LIB) - -SetFlags_Clean: - export FLAGS=CleanAll -CleanAll:SetFlags_Clean $(NETENGINE_LIB) + make -C $(APP_SERVICE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) diff --git a/XEngine_Source/XEngine_ModuleAuthorize/Makefile b/XEngine_Source/XEngine_ModuleAuthorize/Makefile index d1cff36c00995bead86f954cf33c8cbbfab468d0..9b5ebcf955b5d2809324be10bd2351f8bcbbe9de 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/Makefile +++ b/XEngine_Source/XEngine_ModuleAuthorize/Makefile @@ -1,30 +1,23 @@ CC = g++ -Wall -std=c++17 -fPIC -SHAREFLAG = -shared -SHAREDLL = so +PLATFORM = linux +PLATVER = +PLATDIR = +FILEEXT = +LIBFLAG = RELEASE = 0 UNICODE = 0 -INCLUDE = -I ./ -LOADBIN = +LOADHDR = -I ./ +LOADSO = LIB = -LIBEX = -ldl -lpthread -LOADSO = -Wl,-rpath= -LIBINCLUDE = ModuleAuthorize_User.o pch.o - -ifeq ($(shell uname),Darwin) - SHAREDLL = dylib - SHAREFLAG = -dynamiclib - LOADSO = -else - SHAREDLL = so - SHAREFLAG = -shared -endif +LIBEX = +OBJECTS = ModuleAuthorize_User.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -O2 +FLAGS = -c DEBUG = else -FLAGS = -c -DEBUG = -g +FLAGS = -c -lc_p +DEBUG = -g -pg endif ifeq ($(UNICODE),1) @@ -33,24 +26,46 @@ else UNICODE = endif +ifeq ($(PLATFORM),linux) + ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) + PLATVER = -D __CENTOS__ + PLATDIR = XEngine_Linux/Centos + else + PLATVER = -D __UBUNTU__ + PLATDIR = XEngine_Linux/Ubuntu + endif + FILEEXT = so + LIBFLAG = -shared + LIBEX = -lpthread -lrt -ldl + LOADBIN = -Wl,-rpath=./,--disable-new-dtags +else ifeq ($(PLATFORM),mac) + CC += -Wno-deprecated-declarations + PLATVER = -D __MACOS__ + PLATDIR = XEngine_Mac + FILEEXT = dylib + LIBFLAG = -dynamiclib + LIBEX = -lpthread -ldl + LOADBIN = -Wl,-rpath,@loader_path/./ +endif + -all:$(LIBINCLUDE) - $(CC) $(DEBUG) $(LIBINCLUDE) -o libXEngine_ModuleAuthorize.$(SHAREDLL) $(SHAREFLAG) -fPIC $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO) +all:$(OBJECTS) + $(CC) $(DEBUG) $(OBJECTS) -o libXEngine_ModuleAuthorize.$(FILEEXT) $(LIBFLAG) $(LIB) $(LIBEX) $(LOADSO) $(LOADBIN) ModuleAuthorize_User.o:./ModuleAuthorize_User/ModuleAuthorize_User.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./ModuleAuthorize_User/ModuleAuthorize_User.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleAuthorize_User/ModuleAuthorize_User.cpp pch.o:./pch.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./pch.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./pch.cpp InstallAll:InstallSo -InstallSo:./libXEngine_ModuleAuthorize.$(SHAREDLL) - cp ./libXEngine_ModuleAuthorize.$(SHAREDLL) ../../XEngine_Release/libXEngine_ModuleAuthorize.$(SHAREDLL) +InstallSo:./libXEngine_ModuleAuthorize.$(FILEEXT) + cp ./libXEngine_ModuleAuthorize.$(FILEEXT) ../../XEngine_Release/libXEngine_ModuleAuthorize.$(FILEEXT) CleanAll:CleanObj CleanMk CleanObj: rm *.o CleanMk: - rm *.$(SHAREDLL) + rm *.$(FILEEXT) diff --git a/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuth_Define.h b/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuth_Define.h index 026d5d02b926b1fc23dfa8f3597705924362c5c3..58d4c31d9591a6a2a164099b4f137e26bbf6b26e 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuth_Define.h +++ b/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuth_Define.h @@ -13,7 +13,7 @@ ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleAuthorize_GetLastError(int* pInt_SysError = NULL); +extern "C" XLONG ModuleAuthorize_GetLastError(int* pInt_SysError = NULL); /************************************************************************/ /* 验证导出函数 */ /************************************************************************/ @@ -30,7 +30,7 @@ extern "C" DWORD ModuleAuthorize_GetLastError(int* pInt_SysError = NULL); 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile); +extern "C" bool ModuleAuthorize_User_Init(LPCXSTR lpszAuthFile); /************************************************************************ 函数名称:ModuleAuthorize_User_Destory 函数功能:销毁授权管理器 @@ -39,7 +39,7 @@ extern "C" BOOL ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile); 意思:是否销毁成功 备注: ************************************************************************/ -extern "C" BOOL ModuleAuthorize_User_Destory(); +extern "C" bool ModuleAuthorize_User_Destory(); /******************************************************************** 函数名称:ModuleAuthorize_User_Exist 函数功能:是否验证通过 @@ -58,4 +58,4 @@ extern "C" BOOL ModuleAuthorize_User_Destory(); 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleAuthorize_User_Exist(LPCTSTR lpszUser, LPCTSTR lpszPass); \ No newline at end of file +extern "C" bool ModuleAuthorize_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.cpp b/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.cpp index 6fea7b2aaa93c5239ceab99ad63c600bc6379a16..8f6dca13702f63f8f78975ce0127a7c1b82c3cd4 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.cpp +++ b/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.cpp @@ -35,22 +35,22 @@ CModuleAuthorize_User::~CModuleAuthorize_User() 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleAuthorize_User::ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile) +bool CModuleAuthorize_User::ModuleAuthorize_User_Init(LPCXSTR lpszAuthFile) { - Authorize_IsErrorOccur = FALSE; + Authorize_IsErrorOccur = false; - FILE* pSt_File = _tfopen(lpszAuthFile, _T("rb")); + FILE* pSt_File = _xtfopen(lpszAuthFile, _X("rb")); if (NULL == pSt_File) { - Authorize_IsErrorOccur = TRUE; + Authorize_IsErrorOccur = true; Authorize_dwErrorCode = ERROR_MODULE_AUTHORIZE_USER_OPENFILE; - return FALSE; + return false; } int nCount = 0; - TCHAR tszMsgBuffer[4096]; + XCHAR tszMsgBuffer[4096]; memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); - while (TRUE) + while (true) { int nRet = fread(tszMsgBuffer + nCount, 1, 1024, pSt_File); if (nRet <= 0) @@ -61,8 +61,8 @@ BOOL CModuleAuthorize_User::ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile) } fclose(pSt_File); - LPCTSTR lpszLineStr = _T("\r\n"); - TCHAR* ptszTokStr = _tcstok(tszMsgBuffer, lpszLineStr); + LPCXSTR lpszLineStr = _X("\r\n"); + XCHAR* ptszTokStr = _tcsxtok(tszMsgBuffer, lpszLineStr); while (1) { if (NULL == ptszTokStr) @@ -72,12 +72,12 @@ BOOL CModuleAuthorize_User::ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile) XENGINE_USERAUTH st_UserInfo; memset(&st_UserInfo, '\0', sizeof(XENGINE_USERAUTH)); - _stscanf(ptszTokStr, _T("%s %s"), st_UserInfo.tszUserName, st_UserInfo.tszUserPass); + _stxscanf(ptszTokStr, _X("%s %s"), st_UserInfo.tszUserName, st_UserInfo.tszUserPass); stl_MapSession.insert(make_pair(st_UserInfo.tszUserName, st_UserInfo)); - ptszTokStr = _tcstok(NULL, lpszLineStr); + ptszTokStr = _tcsxtok(NULL, lpszLineStr); } - return TRUE; + return true; } /************************************************************************ 函数名称:ModuleAuthorize_User_Destory @@ -87,12 +87,12 @@ BOOL CModuleAuthorize_User::ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile) 意思:是否销毁成功 备注: ************************************************************************/ -BOOL CModuleAuthorize_User::ModuleAuthorize_User_Destory() +bool CModuleAuthorize_User::ModuleAuthorize_User_Destory() { - Authorize_IsErrorOccur = FALSE; + Authorize_IsErrorOccur = false; stl_MapSession.clear(); - return TRUE; + return true; } /******************************************************************** 函数名称:ModuleAuthorize_User_Exist @@ -112,29 +112,29 @@ BOOL CModuleAuthorize_User::ModuleAuthorize_User_Destory() 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleAuthorize_User::ModuleAuthorize_User_Exist(LPCTSTR lpszUser, LPCTSTR lpszPass) +bool CModuleAuthorize_User::ModuleAuthorize_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass) { - Authorize_IsErrorOccur = FALSE; + Authorize_IsErrorOccur = false; unordered_map::const_iterator stl_MapIterator = stl_MapSession.find(lpszUser); if (stl_MapIterator == stl_MapSession.end()) { - Authorize_IsErrorOccur = TRUE; + Authorize_IsErrorOccur = true; Authorize_dwErrorCode = ERROR_MODULE_AUTHORIZE_USER_NOTFOUND; - return FALSE; + return false; } - if (_tcslen(lpszPass) != _tcslen(stl_MapIterator->second.tszUserPass)) + if (_tcsxlen(lpszPass) != _tcsxlen(stl_MapIterator->second.tszUserPass)) { - Authorize_IsErrorOccur = TRUE; + Authorize_IsErrorOccur = true; Authorize_dwErrorCode = ERROR_MODULE_AUTHORIZE_USER_PASSWORD; - return FALSE; + return false; } - if (0 != _tcsncmp(lpszPass, stl_MapIterator->second.tszUserPass, _tcslen(lpszPass))) + if (0 != _tcsxncmp(lpszPass, stl_MapIterator->second.tszUserPass, _tcsxlen(lpszPass))) { - Authorize_IsErrorOccur = TRUE; + Authorize_IsErrorOccur = true; Authorize_dwErrorCode = ERROR_MODULE_AUTHORIZE_USER_PASSWORD; - return FALSE; + return false; } - return TRUE; + return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.h b/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.h index b1c455f221b49f9ec83de129287478a1a7d8f5c9..e81d504c67a6214446f9768c83cf8dcf6d5caa0f 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.h +++ b/XEngine_Source/XEngine_ModuleAuthorize/ModuleAuthorize_User/ModuleAuthorize_User.h @@ -13,8 +13,8 @@ typedef struct { - TCHAR tszUserName[64]; - TCHAR tszUserPass[64]; + XCHAR tszUserName[64]; + XCHAR tszUserPass[64]; }XENGINE_USERAUTH, * LPXENGINE_USERAUTH; class CModuleAuthorize_User @@ -23,9 +23,9 @@ public: CModuleAuthorize_User(); ~CModuleAuthorize_User(); public: - BOOL ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile); - BOOL ModuleAuthorize_User_Destory(); - BOOL ModuleAuthorize_User_Exist(LPCTSTR lpszUser, LPCTSTR lpszPass); + bool ModuleAuthorize_User_Init(LPCXSTR lpszAuthFile); + bool ModuleAuthorize_User_Destory(); + bool ModuleAuthorize_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass); private: unordered_map stl_MapSession; }; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleAuthorize/dllmain.cpp b/XEngine_Source/XEngine_ModuleAuthorize/dllmain.cpp index daed8c8f7ac50ca1466016a0529648d18125a7e7..594ff2123d474b129bb2014fb572f03c9741bf0b 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/dllmain.cpp +++ b/XEngine_Source/XEngine_ModuleAuthorize/dllmain.cpp @@ -1,9 +1,9 @@ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved +bool APIENTRY DllMain( HMODULE hModule, + XLONG ul_reason_for_call, + XPVOID lpReserved ) { switch (ul_reason_for_call) @@ -14,6 +14,6 @@ BOOL APIENTRY DllMain( HMODULE hModule, case DLL_PROCESS_DETACH: break; } - return TRUE; + return true; } diff --git a/XEngine_Source/XEngine_ModuleAuthorize/pch.cpp b/XEngine_Source/XEngine_ModuleAuthorize/pch.cpp index 08ac653e60513275798d9b00751fb4e957256704..32bdad8009e8e9f8639f786d512a2efba73cf37b 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/pch.cpp +++ b/XEngine_Source/XEngine_ModuleAuthorize/pch.cpp @@ -11,14 +11,14 @@ // Purpose: 导出实现 // History: *********************************************************************/ -BOOL Authorize_IsErrorOccur = FALSE; -DWORD Authorize_dwErrorCode = 0; +bool Authorize_IsErrorOccur = false; +XLONG Authorize_dwErrorCode = 0; ////////////////////////////////////////////////////////////////////////// CModuleAuthorize_User m_User; ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleAuthorize_GetLastError(int* pInt_SysError) +extern "C" XLONG ModuleAuthorize_GetLastError(int* pInt_SysError) { if (NULL != pInt_SysError) { @@ -29,15 +29,15 @@ extern "C" DWORD ModuleAuthorize_GetLastError(int* pInt_SysError) /************************************************************************/ /* 验证导出函数 */ /************************************************************************/ -extern "C" BOOL ModuleAuthorize_User_Init(LPCTSTR lpszAuthFile) +extern "C" bool ModuleAuthorize_User_Init(LPCXSTR lpszAuthFile) { return m_User.ModuleAuthorize_User_Init(lpszAuthFile); } -extern "C" BOOL ModuleAuthorize_User_Destory() +extern "C" bool ModuleAuthorize_User_Destory() { return m_User.ModuleAuthorize_User_Destory(); } -extern "C" BOOL ModuleAuthorize_User_Exist(LPCTSTR lpszUser, LPCTSTR lpszPass) +extern "C" bool ModuleAuthorize_User_Exist(LPCXSTR lpszUser, LPCXSTR lpszPass) { return m_User.ModuleAuthorize_User_Exist(lpszUser, lpszPass); } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleAuthorize/pch.h b/XEngine_Source/XEngine_ModuleAuthorize/pch.h index 6f920b9dd259d8833eda7ca0732f1ea06e3b7661..34a07d8a1973da61387d062bdcee70131a6d6d65 100644 --- a/XEngine_Source/XEngine_ModuleAuthorize/pch.h +++ b/XEngine_Source/XEngine_ModuleAuthorize/pch.h @@ -40,5 +40,5 @@ typedef std::string tstring; // Purpose: 公用头文件 // History: *********************************************************************/ -extern BOOL Authorize_IsErrorOccur; -extern DWORD Authorize_dwErrorCode; \ No newline at end of file +extern bool Authorize_IsErrorOccur; +extern XLONG Authorize_dwErrorCode; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleConfigure/Makefile b/XEngine_Source/XEngine_ModuleConfigure/Makefile index f0ec413a7c087b3bd1d7c769aeb62c7e817affa3..ac17d52e38313051909746d44053104f19c3623c 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/Makefile +++ b/XEngine_Source/XEngine_ModuleConfigure/Makefile @@ -1,30 +1,23 @@ CC = g++ -Wall -std=c++17 -fPIC -SHAREFLAG = -shared -SHAREDLL = so +PLATFORM = linux +PLATVER = +PLATDIR = +FILEEXT = +LIBFLAG = RELEASE = 0 UNICODE = 0 -INCLUDE = -I ./ -I ../XEngine_ThirdPart/jsoncpp -LOADBIN = -L ../XEngine_ThirdPart/jsoncpp +LOADHDR = -I ./ -I ../XEngine_ThirdPart/jsoncpp +LOADSO = -L ../XEngine_ThirdPart/jsoncpp LIB = -ljsoncpp -LIBEX = -ldl -lpthread -LOADSO = -Wl,-rpath=./,--disable-new-dtags -LIBINCLUDE = ModuleConfigure_Json.o pch.o - -ifeq ($(shell uname),Darwin) - SHAREDLL = dylib - SHAREFLAG = -dynamiclib - LOADSO = -else - SHAREDLL = so - SHAREFLAG = -shared -endif +LIBEX = +OBJECTS = ModuleConfigure_Json.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -O2 +FLAGS = -c DEBUG = else -FLAGS = -c -DEBUG = -g +FLAGS = -c -lc_p +DEBUG = -g -pg endif ifeq ($(UNICODE),1) @@ -33,24 +26,46 @@ else UNICODE = endif +ifeq ($(PLATFORM),linux) + ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) + PLATVER = -D __CENTOS__ + PLATDIR = XEngine_Linux/Centos + else + PLATVER = -D __UBUNTU__ + PLATDIR = XEngine_Linux/Ubuntu + endif + FILEEXT = so + LIBFLAG = -shared + LIBEX = -lpthread -lrt -ldl + LOADBIN = -Wl,-rpath=./,--disable-new-dtags +else ifeq ($(PLATFORM),mac) + CC += -Wno-deprecated-declarations + PLATVER = -D __MACOS__ + PLATDIR = XEngine_Mac + FILEEXT = dylib + LIBFLAG = -dynamiclib + LIBEX = -lpthread -ldl + LOADBIN = -Wl,-rpath,@loader_path/./ +endif + -all:$(LIBINCLUDE) - $(CC) $(DEBUG) $(LIBINCLUDE) -o libXEngine_ModuleConfigure.$(SHAREDLL) $(SHAREFLAG) -fPIC $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO) +all:$(OBJECTS) + $(CC) $(DEBUG) $(OBJECTS) -o libXEngine_ModuleConfigure.$(FILEEXT) $(LIBFLAG) $(LIB) $(LIBEX) $(LOADSO) $(LOADBIN) ModuleConfigure_Json.o:./ModuleConfigure_Json/ModuleConfigure_Json.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./ModuleConfigure_Json/ModuleConfigure_Json.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleConfigure_Json/ModuleConfigure_Json.cpp pch.o:./pch.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./pch.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./pch.cpp InstallAll:InstallSo -InstallSo:./libXEngine_ModuleConfigure.$(SHAREDLL) - cp ./libXEngine_ModuleConfigure.$(SHAREDLL) ../../XEngine_Release/libXEngine_ModuleConfigure.$(SHAREDLL) +InstallSo:./libXEngine_ModuleConfigure.$(FILEEXT) + cp ./libXEngine_ModuleConfigure.$(FILEEXT) ../../XEngine_Release/libXEngine_ModuleConfigure.$(FILEEXT) CleanAll:CleanObj CleanMk CleanObj: rm *.o CleanMk: - rm *.$(SHAREDLL) + rm *.$(FILEEXT) diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h index 0707ded36928051bc86a4e9fddbc550ba294f9a1..d535a6b28303d0d86feb7e92322d79b8ffe9ce6c 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h @@ -15,8 +15,8 @@ ////////////////////////////////////////////////////////////////////////// typedef struct tag_XEngine_ServiceConfig { - TCHAR tszIPAddr[128]; //本机IP地址,根据需要配置 - BOOL bDeamon; //是否以守护进程启动,LINUX有效 + XCHAR tszIPAddr[128]; //本机IP地址,根据需要配置 + bool bDeamon; //是否以守护进程启动,LINUX有效 int nSocksPort; //Socks端口,<=0不启用 int nTunnelPort; //Tunnel服务端口 int nForwardPort; //数据转发端口 @@ -36,7 +36,7 @@ typedef struct tag_XEngine_ServiceConfig }st_XTime; //次数*时间=超时 struct { - TCHAR tszLogFile[MAX_PATH]; //日志保存路径 + XCHAR tszLogFile[MAX_PATH]; //日志保存路径 int nMaxSize; //最大日志大小 int nMaxCount; //最大日志个数 int nLogLeave; //日志等级 @@ -44,7 +44,7 @@ typedef struct tag_XEngine_ServiceConfig struct { int bAuth; //是否启用验证,大于0启用 - TCHAR tszAuthFile[MAX_PATH]; //验证地址 + XCHAR tszAuthFile[MAX_PATH]; //验证地址 }st_XAuth; struct { @@ -54,7 +54,7 @@ typedef struct tag_XEngine_ServiceConfig ////////////////////////////////////////////////////////////////////////// // 导出函数定义 ////////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleConfigure_GetLastError(int* pInt_ErrorCode = NULL); +extern "C" XLONG ModuleConfigure_GetLastError(int* pInt_ErrorCode = NULL); /************************************************************************/ /* 文件配置读取 */ /************************************************************************/ @@ -76,4 +76,4 @@ extern "C" DWORD ModuleConfigure_GetLastError(int* pInt_ErrorCode = NULL); 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig); \ No newline at end of file +extern "C" bool ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp index 676a8bca3603d7b9c98256c64e246aa6db9c705c..b6ad44e4ac75621b62544e90c6f9df445408505b 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp @@ -40,29 +40,29 @@ CModuleConfigure_Json::~CModuleConfigure_Json() 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleConfigure_Json::ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig) +bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig) { - Config_IsErrorOccur = FALSE; + Config_IsErrorOccur = false; if ((NULL == lpszConfigFile) || (NULL == pSt_ServerConfig)) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_PARAMENT; - return FALSE; + return false; } Json::Value st_JsonRoot; JSONCPP_STRING st_JsonError; Json::CharReaderBuilder st_JsonBuilder; //读取配置文件所有内容到缓冲区 - FILE* pSt_File = _tfopen(lpszConfigFile, _T("rb")); + FILE* pSt_File = _xtfopen(lpszConfigFile, _X("rb")); if (NULL == pSt_File) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_OPENFILE; - return FALSE; + return false; } int nCount = 0; - TCHAR tszMsgBuffer[4096]; + XCHAR tszMsgBuffer[4096]; while (1) { int nRet = fread(tszMsgBuffer + nCount, 1, 2048, pSt_File); @@ -77,11 +77,11 @@ BOOL CModuleConfigure_Json::ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XE std::unique_ptr const pSt_JsonReader(st_JsonBuilder.newCharReader()); if (!pSt_JsonReader->parse(tszMsgBuffer, tszMsgBuffer + nCount, &st_JsonRoot, &st_JsonError)) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_PARSE; - return FALSE; + return false; } - _tcscpy(pSt_ServerConfig->tszIPAddr, st_JsonRoot["tszIPAddr"].asCString()); + _tcsxcpy(pSt_ServerConfig->tszIPAddr, st_JsonRoot["tszIPAddr"].asCString()); pSt_ServerConfig->bDeamon = st_JsonRoot["bDeamon"].asInt(); pSt_ServerConfig->nSocksPort = st_JsonRoot["nSocksPort"].asInt(); pSt_ServerConfig->nTunnelPort = st_JsonRoot["nTunnelPort"].asInt(); @@ -89,9 +89,9 @@ BOOL CModuleConfigure_Json::ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XE if (st_JsonRoot["XMax"].empty() || (4 != st_JsonRoot["XMax"].size())) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_XMAX; - return FALSE; + return false; } Json::Value st_JsonXMax = st_JsonRoot["XMax"]; pSt_ServerConfig->st_XMax.nMaxClient = st_JsonXMax["nMaxClient"].asInt(); @@ -101,9 +101,9 @@ BOOL CModuleConfigure_Json::ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XE if (st_JsonRoot["XTime"].empty() || (4 != st_JsonRoot["XTime"].size())) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_XTIME; - return FALSE; + return false; } Json::Value st_JsonXTime = st_JsonRoot["XTime"]; pSt_ServerConfig->st_XTime.nTimeCheck = st_JsonXTime["nTimeCheck"].asInt(); @@ -113,31 +113,31 @@ BOOL CModuleConfigure_Json::ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XE if (st_JsonRoot["XLog"].empty() || (4 != st_JsonRoot["XLog"].size())) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_XLOG; - return FALSE; + return false; } Json::Value st_JsonXLog = st_JsonRoot["XLog"]; pSt_ServerConfig->st_XLog.nMaxSize = st_JsonXLog["MaxSize"].asInt(); pSt_ServerConfig->st_XLog.nMaxCount = st_JsonXLog["MaxCount"].asInt(); pSt_ServerConfig->st_XLog.nLogLeave = st_JsonXLog["LogLeave"].asInt(); - _tcscpy(pSt_ServerConfig->st_XLog.tszLogFile, st_JsonXLog["tszLogFile"].asCString()); + _tcsxcpy(pSt_ServerConfig->st_XLog.tszLogFile, st_JsonXLog["tszLogFile"].asCString()); if (st_JsonRoot["XAuth"].empty() || (2 != st_JsonRoot["XAuth"].size())) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_XAUTH; - return FALSE; + return false; } Json::Value st_JsonXAuth = st_JsonRoot["XAuth"]; pSt_ServerConfig->st_XAuth.bAuth = st_JsonXAuth["bAuth"].asInt(); - _tcscpy(pSt_ServerConfig->st_XAuth.tszAuthFile, st_JsonXAuth["tszAuthFile"].asCString()); + _tcsxcpy(pSt_ServerConfig->st_XAuth.tszAuthFile, st_JsonXAuth["tszAuthFile"].asCString()); if (st_JsonRoot["XVer"].empty()) { - Config_IsErrorOccur = TRUE; + Config_IsErrorOccur = true; Config_dwErrorCode = ERROR_MODULE_CONFIGURE_JSON_XVER; - return FALSE; + return false; } pSt_ServerConfig->st_XVer.pStl_ListVer = new list; Json::Value st_JsonXVer = st_JsonRoot["XVer"]; @@ -145,5 +145,5 @@ BOOL CModuleConfigure_Json::ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XE { pSt_ServerConfig->st_XVer.pStl_ListVer->push_back(st_JsonXVer[i].asCString()); } - return TRUE; + return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.h b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.h index 7ff49474b6cf2a6cc69fec7cb2a5de586d2663c1..e354ecee348c4a2fc948f2f4c8ff2fbd7771702d 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.h +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.h @@ -17,7 +17,7 @@ public: CModuleConfigure_Json(); ~CModuleConfigure_Json(); public: - BOOL ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig); + bool ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG* pSt_ServerConfig); protected: private: }; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleConfigure/dllmain.cpp b/XEngine_Source/XEngine_ModuleConfigure/dllmain.cpp index daed8c8f7ac50ca1466016a0529648d18125a7e7..594ff2123d474b129bb2014fb572f03c9741bf0b 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/dllmain.cpp +++ b/XEngine_Source/XEngine_ModuleConfigure/dllmain.cpp @@ -1,9 +1,9 @@ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved +bool APIENTRY DllMain( HMODULE hModule, + XLONG ul_reason_for_call, + XPVOID lpReserved ) { switch (ul_reason_for_call) @@ -14,6 +14,6 @@ BOOL APIENTRY DllMain( HMODULE hModule, case DLL_PROCESS_DETACH: break; } - return TRUE; + return true; } diff --git a/XEngine_Source/XEngine_ModuleConfigure/pch.cpp b/XEngine_Source/XEngine_ModuleConfigure/pch.cpp index 2a4bfa52f983d913c273b1411618b0678a76c588..51fb55fa337daca639479a7e224c0dcb78717901 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/pch.cpp +++ b/XEngine_Source/XEngine_ModuleConfigure/pch.cpp @@ -11,14 +11,14 @@ // Purpose: 导出函数实现 // History: *********************************************************************/ -BOOL Config_IsErrorOccur = FALSE; -DWORD Config_dwErrorCode = 0; +bool Config_IsErrorOccur = false; +XLONG Config_dwErrorCode = 0; ////////////////////////////////////////////////////////////////////// CModuleConfigure_Json m_ConfigJson; ////////////////////////////////////////////////////////////////////// // 导出函数定义 ////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleConfigure_GetLastError(int* pInt_ErrorCode) +extern "C" XLONG ModuleConfigure_GetLastError(int* pInt_ErrorCode) { if (pInt_ErrorCode != NULL) { @@ -29,7 +29,7 @@ extern "C" DWORD ModuleConfigure_GetLastError(int* pInt_ErrorCode) /************************************************************************/ /* 配置文件读取 */ /************************************************************************/ -extern "C" BOOL ModuleConfigure_Json_File(LPCTSTR lpszConfigFile, XENGINE_SERVICECONFIG * pSt_ServerConfig) +extern "C" bool ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XENGINE_SERVICECONFIG * pSt_ServerConfig) { return m_ConfigJson.ModuleConfigure_Json_File(lpszConfigFile, pSt_ServerConfig); } diff --git a/XEngine_Source/XEngine_ModuleConfigure/pch.h b/XEngine_Source/XEngine_ModuleConfigure/pch.h index 2bc4ede385a54c7b3b90efa8140ed7ddb1d83bb6..81e37dd5a2e86690e782d70eb3bde630d8ccdb0e 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/pch.h +++ b/XEngine_Source/XEngine_ModuleConfigure/pch.h @@ -35,8 +35,8 @@ using namespace std; // Purpose: 公用头文件 // History: *********************************************************************/ -extern BOOL Config_IsErrorOccur; -extern DWORD Config_dwErrorCode; +extern bool Config_IsErrorOccur; +extern XLONG Config_dwErrorCode; #ifdef _MSC_BUILD #ifdef _DEBUG diff --git a/XEngine_Source/XEngine_ModuleProtocol/Makefile b/XEngine_Source/XEngine_ModuleProtocol/Makefile index 0aa7d15100f030a76c43a36908d0c55aba609ef2..443324a2cf4862f15e459d0f212cdbf1b06c585c 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/Makefile +++ b/XEngine_Source/XEngine_ModuleProtocol/Makefile @@ -1,30 +1,23 @@ CC = g++ -Wall -std=c++17 -fPIC -SHAREFLAG = -shared -SHAREDLL = so +PLATFORM = linux +PLATVER = +PLATDIR = +FILEEXT = +LIBFLAG = RELEASE = 0 UNICODE = 0 -INCLUDE = -I ./ -I ../XEngine_ThirdPart/jsoncpp -LOADBIN = -L ../XEngine_ThirdPart/jsoncpp +LOADHDR = -I ./ -I ../XEngine_ThirdPart/jsoncpp +LOADSO = -L ../XEngine_ThirdPart/jsoncpp LIB = -ljsoncpp -LIBEX = -ldl -lpthread -LOADSO = -Wl,-rpath=./,--disable-new-dtags -LIBINCLUDE = ModuleProtocol_Packet.o ModuleProtocol_Parse.o pch.o - -ifeq ($(shell uname),Darwin) - SHAREDLL = dylib - SHAREFLAG = -dynamiclib - LOADSO = -else - SHAREDLL = so - SHAREFLAG = -shared -endif +LIBEX = +OBJECTS = ModuleProtocol_Packet.o ModuleProtocol_Parse.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -O2 +FLAGS = -c DEBUG = else -FLAGS = -c -DEBUG = -g +FLAGS = -c -lc_p +DEBUG = -g -pg endif ifeq ($(UNICODE),1) @@ -33,26 +26,48 @@ else UNICODE = endif +ifeq ($(PLATFORM),linux) + ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) + PLATVER = -D __CENTOS__ + PLATDIR = XEngine_Linux/Centos + else + PLATVER = -D __UBUNTU__ + PLATDIR = XEngine_Linux/Ubuntu + endif + FILEEXT = so + LIBFLAG = -shared + LIBEX = -lpthread -lrt -ldl + LOADBIN = -Wl,-rpath=./,--disable-new-dtags +else ifeq ($(PLATFORM),mac) + CC += -Wno-deprecated-declarations + PLATVER = -D __MACOS__ + PLATDIR = XEngine_Mac + FILEEXT = dylib + LIBFLAG = -dynamiclib + LIBEX = -lpthread -ldl + LOADBIN = -Wl,-rpath,@loader_path/./ +endif + -all:$(LIBINCLUDE) - $(CC) $(DEBUG) $(LIBINCLUDE) -o libXEngine_ModuleProtocol.$(SHAREDLL) $(SHAREFLAG) -fPIC $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO) +all:$(OBJECTS) + $(CC) $(DEBUG) $(OBJECTS) -o libXEngine_ModuleProtocol.$(FILEEXT) $(LIBFLAG) $(LIB) $(LIBEX) $(LOADSO) $(LOADBIN) ModuleProtocol_Packet.o:./ModuleProtocol_Packet/ModuleProtocol_Packet.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./ModuleProtocol_Packet/ModuleProtocol_Packet.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleProtocol_Packet/ModuleProtocol_Packet.cpp ModuleProtocol_Parse.o:./ModuleProtocol_Parse/ModuleProtocol_Parse.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./ModuleProtocol_Parse/ModuleProtocol_Parse.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleProtocol_Parse/ModuleProtocol_Parse.cpp pch.o:./pch.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./pch.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./pch.cpp InstallAll:InstallSo -InstallSo:./libXEngine_ModuleProtocol.$(SHAREDLL) - cp ./libXEngine_ModuleProtocol.$(SHAREDLL) ../../XEngine_Release/libXEngine_ModuleProtocol.$(SHAREDLL) +InstallSo:./libXEngine_ModuleProtocol.$(FILEEXT) + cp ./libXEngine_ModuleProtocol.$(FILEEXT) ../../XEngine_Release/libXEngine_ModuleProtocol.$(FILEEXT) CleanAll:CleanObj CleanMk CleanObj: rm *.o CleanMk: - rm *.$(SHAREDLL) + rm *.$(FILEEXT) diff --git a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h index fcab271454d99097aa6d355035a2946b56583184..4726aec400d53b60575804c4688a6f4d3b1bd25c 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h @@ -13,7 +13,7 @@ ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleProtocol_GetLastError(int* pInt_SysError = NULL); +extern "C" XLONG ModuleProtocol_GetLastError(int* pInt_SysError = NULL); /************************************************************************/ /* 封包导出函数 */ /************************************************************************/ @@ -50,7 +50,7 @@ extern "C" DWORD ModuleProtocol_GetLastError(int* pInt_SysError = NULL); 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleProtocol_Packet_ForwardList(TCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, TCHAR*** ppptszListAddr, int nCount); +extern "C" bool ModuleProtocol_Packet_ForwardList(XCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XCHAR*** ppptszListAddr, int nCount); /************************************************************************/ /* 解析导出函数 */ /************************************************************************/ @@ -82,4 +82,4 @@ extern "C" BOOL ModuleProtocol_Packet_ForwardList(TCHAR* ptszMsgBuffer, int* pIn 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleProtocol_Parse_ForwardBind(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR * ptszSrcAddr, TCHAR * ptszDstAddr); \ No newline at end of file +extern "C" bool ModuleProtocol_Parse_ForwardBind(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR * ptszSrcAddr, XCHAR * ptszDstAddr); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp index cc163c62a72532ca5b458ee9aa891102cd02301b..823cca22b9d5dabf712cd115408fb76cfd87e003 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp @@ -55,15 +55,15 @@ CModuleProtocol_Packet::~CModuleProtocol_Packet() 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_ForwardList(TCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, TCHAR*** ppptszListAddr, int nCount) +bool CModuleProtocol_Packet::ModuleProtocol_Packet_ForwardList(XCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XCHAR*** ppptszListAddr, int nCount) { - Protocol_IsErrorOccur = FALSE; + Protocol_IsErrorOccur = false; if ((NULL == ptszMsgBuffer) || (NULL == pInt_Len)) { - Protocol_IsErrorOccur = TRUE; + Protocol_IsErrorOccur = true; Protocol_dwErrorCode = ERROR_MODULE_PROTOCOL_PACKET_PARAMENT; - return FALSE; + return false; } Json::Value st_JsonRoot; Json::Value st_JsonArray; @@ -80,5 +80,5 @@ BOOL CModuleProtocol_Packet::ModuleProtocol_Packet_ForwardList(TCHAR* ptszMsgBuf *pInt_Len = 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; + return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h index 950480b6812f4140be5a6ce81b0d09c97d00b624..8f0d43fbacab434a68bccd4b79c10402bd8526b9 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h @@ -17,6 +17,6 @@ public: CModuleProtocol_Packet(); ~CModuleProtocol_Packet(); public: - BOOL ModuleProtocol_Packet_ForwardList(TCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, TCHAR*** ppptszListAddr, int nCount); + bool ModuleProtocol_Packet_ForwardList(XCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, XCHAR*** ppptszListAddr, int nCount); private: }; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.cpp b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.cpp index 14d4ed444628faf02b8e93cfe7da0bd164485826..980730247cdf4e545382c111b42a4abb83afa179 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.cpp +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.cpp @@ -50,15 +50,15 @@ CModuleProtocol_Parse::~CModuleProtocol_Parse() 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleProtocol_Parse::ModuleProtocol_Parse_ForwardBind(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszSrcAddr, TCHAR* ptszDstAddr) +bool CModuleProtocol_Parse::ModuleProtocol_Parse_ForwardBind(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR* ptszSrcAddr, XCHAR* ptszDstAddr) { - Protocol_IsErrorOccur = FALSE; + Protocol_IsErrorOccur = false; if (NULL == lpszMsgBuffer) { - Protocol_IsErrorOccur = TRUE; + Protocol_IsErrorOccur = true; Protocol_dwErrorCode = ERROR_MODULE_PROTOCOL_PARSE_PARAMENT; - return FALSE; + return false; } Json::Value st_JsonRoot; JSONCPP_STRING st_JsonError; @@ -67,12 +67,12 @@ BOOL CModuleProtocol_Parse::ModuleProtocol_Parse_ForwardBind(LPCTSTR lpszMsgBuff std::unique_ptr const pSt_JsonReader(st_JsonBuilder.newCharReader()); if (!pSt_JsonReader->parse(lpszMsgBuffer, lpszMsgBuffer + nMsgLen, &st_JsonRoot, &st_JsonError)) { - Protocol_IsErrorOccur = TRUE; + Protocol_IsErrorOccur = true; Protocol_dwErrorCode = ERROR_MODULE_PROTOCOL_PARSE_JSON; - return FALSE; + return false; } - //_tcscpy(ptszSrcAddr, st_JsonRoot["tszSrcAddr"].asCString()); 暂时不支持 - _tcscpy(ptszDstAddr, st_JsonRoot["tszDstAddr"].asCString()); + //_tcsxcpy(ptszSrcAddr, st_JsonRoot["tszSrcAddr"].asCString()); 暂时不支持 + _tcsxcpy(ptszDstAddr, st_JsonRoot["tszDstAddr"].asCString()); - return TRUE; + return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.h b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.h index dd3b62255451b6df5f32063125f70c821d53ec9c..f00e686c7097bb878fbd87877b2b3b5e392fef8e 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.h +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Parse/ModuleProtocol_Parse.h @@ -17,6 +17,6 @@ public: CModuleProtocol_Parse(); ~CModuleProtocol_Parse(); public: - BOOL ModuleProtocol_Parse_ForwardBind(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR* ptszSrcAddr, TCHAR* ptszDstAddr); + bool ModuleProtocol_Parse_ForwardBind(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR* ptszSrcAddr, XCHAR* ptszDstAddr); private: }; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/dllmain.cpp b/XEngine_Source/XEngine_ModuleProtocol/dllmain.cpp index daed8c8f7ac50ca1466016a0529648d18125a7e7..594ff2123d474b129bb2014fb572f03c9741bf0b 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/dllmain.cpp +++ b/XEngine_Source/XEngine_ModuleProtocol/dllmain.cpp @@ -1,9 +1,9 @@ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved +bool APIENTRY DllMain( HMODULE hModule, + XLONG ul_reason_for_call, + XPVOID lpReserved ) { switch (ul_reason_for_call) @@ -14,6 +14,6 @@ BOOL APIENTRY DllMain( HMODULE hModule, case DLL_PROCESS_DETACH: break; } - return TRUE; + return true; } diff --git a/XEngine_Source/XEngine_ModuleProtocol/pch.cpp b/XEngine_Source/XEngine_ModuleProtocol/pch.cpp index 0991c41981a4b94529a5d70f742252a8c9e70b1d..3b7e0e73fe6a49438d15ad0e16d4b3eebe9b9a5f 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/pch.cpp +++ b/XEngine_Source/XEngine_ModuleProtocol/pch.cpp @@ -12,15 +12,15 @@ // Purpose: 导出实现 // History: *********************************************************************/ -BOOL Protocol_IsErrorOccur = FALSE; -DWORD Protocol_dwErrorCode = 0; +bool Protocol_IsErrorOccur = false; +XLONG Protocol_dwErrorCode = 0; ////////////////////////////////////////////////////////////////////////// CModuleProtocol_Packet m_ProtocolPacket; CModuleProtocol_Parse m_ProtocolParse; ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleProtocol_GetLastError(int* pInt_SysError) +extern "C" XLONG ModuleProtocol_GetLastError(int* pInt_SysError) { if (NULL != pInt_SysError) { @@ -31,14 +31,14 @@ extern "C" DWORD ModuleProtocol_GetLastError(int* pInt_SysError) /************************************************************************/ /* 封包导出函数 */ /************************************************************************/ -extern "C" BOOL ModuleProtocol_Packet_ForwardList(TCHAR * ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, TCHAR * **ppptszListAddr, int nCount) +extern "C" bool ModuleProtocol_Packet_ForwardList(XCHAR * ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR * pSt_ProtocolHdr, XCHAR * **ppptszListAddr, int nCount) { return m_ProtocolPacket.ModuleProtocol_Packet_ForwardList(ptszMsgBuffer, pInt_Len, pSt_ProtocolHdr, ppptszListAddr, nCount); } /************************************************************************/ /* 解析导出函数 */ /************************************************************************/ -extern "C" BOOL ModuleProtocol_Parse_ForwardBind(LPCTSTR lpszMsgBuffer, int nMsgLen, TCHAR * ptszSrcAddr, TCHAR * ptszDstAddr) +extern "C" bool ModuleProtocol_Parse_ForwardBind(LPCXSTR lpszMsgBuffer, int nMsgLen, XCHAR * ptszSrcAddr, XCHAR * ptszDstAddr) { return m_ProtocolParse.ModuleProtocol_Parse_ForwardBind(lpszMsgBuffer, nMsgLen, ptszSrcAddr, ptszDstAddr); } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/pch.h b/XEngine_Source/XEngine_ModuleProtocol/pch.h index bd50bec8d19d4015088e4aaf22d19fd4114880e4..38e32f9ed4ae9b34c893c76d1c851c75796d6b69 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/pch.h +++ b/XEngine_Source/XEngine_ModuleProtocol/pch.h @@ -35,8 +35,8 @@ using namespace std; // Purpose: 公用头文件 // History: *********************************************************************/ -extern BOOL Protocol_IsErrorOccur; -extern DWORD Protocol_dwErrorCode; +extern bool Protocol_IsErrorOccur; +extern XLONG Protocol_dwErrorCode; #ifdef _MSC_BUILD #ifdef _DEBUG diff --git a/XEngine_Source/XEngine_ModuleSession/Makefile b/XEngine_Source/XEngine_ModuleSession/Makefile index 04d11cf5a65fc300de9d12e785127a061bb9fec1..a7fbed3ef3dc5b3b56104780fb2ab9b2814c4a5d 100644 --- a/XEngine_Source/XEngine_ModuleSession/Makefile +++ b/XEngine_Source/XEngine_ModuleSession/Makefile @@ -1,30 +1,23 @@ CC = g++ -Wall -std=c++17 -fPIC -SHAREFLAG = -shared -SHAREDLL = so +PLATFORM = linux +PLATVER = +PLATDIR = +FILEEXT = +LIBFLAG = RELEASE = 0 UNICODE = 0 -INCLUDE = -I ./ -LOADBIN = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib +LOADHDR = -I ./ -I ../XEngine_ThirdPart/jsoncpp +LOADSO = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib LIB = -lXEngine_BaseLib -LIBEX = -ldl -lpthread -LOADSO = -Wl,-rpath=./,--disable-new-dtags -LIBINCLUDE = ModuleSession_Forward.o pch.o - -ifeq ($(shell uname),Darwin) - SHAREDLL = dylib - SHAREFLAG = -dynamiclib - LOADSO = -else - SHAREDLL = so - SHAREFLAG = -shared -endif +LIBEX = +OBJECTS = ModuleSession_Forward.o pch.o ifeq ($(RELEASE),1) -FLAGS = -c -O2 +FLAGS = -c DEBUG = else -FLAGS = -c -DEBUG = -g +FLAGS = -c -lc_p +DEBUG = -g -pg endif ifeq ($(UNICODE),1) @@ -33,24 +26,46 @@ else UNICODE = endif +ifeq ($(PLATFORM),linux) + ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) + PLATVER = -D __CENTOS__ + PLATDIR = XEngine_Linux/Centos + else + PLATVER = -D __UBUNTU__ + PLATDIR = XEngine_Linux/Ubuntu + endif + FILEEXT = so + LIBFLAG = -shared + LIBEX = -lpthread -lrt -ldl + LOADBIN = -Wl,-rpath=./,--disable-new-dtags +else ifeq ($(PLATFORM),mac) + CC += -Wno-deprecated-declarations + PLATVER = -D __MACOS__ + PLATDIR = XEngine_Mac + FILEEXT = dylib + LIBFLAG = -dynamiclib + LIBEX = -lpthread -ldl + LOADBIN = -Wl,-rpath,@loader_path/./ +endif + -all:$(LIBINCLUDE) - $(CC) $(DEBUG) $(LIBINCLUDE) -o libXEngine_ModuleSession.$(SHAREDLL) $(SHAREFLAG) -fPIC $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO) +all:$(OBJECTS) + $(CC) $(DEBUG) $(OBJECTS) -o libXEngine_ModuleSession.$(FILEEXT) $(LIBFLAG) $(LIB) $(LIBEX) $(LOADSO) $(LOADBIN) ModuleSession_Forward.o:./ModuleSession_Forward/ModuleSession_Forward.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./ModuleSession_Forward/ModuleSession_Forward.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./ModuleSession_Forward/ModuleSession_Forward.cpp pch.o:./pch.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) ./pch.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./pch.cpp InstallAll:InstallSo -InstallSo:./libXEngine_ModuleSession.$(SHAREDLL) - cp ./libXEngine_ModuleSession.$(SHAREDLL) ../../XEngine_Release/libXEngine_ModuleSession.$(SHAREDLL) +InstallSo:./libXEngine_ModuleSession.$(FILEEXT) + cp ./libXEngine_ModuleSession.$(FILEEXT) ../../XEngine_Release/libXEngine_ModuleSession.$(FILEEXT) CleanAll:CleanObj CleanMk CleanObj: rm *.o CleanMk: - rm *.$(SHAREDLL) + rm *.$(FILEEXT) diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h index bfc5c179430c585651b69a15beb53f66853df1b4..6180c962d9dc2f48eff1455c19d39dc29c09dec0 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h @@ -13,7 +13,7 @@ ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleSession_GetLastError(int* pInt_SysError = NULL); +extern "C" XLONG ModuleSession_GetLastError(int* pInt_SysError = NULL); /************************************************************************/ /* 转发导出函数 */ /************************************************************************/ @@ -30,7 +30,7 @@ extern "C" DWORD ModuleSession_GetLastError(int* pInt_SysError = NULL); 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleSession_Forward_Insert(LPCTSTR lpszAddr); +extern "C" bool ModuleSession_Forward_Insert(LPCXSTR lpszAddr); /******************************************************************** 函数名称:ModuleSession_Forward_List 函数功能:获取列表 @@ -54,7 +54,7 @@ extern "C" BOOL ModuleSession_Forward_Insert(LPCTSTR lpszAddr); 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleSession_Forward_List(TCHAR*** ppptszListAddr, int* pInt_Count, LPCTSTR lpszAddr = NULL); +extern "C" bool ModuleSession_Forward_List(XCHAR*** ppptszListAddr, int* pInt_Count, LPCXSTR lpszAddr = NULL); /******************************************************************** 函数名称:ModuleSession_Forward_Bind 函数功能:绑定转发需求 @@ -73,7 +73,7 @@ extern "C" BOOL ModuleSession_Forward_List(TCHAR*** ppptszListAddr, int* pInt_Co 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleSession_Forward_Bind(LPCTSTR lpszSrcAddr, LPCTSTR lpszDstAddr); +extern "C" bool ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr); /******************************************************************** 函数名称:ModuleSession_Forward_Delete 函数功能:删除用户 @@ -92,7 +92,7 @@ extern "C" BOOL ModuleSession_Forward_Bind(LPCTSTR lpszSrcAddr, LPCTSTR lpszDstA 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleSession_Forward_Delete(LPCTSTR lpszAddr, TCHAR * ptszDstAddr); +extern "C" bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR * ptszDstAddr); /******************************************************************** 函数名称:ModuleSession_Forward_Get 函数功能:获取转发用户给 @@ -111,4 +111,4 @@ extern "C" BOOL ModuleSession_Forward_Delete(LPCTSTR lpszAddr, TCHAR * ptszDstAd 意思:是否成功 备注: *********************************************************************/ -extern "C" BOOL ModuleSession_Forward_Get(LPCTSTR lpszAddr, TCHAR* ptszDstAddr); \ No newline at end of file +extern "C" bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.cpp b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.cpp index 9c357932eee040a529665b2fb59ad959514148e1..2f7d507766ce33e202bf5763249f3adf756bd795 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.cpp +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.cpp @@ -35,33 +35,33 @@ CModuleSession_Forward::~CModuleSession_Forward() 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleSession_Forward::ModuleSession_Forward_Insert(LPCTSTR lpszAddr) +bool CModuleSession_Forward::ModuleSession_Forward_Insert(LPCXSTR lpszAddr) { - Session_IsErrorOccur = FALSE; + Session_IsErrorOccur = false; if (NULL == lpszAddr) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_PARAMENT; - return FALSE; + return false; } SESSION_FORWARD st_Forward; memset(&st_Forward, '\0', sizeof(SESSION_FORWARD)); - _tcscpy(st_Forward.tszSrcAddr, lpszAddr); + _tcsxcpy(st_Forward.tszSrcAddr, lpszAddr); st_Locker.lock(); unordered_map::const_iterator stl_MapIterator = stl_MapSession.find(lpszAddr); if (stl_MapIterator != stl_MapSession.end()) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_EXIST; st_Locker.unlock(); - return FALSE; + return false; } stl_MapSession.insert(make_pair(lpszAddr, st_Forward)); st_Locker.unlock(); - return TRUE; + return true; } /******************************************************************** 函数名称:ModuleSession_Forward_List @@ -86,15 +86,15 @@ BOOL CModuleSession_Forward::ModuleSession_Forward_Insert(LPCTSTR lpszAddr) 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleSession_Forward::ModuleSession_Forward_List(TCHAR*** ppptszListAddr, int* pInt_Count, LPCTSTR lpszAddr) +bool CModuleSession_Forward::ModuleSession_Forward_List(XCHAR*** ppptszListAddr, int* pInt_Count, LPCXSTR lpszAddr) { - Session_IsErrorOccur = FALSE; + Session_IsErrorOccur = false; if (NULL == pInt_Count) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_PARAMENT; - return FALSE; + return false; } st_Locker.lock_shared(); @@ -113,15 +113,15 @@ BOOL CModuleSession_Forward::ModuleSession_Forward_List(TCHAR*** ppptszListAddr, { if (NULL != lpszAddr) { - if (0 == _tcsncmp(lpszAddr, stl_MapIterator->first.c_str(), _tcslen(lpszAddr))) + if (0 == _tcsxncmp(lpszAddr, stl_MapIterator->first.c_str(), _tcsxlen(lpszAddr))) { continue; } } - _tcscpy((*ppptszListAddr)[i], stl_MapIterator->first.c_str()); + _tcsxcpy((*ppptszListAddr)[i], stl_MapIterator->first.c_str()); } st_Locker.unlock_shared(); - return TRUE; + return true; } /******************************************************************** 函数名称:ModuleSession_Forward_Bind @@ -141,15 +141,15 @@ BOOL CModuleSession_Forward::ModuleSession_Forward_List(TCHAR*** ppptszListAddr, 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleSession_Forward::ModuleSession_Forward_Bind(LPCTSTR lpszSrcAddr, LPCTSTR lpszDstAddr) +bool CModuleSession_Forward::ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr) { - Session_IsErrorOccur = FALSE; + Session_IsErrorOccur = false; if ((NULL == lpszSrcAddr) || (NULL == lpszDstAddr)) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_PARAMENT; - return FALSE; + return false; } st_Locker.lock_shared(); //查找 @@ -157,27 +157,27 @@ BOOL CModuleSession_Forward::ModuleSession_Forward_Bind(LPCTSTR lpszSrcAddr, LPC auto stl_MapDstIterator = stl_MapSession.find(lpszDstAddr); if (stl_MapSrcIterator == stl_MapSession.end() || stl_MapDstIterator == stl_MapSession.end()) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_NOTFOUND; st_Locker.unlock_shared(); - return FALSE; + return false; } //如果设置过,不允许在设置 if (stl_MapSrcIterator->second.bForward || stl_MapDstIterator->second.bForward) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_BIND; st_Locker.unlock_shared(); - return FALSE; + return false; } //需要设置两方的转发内容 - stl_MapSrcIterator->second.bForward = TRUE; - _tcscpy(stl_MapSrcIterator->second.tszDstAddr, lpszDstAddr); + stl_MapSrcIterator->second.bForward = true; + _tcsxcpy(stl_MapSrcIterator->second.tszDstAddr, lpszDstAddr); - stl_MapDstIterator->second.bForward = TRUE; - _tcscpy(stl_MapDstIterator->second.tszDstAddr, lpszSrcAddr); + stl_MapDstIterator->second.bForward = true; + _tcsxcpy(stl_MapDstIterator->second.tszDstAddr, lpszSrcAddr); st_Locker.unlock_shared(); - return TRUE; + return true; } /******************************************************************** 函数名称:ModuleSession_Forward_Delete @@ -197,40 +197,40 @@ BOOL CModuleSession_Forward::ModuleSession_Forward_Bind(LPCTSTR lpszSrcAddr, LPC 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleSession_Forward::ModuleSession_Forward_Delete(LPCTSTR lpszAddr, TCHAR* ptszDstAddr) +bool CModuleSession_Forward::ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR* ptszDstAddr) { - Session_IsErrorOccur = FALSE; + Session_IsErrorOccur = false; if (NULL == lpszAddr) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_PARAMENT; - return FALSE; + return false; } st_Locker.lock(); //查找 auto stl_MapSrcIterator = stl_MapSession.find(lpszAddr); if (stl_MapSrcIterator == stl_MapSession.end()) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_NOTFOUND; st_Locker.unlock(); - return FALSE; + return false; } //如果有转发,需要清理对方的转发设置 if (stl_MapSrcIterator->second.bForward) { - _tcscpy(ptszDstAddr, stl_MapSrcIterator->second.tszDstAddr); + _tcsxcpy(ptszDstAddr, stl_MapSrcIterator->second.tszDstAddr); auto stl_MapDstIterator = stl_MapSession.find(stl_MapSrcIterator->second.tszSrcAddr); if (stl_MapDstIterator == stl_MapSession.end()) { - stl_MapDstIterator->second.bForward = FALSE; + stl_MapDstIterator->second.bForward = false; memset(stl_MapDstIterator->second.tszDstAddr, '\0', sizeof(stl_MapDstIterator->second.tszDstAddr)); } } stl_MapSession.erase(stl_MapSrcIterator); st_Locker.unlock(); - return TRUE; + return true; } /******************************************************************** 函数名称:ModuleSession_Forward_Get @@ -250,35 +250,35 @@ BOOL CModuleSession_Forward::ModuleSession_Forward_Delete(LPCTSTR lpszAddr, TCHA 意思:是否成功 备注: *********************************************************************/ -BOOL CModuleSession_Forward::ModuleSession_Forward_Get(LPCTSTR lpszAddr, TCHAR* ptszDstAddr) +bool CModuleSession_Forward::ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr) { - Session_IsErrorOccur = FALSE; + Session_IsErrorOccur = false; if ((NULL == lpszAddr) || (NULL == ptszDstAddr)) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_PARAMENT; - return FALSE; + return false; } st_Locker.lock_shared(); //查找 auto stl_MapIterator = stl_MapSession.find(lpszAddr); if (stl_MapIterator == stl_MapSession.end()) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_NOTFOUND; st_Locker.unlock_shared(); - return FALSE; + return false; } //如果有转发,需要清理对方的转发设置 if (!stl_MapIterator->second.bForward) { - Session_IsErrorOccur = TRUE; + Session_IsErrorOccur = true; Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_NOTFORWARD; st_Locker.unlock_shared(); - return FALSE; + return false; } - _tcscpy(ptszDstAddr, stl_MapIterator->second.tszDstAddr); + _tcsxcpy(ptszDstAddr, stl_MapIterator->second.tszDstAddr); st_Locker.unlock_shared(); - return TRUE; + return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h index 5654b16e711119d418eb092e680df88eb0cc63ad..f1939334c44e05f7282490f2213880703c37ee8f 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h @@ -12,9 +12,9 @@ *********************************************************************/ typedef struct { - TCHAR tszSrcAddr[128]; - TCHAR tszDstAddr[128]; - BOOL bForward; + XCHAR tszSrcAddr[128]; + XCHAR tszDstAddr[128]; + bool bForward; }SESSION_FORWARD, * LPSESSION_FORWARD; class CModuleSession_Forward @@ -23,11 +23,11 @@ public: CModuleSession_Forward(); ~CModuleSession_Forward(); public: - BOOL ModuleSession_Forward_Insert(LPCTSTR lpszAddr); - BOOL ModuleSession_Forward_List(TCHAR*** ppptszListAddr, int* pInt_Count, LPCTSTR lpszAddr = NULL); - BOOL ModuleSession_Forward_Bind(LPCTSTR lpszSrcAddr, LPCTSTR lpszDstAddr); - BOOL ModuleSession_Forward_Delete(LPCTSTR lpszAddr, TCHAR* ptszDstAddr); - BOOL ModuleSession_Forward_Get(LPCTSTR lpszAddr, TCHAR* ptszDstAddr); + bool ModuleSession_Forward_Insert(LPCXSTR lpszAddr); + bool ModuleSession_Forward_List(XCHAR*** ppptszListAddr, int* pInt_Count, LPCXSTR lpszAddr = NULL); + bool ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr); + bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR* ptszDstAddr); + bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr); private: shared_mutex st_Locker; private: diff --git a/XEngine_Source/XEngine_ModuleSession/dllmain.cpp b/XEngine_Source/XEngine_ModuleSession/dllmain.cpp index daed8c8f7ac50ca1466016a0529648d18125a7e7..594ff2123d474b129bb2014fb572f03c9741bf0b 100644 --- a/XEngine_Source/XEngine_ModuleSession/dllmain.cpp +++ b/XEngine_Source/XEngine_ModuleSession/dllmain.cpp @@ -1,9 +1,9 @@ // dllmain.cpp : 定义 DLL 应用程序的入口点。 #include "pch.h" -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved +bool APIENTRY DllMain( HMODULE hModule, + XLONG ul_reason_for_call, + XPVOID lpReserved ) { switch (ul_reason_for_call) @@ -14,6 +14,6 @@ BOOL APIENTRY DllMain( HMODULE hModule, case DLL_PROCESS_DETACH: break; } - return TRUE; + return true; } diff --git a/XEngine_Source/XEngine_ModuleSession/pch.cpp b/XEngine_Source/XEngine_ModuleSession/pch.cpp index 8be30dcabca6f9f67e3ed1a5c1c3ab5f3fdb9ee2..e6741b2c306ed3583116dbe502dd78fc5a667720 100644 --- a/XEngine_Source/XEngine_ModuleSession/pch.cpp +++ b/XEngine_Source/XEngine_ModuleSession/pch.cpp @@ -11,14 +11,14 @@ // Purpose: 导出实现 // History: *********************************************************************/ -BOOL Session_IsErrorOccur = FALSE; -DWORD Session_dwErrorCode = 0; +bool Session_IsErrorOccur = false; +XLONG Session_dwErrorCode = 0; ////////////////////////////////////////////////////////////////////////// CModuleSession_Forward m_Forward; ////////////////////////////////////////////////////////////////////////// // 导出函数 ////////////////////////////////////////////////////////////////////////// -extern "C" DWORD ModuleSession_GetLastError(int* pInt_SysError) +extern "C" XLONG ModuleSession_GetLastError(int* pInt_SysError) { if (NULL != pInt_SysError) { @@ -29,23 +29,23 @@ extern "C" DWORD ModuleSession_GetLastError(int* pInt_SysError) /************************************************************************/ /* 转发导出函数 */ /************************************************************************/ -extern "C" BOOL ModuleSession_Forward_Insert(LPCTSTR lpszAddr) +extern "C" bool ModuleSession_Forward_Insert(LPCXSTR lpszAddr) { return m_Forward.ModuleSession_Forward_Insert(lpszAddr); } -extern "C" BOOL ModuleSession_Forward_List(TCHAR * **ppptszListAddr, int* pInt_Count, LPCTSTR lpszAddr) +extern "C" bool ModuleSession_Forward_List(XCHAR * **ppptszListAddr, int* pInt_Count, LPCXSTR lpszAddr) { return m_Forward.ModuleSession_Forward_List(ppptszListAddr, pInt_Count, lpszAddr); } -extern "C" BOOL ModuleSession_Forward_Bind(LPCTSTR lpszSrcAddr, LPCTSTR lpszDstAddr) +extern "C" bool ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr) { return m_Forward.ModuleSession_Forward_Bind(lpszSrcAddr, lpszDstAddr); } -extern "C" BOOL ModuleSession_Forward_Delete(LPCTSTR lpszAddr, TCHAR * ptszDstAddr) +extern "C" bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR * ptszDstAddr) { return m_Forward.ModuleSession_Forward_Delete(lpszAddr, ptszDstAddr); } -extern "C" BOOL ModuleSession_Forward_Get(LPCTSTR lpszAddr, TCHAR * ptszDstAddr) +extern "C" bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR * ptszDstAddr) { return m_Forward.ModuleSession_Forward_Get(lpszAddr, ptszDstAddr); } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/pch.h b/XEngine_Source/XEngine_ModuleSession/pch.h index 9b9ffc8e59a7f7f45d2e353749cda493ef041456..bf917ba04155bdbd114e80b6415918ca059ba130 100644 --- a/XEngine_Source/XEngine_ModuleSession/pch.h +++ b/XEngine_Source/XEngine_ModuleSession/pch.h @@ -35,8 +35,8 @@ using namespace std; // Purpose: 公用头文件 // History: *********************************************************************/ -extern BOOL Session_IsErrorOccur; -extern DWORD Session_dwErrorCode; +extern bool Session_IsErrorOccur; +extern XLONG Session_dwErrorCode; #ifdef _UNICODE typedef std::wstring tstring; diff --git a/XEngine_Source/XEngine_ServiceApp/Makefile b/XEngine_Source/XEngine_ServiceApp/Makefile index 29052d222ddfff8324034aa9428e9643d81ced1e..49490ecb1c930bf667a6ec11015d7af801807572 100644 --- a/XEngine_Source/XEngine_ServiceApp/Makefile +++ b/XEngine_Source/XEngine_ServiceApp/Makefile @@ -1,26 +1,25 @@ CC = g++ -Wall -std=c++17 +PLATFORM = linux +PLATVER = +PLATDIR = RELEASE = 0 -UNICODE = 0 -LOADBIN = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_HelpComponents -L /usr/local/lib/XEngine_Release/XEngine_RfcComponents -L /usr/local/lib/XEngine_Release/XEngine_Client -L /usr/local/lib/XEngine_Release/XEngine_NetHelp \ - -L ../XEngine_ThirdPart/jsoncpp \ - -L ../XEngine_ModuleConfigure -L ../XEngine_ModuleAuthorize -L ../XEngine_ModuleSession -L ../XEngine_ModuleProtocol +UNICODE = 0 +LOADHDR = -I ./ -I ../XEngine_ThirdPart/jsoncpp +LOADSO = -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_HelpComponents -L /usr/local/lib/XEngine_Release/XEngine_RfcComponents -L /usr/local/lib/XEngine_Release/XEngine_Client -L /usr/local/lib/XEngine_Release/XEngine_NetHelp \ + -L ../XEngine_ModuleConfigure -L ../XEngine_ModuleAuthorize -L ../XEngine_ModuleSession -L ../XEngine_ModuleProtocol \ + -L ../XEngine_ThirdPart/jsoncpp LIB = -lXEngine_BaseLib -lXEngine_Algorithm -lXEngine_Core -lXEngine_OPenSsl -lXEngine_ManagePool -lXEngine_NetXApi -lHelpComponents_XLog -lHelpComponents_Packets -lRfcComponents_ProxyProtocol -lXClient_Socket -lNetHelp_APIHelp \ - -ljsoncpp \ - -lXEngine_ModuleConfigure -lXEngine_ModuleAuthorize -lXEngine_ModuleSession -lXEngine_ModuleProtocol -LIBEX = -ldl -lpthread -LOADSO = -Wl,-rpath=./,--disable-new-dtags -LIBINCLUDE = XEngine_Configure.o XEngine_Network.o XEngine_SocksTask.o XEngine_TunnelTask.o XEngine_ForwardTask.o XEngine_ServiceApp.o - -ifeq ($(shell uname),Darwin) - LOADSO = -endif + -lXEngine_ModuleConfigure -lXEngine_ModuleAuthorize -lXEngine_ModuleSession -lXEngine_ModuleProtocol \ + -ljsoncpp +LIBEX = +OBJECTS = XEngine_Configure.o XEngine_Network.o XEngine_SocksTask.o XEngine_TunnelTask.o XEngine_ForwardTask.o XEngine_ServiceApp.o ifeq ($(RELEASE),1) -FLAGS = -c -O2 +FLAGS = -c DEBUG = else -FLAGS = -c -DEBUG = -g +FLAGS = -c -lc_p +DEBUG = -g -pg endif ifeq ($(UNICODE),1) @@ -29,22 +28,40 @@ else UNICODE = endif -all:$(LIBINCLUDE) - $(CC) $(DEBUG) $(LIBINCLUDE) -o XEngine_ProxyServiceApp $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO) +ifeq ($(PLATFORM),linux) + ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) + PLATVER = -D __CENTOS__ + PLATDIR = XEngine_Linux/Centos + else + PLATVER = -D __UBUNTU__ + PLATDIR = XEngine_Linux/Ubuntu + endif + LIBEX = -lpthread -lrt -ldl + LOADBIN = -Wl,-rpath=./,--disable-new-dtags +else ifeq ($(PLATFORM),mac) + CC += -Wno-deprecated-declarations + PLATVER = -D __MACOS__ + PLATDIR = XEngine_Mac + LIBEX = -lpthread -ldl + LOADBIN = -Wl,-rpath,@loader_path/./ +endif + +all:$(OBJECTS) + $(CC) $(DEBUG) $(OBJECTS) -o XEngine_ProxyServiceApp $(LIB) $(LIBEX) $(LOADSO) $(LOADBIN) XEngine_Configure.o:./XEngine_Configure.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./XEngine_Configure.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./XEngine_Configure.cpp XEngine_Network.o:./XEngine_Network.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./XEngine_Network.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./XEngine_Network.cpp XEngine_SocksTask.o:./XEngine_SocksTask.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./XEngine_SocksTask.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./XEngine_SocksTask.cpp XEngine_TunnelTask.o:./XEngine_TunnelTask.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./XEngine_TunnelTask.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./XEngine_TunnelTask.cpp XEngine_ForwardTask.o:./XEngine_ForwardTask.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./XEngine_ForwardTask.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./XEngine_ForwardTask.cpp XEngine_ServiceApp.o:./XEngine_ServiceApp.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./XEngine_ServiceApp.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) ./XEngine_ServiceApp.cpp InstallAll:InstallApp diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp index 2b3a81c22e563ee3e03b25737e07c439b9ee8067..d230c5a54f001b51ab2b08f22736963e0d8db745 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp @@ -10,52 +10,53 @@ // Purpose: 配置文件读写代码 // History: *********************************************************************/ -BOOL XEngine_Configure_Parament(int argc, char** argv, XENGINE_SERVICECONFIG* pSt_Configure) +bool XEngine_Configure_Parament(int argc, char** argv, XENGINE_SERVICECONFIG* pSt_Configure) { - LPCTSTR lpszConfigFile = _T("./XEngine_Config/XEngine_Config.json"); + LPCXSTR lpszConfigFile = _X("./XEngine_Config/XEngine_Config.json"); if (!ModuleConfigure_Json_File(lpszConfigFile, pSt_Configure)) { printf("解析配置文件失败,ModuleConfigure_Json_File:%lX\n", ModuleConfigure_GetLastError()); - return FALSE; + return false; } for (int i = 0; i < argc; i++) { - if ((0 == _tcscmp("-h", argv[i])) || (0 == _tcscmp("-H", argv[i]))) + if ((0 == _tcsxcmp("-h", argv[i])) || (0 == _tcsxcmp("-H", argv[i]))) { XEngine_Configure_Help(); - return FALSE; + return false; } - else if (0 == _tcscmp("-TP", argv[i])) + else if (0 == _tcsxcmp("-TP", argv[i])) { - pSt_Configure->nSocksPort = _ttoi(argv[i + 1]); + pSt_Configure->nSocksPort = _ttxoi(argv[i + 1]); } - else if (0 == _tcscmp("-HP", argv[i])) + else if (0 == _tcsxcmp("-HP", argv[i])) { - pSt_Configure->nTunnelPort = _ttoi(argv[i + 1]); + pSt_Configure->nTunnelPort = _ttxoi(argv[i + 1]); } - else if (0 == _tcscmp("-d", argv[i])) + else if (0 == _tcsxcmp("-d", argv[i])) { - pSt_Configure->bDeamon = _ttoi(argv[i + 1]); + pSt_Configure->bDeamon = _ttxoi(argv[i + 1]); } - else if (0 == _tcscmp("-v", argv[i])) + else if (0 == _tcsxcmp("-v", argv[i])) { - printf("XEngine版本:%s,服务版本;%s", XENGINE_VERSION_STR, st_ServiceConfig.st_XVer.pStl_ListVer->front().c_str()); - return FALSE; + string m_StrVersion = st_ServiceConfig.st_XVer.pStl_ListVer->front(); + printf("Version:%s\n", m_StrVersion.c_str()); + return false; } } - return TRUE; + return true; } void XEngine_Configure_Help() { - printf(_T("--------------------------启动参数帮助开始--------------------------\n")); - printf(_T("网络消息队列服务启动参数:程序 参数 参数值,参数是区分大小写的。如果不指定将会加载默认的ini配置文件里面的参数\n")); - printf(_T("-h or -H:启动参数帮助提示信息\n")); - printf(_T("-TP:设置消息队列TCP服务端口号\n")); - printf(_T("-HP:设置消息队列HTTP服务端口号\n")); - printf(_T("-d:1 启用守护进程,2不启用\n")); - printf(_T("--------------------------启动参数帮助结束--------------------------\n")); + printf(_X("--------------------------启动参数帮助开始--------------------------\n")); + printf(_X("网络消息队列服务启动参数:程序 参数 参数值,参数是区分大小写的。如果不指定将会加载默认的ini配置文件里面的参数\n")); + printf(_X("-h or -H:启动参数帮助提示信息\n")); + printf(_X("-TP:设置消息队列TCP服务端口号\n")); + printf(_X("-HP:设置消息队列HTTP服务端口号\n")); + printf(_X("-d:1 启用守护进程,2不启用\n")); + printf(_X("--------------------------启动参数帮助结束--------------------------\n")); } diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.h b/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.h index bcf8203f8aba534bf2ca180ec9ea54d151044c44..643682ee0dbc8b83dd695d827cfd294377604650 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.h @@ -10,5 +10,5 @@ // Purpose: 配置文件操作代码 // History: *********************************************************************/ -BOOL XEngine_Configure_Parament(int argc, char** argv, XENGINE_SERVICECONFIG* pSt_Configure); +bool XEngine_Configure_Parament(int argc, char** argv, XENGINE_SERVICECONFIG* pSt_Configure); void XEngine_Configure_Help(); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp index 25eee39f80c7b80a1dc6d876799e19c4fa179f99..debf044a5c1b540c0bcf21c3d564c2a47bc68f30 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp @@ -10,7 +10,7 @@ // Purpose: 代理转发协议 // History: *********************************************************************/ -XHTHREAD CALLBACK XEngine_Forward_Thread(LPVOID lParam) +XHTHREAD CALLBACK XEngine_Forward_Thread(XPVOID lParam) { int nPoolIndex = *(int*)lParam; int nThreadPos = nPoolIndex + 1; @@ -27,7 +27,7 @@ XHTHREAD CALLBACK XEngine_Forward_Thread(LPVOID lParam) for (int i = 0; i < nListCount; i++) { int nMsgLen = 0; - CHAR* ptszMsgBuffer = NULL; + XCHAR* ptszMsgBuffer = NULL; XENGINE_PROTOCOLHDR st_ProtocolHdr; memset(&st_ProtocolHdr, '\0', sizeof(XENGINE_PROTOCOLHDR)); @@ -42,16 +42,16 @@ XHTHREAD CALLBACK XEngine_Forward_Thread(LPVOID lParam) return 0; } -BOOL XEngine_Forward_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr) +bool XEngine_Forward_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr) { int nSDLen = 10240; - TCHAR tszSDBuffer[10240]; + XCHAR tszSDBuffer[10240]; memset(tszSDBuffer, '\0', sizeof(tszSDBuffer)); //判断协议头和尾部 if ((XENGIEN_COMMUNICATION_PACKET_PROTOCOL_HEADER != pSt_ProtocolHdr->wHeader) || (XENGIEN_COMMUNICATION_PACKET_PROTOCOL_TAIL != pSt_ProtocolHdr->wTail)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Forward客户端:%s,协议错误"), lpszClientAddr); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Forward客户端:%s,协议错误"), lpszClientAddr); + return false; } //处理验证协议 if (ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_AUTH == pSt_ProtocolHdr->unOperatorType) @@ -60,8 +60,8 @@ BOOL XEngine_Forward_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int n { pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREP; ModuleSession_Forward_Insert(lpszClientAddr); - XEngine_Network_Send(lpszClientAddr, (LPCTSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Forward客户端:%s,登录到服务器"), lpszClientAddr); + XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,登录到服务器"), lpszClientAddr); } } //处理转发协议 @@ -70,26 +70,26 @@ BOOL XEngine_Forward_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int n if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREQ == pSt_ProtocolHdr->unOperatorCode) { int nListCount = 0; - TCHAR** pptszListAddr; + XCHAR** pptszListAddr; pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREP; if (ModuleSession_Forward_List(&pptszListAddr, &nListCount, lpszClientAddr)) { ModuleProtocol_Packet_ForwardList(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, &pptszListAddr, nListCount); XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Forward客户端:%s,请求可用转发列表成功"), lpszClientAddr); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,请求可用转发列表成功"), lpszClientAddr); } else { pSt_ProtocolHdr->unPacketSize = 0; - XEngine_Network_Send(lpszClientAddr, (LPCTSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Forward客户端:%s,请求可用转发列表失败,错误;%lx"), lpszClientAddr, ModuleSession_GetLastError()); + XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,请求可用转发列表失败,错误;%lx"), lpszClientAddr, ModuleSession_GetLastError()); } } else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREQ == pSt_ProtocolHdr->unOperatorCode) { - TCHAR tszSrcAddr[128]; - TCHAR tszDstAddr[128]; + XCHAR tszSrcAddr[128]; + XCHAR tszDstAddr[128]; memset(tszSrcAddr, '\0', sizeof(tszSrcAddr)); memset(tszDstAddr, '\0', sizeof(tszDstAddr)); @@ -100,20 +100,20 @@ BOOL XEngine_Forward_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int n pSt_ProtocolHdr->wReserve = 401; pSt_ProtocolHdr->unPacketSize = 0; pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREP; - XEngine_Network_Send(lpszClientAddr, (LPCTSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Forward客户端:%s,请求绑定转发地址:%s 失败,错误:%lX"), lpszClientAddr, tszDstAddr); - return FALSE; + XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,请求绑定转发地址:%s 失败,错误:%lX"), lpszClientAddr, tszDstAddr); + return false; } //先告知对方要转发数据 pSt_ProtocolHdr->wReserve = 0; pSt_ProtocolHdr->unPacketSize = 0; - XEngine_Network_Send(tszDstAddr, (LPCTSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); + XEngine_Network_Send(tszDstAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); //最后返回结果 pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREP; - XEngine_Network_Send(lpszClientAddr, (LPCTSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Forward客户端:%s,请求绑定转发地址:%s 成功"), lpszClientAddr, tszDstAddr); + XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,请求绑定转发地址:%s 成功"), lpszClientAddr, tszDstAddr); } } - return TRUE; + return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.h b/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.h index 7899dbf0b096dd12df79b0ccaca22bebf9ce3453..cd3f47020cadd82998b1ad3a753e03a3a72ea563 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.h @@ -11,5 +11,5 @@ // History: *********************************************************************/ //任务处理相关函数,处理包的内容 -XHTHREAD CALLBACK XEngine_Forward_Thread(LPVOID lParam); -BOOL XEngine_Forward_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr); \ No newline at end of file +XHTHREAD CALLBACK XEngine_Forward_Thread(XPVOID lParam); +bool XEngine_Forward_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h b/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h index f0c77c9ae9f1b6f19c2e5637379b2e2b9242067e..aabbc6c237f41453f5b9d893dc3f462e07a7f1df 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h @@ -71,8 +71,8 @@ using namespace std; // Purpose: 公用头文件 // History: *********************************************************************/ -extern BOOL bIsRun; -extern XLOG xhLog; +extern bool bIsRun; +extern XHANDLE xhLog; //Socks服务器 extern XHANDLE xhSocksSocket; extern XHANDLE xhSocksHeart; @@ -100,7 +100,7 @@ extern XENGINE_SERVICECONFIG st_ServiceConfig; typedef struct { - TCHAR tszIPAddr[128]; + XCHAR tszIPAddr[128]; ENUM_RFCCOMPONENTS_PROXY_STATUS enStatus; XNETHANDLE xhClient; }PROXYPROTOCOL_CLIENTINFO; diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp index c41499d3ecca45f441fe5cb62fbe340fd8487fc0..5b7a8018bc6169d99f0806ceed73f367e5c4e850 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Network.cpp @@ -11,63 +11,63 @@ // History: *********************************************************************/ //////////////////////////////////////////////////////////////////////////下面是SOCKS网络IO相关代码处理函数 -BOOL CALLBACK Network_Callback_SocksLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam) +bool CALLBACK Network_Callback_SocksLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { //客户端连接后要把客户端插入心跳管理器中才有效 ProxyProtocol_SocksCore_Create(lpszClientAddr); SocketOpt_HeartBeat_InsertAddrEx(xhSocksHeart, lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("SOCKS客户端:%s,连接到服务器"), lpszClientAddr); - return TRUE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SOCKS客户端:%s,连接到服务器"), lpszClientAddr); + return true; } -void CALLBACK Network_Callback_SocksRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam) +void CALLBACK Network_Callback_SocksRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { //需要激活一次 XEngine_SocksTask_Handle(lpszClientAddr, lpszRecvMsg, nMsgLen); SocketOpt_HeartBeat_ActiveAddrEx(xhSocksHeart, lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _T("SOCKS客户端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("SOCKS客户端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_SocksLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam) +void CALLBACK Network_Callback_SocksLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { //交给指定函数来处理客户端离开消息 XEngine_Network_Close(lpszClientAddr, XENGINE_CLIENT_NETTYPE_SOCKS, XENGINE_CLIENT_CLOSE_NETWORK); } -void CALLBACK Network_Callback_SocksHeart(LPCSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam) +void CALLBACK Network_Callback_SocksHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { //同上 XEngine_Network_Close(lpszClientAddr, XENGINE_CLIENT_NETTYPE_SOCKS, XENGINE_CLIENT_CLOSE_HEARTBEAT); } //////////////////////////////////////////////////////////////////////////下面是Tunnel网络IO相关代码处理函数 -BOOL CALLBACK Network_Callback_TunnelLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam) +bool CALLBACK Network_Callback_TunnelLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { ProxyProtocol_TunnelCore_Create(lpszClientAddr); SocketOpt_HeartBeat_InsertAddrEx(xhTunnelHeart, lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Tunnel客户端:%s,连接到服务器"), lpszClientAddr); - return TRUE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Tunnel客户端:%s,连接到服务器"), lpszClientAddr); + return true; } -void CALLBACK Network_Callback_TunnelRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam) +void CALLBACK Network_Callback_TunnelRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { XEngine_TunnelTask_Handle(lpszClientAddr, lpszRecvMsg, nMsgLen); SocketOpt_HeartBeat_ActiveAddrEx(xhTunnelHeart, lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _T("Tunnel客户端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("Tunnel客户端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_TunnelLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam) +void CALLBACK Network_Callback_TunnelLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, XENGINE_CLIENT_NETTYPE_TUNNEL, XENGINE_CLIENT_CLOSE_NETWORK); } -void CALLBACK Network_Callback_TunnelHeart(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam) +void CALLBACK Network_Callback_TunnelHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, XENGINE_CLIENT_NETTYPE_TUNNEL, XENGINE_CLIENT_CLOSE_HEARTBEAT); } //////////////////////////////////////////////////////////////////////////下面是Tunnel网络IO相关代码处理函数 -BOOL CALLBACK Network_Callback_ForwardLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam) +bool CALLBACK Network_Callback_ForwardLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { SocketOpt_HeartBeat_InsertAddrEx(xhForwardHeart, lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Forward客户端:%s,连接到服务器"), lpszClientAddr); - return TRUE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,连接到服务器"), lpszClientAddr); + return true; } -void CALLBACK Network_Callback_ForwardRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam) +void CALLBACK Network_Callback_ForwardRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam) { - TCHAR tszDstAddr[128]; + XCHAR tszDstAddr[128]; memset(tszDstAddr, '\0', sizeof(tszDstAddr)); if (ModuleSession_Forward_Get(lpszClientAddr, tszDstAddr)) @@ -80,22 +80,22 @@ void CALLBACK Network_Callback_ForwardRecv(LPCTSTR lpszClientAddr, SOCKET hSocke //没有绑定转发,投递到包中处理 if (!HelpComponents_Datas_PostEx(xhForwardPacket, lpszClientAddr, lpszRecvMsg, nMsgLen)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Forward客户端:%s,投递数据包失败,大小:%d,错误:%lX"), lpszClientAddr, nMsgLen, Packets_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Forward客户端:%s,投递数据包失败,大小:%d,错误:%lX"), lpszClientAddr, nMsgLen, Packets_GetLastError()); } } SocketOpt_HeartBeat_ActiveAddrEx(xhForwardHeart, lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _T("Forward客户端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_DEBUG, _X("Forward客户端:%s,投递数据包到组包队列成功,大小:%d"), lpszClientAddr, nMsgLen); } -void CALLBACK Network_Callback_ForwardLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam) +void CALLBACK Network_Callback_ForwardLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, XENGINE_CLIENT_NETTYPE_FORWARD, XENGINE_CLIENT_CLOSE_NETWORK); } -void CALLBACK Network_Callback_ForwardHeart(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam) +void CALLBACK Network_Callback_ForwardHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam) { XEngine_Network_Close(lpszClientAddr, XENGINE_CLIENT_NETTYPE_FORWARD, XENGINE_CLIENT_CLOSE_HEARTBEAT); } //////////////////////////////////////////////////////////////////////////网络IO关闭操作 -void XEngine_Network_Close(LPCTSTR lpszClientAddr, int nIPProto, int nCloseType) +void XEngine_Network_Close(LPCXSTR lpszClientAddr, int nIPProto, int nCloseType) { if (XENGINE_CLIENT_NETTYPE_SOCKS == nIPProto) { @@ -121,7 +121,7 @@ void XEngine_Network_Close(LPCTSTR lpszClientAddr, int nIPProto, int nCloseType) ProxyProtocol_SocksCore_GetList((XPPPMEM)&ppSt_ClientList, &nListCount, sizeof(PROXYPROTOCOL_CLIENTINFO)); for (int i = 0; i < nListCount; i++) { - if (0 == _tcsnicmp(lpszClientAddr, ppSt_ClientList[i]->tszIPAddr, _tcslen(lpszClientAddr))) + if (0 == _tcsxnicmp(lpszClientAddr, ppSt_ClientList[i]->tszIPAddr, _tcsxlen(lpszClientAddr))) { XClient_TCPSelect_DeleteEx(xhSocksClient, ppSt_ClientList[i]->xhClient); break; @@ -129,7 +129,7 @@ void XEngine_Network_Close(LPCTSTR lpszClientAddr, int nIPProto, int nCloseType) } BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ClientList, nListCount); ProxyProtocol_SocksCore_Delete(lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("SOCKS客户端:%s,离开服务器,离开类型;%d"), lpszClientAddr, nCloseType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SOCKS客户端:%s,离开服务器,离开类型;%d"), lpszClientAddr, nCloseType); } else if (XENGINE_CLIENT_NETTYPE_TUNNEL == nIPProto) { @@ -152,7 +152,7 @@ void XEngine_Network_Close(LPCTSTR lpszClientAddr, int nIPProto, int nCloseType) ProxyProtocol_TunnelCore_GetList((XPPPMEM)&ppSt_ClientList, &nListCount, sizeof(PROXYPROTOCOL_CLIENTINFO)); for (int i = 0; i < nListCount; i++) { - if (0 == _tcsnicmp(lpszClientAddr, ppSt_ClientList[i]->tszIPAddr, _tcslen(lpszClientAddr))) + if (0 == _tcsxnicmp(lpszClientAddr, ppSt_ClientList[i]->tszIPAddr, _tcsxlen(lpszClientAddr))) { XClient_TCPSelect_DeleteEx(xhTunnelClient, ppSt_ClientList[i]->xhClient); break; @@ -160,7 +160,7 @@ void XEngine_Network_Close(LPCTSTR lpszClientAddr, int nIPProto, int nCloseType) } BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ClientList, nListCount); ProxyProtocol_TunnelCore_Delete(lpszClientAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Tunnel客户端:%s,离开服务器,离开类型;%d"), lpszClientAddr, nCloseType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Tunnel客户端:%s,离开服务器,离开类型;%d"), lpszClientAddr, nCloseType); } else if (XENGINE_CLIENT_NETTYPE_FORWARD == nIPProto) { @@ -177,23 +177,23 @@ void XEngine_Network_Close(LPCTSTR lpszClientAddr, int nIPProto, int nCloseType) SocketOpt_HeartBeat_DeleteAddrEx(xhForwardHeart, lpszClientAddr); NetCore_TCPXCore_CloseForClientEx(xhForwardSocket, lpszClientAddr); } - TCHAR tszClientAddr[128]; + XCHAR tszClientAddr[128]; memset(tszClientAddr, '\0', sizeof(tszClientAddr)); ModuleSession_Forward_Delete(lpszClientAddr, tszClientAddr); - if (_tcslen(tszClientAddr) > 0) + if (_tcsxlen(tszClientAddr) > 0) { XEngine_Network_Close(tszClientAddr, XENGINE_CLIENT_NETTYPE_FORWARD, XENGINE_CLIENT_CLOSE_SERVICE); } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Forward客户端:%s,离开服务器,离开类型;%d"), lpszClientAddr, nCloseType); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,离开服务器,离开类型;%d"), lpszClientAddr, nCloseType); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("未知客户端:%s,离开服务器"), lpszClientAddr); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("未知客户端:%s,离开服务器"), lpszClientAddr); } } ////////////////////////////////////////////////////////////////////////// -BOOL XEngine_Network_Send(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, int nIPProto) +bool XEngine_Network_Send(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, int nIPProto) { //根据客户端类型来处理发送业务逻辑 if (XENGINE_CLIENT_NETTYPE_SOCKS == nIPProto) @@ -201,8 +201,8 @@ BOOL XEngine_Network_Send(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMs //发送数据给指定客户端 if (!NetCore_TCPXCore_SendEx(xhSocksSocket, lpszClientAddr, lpszMsgBuffer, nMsgLen, 1, 1)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,发送数据失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,发送数据失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); + return false; } //发送成功激活一次心跳 SocketOpt_HeartBeat_ActiveAddrEx(xhSocksHeart, lpszClientAddr); @@ -211,8 +211,8 @@ BOOL XEngine_Network_Send(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMs { if (!NetCore_TCPXCore_SendEx(xhTunnelSocket, lpszClientAddr, lpszMsgBuffer, nMsgLen, 1, 1)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Tunnel客户端:%s,发送数据失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Tunnel客户端:%s,发送数据失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); + return false; } SocketOpt_HeartBeat_ActiveAddrEx(xhTunnelHeart, lpszClientAddr); } @@ -220,14 +220,14 @@ BOOL XEngine_Network_Send(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMs { if (!NetCore_TCPXCore_SendEx(xhForwardSocket, lpszClientAddr, lpszMsgBuffer, nMsgLen, 1, 1)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Forward客户端:%s,发送数据失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Forward客户端:%s,发送数据失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); + return false; } SocketOpt_HeartBeat_ActiveAddrEx(xhForwardHeart, lpszClientAddr); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("未知客户端:%s,发送数据给失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("未知客户端:%s,发送数据给失败,错误:%lX"), lpszClientAddr, NetCore_GetLastError()); } - return TRUE; + return true; } \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Network.h b/XEngine_Source/XEngine_ServiceApp/XEngine_Network.h index 44baa69e902c36ae8ad501dfcbd6e70408350ae9..654f09e0424299a03fc4c9e05812cdcb9fcf5135 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Network.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Network.h @@ -11,20 +11,20 @@ // History: *********************************************************************/ //SOCKS相关 -BOOL CALLBACK Network_Callback_SocksLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam); //用户连接 -void CALLBACK Network_Callback_SocksRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam); //接受到数据 -void CALLBACK Network_Callback_SocksLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam); //用户离开 -void CALLBACK Network_Callback_SocksHeart(LPCSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam); //心跳超时 +bool CALLBACK Network_Callback_SocksLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户连接 +void CALLBACK Network_Callback_SocksRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); //接受到数据 +void CALLBACK Network_Callback_SocksLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); //用户离开 +void CALLBACK Network_Callback_SocksHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //心跳超时 //Tunnel相关 -BOOL CALLBACK Network_Callback_TunnelLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam); -void CALLBACK Network_Callback_TunnelRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam); -void CALLBACK Network_Callback_TunnelLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam); -void CALLBACK Network_Callback_TunnelHeart(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam); +bool CALLBACK Network_Callback_TunnelLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void CALLBACK Network_Callback_TunnelRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void CALLBACK Network_Callback_TunnelLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void CALLBACK Network_Callback_TunnelHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //Forward相关 -BOOL CALLBACK Network_Callback_ForwardLogin(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam); -void CALLBACK Network_Callback_ForwardRecv(LPCTSTR lpszClientAddr, SOCKET hSocket, LPCTSTR lpszRecvMsg, int nMsgLen, LPVOID lParam); -void CALLBACK Network_Callback_ForwardLeave(LPCTSTR lpszClientAddr, SOCKET hSocket, LPVOID lParam); -void CALLBACK Network_Callback_ForwardHeart(LPCTSTR lpszClientAddr, SOCKET hSocket, int nStatus, LPVOID lParam); +bool CALLBACK Network_Callback_ForwardLogin(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void CALLBACK Network_Callback_ForwardRecv(LPCXSTR lpszClientAddr, XSOCKET hSocket, LPCXSTR lpszRecvMsg, int nMsgLen, XPVOID lParam); +void CALLBACK Network_Callback_ForwardLeave(LPCXSTR lpszClientAddr, XSOCKET hSocket, XPVOID lParam); +void CALLBACK Network_Callback_ForwardHeart(LPCXSTR lpszClientAddr, XSOCKET hSocket, int nStatus, XPVOID lParam); //关闭与发送 -void XEngine_Network_Close(LPCTSTR lpszClientAddr, int nIPProto, int nCloseType); -BOOL XEngine_Network_Send(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen, int nIPProto); \ No newline at end of file +void XEngine_Network_Close(LPCXSTR lpszClientAddr, int nIPProto, int nCloseType); +bool XEngine_Network_Send(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen, int nIPProto); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp index 0a23ff9cdf84f226bd25a0b34e91fc1dc4f2b8d5..e22895e26eca4218c5f3cd57e52d4776aa8147d1 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp @@ -1,7 +1,7 @@ #include "XEngine_Hdr.h" -BOOL bIsRun = FALSE; -XLOG xhLog = NULL; +bool bIsRun = false; +XHANDLE xhLog = NULL; XHANDLE xhSocksSocket = NULL; XHANDLE xhSocksHeart = NULL; @@ -22,8 +22,8 @@ void ServiceApp_Stop(int signo) { if (bIsRun) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("服务器退出...")); - bIsRun = FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("服务器退出...")); + bIsRun = false; //销毁Socks资源 NetCore_TCPXCore_DestroyEx(xhSocksSocket); SocketOpt_HeartBeat_DestoryEx(xhSocksHeart); @@ -84,12 +84,7 @@ int main(int argc, char** argv) WSAStartup(MAKEWORD(2, 2), &st_WSAData); #endif -#if XENGINE_VERSION_BIT < 7370001001 - printf("版本号过低,无法继续,按任意键退出!\n"); - getchar(); - return 0; -#endif - bIsRun = TRUE; + bIsRun = true; HELPCOMPONENTS_XLOG_CONFIGURE st_XLogConfig; memset(&st_XLogConfig, '\0', sizeof(HELPCOMPONENTS_XLOG_CONFIGURE)); @@ -111,7 +106,7 @@ int main(int argc, char** argv) //初始日志 st_XLogConfig.XLog_MaxBackupFile = 10; st_XLogConfig.XLog_MaxSize = 1024000; - _tcscpy(st_XLogConfig.tszFileName, st_ServiceConfig.st_XLog.tszLogFile); + _tcsxcpy(st_XLogConfig.tszFileName, st_ServiceConfig.st_XLog.tszLogFile); xhLog = HelpComponents_XLog_Init(HELPCOMPONENTS_XLOG_OUTTYPE_STD | HELPCOMPONENTS_XLOG_OUTTYPE_FILE, &st_XLogConfig); if (NULL == xhLog) { @@ -120,20 +115,20 @@ int main(int argc, char** argv) } //设置日志打印级别 HelpComponents_XLog_SetLogPriority(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化日志系统成功")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化日志系统成功")); if (st_ServiceConfig.st_XAuth.bAuth >0) { if (!ModuleAuthorize_User_Init(st_ServiceConfig.st_XAuth.tszAuthFile)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启用用户验证服务失败,错误:%lX"), ModuleAuthorize_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启用用户验证服务失败,错误:%lX"), ModuleAuthorize_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启用用户验证服务,用户列表地址:%s"), st_ServiceConfig.st_XAuth.tszAuthFile); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启用用户验证服务,用户列表地址:%s"), st_ServiceConfig.st_XAuth.tszAuthFile); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,没有启用用户验证服务")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,没有启用用户验证服务")); } //启动Socks服务相关代码 if (st_ServiceConfig.nSocksPort > 0) @@ -144,38 +139,38 @@ int main(int argc, char** argv) xhSocksHeart = SocketOpt_HeartBeat_InitEx(st_ServiceConfig.st_XTime.nSocksTimeOut, st_ServiceConfig.st_XTime.nTimeCheck, Network_Callback_SocksHeart); if (NULL == xhSocksHeart) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化Socks心跳服务失败,错误:%lX"), NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化Socks心跳服务失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化Socks心跳服务成功,时间:%d,次数:%d"), st_ServiceConfig.st_XTime.nSocksTimeOut, st_ServiceConfig.st_XTime.nTimeCheck); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化Socks心跳服务成功,时间:%d,次数:%d"), st_ServiceConfig.st_XTime.nSocksTimeOut, st_ServiceConfig.st_XTime.nTimeCheck); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,Socks心跳服务被设置为不启用")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,Socks心跳服务被设置为不启用")); } //启动网络 xhSocksSocket = NetCore_TCPXCore_StartEx(st_ServiceConfig.nSocksPort, st_ServiceConfig.st_XMax.nMaxClient, st_ServiceConfig.st_XMax.nIOThread); if (NULL == xhSocksSocket) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动Socks网络服务器失败,错误:%lX"), NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动Socks网络服务器失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动Socks网络服务器成功,Socks端口:%d,网络IO线程个数:%d"), st_ServiceConfig.nSocksPort, st_ServiceConfig.st_XMax.nIOThread); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Socks网络服务器成功,Socks端口:%d,网络IO线程个数:%d"), st_ServiceConfig.nSocksPort, st_ServiceConfig.st_XMax.nIOThread); //绑定网络事件 NetCore_TCPXCore_RegisterCallBackEx(xhSocksSocket, Network_Callback_SocksLogin, Network_Callback_SocksRecv, Network_Callback_SocksLeave); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,注册Socks网络事件成功")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册Socks网络事件成功")); //客户端 xhSocksClient = XClient_TCPSelect_StartEx(XEngine_Socks_CBRecv); if (NULL == xhSocksClient) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动Socks客户端服务失败,错误:%lX"), XClient_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动Socks客户端服务失败,错误:%lX"), XClient_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动Socks客户端服务成功")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Socks客户端服务成功")); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,Socks消息服务没有被启用")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,Socks消息服务没有被启用")); } //启动Tunnel服务相关代码 if (st_ServiceConfig.nTunnelPort > 0) @@ -186,37 +181,37 @@ int main(int argc, char** argv) xhTunnelHeart = SocketOpt_HeartBeat_InitEx(st_ServiceConfig.st_XTime.nTunnelTimeOut, st_ServiceConfig.st_XTime.nTimeCheck, Network_Callback_TunnelHeart); if (NULL == xhTunnelHeart) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化Tunnel心跳服务失败,错误:%lX"), NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化Tunnel心跳服务失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化Tunnel心跳服务成功,时间:%d,次数:%d"), st_ServiceConfig.st_XTime.nTunnelTimeOut, st_ServiceConfig.st_XTime.nTimeCheck); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化Tunnel心跳服务成功,时间:%d,次数:%d"), st_ServiceConfig.st_XTime.nTunnelTimeOut, st_ServiceConfig.st_XTime.nTimeCheck); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,Tunnel心跳服务被设置为不启用")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,Tunnel心跳服务被设置为不启用")); } //网络 xhTunnelSocket = NetCore_TCPXCore_StartEx(st_ServiceConfig.nTunnelPort, st_ServiceConfig.st_XMax.nMaxClient, st_ServiceConfig.st_XMax.nIOThread); if (NULL == xhTunnelSocket) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动Tunnel网络服务器失败,错误:%lX"), NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动Tunnel网络服务器失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动Tunnel网络服务器成功,Tunnel端口:%d,IO:%d"), st_ServiceConfig.nTunnelPort, st_ServiceConfig.st_XMax.nIOThread); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Tunnel网络服务器成功,Tunnel端口:%d,IO:%d"), st_ServiceConfig.nTunnelPort, st_ServiceConfig.st_XMax.nIOThread); NetCore_TCPXCore_RegisterCallBackEx(xhTunnelSocket, Network_Callback_TunnelLogin, Network_Callback_TunnelRecv, Network_Callback_TunnelLeave); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,注册Tunnel网络事件成功")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册Tunnel网络事件成功")); //客户端 xhTunnelClient = XClient_TCPSelect_StartEx(XEngine_Tunnel_CBRecv); if (NULL == xhTunnelClient) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动Tunnel客户端服务失败,错误:%lX"), XClient_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动Tunnel客户端服务失败,错误:%lX"), XClient_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动Tunnel客户端服务成功")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Tunnel客户端服务成功")); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,Tunnel消息服务没有被启用")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,Tunnel消息服务没有被启用")); } //启动转发协议服务 if (st_ServiceConfig.nForwardPort > 0) @@ -225,35 +220,35 @@ int main(int argc, char** argv) xhForwardPacket = HelpComponents_Datas_Init(st_ServiceConfig.st_XMax.nMaxQueue, st_ServiceConfig.st_XMax.nForwardThread); if (NULL == xhForwardPacket) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("初始化Forward组包器失败,错误:%lX"), Packets_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("初始化Forward组包器失败,错误:%lX"), Packets_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动Forward组包器成功")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Forward组包器成功")); //启动心跳 if (st_ServiceConfig.st_XTime.nForwardTimeOut > 0) { xhForwardHeart = SocketOpt_HeartBeat_InitEx(st_ServiceConfig.st_XTime.nForwardTimeOut, st_ServiceConfig.st_XTime.nTimeCheck, Network_Callback_ForwardHeart); if (NULL == xhForwardHeart) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,初始化Forward心跳服务失败,错误:%lX"), NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,初始化Forward心跳服务失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,初始化Forward心跳服务成功,时间:%d,次数:%d"), st_ServiceConfig.st_XTime.nForwardTimeOut, st_ServiceConfig.st_XTime.nTimeCheck); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,初始化Forward心跳服务成功,时间:%d,次数:%d"), st_ServiceConfig.st_XTime.nForwardTimeOut, st_ServiceConfig.st_XTime.nTimeCheck); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,Forward心跳服务被设置为不启用")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,Forward心跳服务被设置为不启用")); } //网络 xhForwardSocket = NetCore_TCPXCore_StartEx(st_ServiceConfig.nForwardPort, st_ServiceConfig.st_XMax.nMaxClient, st_ServiceConfig.st_XMax.nIOThread); if (NULL == xhForwardSocket) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动服务中,启动Forward网络服务器失败,错误:%lX"), NetCore_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动服务中,启动Forward网络服务器失败,错误:%lX"), NetCore_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动Forward网络服务器成功,Forward端口:%d,IO:%d"), st_ServiceConfig.nForwardPort, st_ServiceConfig.st_XMax.nIOThread); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Forward网络服务器成功,Forward端口:%d,IO:%d"), st_ServiceConfig.nForwardPort, st_ServiceConfig.st_XMax.nIOThread); NetCore_TCPXCore_RegisterCallBackEx(xhForwardSocket, Network_Callback_ForwardLogin, Network_Callback_ForwardRecv, Network_Callback_ForwardLeave); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,注册Forward网络事件成功")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,注册Forward网络事件成功")); //任务池 THREADPOOL_PARAMENT** ppSt_ListParam; BaseLib_OperatorMemory_Malloc((XPPPMEM)&ppSt_ListParam, st_ServiceConfig.st_XMax.nForwardThread, sizeof(THREADPOOL_PARAMENT)); @@ -268,27 +263,27 @@ int main(int argc, char** argv) xhForwardPool = ManagePool_Thread_NQCreate(&ppSt_ListParam, st_ServiceConfig.st_XMax.nForwardThread); if (NULL == xhForwardPool) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("启动Forward线程池服务失败,错误:%lX"), ManagePool_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("启动Forward线程池服务失败,错误:%lX"), ManagePool_GetLastError()); goto XENGINE_SERVICEAPP_EXIT; } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("启动服务中,启动Forward线程池服务成功,启动个数:%d"), st_ServiceConfig.st_XMax.nForwardThread); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启动Forward线程池服务成功,启动个数:%d"), st_ServiceConfig.st_XMax.nForwardThread); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _T("启动服务中,Forward服务没有被启用")); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_WARN, _X("启动服务中,Forward服务没有被启用")); } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("所有服务成功启动,服务运行中,XEngine版本:%s,服务版本;%s,发行次数:%d。。。"), BaseLib_OperatorVer_XGetStr(), st_ServiceConfig.st_XVer.pStl_ListVer->front().c_str(), st_ServiceConfig.st_XVer.pStl_ListVer->size()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("所有服务成功启动,服务运行中,XEngine版本:%s%s,服务版本:%s,发行次数:%d。。。"), BaseLib_OperatorVer_XNumberStr(), BaseLib_OperatorVer_XTypeStr(), st_ServiceConfig.st_XVer.pStl_ListVer->front().c_str(), st_ServiceConfig.st_XVer.pStl_ListVer->size()); - while (TRUE) + while (true) { std::this_thread::sleep_for(std::chrono::seconds(1)); } XENGINE_SERVICEAPP_EXIT: if (bIsRun) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("有服务启动失败,服务器退出...")); - bIsRun = FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("有服务启动失败,服务器退出...")); + bIsRun = false; //销毁Socks资源 NetCore_TCPXCore_DestroyEx(xhSocksSocket); SocketOpt_HeartBeat_DestoryEx(xhSocksHeart); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp index 65511dbdbe774f558473e144876a760781a1ef64..2d36f140fc9b461af1b153864d7160e958935352 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp @@ -10,17 +10,17 @@ // Purpose: Socks任务处理代码 // History: *********************************************************************/ -BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen) +bool XEngine_SocksTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen) { int nLen = 4096; - TCHAR tszMsgBuffer[4096]; + XCHAR tszMsgBuffer[4096]; memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer)); ENUM_RFCCOMPONENTS_PROXY_STATUS enSocksStatus; if (!ProxyProtocol_SocksCore_GetStatus(lpszClientAddr, &enSocksStatus)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,获取状态失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,获取状态失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); + return false; } //获取到的状态来处理相对应的事件 if (ENUM_RFCCOMPONENTS_PROXY_STATUS_CREATE == enSocksStatus) @@ -31,34 +31,34 @@ BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int { ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH_NOAUTH); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,解析验证协议失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,解析验证协议失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); + return false; } - BOOL bFoundAuth = FALSE; - TCHAR tszAuthBuffer[MAX_PATH]; + bool bFoundAuth = false; + XCHAR tszAuthBuffer[MAX_PATH]; memset(tszAuthBuffer, '\0', MAX_PATH); //客户端支持的验证类型 for (int i = 0; i < nListCount; i++) { - TCHAR tszTmpBuffer[64]; + XCHAR tszTmpBuffer[64]; memset(tszTmpBuffer, '\0', sizeof(tszTmpBuffer)); - _stprintf(tszTmpBuffer, _T("%d"), enListAuths[i]); - _tcscat(tszAuthBuffer, tszTmpBuffer); - _tcscat(tszAuthBuffer, _T(" ")); + _xstprintf(tszTmpBuffer, _X("%d"), enListAuths[i]); + _tcsxcat(tszAuthBuffer, tszTmpBuffer); + _tcsxcat(tszAuthBuffer, _X(" ")); //服务器是否支持 if (st_ServiceConfig.st_XAuth.bAuth == enListAuths[i]) { - bFoundAuth = TRUE; + bFoundAuth = true; } } if (!bFoundAuth) { ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH_NOAUTH); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,解析验证协议成功,但是验证类型不支持,客户端的支持验证:%s,服务器支持的验证:%d"), lpszClientAddr, tszAuthBuffer, st_ServiceConfig.st_XAuth.bAuth); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,解析验证协议成功,但是验证类型不支持,客户端的支持验证:%s,服务器支持的验证:%d"), lpszClientAddr, tszAuthBuffer, st_ServiceConfig.st_XAuth.bAuth); + return false; } ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, st_ServiceConfig.st_XAuth.bAuth); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); @@ -68,12 +68,12 @@ BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int //跳过 ProxyProtocol_SocksCore_SetStatus(lpszClientAddr, ENUM_RFCCOMPONENTS_PROXY_STATUS_USER); } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("SOCKS客户端:%s,解析验证协议成功,支持的验证类型:%s,使用的验证类型:%d"), lpszClientAddr, tszAuthBuffer, st_ServiceConfig.st_XAuth.bAuth); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SOCKS客户端:%s,解析验证协议成功,支持的验证类型:%s,使用的验证类型:%d"), lpszClientAddr, tszAuthBuffer, st_ServiceConfig.st_XAuth.bAuth); } else if (ENUM_RFCCOMPONENTS_PROXY_STATUS_AUTH == enSocksStatus) { - TCHAR tszUserName[MAX_PATH]; - TCHAR tszUserPass[MAX_PATH]; + XCHAR tszUserName[MAX_PATH]; + XCHAR tszUserPass[MAX_PATH]; ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH enProxyAuth; memset(tszUserName, '\0', MAX_PATH); @@ -83,31 +83,31 @@ BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int { ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, XENGINE_RFCCOMPONENT_PROXY_SOCKS_RESPONSE_FAILED); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,用户登录验证失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,用户登录验证失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); + return false; } if (enProxyAuth != st_ServiceConfig.st_XAuth.bAuth) { ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, XENGINE_RFCCOMPONENT_PROXY_SOCKS_RESPONSE_FAILED); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,用户登录验证失败,客户端发送的验证类型不支持"), lpszClientAddr); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,用户登录验证失败,客户端发送的验证类型不支持"), lpszClientAddr); + return false; } if (!ModuleAuthorize_User_Exist(tszUserName, tszUserPass)) { ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, XENGINE_RFCCOMPONENT_PROXY_SOCKS_RESPONSE_FAILED); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,用户登录验证失败,用户名:%s,或者密码:%s 不正确"), lpszClientAddr, tszUserPass, tszUserPass); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,用户登录验证失败,用户名:%s,或者密码:%s 不正确"), lpszClientAddr, tszUserPass, tszUserPass); + return false; } ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, XENGINE_RFCCOMPONENT_PROXY_SOCKS_RESPONSE_SUCCESS); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("SOCKS客户端:%s,用户登录验证成功,使用的验证类型:%d,用户名:%s"), lpszClientAddr, enProxyAuth, tszUserName); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SOCKS客户端:%s,用户登录验证成功,使用的验证类型:%d,用户名:%s"), lpszClientAddr, enProxyAuth, tszUserName); } else if (ENUM_RFCCOMPONENTS_PROXY_STATUS_USER == enSocksStatus) { int nPort = 0; - TCHAR tszClientAddr[1024]; + XCHAR tszClientAddr[1024]; PROXYPROTOCOL_CLIENTINFO st_ProxyClient; ENUM_RFCCOMPONENTS_PROXYSOCKS_COMMAND enCommand; ENUM_RFCCOMPONENTS_PROXYSOCKS_IPADDR enIPType; @@ -118,8 +118,8 @@ BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int { ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, XENGINE_RFCCOMPONENT_PROXY_SOCKS_RESPONSE_NETWORK); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,用户连接失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,用户连接失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); + return false; } //命令类型 if (ENUM_RFCCOMPONENTS_PROXYSOCKS_COMMAND_CONNECT == enCommand) @@ -127,16 +127,16 @@ BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int //连接类型,IP还是域名,没有IPV6环境.不好测试 if (ENUM_RFCCOMPONENTS_PROXYSOCKS_IPADDR_IPV4 == enIPType) { - if (!XClient_TCPSelect_InsertEx(xhSocksClient, tszClientAddr, nPort)) + if (!XClient_TCPSelect_InsertEx(xhSocksClient, &st_ProxyClient.xhClient, tszClientAddr, nPort)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,创建客户端连接失败,连接到服务器:%s:%d,错误:%lX"), lpszClientAddr, tszClientAddr, nPort, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,创建客户端连接失败,连接到服务器:%s:%d,错误:%lX"), lpszClientAddr, tszClientAddr, nPort, ProxyProtocol_GetLastError()); + return false; } } else { int nListCount = 0; - CHAR** ppszListAddr; + XCHAR** ppszListAddr; ENUM_APIHELP_DOMAINTYPE enDomainType; APIHELP_DOMAIN st_APIUrl; @@ -144,38 +144,38 @@ BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int APIHelp_Domain_GetInfo(tszClientAddr, &st_APIUrl, &enDomainType); memset(tszClientAddr, '\0', sizeof(tszClientAddr)); - if (_tcslen(st_APIUrl.tszSubDomain) > 0) + if (_tcsxlen(st_APIUrl.tszSubDomain) > 0) { - _stprintf(tszClientAddr, _T("%s.%s"), st_APIUrl.tszSubDomain, st_APIUrl.tszMainDomain); + _xstprintf(tszClientAddr, _X("%s.%s"), st_APIUrl.tszSubDomain, st_APIUrl.tszMainDomain); } else { - _stprintf(tszClientAddr, _T("%s"), st_APIUrl.tszMainDomain); + _xstprintf(tszClientAddr, _X("%s"), st_APIUrl.tszMainDomain); } if (!NetXApi_Socket_DomainToAddr(tszClientAddr, &ppszListAddr, &nListCount)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,解析域名失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,解析域名失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); + return false; } memset(tszClientAddr, '\0', sizeof(tszClientAddr)); - _tcscpy(tszClientAddr, ppszListAddr[0]); //随便选择一个IP地址 + _tcsxcpy(tszClientAddr, ppszListAddr[0]); //随便选择一个IP地址 BaseLib_OperatorMemory_Free((XPPPMEM)&ppszListAddr, nListCount); - if (!XClient_TCPSelect_InsertEx(xhSocksClient, tszClientAddr, nPort, &st_ProxyClient.xhClient)) + if (!XClient_TCPSelect_InsertEx(xhSocksClient, &st_ProxyClient.xhClient, tszClientAddr, nPort)) { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("SOCKS客户端:%s,创建客户端连接失败,连接到服务器:%s:%d,错误:%lX"), lpszClientAddr, tszClientAddr, nPort, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("SOCKS客户端:%s,创建客户端连接失败,连接到服务器:%s:%d,错误:%lX"), lpszClientAddr, tszClientAddr, nPort, ProxyProtocol_GetLastError()); + return false; } } } //配置客户端信息 st_ProxyClient.enStatus = ENUM_RFCCOMPONENTS_PROXY_STATUS_FORWARD; - _tcscpy(st_ProxyClient.tszIPAddr, lpszClientAddr); + _tcsxcpy(st_ProxyClient.tszIPAddr, lpszClientAddr); ProxyProtocol_SocksCore_SetInfo(lpszClientAddr, &st_ProxyClient, sizeof(PROXYPROTOCOL_CLIENTINFO)); //回复结果 ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, XENGINE_RFCCOMPONENT_PROXY_SOCKS_RESPONSE_SUCCESS); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("SOCKS客户端:%s,用户登录验证成功,连接到地址:%s:%d"), lpszClientAddr, tszClientAddr, nPort); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("SOCKS客户端:%s,用户登录验证成功,连接到地址:%s:%d"), lpszClientAddr, tszClientAddr, nPort); } else { @@ -184,17 +184,17 @@ BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int memset(&st_ProxyClient, '\0', sizeof(PROXYPROTOCOL_CLIENTINFO)); if (ProxyProtocol_SocksCore_GetInfo(lpszClientAddr, &st_ProxyClient)) { - XClient_TCPSelect_SendEx(xhSocksClient, st_ProxyClient.xhClient, lpszMsgBuffer, &nMsgLen); + XClient_TCPSelect_SendEx(xhSocksClient, st_ProxyClient.xhClient, lpszMsgBuffer, nMsgLen); } else { - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Socks客户端:%s,转发数据失败,可能与服务器的连接已经关闭,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Socks客户端:%s,转发数据失败,可能与服务器的连接已经关闭,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); } } - return TRUE; + return true; } -void CALLBACK XEngine_Socks_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, SOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCSTR lpszMsgBuffer, int nLen, LPVOID lParam) +void CALLBACK XEngine_Socks_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, XSOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCXSTR lpszMsgBuffer, int nLen, XPVOID lParam) { int nListCount = 0; PROXYPROTOCOL_CLIENTINFO** ppSt_ClientList; @@ -214,7 +214,7 @@ void CALLBACK XEngine_Socks_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, SOCKET { //退出处理 SocketOpt_HeartBeat_ForceOutAddrEx(xhSocksHeart, ppSt_ClientList[i]->tszIPAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Socks客户端:%s,离开服务器,客户端主动断开"), ppSt_ClientList[i]->tszIPAddr); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Socks客户端:%s,离开服务器,客户端主动断开"), ppSt_ClientList[i]->tszIPAddr); } break; } diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.h b/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.h index 3185490bf25f5928283b57a765423eac6345d87f..b062e1e831beade1df5c8cfc32e6ded209e72918 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.h @@ -11,5 +11,5 @@ // History: *********************************************************************/ //任务处理相关函数,处理包的内容 -BOOL XEngine_SocksTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen); -void CALLBACK XEngine_Socks_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, SOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCSTR lpszMsgBuffer, int nLen, LPVOID lParam); \ No newline at end of file +bool XEngine_SocksTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen); +void CALLBACK XEngine_Socks_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, XSOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCXSTR lpszMsgBuffer, int nLen, XPVOID lParam); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp index ed6e9acb28b40151fcee9dcd1ac3712627267cef..39b979ffe44f03371cede79774e6ca62a4f2c0f7 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp @@ -10,7 +10,7 @@ // Purpose: HTTP任务处理代码 // History: *********************************************************************/ -BOOL XEngine_TunnelTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen) +bool XEngine_TunnelTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen) { PROXYPROTOCOL_CLIENTINFO st_ProxyClient; memset(&st_ProxyClient, '\0', sizeof(PROXYPROTOCOL_CLIENTINFO)); @@ -21,10 +21,10 @@ BOOL XEngine_TunnelTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in { int nLen = 0; int nIPPort = 0; - BOOL bProxy = TRUE; - TCHAR tszIPAddr[1024]; - TCHAR tszAuthInfo[MAX_PATH]; - TCHAR tszMsgBuffer[MAX_PATH]; + bool bProxy = true; + XCHAR tszIPAddr[1024]; + XCHAR tszAuthInfo[MAX_PATH]; + XCHAR tszMsgBuffer[MAX_PATH]; memset(tszIPAddr, '\0', sizeof(tszIPAddr)); memset(tszAuthInfo, '\0', MAX_PATH); @@ -33,15 +33,15 @@ BOOL XEngine_TunnelTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in { ProxyProtocol_TunnelCore_Packet(tszMsgBuffer, &nLen, 400); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_TUNNEL); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Tunnel客户端:%s,解析协议失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Tunnel客户端:%s,解析协议失败,错误:%lX"), lpszClientAddr, ProxyProtocol_GetLastError()); + return false; } - TCHAR tszConnectAddr[128]; + XCHAR tszConnectAddr[128]; memset(tszConnectAddr, '\0', sizeof(tszConnectAddr)); if (st_ServiceConfig.st_XAuth.bAuth > 0) { - TCHAR tszUser[128]; - TCHAR tszPass[128]; + XCHAR tszUser[128]; + XCHAR tszPass[128]; memset(tszUser, '\0', sizeof(tszUser)); memset(tszPass, '\0', sizeof(tszPass)); @@ -49,26 +49,26 @@ BOOL XEngine_TunnelTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in { ProxyProtocol_TunnelCore_Packet(tszMsgBuffer, &nLen, 401); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_TUNNEL); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Tunnel客户端:%s,失败无法继续,错误:%lX"), lpszClientAddr, OPenSsl_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Tunnel客户端:%s,失败无法继续,错误:%lX"), lpszClientAddr, OPenSsl_GetLastError()); + return false; } if (!ModuleAuthorize_User_Exist(tszUser, tszPass)) { ProxyProtocol_TunnelCore_Packet(tszMsgBuffer, &nLen, 401); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_TUNNEL); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Tunnel客户端:%s,验证用户名:%s,密码:%s 失败,错误:%lX"), lpszClientAddr, tszUser, tszPass); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Tunnel客户端:%s,验证用户名:%s,密码:%s 失败,错误:%lX"), lpszClientAddr, tszUser, tszPass); + return false; } } //是否为IP地址 if (BaseLib_OperatorIPAddr_IsIPV4Addr(tszIPAddr)) { - _tcscpy(tszConnectAddr, tszIPAddr); + _tcsxcpy(tszConnectAddr, tszIPAddr); } else { int nListCount = 0; - CHAR** ppszListAddr; + XCHAR** ppszListAddr; ENUM_APIHELP_DOMAINTYPE enDomainType; APIHELP_DOMAIN st_APIUrl; @@ -76,35 +76,35 @@ BOOL XEngine_TunnelTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in APIHelp_Domain_GetInfo(tszIPAddr, &st_APIUrl, &enDomainType); memset(tszIPAddr, '\0', sizeof(tszIPAddr)); - if (_tcslen(st_APIUrl.tszSubDomain) > 0) + if (_tcsxlen(st_APIUrl.tszSubDomain) > 0) { - _stprintf(tszIPAddr, _T("%s.%s"), st_APIUrl.tszSubDomain, st_APIUrl.tszMainDomain); + _xstprintf(tszIPAddr, _X("%s.%s"), st_APIUrl.tszSubDomain, st_APIUrl.tszMainDomain); } else { - _stprintf(tszIPAddr, _T("%s"), st_APIUrl.tszMainDomain); + _xstprintf(tszIPAddr, _X("%s"), st_APIUrl.tszMainDomain); } if (!NetXApi_Socket_DomainToAddr(tszIPAddr, &ppszListAddr, &nListCount)) { ProxyProtocol_TunnelCore_Packet(tszMsgBuffer, &nLen, 500); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_TUNNEL); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Tunnel客户端:%s,解析域名:%s,失败,错误:%lX"), lpszClientAddr, tszIPAddr, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Tunnel客户端:%s,解析域名:%s,失败,错误:%lX"), lpszClientAddr, tszIPAddr, ProxyProtocol_GetLastError()); + return false; } - _tcscpy(tszConnectAddr, ppszListAddr[0]); //随便选择一个IP地址 + _tcsxcpy(tszConnectAddr, ppszListAddr[0]); //随便选择一个IP地址 BaseLib_OperatorMemory_Free((XPPPMEM)&ppszListAddr, nListCount); } - if (!XClient_TCPSelect_InsertEx(xhTunnelClient, tszConnectAddr, nIPPort, &st_ProxyClient.xhClient)) + if (!XClient_TCPSelect_InsertEx(xhTunnelClient, &st_ProxyClient.xhClient, tszConnectAddr, nIPPort)) { ProxyProtocol_TunnelCore_Packet(tszMsgBuffer, &nLen, 500); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_TUNNEL); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _T("Tunnel客户端:%s,创建客户端连接失败,连接到服务器:%s:%d,错误:%lX"), lpszClientAddr, tszConnectAddr, nIPPort, ProxyProtocol_GetLastError()); - return FALSE; + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Tunnel客户端:%s,创建客户端连接失败,连接到服务器:%s:%d,错误:%lX"), lpszClientAddr, tszConnectAddr, nIPPort, ProxyProtocol_GetLastError()); + return false; } //设置属于 st_ProxyClient.enStatus = ENUM_RFCCOMPONENTS_PROXY_STATUS_FORWARD; - _tcscpy(st_ProxyClient.tszIPAddr, lpszClientAddr); + _tcsxcpy(st_ProxyClient.tszIPAddr, lpszClientAddr); ProxyProtocol_TunnelCore_SetInfo(lpszClientAddr, &st_ProxyClient, sizeof(PROXYPROTOCOL_CLIENTINFO)); //判断是代理还是非代理协议 if (bProxy) @@ -116,19 +116,19 @@ BOOL XEngine_TunnelTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, in else { //非代理协议直接发送数据,客户端->代理服务->服务器 - XClient_TCPSelect_SendEx(xhTunnelClient, st_ProxyClient.xhClient, lpszMsgBuffer, &nMsgLen); + XClient_TCPSelect_SendEx(xhTunnelClient, st_ProxyClient.xhClient, lpszMsgBuffer, nMsgLen); } - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Tunnel客户端:%s,创建隧道代理服务成功,连接到服务器:%s:%d,代理模式:%s"), lpszClientAddr, tszConnectAddr, nIPPort, bProxy ? "代理" : "直连"); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Tunnel客户端:%s,创建隧道代理服务成功,连接到服务器:%s:%d,代理模式:%s"), lpszClientAddr, tszConnectAddr, nIPPort, bProxy ? "代理" : "直连"); } else { //转发数据 - XClient_TCPSelect_SendEx(xhTunnelClient, st_ProxyClient.xhClient, lpszMsgBuffer, &nMsgLen); + XClient_TCPSelect_SendEx(xhTunnelClient, st_ProxyClient.xhClient, lpszMsgBuffer, nMsgLen); } - return TRUE; + return true; } -void CALLBACK XEngine_Tunnel_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, SOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCSTR lpszMsgBuffer, int nLen, LPVOID lParam) +void CALLBACK XEngine_Tunnel_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, XSOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCXSTR lpszMsgBuffer, int nLen, XPVOID lParam) { int nListCount = 0; PROXYPROTOCOL_CLIENTINFO** ppSt_ClientList; @@ -148,7 +148,7 @@ void CALLBACK XEngine_Tunnel_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, SOCKET { //退出处理 SocketOpt_HeartBeat_ForceOutAddrEx(xhTunnelHeart, ppSt_ClientList[i]->tszIPAddr); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _T("Tunnel客户端:%s,离开服务器,客户端主动断开"), ppSt_ClientList[i]->tszIPAddr); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Tunnel客户端:%s,离开服务器,客户端主动断开"), ppSt_ClientList[i]->tszIPAddr); } break; } diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.h b/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.h index fd8b66d41ed7aa292d11deb5b1a49c525a07928c..6b84db1cb9c960b6b3b37edfa6997025c2658a4b 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.h @@ -11,5 +11,5 @@ // History: *********************************************************************/ //任务处理相关函数,处理包的内容 -BOOL XEngine_TunnelTask_Handle(LPCTSTR lpszClientAddr, LPCTSTR lpszMsgBuffer, int nMsgLen); -void CALLBACK XEngine_Tunnel_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, SOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCSTR lpszMsgBuffer, int nLen, LPVOID lParam); \ No newline at end of file +bool XEngine_TunnelTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int nMsgLen); +void CALLBACK XEngine_Tunnel_CBRecv(XHANDLE xhToken, XNETHANDLE xhClient, XSOCKET hSocket, ENUM_NETCLIENT_TCPEVENTS enTCPClientEvents, LPCXSTR lpszMsgBuffer, int nLen, XPVOID lParam); \ No newline at end of file diff --git a/XEngine_Source/XEngine_ThirdPart/jsoncpp/Makefile b/XEngine_Source/XEngine_ThirdPart/jsoncpp/Makefile index 9302ec2d3afdae1d1419fc94d18406be75e36113..39af933f1d734cf10ea5cee4be99b9aa2d3f3d65 100644 --- a/XEngine_Source/XEngine_ThirdPart/jsoncpp/Makefile +++ b/XEngine_Source/XEngine_ThirdPart/jsoncpp/Makefile @@ -1,52 +1,66 @@ CC = g++ -Wall -std=c++17 -fPIC -SHAREFLAG = -shared -SHAREDLL = so +PLATFORM = linux +PLATVER = +PLATDIR = +FILEEXT = +LIBFLAG = RELEASE = 0 UNICODE = 0 -INCLUDE = -I ./ -FILECENTOS = /etc/redhat-release -LOADBIN = +LOADHDR = -I ./ +LOADSO = -L LIB = -LIBEX = -ldl -lpthread -LOADSO = -Wl,-rpath= -LIBINCLUDE = json_reader.o json_value.o json_writer.o - -ifeq ($(shell uname),Darwin) - SHAREDLL = dylib - SHAREFLAG = -dynamiclib - LOADSO = -else - SHAREDLL = so - SHAREFLAG = -shared -endif +LIBEX = +OBJECTS = json_reader.o json_value.o json_writer.o ifeq ($(RELEASE),1) -FLAGS = -c -O2 -DEBUG = +FLAGS = -c +DEBUG = else -FLAGS = -c -DEBUG = -g +FLAGS = -c -lc_p +DEBUG = -g -pg endif ifeq ($(UNICODE),1) UNICODE = -D _UNICODE else -UNICODE = +UNICODE = +endif + +ifeq ($(PLATFORM),linux) + ifeq (/etc/redhat-release,$(wildcard /etc/redhat-release)) + PLATVER = -D __CENTOS__ + PLATDIR = XEngine_Linux/Centos + else + PLATVER = -D __UBUNTU__ + PLATDIR = XEngine_Linux/Ubuntu + endif + FILEEXT = so + LIBFLAG = -shared + LIBEX = -lpthread -lrt -ldl + LOADBIN = -Wl,-rpath=./,--disable-new-dtags +else ifeq ($(PLATFORM),mac) + CC += -Wno-deprecated-declarations + PLATVER = -D __MACOS__ + PLATDIR = XEngine_Mac + FILEEXT = dylib + LIBFLAG = -dynamiclib + LIBEX = -lpthread -ldl + LOADBIN = -Wl,-rpath,@loader_path/./ endif -all:$(LIBINCLUDE) - $(CC) $(DEBUG) $(LIBINCLUDE) -o libjsoncpp.$(SHAREDLL) $(SHAREFLAG) -fPIC $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO) +all:$(OBJECTS) + $(CC) $(DEBUG) $(OBJECTS) -o libjsoncpp.$(FILEEXT) $(LIBFLAG) $(LIB) $(LIBEX) $(LOADSO) $(LOADBIN) json_reader.o:json_reader.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) json_reader.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) json_reader.cpp json_value.o:json_value.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) json_value.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) json_value.cpp json_writer.o:json_writer.cpp - $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(INCLUDE) json_writer.cpp + $(CC) $(DEBUG) $(FLAGS) $(UNICODE) $(PLATVER) $(LOADHDR) json_writer.cpp InstallAll:InstallSo -InstallSo:./libjsoncpp.$(SHAREDLL) - cp ./libjsoncpp.$(SHAREDLL) ../../../XEngine_Release/libjsoncpp.$(SHAREDLL) +InstallSo:./libjsoncpp.$(FILEEXT) + cp ./libjsoncpp.$(FILEEXT) ../../../XEngine_Release/libjsoncpp.$(FILEEXT) @@ -54,4 +68,4 @@ CleanAll:CleanObj CleanMk CleanObj: rm *.o CleanMk: - rm *.$(SHAREDLL) + rm *.$(FILEEXT)