add rpc update interface

This commit is contained in:
yihaoDeng 2023-09-07 21:10:05 +08:00
parent 60d6a622e1
commit 27e3ee8f1d
5 changed files with 38 additions and 1 deletions

View File

@ -31,6 +31,8 @@ int32_t mndGetDnodeSize(SMnode *pMnode);
bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs);
void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo);
SIpWhiteList *mndCreateIpWhiteFromDnode(SMnode *pMnode);
#ifdef __cplusplus
}
#endif

View File

@ -42,6 +42,8 @@ int32_t mndUserDupObj(SUserObj *pUser, SUserObj *pNew);
void mndUserFreeObj(SUserObj *pUser);
int64_t mndGetIpWhiteVer(SMnode *pMnode);
#ifdef __cplusplus
}
#endif

View File

@ -820,6 +820,38 @@ _OVER:
return code;
}
SIpWhiteList *mndCreateIpWhiteFromDnode(SMnode *pMnode) {
SDnodeObj *pObj = NULL;
void *pIter = NULL;
SSdb *pSdb = pMnode->pSdb;
SArray *fqdns = taosArrayInit(4, sizeof(void *));
while (1) {
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pObj);
if (pIter == NULL) break;
char *fqdn = taosStrdup(pObj->fqdn);
taosArrayPush(fqdns, &fqdn);
sdbRelease(pSdb, pObj);
}
int32_t sz = taosArrayGetSize(fqdns);
SIpWhiteList *list = NULL;
if (sz != 0) {
list = taosMemoryCalloc(1, sizeof(SIpWhiteList) + sz * sizeof(SIpV4Range));
for (int i = 0; i < sz; i++) {
char *e = taosArrayGetP(fqdns, i);
taosMemoryFree(e);
int32_t ip = taosGetFqdn(e);
SIpV4Range *pRange = &list->pIpRange[0];
pRange->ip = ip;
pRange->mask = 0;
}
}
taosArrayDestroy(fqdns);
return list;
}
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
SShowVariablesRsp rsp = {0};
int32_t code = -1;

View File

@ -240,6 +240,7 @@ SHashObj *mndFetchAllIpWhite(SMnode *pMnode) {
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
SHashObj *pIpWhiteTab = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 1, HASH_ENTRY_LOCK);
while (1) {
SUserObj *pUser = NULL;
pIter = sdbFetch(pSdb, SDB_USER, pIter, (void **)&pUser);

View File

@ -354,7 +354,7 @@ bool uvWhiteListFilte(SWhiteList* pWhite, char* user, uint32_t ip, int64_t ver)
return valid;
}
bool uvWhiteListCheckConn(SWhiteList* pWhite, SSvrConn* pConn) {
if (pWhite->ver == pConn->whiteListVer) return true;
if (pWhite->ver == pConn->whiteListVer || strncmp(pConn->user, "_dnd", strlen("_dnd")) == 0) return true;
return uvWhiteListFilte(pWhite, pConn->user, pConn->clientIp, pConn->whiteListVer);
}