Merge branch 'enh/ipWhiteList' of github.com:taosdata/TDengine into szhou/enh/ipWhiteList

This commit is contained in:
slzhou 2023-09-14 13:06:15 +08:00
commit a15a41f396
3 changed files with 15 additions and 14 deletions

View File

@ -31,10 +31,10 @@ static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
}
}
static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
dInfo("ip-white-dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->ipWhiteVer, ver);
dDebug("ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->ipWhiteVer, ver);
if (pMgmt->ipWhiteVer == ver) {
if (ver == 0) {
dInfo("disable ip-white-dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->ipWhiteVer, ver);
dDebug("disable ip-white-list on dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->ipWhiteVer, ver);
rpcSetIpWhite(pMgmt->msgCb.serverRpc, NULL);
pMgmt->ipWhiteVer = ver;
}

View File

@ -195,7 +195,7 @@ int64_t mndGetIpWhiteVer(SMnode *pMnode) {
}
ver = ipWhiteMgt.ver;
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
mInfo("ip-white-mnode ver: %" PRId64 "", ver);
mDebug("ip-white-list on mnode ver: %" PRId64 "", ver);
// if (mndEnableIpWhiteList(pMnode) == 0 || tsEnableWhiteList == false) {
// return 0;
@ -616,7 +616,7 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
int32_t ipWhiteReserve =
pUser->pIpWhiteList ? (sizeof(SIpV4Range) * pUser->pIpWhiteList->num + sizeof(SIpWhiteList) + 4) : 4;
pUser->pIpWhiteList ? (sizeof(SIpV4Range) * pUser->pIpWhiteList->num + sizeof(SIpWhiteList) + 4) : 16;
int32_t numOfReadDbs = taosHashGetSize(pUser->readDbs);
int32_t numOfWriteDbs = taosHashGetSize(pUser->writeDbs);
int32_t numOfReadStbs = taosHashGetSize(pUser->readTbs);
@ -1078,6 +1078,7 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) {
int32_t sz = sizeof(SIpWhiteList) + pNew->pIpWhiteList->num * sizeof(SIpV4Range);
pOld->pIpWhiteList = taosMemoryRealloc(pOld->pIpWhiteList, sz);
memcpy(pOld->pIpWhiteList, pNew->pIpWhiteList, sz);
pOld->ipWhiteListVer = pNew->ipWhiteListVer;
taosWUnLockLatch(&pOld->lock);

View File

@ -96,8 +96,8 @@ typedef struct SWorkThrd {
bool quit;
SIpWhiteListTab* pWhiteList;
int64_t whiteListVer;
int8_t enableIpWhiteList;
int64_t whiteListVer;
int8_t enableIpWhiteList;
} SWorkThrd;
typedef struct SServerObj {
@ -121,12 +121,12 @@ typedef struct SServerObj {
} SServerObj;
SIpWhiteListTab* uvWhiteListCreate();
void uvWhiteListDestroy(SIpWhiteListTab* pWhite);
void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver);
void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable);
bool uvWhiteListCheckConn(SIpWhiteListTab* pWhite, SSvrConn* pConn);
bool uvWhiteListFilte(SIpWhiteListTab* pWhite, char* user, uint32_t ip, int64_t ver);
void uvWhiteListSetConnVer(SIpWhiteListTab* pWhite, SSvrConn* pConn);
void uvWhiteListDestroy(SIpWhiteListTab* pWhite);
void uvWhiteListAdd(SIpWhiteListTab* pWhite, char* user, SIpWhiteList* pList, int64_t ver);
void uvWhiteListUpdate(SIpWhiteListTab* pWhite, SHashObj* pTable);
bool uvWhiteListCheckConn(SIpWhiteListTab* pWhite, SSvrConn* pConn);
bool uvWhiteListFilte(SIpWhiteListTab* pWhite, char* user, uint32_t ip, int64_t ver);
void uvWhiteListSetConnVer(SIpWhiteListTab* pWhite, SSvrConn* pConn);
static void uvAllocConnBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
static void uvAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
@ -263,7 +263,7 @@ void uvWhiteListDebug(SIpWhiteListTab* pWrite) {
char* buf = NULL;
uvWhiteListToStr(pUserList, user, &buf);
tDebug("white %s", buf);
tDebug("ip-white-list %s", buf);
taosMemoryFree(buf);
pIter = taosHashIterate(pWhiteList, pIter);
}
@ -1568,7 +1568,7 @@ _return2:
void transSetIpWhiteList(void* thandle, void* arg, FilteFunc* func) {
STrans* pTransInst = (STrans*)transAcquireExHandle(transGetInstMgt(), (int64_t)thandle);
tInfo("update ip white list");
tDebug("ip-white-list update on rpc");
SServerObj* svrObj = pTransInst->tcphandle;
for (int i = 0; i < svrObj->numOfThreads; i++) {
SWorkThrd* pThrd = svrObj->pThreadObj[i];