diff --git a/CHANGELOG b/CHANGELOG index 92ae9c0d3c8d40fa96d8ace3dd3688cf49427082..fa4ac7d44fdaafb29db7c1fb13f68d3c78d9c6bf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,25 @@ +XEngine_ProxyServer V1.7.0.1001 + +增加:转发协议支持用户验证了 +修改:用户验证从本地用户验证修改为http用户验证 +修改:http转发包协议现在有code和msg字段了 +修改:ModuleSession_Forward_Get是否登录处理 +修改:转发列表和绑定协议错误处理方法 +修改:转发协议请求必须登录了 +修正:套接字验证类型不正确 +删除:SOCKS和TUNNEL代理启动参数支持 +删除:解绑协议支持,因为不会被使用到 + +added:forward user verifacation supported +modify:user verifacation modify to http pass from local user +modify:http forward packet protocol have code and msg field +modify:ModuleSession_Forward_Get supported addr whether login +modify:forward list and bind protocol error process way +modify:forward must be login now +fixed:socks ver type is incorrent +delete:socks and tunnel start parament supported +delete:unbind protocol,because that does not work +====================================================================================== XEngine_ProxyServer V1.6.0.1001 增加:数据转发解绑协议支持 diff --git a/README.en.md b/README.en.md index 8be2a81bd0826f27f7e7797a62f40b327040ff59..d47bbe50150e02597218a7d871c27825a4fefdad 100644 --- a/README.en.md +++ b/README.en.md @@ -14,7 +14,7 @@ This software is a standard proxy server that supports Socks5 and HTTP tunnel pr this software support following features 1. SOCKS5 proxy 2. Tunnel proxy -3. forward proxy +3. TCP forward proxy 4. support Permission Validation 5. operator log 6. encrypt Communication(planning) diff --git a/README.md b/README.md index e58d7716f7b6abfeb4e7a04b9ad488e64d6948c5..060435cee81746314a0e646638ee1bc76b40f01a 100644 --- a/README.md +++ b/README.md @@ -12,15 +12,15 @@ c c++ Socks5 Proxy Service,HTTP Tunnel Proxy Service,tcp forward service 此软件是一款标准的代理服务器,支持Socks5和HTTP的隧道代理 ## 软件特性 此软件支持以下特性 -1. SOCKS5代理 -2. Tunnel代理 -3. 数据转发服务 -4. 权限验证 +1. SOCKS5代理 +2. Tunnel代理 +3. TCP数据转发服务 +4. 权限验证 5. 操作日志 -6. 加密通信(planning) -7. 负载均衡(planning) -8. 自定义证书代理协议(planning) -9. 多级代理(planning) +6. 加密通信(planning) +7. 负载均衡(planning) +8. 自定义证书代理协议(planning) +9. 多级代理(planning) ## 安装教程 @@ -87,11 +87,11 @@ make FLAGS=CleanAll 清理编译 ## 开发计划 透传代理 -转发代理支持权限和确认 支持加密代理 转发代理绑定解绑支持附加用户信息 转发代理绑定支持拒绝 -转发代理支持用户验证 +支持UDP转发代理 +性能优化 ## 关注我们 如果你觉得这个软件对你有帮助,请你给我们一个START吧 diff --git a/XEngine_Docment/Docment_en.docx b/XEngine_Docment/Docment_en.docx index 0dc825f93a36bb7143147f78b555a35295ae2487..591a1c3e26cba6b0ce2001894a0fe0d21d0c96ea 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 b2ddcc719bf3611707e64aff380f2f5ef180e831..bfb532b007a916dc70baaae4c7475989d2920085 100644 Binary files a/XEngine_Docment/Docment_zh.docx and b/XEngine_Docment/Docment_zh.docx differ diff --git a/XEngine_Release/XEngine_Config/UserList.txt b/XEngine_Release/XEngine_Config/UserList.txt deleted file mode 100644 index bc05bbb93ea00858cc22c4cbb1803f44cadce2c5..0000000000000000000000000000000000000000 --- a/XEngine_Release/XEngine_Config/UserList.txt +++ /dev/null @@ -1,2 +0,0 @@ -123123aa 123123 -aaadddaa 123123 \ No newline at end of file diff --git a/XEngine_Release/XEngine_Config/XEngine_Config.json b/XEngine_Release/XEngine_Config/XEngine_Config.json index 353d57e9e79267fcf5338096419aa964e76e9c27..f574ab4860f7aa24883c37049ed9b6a156e8540b 100644 --- a/XEngine_Release/XEngine_Config/XEngine_Config.json +++ b/XEngine_Release/XEngine_Config/XEngine_Config.json @@ -23,10 +23,11 @@ "tszLogFile": "./XEngine_Log/XEngine_ProxyServiceApp.log" }, "XAuth": { - "bAuth": 0, - "tszAuthFile": "./XEngine_Config/UserList.txt" + "bAuth": false, + "tszAuthUrl": "" }, "XVer": [ + "1.7.0.1001 Build20240104", "1.6.0.1001 Build20230817", "1.5.1.1001 Build20230426", "1.5.0.1001 Build20230202", diff --git a/XEngine_Source/Makefile b/XEngine_Source/Makefile index becd2dedfe51abd6be68d6998d5f1f379b0e0b2b..83bf2d9597b61d1a34a5a2ca940c98cc8ffe9780 100644 --- a/XEngine_Source/Makefile +++ b/XEngine_Source/Makefile @@ -4,14 +4,12 @@ PLATFORM=linux FLAGS= #要编译的模块 THIRDPART_MODULE_JSONCPP = ./XEngine_ThirdPart/jsoncpp - MODULE_CONFIGURE_PATH = ./XEngine_ModuleConfigure -MODULE_AUTHORIZE_PATH = ./XEngine_ModuleAuthorize MODULE_PROTOCOL_PATH = ./XEngine_ModuleProtocol MODULE_SESSION_PATH = ./XEngine_ModuleSession APP_SERVICE_PATH = ./XEngine_ServiceApp -XENGINE_MODULES = libjsoncpp.so libXEngine_ModuleConfigure.so libXEngine_ModuleAuthorize.so libXEngine_ModuleProtocol.so libXEngine_ModuleSession.so XEngine_ServiceApp.exe +XENGINE_MODULES = libjsoncpp.so libXEngine_ModuleConfigure.so libXEngine_ModuleProtocol.so libXEngine_ModuleSession.so XEngine_ServiceApp.exe .PHONY:MakeAll MakeAll:$(XENGINE_MODULES) @@ -21,8 +19,6 @@ libjsoncpp.so: libXEngine_ModuleConfigure.so: make -C $(MODULE_CONFIGURE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) -libXEngine_ModuleAuthorize.so: - make -C $(MODULE_AUTHORIZE_PATH) PLATFORM=$(PLATFORM) $(FLAGS) libXEngine_ModuleProtocol.so: make -C $(MODULE_PROTOCOL_PATH) PLATFORM=$(PLATFORM) $(FLAGS) libXEngine_ModuleSession.so: diff --git a/XEngine_Source/VSCopy-Debug.bat b/XEngine_Source/VSCopy-Debug.bat index 7fc034a94b4c0f9831b0bc39d0d5c2e076c9072d..1a62942908f3ddaae3102075349c0813b1369522 100644 --- a/XEngine_Source/VSCopy-Debug.bat +++ b/XEngine_Source/VSCopy-Debug.bat @@ -6,11 +6,11 @@ copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_ManagePool.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_NetXApi.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\NetHelp_APIHelp.dll" "./" +copy /y "D:\XEngine\XEngine_SourceCode\Debug\NetHelp_APIClient.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XClient_Socket.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\HelpComponents_XLog.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\HelpComponents_Packets.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\RfcComponents_ProxyProtocol.dll" "./" -copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_ProcFile.dll" "./" copy /y "D:\XEngine\XEngine_SourceCode\Debug\XEngine_SystemApi.dll" "./" \ No newline at end of file diff --git a/XEngine_Source/VSCopy-x64.bat b/XEngine_Source/VSCopy-x64.bat index b74c70f93848c89a247537ec9e734d6dd3fa8a0a..7f1b6bc5091b0dd5850c0ff53b41d15d48e5eecb 100644 --- a/XEngine_Source/VSCopy-x64.bat +++ b/XEngine_Source/VSCopy-x64.bat @@ -1,19 +1,16 @@ -copy /y "%XEngine_Lib64%\x64\XEngine_BaseLib\XEngine_BaseLib.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_BaseLib\XEngine_Algorithm.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_Core\XEngine_Core.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_Core\XEngine_OPenSsl.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_Core\XEngine_ManagePool.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_Core\XEngine_NetXApi.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_BaseLib.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_BaseLib\XEngine_Algorithm.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_Core.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_OPenSsl.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_ManagePool.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Core\XEngine_NetXApi.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_NetHelp\NetHelp_APIHelp.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_Client\XClient_Socket.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_NetHelp\NetHelp_APIHelp.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_NetHelp\NetHelp_APIClient.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_Client\XClient_Socket.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_HelpComponents\HelpComponents_XLog.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_HelpComponents\HelpComponents_Packets.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_RfcComponents\RfcComponents_ProxyProtocol.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_HelpComponents\HelpComponents_XLog.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_HelpComponents\HelpComponents_Packets.dll" "./" +copy /y "%XEngine_Lib64%\XEngine_RfcComponents\RfcComponents_ProxyProtocol.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_SystemSdk\XEngine_ProcFile.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_SystemSdk\XEngine_SystemApi.dll" "./" - -copy /y "%XEngine_Lib64%\x64\XEngine_LibEx\libcrypto-3-x64.dll" "./" -copy /y "%XEngine_Lib64%\x64\XEngine_LibEx\libssl-3-x64.dll" "./" \ No newline at end of file +copy /y "%XEngine_Lib64%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./" \ No newline at end of file diff --git a/XEngine_Source/VSCopy-x86.bat b/XEngine_Source/VSCopy-x86.bat index 28d01c6e0ef245f5ff910c250f19b3350b96e29c..b1d669169464c8897fc4b7eaf3b7a9b51b220514 100644 --- a/XEngine_Source/VSCopy-x86.bat +++ b/XEngine_Source/VSCopy-x86.bat @@ -6,14 +6,11 @@ copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_ManagePool.dll" "./" copy /y "%XEngine_Lib32%\XEngine_Core\XEngine_NetXApi.dll" "./" copy /y "%XEngine_Lib32%\XEngine_NetHelp\NetHelp_APIHelp.dll" "./" +copy /y "%XEngine_Lib32%\XEngine_NetHelp\NetHelp_APIClient.dll" "./" copy /y "%XEngine_Lib32%\XEngine_Client\XClient_Socket.dll" "./" copy /y "%XEngine_Lib32%\XEngine_HelpComponents\HelpComponents_XLog.dll" "./" copy /y "%XEngine_Lib32%\XEngine_HelpComponents\HelpComponents_Packets.dll" "./" copy /y "%XEngine_Lib32%\XEngine_RfcComponents\RfcComponents_ProxyProtocol.dll" "./" -copy /y "%XEngine_Lib32%\XEngine_SystemSdk\XEngine_ProcFile.dll" "./" -copy /y "%XEngine_Lib32%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./" - -copy /y "%XEngine_Lib32%\XEngine_LibEx\libcrypto-3.dll" "./" -copy /y "%XEngine_Lib32%\XEngine_LibEx\libssl-3.dll" "./" \ No newline at end of file +copy /y "%XEngine_Lib32%\XEngine_SystemSdk\XEngine_SystemApi.dll" "./" \ No newline at end of file diff --git a/XEngine_Source/XEngine.sln b/XEngine_Source/XEngine.sln index 02c92cb45a9b5e8b39d7a87da7f8829697aa9702..bbf18d247c95bebdd5f0cf77c13b0cd2005fde00 100644 --- a/XEngine_Source/XEngine.sln +++ b/XEngine_Source/XEngine.sln @@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "XEngine_UserHdr", "XEngine_ XEngine_UserProtocol.h = XEngine_UserProtocol.h EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XEngine_ModuleAuthorize", "XEngine_ModuleAuthorize\XEngine_ModuleAuthorize.vcxproj", "{58026DC2-5383-490C-9BB4-BF3152192F0C}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "XEngine_ThirdPart", "XEngine_ThirdPart", "{F18FFEA0-27D2-4590-9190-F69F5E3D21D2}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "jsoncpp", "XEngine_ThirdPart\jsoncpp\jsoncpp.vcxproj", "{F1736B3F-03A2-4FC7-B045-A12BA8D724FB}" @@ -46,14 +44,6 @@ Global {F54F152C-594F-4465-A44E-2DB915B39760}.Release|x64.Build.0 = Release|x64 {F54F152C-594F-4465-A44E-2DB915B39760}.Release|x86.ActiveCfg = Release|Win32 {F54F152C-594F-4465-A44E-2DB915B39760}.Release|x86.Build.0 = Release|Win32 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Debug|x64.ActiveCfg = Debug|x64 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Debug|x64.Build.0 = Debug|x64 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Debug|x86.ActiveCfg = Debug|Win32 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Debug|x86.Build.0 = Debug|Win32 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Release|x64.ActiveCfg = Release|x64 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Release|x64.Build.0 = Release|x64 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Release|x86.ActiveCfg = Release|Win32 - {58026DC2-5383-490C-9BB4-BF3152192F0C}.Release|x86.Build.0 = Release|Win32 {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}.Debug|x64.ActiveCfg = Debug|x64 {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}.Debug|x64.Build.0 = Debug|x64 {F1736B3F-03A2-4FC7-B045-A12BA8D724FB}.Debug|x86.ActiveCfg = Debug|Win32 diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h index d535a6b28303d0d86feb7e92322d79b8ffe9ce6c..a685e9b3395e7547c89d800d0316529f634adbf6 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfig_Define.h @@ -43,8 +43,8 @@ typedef struct tag_XEngine_ServiceConfig }st_XLog; struct { - int bAuth; //是否启用验证,大于0启用 - XCHAR tszAuthFile[MAX_PATH]; //验证地址 + bool bAuth; //是否启用验证 + XCHAR tszAuthUrl[MAX_PATH]; //验证地址 }st_XAuth; struct { diff --git a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp index b6ad44e4ac75621b62544e90c6f9df445408505b..20b3af05796ec5a2740850d4dd1d91d4df614ce2 100644 --- a/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp +++ b/XEngine_Source/XEngine_ModuleConfigure/ModuleConfigure_Json/ModuleConfigure_Json.cpp @@ -130,8 +130,8 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE return false; } Json::Value st_JsonXAuth = st_JsonRoot["XAuth"]; - pSt_ServerConfig->st_XAuth.bAuth = st_JsonXAuth["bAuth"].asInt(); - _tcsxcpy(pSt_ServerConfig->st_XAuth.tszAuthFile, st_JsonXAuth["tszAuthFile"].asCString()); + pSt_ServerConfig->st_XAuth.bAuth = st_JsonXAuth["bAuth"].asBool(); + _tcsxcpy(pSt_ServerConfig->st_XAuth.tszAuthUrl, st_JsonXAuth["tszAuthUrl"].asCString()); if (st_JsonRoot["XVer"].empty()) { diff --git a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h index 1050015047fc8871716a3946f067e0f64242cbc6..d716a14cebe7504a90a27be43e7dd1b885a8ec26 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Define.h @@ -51,6 +51,35 @@ extern "C" XLONG ModuleProtocol_GetLastError(int* pInt_SysError = NULL); 备注: *********************************************************************/ extern "C" bool ModuleProtocol_Packet_ForwardList(XCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, SESSION_FORWARD * **pppSt_ListUser, int nCount); +/******************************************************************** +函数名称:ModuleProtocol_Packet_Auth +函数功能:验证信息打包 + 参数.一:ptszMsgBuffer + In/Out:Out + 类型:字符指针 + 可空:N + 意思:输出封装好的包 + 参数.二:pInt_Len + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出封装大小 + 参数.三:lpszUser + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入用户名 + 参数.四:lpszPass + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入密码 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +extern "C" bool ModuleProtocol_Packet_Auth(XCHAR* ptszMsgBuffer, int* pInt_Len, LPCXSTR lpszUser, LPCXSTR lpszPass); /************************************************************************/ /* 解析导出函数 */ /************************************************************************/ diff --git a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp index cfa60ff1d026770487798ff8340fbc1a54005ff3..fd90d5175887bf55d5ae6fce29231a812fff6a0f 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.cpp @@ -85,6 +85,8 @@ bool CModuleProtocol_Packet::ModuleProtocol_Packet_ForwardList(XCHAR* ptszMsgBuf st_JsonObject["st_UserAuth"] = st_JsonSub; st_JsonArray.append(st_JsonObject); } + st_JsonRoot["code"] = 0; + st_JsonRoot["msg"] = "success"; st_JsonRoot["Count"] = nCount; st_JsonRoot["Array"] = st_JsonArray; @@ -94,4 +96,53 @@ bool CModuleProtocol_Packet::ModuleProtocol_Packet_ForwardList(XCHAR* ptszMsgBuf memcpy(ptszMsgBuffer, pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR)); memcpy(ptszMsgBuffer + sizeof(XENGINE_PROTOCOLHDR), st_JsonRoot.toStyledString().c_str(), pSt_ProtocolHdr->unPacketSize); return true; +} +/******************************************************************** +函数名称:ModuleProtocol_Packet_Auth +函数功能:验证信息打包 + 参数.一:ptszMsgBuffer + In/Out:Out + 类型:字符指针 + 可空:N + 意思:输出封装好的包 + 参数.二:pInt_Len + In/Out:Out + 类型:整数型指针 + 可空:N + 意思:输出封装大小 + 参数.三:lpszUser + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入用户名 + 参数.四:lpszPass + In/Out:In + 类型:常量字符指针 + 可空:N + 意思:输入密码 +返回值 + 类型:逻辑型 + 意思:是否成功 +备注: +*********************************************************************/ +bool CModuleProtocol_Packet::ModuleProtocol_Packet_Auth(XCHAR* ptszMsgBuffer, int* pInt_Len, LPCXSTR lpszUser, LPCXSTR lpszPass) +{ + Protocol_IsErrorOccur = false; + + if ((NULL == ptszMsgBuffer) || (NULL == pInt_Len)) + { + Protocol_IsErrorOccur = true; + Protocol_dwErrorCode = ERROR_MODULE_PROTOCOL_PACKET_PARAMENT; + return false; + } + Json::Value st_JsonRoot; + + st_JsonRoot["code"] = 0; + st_JsonRoot["msg"] = "success"; + st_JsonRoot["lpszUser"] = lpszUser; + st_JsonRoot["lpszPass"] = lpszPass; + + *pInt_Len = st_JsonRoot.toStyledString().length(); + memcpy(ptszMsgBuffer, st_JsonRoot.toStyledString().c_str(), *pInt_Len); + 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 4367f0e655a70fdbfb2fa2aa3a6d243800d10187..81a275c903cfb4317feb4889b009e946afeac061 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h +++ b/XEngine_Source/XEngine_ModuleProtocol/ModuleProtocol_Packet/ModuleProtocol_Packet.h @@ -18,5 +18,6 @@ public: ~CModuleProtocol_Packet(); public: bool ModuleProtocol_Packet_ForwardList(XCHAR* ptszMsgBuffer, int* pInt_Len, XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, SESSION_FORWARD*** pppSt_ListUser, int nCount); + bool ModuleProtocol_Packet_Auth(XCHAR* ptszMsgBuffer, int* pInt_Len, LPCXSTR lpszUser, LPCXSTR lpszPass); private: }; \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.def b/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.def index 5d5832cdda29b48119d4a928614a2ce440a21006..0e2159f7a2f4a424302cef51f3b92b32ee9372fb 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.def +++ b/XEngine_Source/XEngine_ModuleProtocol/XEngine_ModuleProtocol.def @@ -4,5 +4,6 @@ EXPORTS ModuleProtocol_GetLastError ModuleProtocol_Packet_ForwardList + ModuleProtocol_Packet_Auth ModuleProtocol_Parse_ForwardBind \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleProtocol/pch.cpp b/XEngine_Source/XEngine_ModuleProtocol/pch.cpp index 0a6fc70cd68809eddbda8158d40b9d861ee1d38b..743ff5240c972f72d1f8d1b766a8b954d3d0198f 100644 --- a/XEngine_Source/XEngine_ModuleProtocol/pch.cpp +++ b/XEngine_Source/XEngine_ModuleProtocol/pch.cpp @@ -35,6 +35,10 @@ extern "C" bool ModuleProtocol_Packet_ForwardList(XCHAR * ptszMsgBuffer, int* pI { return m_ProtocolPacket.ModuleProtocol_Packet_ForwardList(ptszMsgBuffer, pInt_Len, pSt_ProtocolHdr, pppSt_ListUser, nCount); } +extern "C" bool ModuleProtocol_Packet_Auth(XCHAR * ptszMsgBuffer, int* pInt_Len, LPCXSTR lpszUser, LPCXSTR lpszPass) +{ + return m_ProtocolPacket.ModuleProtocol_Packet_Auth(ptszMsgBuffer, pInt_Len, lpszUser, lpszPass); +} /************************************************************************/ /* 解析导出函数 */ /************************************************************************/ diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h index 569cf44b265694f4a197d245fa615b9bd5cf9529..836054d05c6cff2ece8345467f595fd23e5e35fd 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Define.h @@ -87,25 +87,6 @@ extern "C" bool ModuleSession_Forward_List(SESSION_FORWARD * **pppSt_ListUser, i *********************************************************************/ extern "C" bool ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr); /******************************************************************** -函数名称:ModuleSession_Forward_UNBind -函数功能:解除绑定转发需求 - 参数.一:lpszSrcAddr - In/Out:In - 类型:常量字符指针 - 可空:N - 意思:输入绑定的原始地址 - 参数.二:lpszDstAddr - In/Out:In - 类型:常量字符指针 - 可空:N - 意思:输出绑定的目标地址 -返回值 - 类型:逻辑型 - 意思:是否成功 -备注: -*********************************************************************/ -extern "C" bool ModuleSession_Forward_UNBind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr); -/******************************************************************** 函数名称:ModuleSession_Forward_Delete 函数功能:删除用户 参数.一:lpszAddr @@ -135,11 +116,11 @@ extern "C" bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR * ptszDstAd 参数.二:ptszDstAddr In/Out:Out 类型:字符指针 - 可空:N + 可空:Y 意思:输出对端地址 返回值 类型:逻辑型 意思:是否成功 备注: *********************************************************************/ -extern "C" bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr); \ No newline at end of file +extern "C" bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr = NULL); \ 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 d49c84bdda86c60eb304b77ca05ab9d451046eea..5da113894655cc4fbc9284d47469b0169d9eea5f 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.cpp +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.cpp @@ -186,54 +186,6 @@ bool CModuleSession_Forward::ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPC return true; } /******************************************************************** -函数名称:ModuleSession_Forward_UNBind -函数功能:解除绑定转发需求 - 参数.一:lpszSrcAddr - In/Out:In - 类型:常量字符指针 - 可空:N - 意思:输入绑定的原始地址 - 参数.二:lpszDstAddr - In/Out:In - 类型:常量字符指针 - 可空:N - 意思:输出绑定的目标地址 -返回值 - 类型:逻辑型 - 意思:是否成功 -备注: -*********************************************************************/ -bool CModuleSession_Forward::ModuleSession_Forward_UNBind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr) -{ - Session_IsErrorOccur = false; - - if ((NULL == lpszSrcAddr) || (NULL == lpszDstAddr)) - { - Session_IsErrorOccur = true; - Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_PARAMENT; - return false; - } - st_Locker.lock_shared(); - //查找 - auto stl_MapSrcIterator = stl_MapSession.find(lpszSrcAddr); - auto stl_MapDstIterator = stl_MapSession.find(lpszDstAddr); - if (stl_MapSrcIterator == stl_MapSession.end() || stl_MapDstIterator == stl_MapSession.end()) - { - Session_IsErrorOccur = true; - Session_dwErrorCode = ERROR_MODULE_SESSION_FORWARD_NOTFOUND; - st_Locker.unlock_shared(); - return false; - } - //解除双方绑定 - stl_MapSrcIterator->second.bForward = false; - memset(stl_MapSrcIterator->second.tszDstAddr, '\0', sizeof(stl_MapSrcIterator->second.tszDstAddr)); - - stl_MapDstIterator->second.bForward = false; - memset(stl_MapDstIterator->second.tszDstAddr, '\0', sizeof(stl_MapDstIterator->second.tszDstAddr)); - st_Locker.unlock_shared(); - return true; -} -/******************************************************************** 函数名称:ModuleSession_Forward_Delete 函数功能:删除用户 参数.一:lpszAddr @@ -301,7 +253,7 @@ bool CModuleSession_Forward::ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHA 参数.二:ptszDstAddr In/Out:Out 类型:字符指针 - 可空:N + 可空:Y 意思:输出对端地址 返回值 类型:逻辑型 @@ -328,6 +280,11 @@ bool CModuleSession_Forward::ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* st_Locker.unlock_shared(); return false; } + if (NULL == ptszDstAddr) + { + st_Locker.unlock_shared(); + return true; + } //如果有转发,需要清理对方的转发设置 if (!stl_MapIterator->second.bForward) { diff --git a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h index eb65cb0e522838068c9a6af513e1f7b7b318b590..dfc6b6821a666a325c30feec0c127770ad64987a 100644 --- a/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h +++ b/XEngine_Source/XEngine_ModuleSession/ModuleSession_Forward/ModuleSession_Forward.h @@ -20,9 +20,8 @@ public: bool ModuleSession_Forward_Insert(LPCXSTR lpszAddr, XENGINE_PROTOCOL_USERAUTH* pSt_UserAuth); bool ModuleSession_Forward_List(SESSION_FORWARD*** pppSt_ListUser, int* pInt_Count, LPCXSTR lpszAddr = NULL); bool ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr); - bool ModuleSession_Forward_UNBind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr); bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR* ptszDstAddr = NULL); - bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr); + bool ModuleSession_Forward_Get(LPCXSTR lpszAddr, XCHAR* ptszDstAddr = NULL); private: shared_mutex st_Locker; private: diff --git a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def index f04006375134c4a7506aaaeaea070137d2171948..9a8c8aca31f222a901793b62702d7b6a7dad1ae2 100644 --- a/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def +++ b/XEngine_Source/XEngine_ModuleSession/XEngine_ModuleSession.def @@ -6,6 +6,5 @@ EXPORTS ModuleSession_Forward_Insert ModuleSession_Forward_List ModuleSession_Forward_Bind - ModuleSession_Forward_UNBind ModuleSession_Forward_Delete ModuleSession_Forward_Get \ No newline at end of file diff --git a/XEngine_Source/XEngine_ModuleSession/pch.cpp b/XEngine_Source/XEngine_ModuleSession/pch.cpp index 68c76a32f3093b9ed51d0de1b678895d97e26ec6..c722b737c9d71bf3642c063c8fe3efd640dfc24a 100644 --- a/XEngine_Source/XEngine_ModuleSession/pch.cpp +++ b/XEngine_Source/XEngine_ModuleSession/pch.cpp @@ -41,10 +41,6 @@ extern "C" bool ModuleSession_Forward_Bind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstA { return m_Forward.ModuleSession_Forward_Bind(lpszSrcAddr, lpszDstAddr); } -extern "C" bool ModuleSession_Forward_UNBind(LPCXSTR lpszSrcAddr, LPCXSTR lpszDstAddr) -{ - return m_Forward.ModuleSession_Forward_UNBind(lpszSrcAddr, lpszDstAddr); -} extern "C" bool ModuleSession_Forward_Delete(LPCXSTR lpszAddr, XCHAR * ptszDstAddr) { return m_Forward.ModuleSession_Forward_Delete(lpszAddr, ptszDstAddr); diff --git a/XEngine_Source/XEngine_ServiceApp/Makefile b/XEngine_Source/XEngine_ServiceApp/Makefile index 49490ecb1c930bf667a6ec11015d7af801807572..2d1446ce03985d47698b0da318618184d372da46 100644 --- a/XEngine_Source/XEngine_ServiceApp/Makefile +++ b/XEngine_Source/XEngine_ServiceApp/Makefile @@ -6,10 +6,10 @@ RELEASE = 0 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_ModuleConfigure -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 \ - -lXEngine_ModuleConfigure -lXEngine_ModuleAuthorize -lXEngine_ModuleSession -lXEngine_ModuleProtocol \ +LIB = -lXEngine_BaseLib -lXEngine_Algorithm -lXEngine_Core -lXEngine_OPenSsl -lXEngine_ManagePool -lXEngine_NetXApi -lHelpComponents_XLog -lHelpComponents_Packets -lRfcComponents_ProxyProtocol -lXClient_Socket -lNetHelp_APIHelp -lNetHelp_APIClient \ + -lXEngine_ModuleConfigure -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 diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp index d230c5a54f001b51ab2b08f22736963e0d8db745..8279d834c9fbcbd00295270c5bad7ff30532ef6b 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Configure.cpp @@ -27,14 +27,6 @@ bool XEngine_Configure_Parament(int argc, char** argv, XENGINE_SERVICECONFIG* pS XEngine_Configure_Help(); return false; } - else if (0 == _tcsxcmp("-TP", argv[i])) - { - pSt_Configure->nSocksPort = _ttxoi(argv[i + 1]); - } - else if (0 == _tcsxcmp("-HP", argv[i])) - { - pSt_Configure->nTunnelPort = _ttxoi(argv[i + 1]); - } else if (0 == _tcsxcmp("-d", argv[i])) { pSt_Configure->bDeamon = _ttxoi(argv[i + 1]); @@ -55,8 +47,6 @@ void XEngine_Configure_Help() 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_ForwardTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp index 007394dd72e831947e2f7eec66373e8d3a87b58c..1602bcf9b1ac0dc996e3108b6e07813060ea43bc 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_ForwardTask.cpp @@ -56,7 +56,21 @@ bool XEngine_Forward_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n memset(&st_UserAuth, '\0', sizeof(XENGINE_PROTOCOL_USERAUTH)); memcpy(&st_UserAuth, lpszMsgBuffer, sizeof(XENGINE_PROTOCOL_USERAUTH)); - + //是否需要进行验证 + if (st_ServiceConfig.st_XAuth.bAuth) + { + int nHTTPCode = 0; + ModuleProtocol_Packet_Auth(tszSDBuffer, &nSDLen, st_UserAuth.tszUserName, st_UserAuth.tszUserPass); + if (!APIClient_Http_Request(_X("POST"), st_ServiceConfig.st_XAuth.tszAuthUrl, tszSDBuffer, &nHTTPCode)) + { + pSt_ProtocolHdr->wReserve = 401; + pSt_ProtocolHdr->unPacketSize = 0; + pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREP; + 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,密码:%s,验证失败无法继续."), lpszClientAddr, st_UserAuth.tszUserName, st_UserAuth.tszUserPass); + return false; + } + } pSt_ProtocolHdr->wReserve = 0; pSt_ProtocolHdr->unPacketSize = 0; pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREP; @@ -68,25 +82,29 @@ bool XEngine_Forward_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n //处理转发协议 if (ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_USER_FORWARD == pSt_ProtocolHdr->unOperatorType) { + if (!ModuleSession_Forward_Get(lpszClientAddr)) + { + pSt_ProtocolHdr->wReserve = 401; + pSt_ProtocolHdr->unPacketSize = 0; + pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREP; + 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,请求转发协议:%d 失败,因为没有登录"), lpszClientAddr, pSt_ProtocolHdr->unOperatorCode); + return false; + } + if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREQ == pSt_ProtocolHdr->unOperatorCode) { int nListCount = 0; SESSION_FORWARD** ppSt_ListUser; + pSt_ProtocolHdr->wReserve = 0; + pSt_ProtocolHdr->unPacketSize = 0; pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREP; - if (ModuleSession_Forward_List(&ppSt_ListUser, &nListCount, lpszClientAddr)) - { - ModuleProtocol_Packet_ForwardList(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, &ppSt_ListUser, nListCount); - BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListUser, nListCount); - XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,请求可用转发列表成功"), lpszClientAddr); - } - else - { - pSt_ProtocolHdr->unPacketSize = 0; - 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()); - } + ModuleSession_Forward_List(&ppSt_ListUser, &nListCount, lpszClientAddr); + ModuleProtocol_Packet_ForwardList(tszSDBuffer, &nSDLen, pSt_ProtocolHdr, &ppSt_ListUser, nListCount); + BaseLib_OperatorMemory_Free((XPPPMEM)&ppSt_ListUser, nListCount); + XEngine_Network_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_CLIENT_NETTYPE_FORWARD); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("Forward客户端:%s,请求可用转发列表成功"), lpszClientAddr); } else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREQ == pSt_ProtocolHdr->unOperatorCode) { @@ -99,7 +117,7 @@ bool XEngine_Forward_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n ModuleProtocol_Parse_ForwardBind(lpszMsgBuffer, nMsgLen, tszSrcAddr, tszDstAddr); if (!ModuleSession_Forward_Bind(lpszClientAddr, tszDstAddr)) { - pSt_ProtocolHdr->wReserve = 401; + pSt_ProtocolHdr->wReserve = 404; pSt_ProtocolHdr->unPacketSize = 0; pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREP; XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); @@ -115,38 +133,6 @@ bool XEngine_Forward_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int n 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); } - else if (XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_UNREQ == pSt_ProtocolHdr->unOperatorCode) - { - XCHAR tszDstAddr[128]; - memset(tszDstAddr, '\0', sizeof(tszDstAddr)); - - if (!ModuleSession_Forward_Get(lpszClientAddr, tszDstAddr)) - { - pSt_ProtocolHdr->wReserve = 411; - pSt_ProtocolHdr->unPacketSize = 0; - pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_UNREP; - XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Forward客户端:%s,请求解绑失败,错误:%lX"), lpszClientAddr, ModuleSession_GetLastError()); - return false; - } - if (!ModuleSession_Forward_UNBind(lpszClientAddr, tszDstAddr)) - { - pSt_ProtocolHdr->wReserve = 411; - pSt_ProtocolHdr->unPacketSize = 0; - pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_UNREP; - XEngine_Network_Send(lpszClientAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); - XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Forward客户端:%s,请求解绑失败,解除绑定的地址:%s,错误:%lX"), lpszClientAddr, tszDstAddr, ModuleSession_GetLastError()); - return false; - } - //先告知对方要转发数据 - pSt_ProtocolHdr->wReserve = 0; - pSt_ProtocolHdr->unPacketSize = 0; - XEngine_Network_Send(tszDstAddr, (LPCXSTR)pSt_ProtocolHdr, sizeof(XENGINE_PROTOCOLHDR), XENGINE_CLIENT_NETTYPE_FORWARD); - //最后返回结果 - pSt_ProtocolHdr->unOperatorCode = XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_UNREP; - 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; diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h b/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h index aabbc6c237f41453f5b9d893dc3f462e07a7f1df..935b2bf3993d11e0e5ad1f8766b62740d5e088dd 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_Hdr.h @@ -36,6 +36,8 @@ using namespace std; #include #include #include +#include +#include #include #include #include @@ -48,8 +50,6 @@ using namespace std; #include "../XEngine_UserProtocol.h" #include "../XEngine_ModuleConfigure/ModuleConfig_Define.h" #include "../XEngine_ModuleConfigure/ModuleConfig_Error.h" -#include "../XEngine_ModuleAuthorize/ModuleAuth_Define.h" -#include "../XEngine_ModuleAuthorize/ModuleAuth_Error.h" #include "../XEngine_ModuleSession/ModuleSession_Define.h" #include "../XEngine_ModuleSession/ModuleSession_Error.h" #include "../XEngine_ModuleProtocol/ModuleProtocol_Define.h" @@ -110,24 +110,20 @@ typedef struct #ifdef _WIN64 #ifdef _DEBUG #pragma comment(lib,"../x64/Debug/XEngine_ModuleConfigure.lib") -#pragma comment(lib,"../x64/Debug/XEngine_ModuleAuthorize.lib") #pragma comment(lib,"../x64/Debug/XEngine_ModuleSession.lib") #pragma comment(lib,"../x64/Debug/XEngine_ModuleProtocol.lib") #else #pragma comment(lib,"../x64/Release/XEngine_ModuleConfigure.lib") -#pragma comment(lib,"../x64/Release/XEngine_ModuleAuthorize.lib") #pragma comment(lib,"../x64/Release/XEngine_ModuleSession.lib") #pragma comment(lib,"../x64/Release/XEngine_ModuleProtocol.lib") #endif #else #ifdef _DEBUG #pragma comment(lib,"../Debug/XEngine_ModuleConfigure.lib") -#pragma comment(lib,"../Debug/XEngine_ModuleAuthorize.lib") #pragma comment(lib,"../Debug/XEngine_ModuleSession.lib") #pragma comment(lib,"../Debug/XEngine_ModuleProtocol.lib") #else #pragma comment(lib,"../Release/XEngine_ModuleConfigure.lib") -#pragma comment(lib,"../Release/XEngine_ModuleAuthorize.lib") #pragma comment(lib,"../Release/XEngine_ModuleSession.lib") #pragma comment(lib,"../Release/XEngine_ModuleProtocol.lib") #endif @@ -138,6 +134,7 @@ typedef struct #pragma comment(lib,"XEngine_Core/XEngine_OPenSsl.lib") #pragma comment(lib,"XEngine_Core/XEngine_NetXApi.lib") #pragma comment(lib,"XEngine_NetHelp/NetHelp_APIHelp.lib") +#pragma comment(lib,"XEngine_NetHelp/NetHelp_APIClient.lib") #pragma comment(lib,"XEngine_HelpComponents/HelpComponents_XLog.lib") #pragma comment(lib,"XEngine_HelpComponents/HelpComponents_Packets.lib") #pragma comment(lib,"XEngine_RfcComponents/RfcComponents_ProxyProtocol.lib") diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp index e22895e26eca4218c5f3cd57e52d4776aa8147d1..f4cb21eed5be400b3d0f8e5d6c472f5ce48af702 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_ServiceApp.cpp @@ -39,7 +39,6 @@ void ServiceApp_Stop(int signo) ManagePool_Thread_NQDestroy(xhForwardPool); //销毁日志资源 HelpComponents_XLog_Destroy(xhLog); - ModuleAuthorize_User_Destory(); } #ifdef _WINDOWS WSACleanup(); @@ -117,14 +116,9 @@ 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, _X("启动服务中,初始化日志系统成功")); - if (st_ServiceConfig.st_XAuth.bAuth >0) + if (st_ServiceConfig.st_XAuth.bAuth) { - if (!ModuleAuthorize_User_Init(st_ServiceConfig.st_XAuth.tszAuthFile)) - { - 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, _X("启动服务中,启用用户验证服务,用户列表地址:%s"), st_ServiceConfig.st_XAuth.tszAuthFile); + XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,启用用户验证服务,用户验证地址:%s"), st_ServiceConfig.st_XAuth.tszAuthUrl); } else { @@ -299,7 +293,6 @@ XENGINE_SERVICEAPP_EXIT: ManagePool_Thread_NQDestroy(xhForwardPool); //销毁日志资源 HelpComponents_XLog_Destroy(xhLog); - ModuleAuthorize_User_Destory(); } #ifdef _MSC_BUILD WSACleanup(); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp index 2d36f140fc9b461af1b153864d7160e958935352..2e4a37bbb4482021bafe52ff383c6d1829925fa9 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_SocksTask.cpp @@ -48,7 +48,7 @@ bool XEngine_SocksTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int _tcsxcat(tszAuthBuffer, tszTmpBuffer); _tcsxcat(tszAuthBuffer, _X(" ")); //服务器是否支持 - if (st_ServiceConfig.st_XAuth.bAuth == enListAuths[i]) + if ((ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH_USERPASS == enListAuths[i]) || (ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH_ANONYMOUS == enListAuths[i])) { bFoundAuth = true; } @@ -86,14 +86,16 @@ bool XEngine_SocksTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int 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) + if (enProxyAuth != ENUM_RFCCOMPONENTS_PROXYSOCKS_AUTH_USERPASS) { 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, _X("SOCKS客户端:%s,用户登录验证失败,客户端发送的验证类型不支持"), lpszClientAddr); return false; } - if (!ModuleAuthorize_User_Exist(tszUserName, tszUserPass)) + int nHTTPCode = 0; + ModuleProtocol_Packet_Auth(tszMsgBuffer, &nLen, tszUserName, tszUserPass); + if (!APIClient_Http_Request(_X("POST"), st_ServiceConfig.st_XAuth.tszAuthUrl, tszMsgBuffer, &nHTTPCode)) { ProxyProtocol_SocksCore_HdrPacket(lpszClientAddr, tszMsgBuffer, &nLen, XENGINE_RFCCOMPONENT_PROXY_SOCKS_RESPONSE_FAILED); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_SOCKS); diff --git a/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp b/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp index 39b979ffe44f03371cede79774e6ca62a4f2c0f7..d579c5af059dcd3939c8cd61eb6812a33db6a6e5 100644 --- a/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp +++ b/XEngine_Source/XEngine_ServiceApp/XEngine_TunnelTask.cpp @@ -38,13 +38,11 @@ bool XEngine_TunnelTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in } XCHAR tszConnectAddr[128]; memset(tszConnectAddr, '\0', sizeof(tszConnectAddr)); - if (st_ServiceConfig.st_XAuth.bAuth > 0) + if (st_ServiceConfig.st_XAuth.bAuth) { - XCHAR tszUser[128]; - XCHAR tszPass[128]; + XCHAR tszUser[128] = {}; + XCHAR tszPass[128] = {}; - memset(tszUser, '\0', sizeof(tszUser)); - memset(tszPass, '\0', sizeof(tszPass)); if (!OPenSsl_Help_BasicDecoder(tszAuthInfo, tszUser, tszPass)) { ProxyProtocol_TunnelCore_Packet(tszMsgBuffer, &nLen, 401); @@ -52,7 +50,9 @@ bool XEngine_TunnelTask_Handle(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, in XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("Tunnel客户端:%s,失败无法继续,错误:%lX"), lpszClientAddr, OPenSsl_GetLastError()); return false; } - if (!ModuleAuthorize_User_Exist(tszUser, tszPass)) + int nHTTPCode = 0; + ModuleProtocol_Packet_Auth(tszMsgBuffer, &nLen, tszUser, tszPass); + if (!APIClient_Http_Request(_X("POST"), st_ServiceConfig.st_XAuth.tszAuthUrl, tszMsgBuffer, &nHTTPCode)) { ProxyProtocol_TunnelCore_Packet(tszMsgBuffer, &nLen, 401); XEngine_Network_Send(lpszClientAddr, tszMsgBuffer, nLen, XENGINE_CLIENT_NETTYPE_TUNNEL); diff --git a/XEngine_Source/XEngine_UserProtocol.h b/XEngine_Source/XEngine_UserProtocol.h index 7bfd641a22f355acf77d59af9e70a176c730f355..82927328f83f183b74fd18b962314536ee58aa1c 100644 --- a/XEngine_Source/XEngine_UserProtocol.h +++ b/XEngine_Source/XEngine_UserProtocol.h @@ -18,14 +18,12 @@ typedef enum en_XEngine_XUser_Protocol ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_USER_FORWARD = ENUM_XENGINE_COMMUNICATION_PROTOCOL_TYPE_USER + 1 }ENUM_XNETENGINE_XUSER_PROTOCOL; //转发协议 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREQ 0xE1000 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREP 0xE1001 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREQ 0xE1002 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREP 0xE1003 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREQ 0xE1004 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREQ 0xE1000 //登录请求 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LOGREP 0xE1001 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREQ 0xE1002 //列表请求 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_LISTREP 0xE1003 +#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREQ 0xE1004 //绑定请求 #define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_BINDREP 0xE1005 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_UNREQ 0xE1006 -#define XENGINE_COMMUNICATION_PROTOCOL_OPERATOR_CODE_FORWARD_UNREP 0xE1007 /////////////////////////////////////////////////////////////////////////// // 导出的数据结构 ///////////////////////////////////////////////////////////////////////////