Skip to content

Commit 8282e81

Browse files
committed
modify:crypt communication pass word support
1 parent a60ffa7 commit 8282e81

File tree

8 files changed

+12
-34
lines changed

8 files changed

+12
-34
lines changed

XEngine_Release/XEngine_Config/XEngine_Config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
}
5252
},
5353
"XCrypto": {
54-
"bEnable": false,
55-
"nPass": 123123
54+
"bEnable": true,
55+
"tszPassKey": "123123aa"
5656
},
5757
"XApiVer": {
5858
"bEnable": false,

XEngine_Source/AuthorizeModule_Configure/Config_Define.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ typedef struct
8181
}st_XLogin;
8282
struct
8383
{
84+
XCHAR tszCryptoKey[32]; //加密传输密钥
8485
bool bEnable; //是否启用加密传输
85-
int nPassword; //密码
8686
}st_XCrypto;
8787
struct
8888
{

XEngine_Source/AuthorizeModule_Configure/ModuleConfigure_Json/ModuleConfigure_Json.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ bool CModuleConfigure_Json::ModuleConfigure_Json_File(LPCXSTR lpszConfigFile, XE
154154
}
155155
Json::Value st_JsonXCrypto = st_JsonRoot["XCrypto"];
156156
pSt_ServerConfig->st_XCrypto.bEnable = st_JsonXCrypto["bEnable"].asBool();
157-
pSt_ServerConfig->st_XCrypto.nPassword = st_JsonXCrypto["nPass"].asInt();
157+
_tcsxcpy(pSt_ServerConfig->st_XCrypto.tszCryptoKey, st_JsonXCrypto["tszPassKey"].asCString());
158158
//接口验证
159159
if (st_JsonRoot["XApiVer"].empty() || (5 != st_JsonRoot["XApiVer"].size()))
160160
{

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_HttpTask.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,8 @@ XHTHREAD XCALLBACK XEngine_AuthService_HttpThread(XPVOID lParam)
2626
{
2727
if (st_AuthConfig.st_XCrypto.bEnable)
2828
{
29-
XCHAR tszPassword[64];
30-
XCHAR tszDeBuffer[2048];
31-
32-
memset(tszPassword, '\0', sizeof(tszPassword));
33-
memset(tszDeBuffer, '\0', sizeof(tszDeBuffer));
34-
35-
_xstprintf(tszPassword, _X("%d"), st_AuthConfig.st_XCrypto.nPassword);
36-
Cryption_XCrypto_Decoder(ptszMsgBuffer, &nMsgLen, tszDeBuffer, tszPassword);
29+
XCHAR tszDeBuffer[2048] = {};
30+
Cryption_XCrypto_Decoder(ptszMsgBuffer, &nMsgLen, tszDeBuffer, st_AuthConfig.st_XCrypto.tszCryptoKey);
3731
XEngine_Client_HttpTask(ppSt_ListClient[i]->tszClientAddr, tszDeBuffer, nMsgLen, &st_HTTPParament, ppszListHdr, nHdrCount);
3832
}
3933
else

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_Net.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,7 @@ bool XEngine_Client_TaskSend(LPCXSTR lpszClientAddr, LPCXSTR lpszMsgBuffer, int
159159
{
160160
if (st_AuthConfig.st_XCrypto.bEnable)
161161
{
162-
XCHAR tszPassword[64];
163-
memset(tszPassword, '\0', sizeof(tszPassword));
164-
165-
_xstprintf(tszPassword, _X("%d"), st_AuthConfig.st_XCrypto.nPassword);
166-
XEngine_SendMsg(lpszClientAddr, lpszMsgBuffer, nMsgLen, nNetType, tszPassword);
162+
XEngine_SendMsg(lpszClientAddr, lpszMsgBuffer, nMsgLen, nNetType, st_AuthConfig.st_XCrypto.tszCryptoKey);
167163
}
168164
else
169165
{

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_TCPTask.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,8 @@ XHTHREAD XCALLBACK XEngine_AuthService_TCPThread(XPVOID lParam)
2929
}
3030
if (st_AuthConfig.st_XCrypto.bEnable && (ENUM_XENGINE_PROTOCOLHDR_CRYPTO_TYPE_XCRYPT == st_ProtocolHdr.wCrypto))
3131
{
32-
XCHAR tszPassword[64];
33-
XCHAR tszDeBuffer[2048];
34-
35-
memset(tszPassword, '\0', sizeof(tszPassword));
36-
memset(tszDeBuffer, '\0', sizeof(tszDeBuffer));
37-
38-
_xstprintf(tszPassword, _X("%d"), st_AuthConfig.st_XCrypto.nPassword);
39-
Cryption_XCrypto_Decoder(tszMsgBuffer, &nMsgLen, tszDeBuffer, tszPassword);
32+
XCHAR tszDeBuffer[2048] = {};
33+
Cryption_XCrypto_Decoder(tszMsgBuffer, &nMsgLen, tszDeBuffer, st_AuthConfig.st_XCrypto.tszCryptoKey);
4034
XEngine_Client_TCPTask(ppSt_ListClient[i]->tszClientAddr, tszDeBuffer, nMsgLen, &st_ProtocolHdr, XENGINE_AUTH_APP_NETTYPE_TCP);
4135
}
4236
else

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/Authorize_WSTask.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,8 @@ XHTHREAD XCALLBACK XEngine_AuthService_WSThread(XPVOID lParam)
2727
}
2828
if (st_AuthConfig.st_XCrypto.bEnable)
2929
{
30-
XCHAR tszPassword[64];
31-
XCHAR tszDeBuffer[2048];
32-
33-
memset(tszPassword, '\0', sizeof(tszPassword));
34-
memset(tszDeBuffer, '\0', sizeof(tszDeBuffer));
35-
36-
_xstprintf(tszPassword, _X("%d"), st_AuthConfig.st_XCrypto.nPassword);
37-
Cryption_XCrypto_Decoder(tszMsgBuffer, &nMsgLen, tszDeBuffer, tszPassword);
30+
XCHAR tszDeBuffer[2048] = {};
31+
Cryption_XCrypto_Decoder(tszMsgBuffer, &nMsgLen, tszDeBuffer, st_AuthConfig.st_XCrypto.tszCryptoKey);
3832
XEngine_Client_WSTask(ppSt_ListClient[i]->tszClientAddr, tszDeBuffer, nMsgLen, enOPCode);
3933
}
4034
else

XEngine_Source/XEngine_APPService/XEngine_AuthorizeService/XEngine_AuthorizeService.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ int main(int argc, char** argv)
374374

375375
if (st_AuthConfig.st_XCrypto.bEnable)
376376
{
377-
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,加密传输设置为开启,密码:%d"), st_AuthConfig.st_XCrypto.nPassword);
377+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_INFO, _X("启动服务中,加密传输设置为开启,密码:%s"), st_AuthConfig.st_XCrypto.tszCryptoKey);
378378
}
379379
else
380380
{

0 commit comments

Comments
 (0)