Skip to content

Commit 3dbd410

Browse files
committed
added:permission control of build switch
modify:tcp login permission handle
1 parent 1f3fa6c commit 3dbd410

5 files changed

Lines changed: 37 additions & 3 deletions

File tree

XEngine_Source/XEngine_MQServiceApp.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MQCore_SessionModule", "MQC
3232
EndProject
3333
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MQCore_Hdr", "MQCore_Hdr", "{3A9FE48B-7FD1-4D02-8ED7-7521DC469765}"
3434
ProjectSection(SolutionItems) = preProject
35+
XQueue_BuildSwtich.h = XQueue_BuildSwtich.h
3536
XQueue_ProtocolHdr.h = XQueue_ProtocolHdr.h
3637
EndProjectSection
3738
EndProject

XEngine_Source/XEngine_MQServiceApp/MQService_HTTPTask/MQService_HTTPPost.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ bool MessageQueue_HttpTask_Post(LPCXSTR lpszClientAddr, LPCXSTR lpszFuncName, LP
2626
LPCXSTR lpszAPIBind = _X("bind");
2727
LPCXSTR lpszAPIUMBind = _X("unbind");
2828
LPCXSTR lpszAPIUNReadMsg = _X("unreadmsg");
29+
2930
LPCXSTR lpszAPICreateTopic = _X("createtopic");
3031
LPCXSTR lpszAPIDelTopic = _X("deletetopic");
31-
3232
LPCXSTR lpszAPIDelMsg = _X("deletemsg");
3333
LPCXSTR lpszAPIModifyMsg = _X("modifymsg");
3434
LPCXSTR lpszAPIModifyTopic = _X("modifytopic");
@@ -340,14 +340,15 @@ bool MessageQueue_HttpTask_Post(LPCXSTR lpszClientAddr, LPCXSTR lpszFuncName, LP
340340
{
341341
//http://127.0.0.1:5202/api?function=createtopic
342342
XENGINE_PROTOCOL_XMQ st_MQProtocol = {};
343-
343+
#if (1 == __XENGINE_MESSAGEQUEUE_BUILD_SWITCH_PERMISSION__)
344344
if ((st_UserInfo.nUserLevel < ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_ROOT) || (st_UserInfo.nUserLevel >= ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_SVIP))
345345
{
346346
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PERMISSION, _X("permission Error,user accesss Denied"));
347347
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_MQAPP_NETTYPE_HTTP);
348348
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP消息端:%s,请求创建主题失败,权限错误,权限级别:%d"), lpszClientAddr, st_UserInfo.nUserLevel);
349349
return false;
350350
}
351+
#endif
351352
if (!ProtocolModule_Parse_XMQ(lpszMsgBuffer, nMsgLen, &st_MQProtocol))
352353
{
353354
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PARSE, _X("request json parse failure"));
@@ -405,14 +406,15 @@ bool MessageQueue_HttpTask_Post(LPCXSTR lpszClientAddr, LPCXSTR lpszFuncName, LP
405406
XENGINE_DBUSERKEY st_UserKey = {};
406407
XENGINE_DBTIMERELEASE st_DBInfo = {};
407408
XENGINE_PROTOCOL_XMQ st_MQProtocol = {};
408-
409+
#if (1 == __XENGINE_MESSAGEQUEUE_BUILD_SWITCH_PERMISSION__)
409410
if ((st_UserInfo.nUserLevel < ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_ROOT) || (st_UserInfo.nUserLevel >= ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_SVIP))
410411
{
411412
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PERMISSION, _X("permission Error,user accesss Denied"));
412413
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_MQAPP_NETTYPE_HTTP);
413414
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP消息端:%s,请求删除主题失败,权限错误,权限级别:%d"), lpszClientAddr, st_UserInfo.nUserLevel);
414415
return false;
415416
}
417+
#endif
416418
if (!ProtocolModule_Parse_XMQ(lpszMsgBuffer, nMsgLen, &st_MQProtocol))
417419
{
418420
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PARSE, _X("json load parse is failure"));
@@ -456,13 +458,16 @@ bool MessageQueue_HttpTask_Post(LPCXSTR lpszClientAddr, LPCXSTR lpszFuncName, LP
456458
XENGINE_PROTOCOL_XMQ st_MQProtocol = {};
457459
XENGINE_DBMESSAGEQUEUE st_MessageQueue = {};
458460

461+
#if (1 == __XENGINE_MESSAGEQUEUE_BUILD_SWITCH_PERMISSION__)
459462
if ((st_UserInfo.nUserLevel < ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_ROOT) || (st_UserInfo.nUserLevel >= ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_SVIP))
460463
{
461464
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PERMISSION, _X("permission Error,user accesss Denied"));
462465
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_MQAPP_NETTYPE_HTTP);
463466
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP消息端:%s,请求删除消息失败,权限错误,权限级别:%d"), lpszClientAddr, st_UserInfo.nUserLevel);
464467
return false;
465468
}
469+
#endif
470+
466471
if (!ProtocolModule_Parse_XMQ(lpszMsgBuffer, nMsgLen, &st_MQProtocol))
467472
{
468473
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PARSE, _X("json load parse is failure"));
@@ -496,13 +501,16 @@ bool MessageQueue_HttpTask_Post(LPCXSTR lpszClientAddr, LPCXSTR lpszFuncName, LP
496501
{
497502
XENGINE_DBMESSAGEQUEUE st_DBQueue = {};
498503

504+
#if (1 == __XENGINE_MESSAGEQUEUE_BUILD_SWITCH_PERMISSION__)
499505
if ((st_UserInfo.nUserLevel < ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_ROOT) || (st_UserInfo.nUserLevel >= ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_SVIP))
500506
{
501507
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PERMISSION, _X("permission Error,user accesss Denied"));
502508
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_MQAPP_NETTYPE_HTTP);
503509
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP消息端:%s,请求修改消息失败,权限错误,权限级别:%d"), lpszClientAddr, st_UserInfo.nUserLevel);
504510
return false;
505511
}
512+
#endif
513+
506514
if (!ProtocolModule_Parse_MessageQueue(lpszMsgBuffer, nMsgLen, &st_DBQueue))
507515
{
508516
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PARSE, _X("json load parse is failure"));
@@ -528,13 +536,16 @@ bool MessageQueue_HttpTask_Post(LPCXSTR lpszClientAddr, LPCXSTR lpszFuncName, LP
528536
XCHAR tszDstTopic[XPATH_MIN] = {};
529537
XCHAR tszUserName[XPATH_MIN] = {};
530538

539+
#if (1 == __XENGINE_MESSAGEQUEUE_BUILD_SWITCH_PERMISSION__)
531540
if ((st_UserInfo.nUserLevel < ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_ROOT) || (st_UserInfo.nUserLevel >= ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_SVIP))
532541
{
533542
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PERMISSION, _X("permission Error,user accesss Denied"));
534543
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_MQAPP_NETTYPE_HTTP);
535544
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("HTTP消息端:%s,请求修改主题失败,权限错误,权限级别:%d"), lpszClientAddr, st_UserInfo.nUserLevel);
536545
return false;
537546
}
547+
#endif
548+
538549
if (!ProtocolModule_Parse_ModifyTopic(lpszMsgBuffer, nMsgLen, tszSrcTopic, tszDstTopic, tszUserName))
539550
{
540551
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_PARSE, _X("json load parse is failure"));

XEngine_Source/XEngine_MQServiceApp/MQService_Hdr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ using namespace std;
5656
#include "../XEngine_DependLibrary/XEngine_Module/XEngine_MSGNotify/MSGNotify_Define.h"
5757
#include "../XEngine_DependLibrary/XEngine_Module/XEngine_MSGNotify/MSGNotify_Error.h"
5858
#include "../XQueue_ProtocolHdr.h"
59+
#include "../XQueue_BuildSwtich.h"
5960
#include "../MQCore_ConfigModule/Config_Define.h"
6061
#include "../MQCore_ConfigModule/Config_Error.h"
6162
#include "../MQCore_SessionModule/Session_Define.h"

XEngine_Source/XEngine_MQServiceApp/MQService_TCPTask.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ bool MessageQueue_TCP_Handle(XENGINE_PROTOCOLHDR* pSt_ProtocolHdr, LPCXSTR lpszC
145145
st_UserInfo.nUserState = 1;
146146
DBModule_MQUser_UserUPDate(&st_UserInfo);
147147
}
148+
//权限是否正确
149+
if (ENUM_XENGINE_PROTOCOLHDR_LEVEL_TYPE_BAN == st_UserInfo.nUserLevel)
150+
{
151+
ProtocolModule_Packet_Http(tszSDBuffer, &nSDLen, ERROR_XENGINE_MESSAGE_HTTP_AUTHORIZE, "permission error");
152+
XEngine_MQXService_Send(lpszClientAddr, tszSDBuffer, nSDLen, XENGINE_MQAPP_NETTYPE_HTTP);
153+
XLOG_PRINT(xhLog, XENGINE_HELPCOMPONENTS_XLOG_IN_LOGLEVEL_ERROR, _X("%s客户端:%s,用户名:%s,登录失败,客户端权限不足够"), lpszClientAddr, st_UserInfo.tszUserName);
154+
return false;
155+
}
148156
pSt_ProtocolHdr->wReserve = 0;
149157
SessionModule_Client_Create(lpszClientAddr, &st_UserInfo, nNetType);
150158
ProtocolModule_Packet_Common(nNetType, pSt_ProtocolHdr, NULL, tszSDBuffer, &nSDLen);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#pragma once
2+
/********************************************************************
3+
// Created: 2026/02/27 13:49:51
4+
// File Name: D:\XEngine_MQService\XEngine_Source\XQueue_BuildSwtich.h
5+
// File Path: D:\XEngine_MQService\XEngine_Source
6+
// File Base: XQueue_BuildSwtich
7+
// File Ext: h
8+
// Project: XEngine
9+
// Author: qyt
10+
// Purpose: 编译选项
11+
// History:
12+
*********************************************************************/
13+
#define __XENGINE_MESSAGEQUEUE_BUILD_SWITCH_PERMISSION__ 0

0 commit comments

Comments
 (0)