add rpc update interface
This commit is contained in:
parent
8c5fa3526a
commit
60d6a622e1
|
@ -885,6 +885,7 @@ typedef struct {
|
||||||
SIpV4Range pIpRange[];
|
SIpV4Range pIpRange[];
|
||||||
} SIpWhiteList;
|
} SIpWhiteList;
|
||||||
|
|
||||||
|
SIpWhiteList* cloneIpWhiteList(SIpWhiteList* pIpWhiteList);
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t createType;
|
int8_t createType;
|
||||||
int8_t superUser; // denote if it is a super user or not
|
int8_t superUser; // denote if it is a super user or not
|
||||||
|
|
|
@ -1376,6 +1376,13 @@ int32_t tDeserializeSDropUserReq(void *buf, int32_t bufLen, SDropUserReq *pReq)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SIpWhiteList *cloneIpWhiteList(SIpWhiteList *pIpWhiteList) {
|
||||||
|
int32_t sz = sizeof(SIpWhiteList) + pIpWhiteList->num * sizeof(SIpV4Range);
|
||||||
|
SIpWhiteList *pNew = taosMemoryCalloc(1, sz);
|
||||||
|
memcpy(pNew, pIpWhiteList, sz);
|
||||||
|
return pNew;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t tSerializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pReq) {
|
int32_t tSerializeSCreateUserReq(void *buf, int32_t bufLen, SCreateUserReq *pReq) {
|
||||||
SEncoder encoder = {0};
|
SEncoder encoder = {0};
|
||||||
tEncoderInit(&encoder, buf, bufLen);
|
tEncoderInit(&encoder, buf, bufLen);
|
||||||
|
@ -1491,8 +1498,10 @@ void tFreeSUpdateIpWhiteReq(SUpdateIpWhite *pReq) {
|
||||||
SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) {
|
SUpdateIpWhite *cloneSUpdateIpWhiteReq(SUpdateIpWhite *pReq) {
|
||||||
SUpdateIpWhite *pClone = taosMemoryCalloc(1, sizeof(SUpdateIpWhite));
|
SUpdateIpWhite *pClone = taosMemoryCalloc(1, sizeof(SUpdateIpWhite));
|
||||||
|
|
||||||
pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser);
|
pClone->numOfUser = pReq->numOfUser;
|
||||||
pClone->ver = pReq->ver;
|
pClone->ver = pReq->ver;
|
||||||
|
pClone->pUserIpWhite = taosMemoryCalloc(1, sizeof(SUpdateUserIpWhite) * pReq->numOfUser);
|
||||||
|
|
||||||
for (int i = 0; i < pReq->numOfUser; i++) {
|
for (int i = 0; i < pReq->numOfUser; i++) {
|
||||||
SUpdateUserIpWhite *pNew = &pClone->pUserIpWhite[i];
|
SUpdateUserIpWhite *pNew = &pClone->pUserIpWhite[i];
|
||||||
SUpdateUserIpWhite *pOld = &pReq->pUserIpWhite[i];
|
SUpdateUserIpWhite *pOld = &pReq->pUserIpWhite[i];
|
||||||
|
|
|
@ -31,6 +31,7 @@ static void dmUpdateDnodeCfg(SDnodeMgmt *pMgmt, SDnodeCfg *pCfg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
static void dmMayShouldUpdateIpWhiteList(SDnodeMgmt *pMgmt, int64_t ver) {
|
||||||
|
dInfo("ip-white-dnode ver: %" PRId64 ", status ver: %" PRId64 "", pMgmt->ipWhiteVer, ver);
|
||||||
if (pMgmt->ipWhiteVer == ver) {
|
if (pMgmt->ipWhiteVer == ver) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,13 +64,12 @@ static void dmConvertErrCode(tmsg_t msgType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void dmUpdateRpcIpWhite(void *pTrans, SRpcMsg *pRpc) {
|
static void dmUpdateRpcIpWhite(void *pTrans, SRpcMsg *pRpc) {
|
||||||
SUpdateIpWhite *pIpWhite = taosMemoryCalloc(1, sizeof(SUpdateIpWhite));
|
SUpdateIpWhite ipWhite = {0}; // aosMemoryCalloc(1, sizeof(SUpdateIpWhite));
|
||||||
tDeserializeSUpdateIpWhite(pRpc->pCont, pRpc->contLen, pIpWhite);
|
tDeserializeSUpdateIpWhite(pRpc->pCont, pRpc->contLen, &ipWhite);
|
||||||
|
|
||||||
rpcSetIpWhite(pTrans, pIpWhite);
|
rpcSetIpWhite(pTrans, &ipWhite);
|
||||||
|
|
||||||
tFreeSUpdateIpWhiteReq(pIpWhite);
|
tFreeSUpdateIpWhiteReq(&ipWhite);
|
||||||
taosMemoryFree(pIpWhite);
|
|
||||||
|
|
||||||
rpcFreeCont(pRpc->pCont);
|
rpcFreeCont(pRpc->pCont);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ typedef struct SMnode {
|
||||||
SGrantInfo grant;
|
SGrantInfo grant;
|
||||||
MndMsgFp msgFp[TDMT_MAX];
|
MndMsgFp msgFp[TDMT_MAX];
|
||||||
SMsgCb msgCb;
|
SMsgCb msgCb;
|
||||||
|
int64_t ipWhiteVer;
|
||||||
} SMnode;
|
} SMnode;
|
||||||
|
|
||||||
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
|
void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp);
|
||||||
|
|
|
@ -517,6 +517,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int64_t ver = mndGetIpWhiteVer(pMnode);
|
||||||
|
|
||||||
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
int64_t dnodeVer = sdbGetTableVer(pMnode->pSdb, SDB_DNODE) + sdbGetTableVer(pMnode->pSdb, SDB_MNODE);
|
||||||
int64_t curMs = taosGetTimestampMs();
|
int64_t curMs = taosGetTimestampMs();
|
||||||
|
@ -524,7 +525,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
bool dnodeChanged = (statusReq.dnodeVer == 0) || (statusReq.dnodeVer != dnodeVer);
|
||||||
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
bool reboot = (pDnode->rebootTime != statusReq.rebootTime);
|
||||||
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
bool supportVnodesChanged = pDnode->numOfSupportVnodes != statusReq.numOfSupportVnodes;
|
||||||
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged;
|
bool needCheck = !online || dnodeChanged || reboot || supportVnodesChanged || pMnode->ipWhiteVer != ver;
|
||||||
|
|
||||||
|
pMnode->ipWhiteVer = ver;
|
||||||
|
|
||||||
const STraceId *trace = &pReq->info.traceId;
|
const STraceId *trace = &pReq->info.traceId;
|
||||||
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
mGTrace("dnode:%d, status received, accessTimes:%d check:%d online:%d reboot:%d changed:%d statusSeq:%d", pDnode->id,
|
||||||
|
@ -645,7 +648,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mndGetDnodeEps(pMnode, statusRsp.pDnodeEps);
|
mndGetDnodeEps(pMnode, statusRsp.pDnodeEps);
|
||||||
statusRsp.ipWhiteVer = mndGetIpWhiteVer(pMnode);
|
statusRsp.ipWhiteVer = ver;
|
||||||
|
|
||||||
int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp);
|
int32_t contLen = tSerializeSStatusRsp(NULL, 0, &statusRsp);
|
||||||
void *pHead = rpcMallocCont(contLen);
|
void *pHead = rpcMallocCont(contLen);
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#define USER_VER_NUMBER 5
|
#define USER_VER_NUMBER 5
|
||||||
#define USER_RESERVE_SIZE 64
|
#define USER_RESERVE_SIZE 64
|
||||||
|
|
||||||
static SIpWhiteList *cloneIpWhiteList(SIpWhiteList *pIpWhiteList);
|
|
||||||
static SIpWhiteList *createDefaultIpWhiteList();
|
static SIpWhiteList *createDefaultIpWhiteList();
|
||||||
SIpWhiteList *createIpWhiteList(void *buf, int32_t len);
|
SIpWhiteList *createIpWhiteList(void *buf, int32_t len);
|
||||||
static bool updateIpWhiteList(SIpWhiteList *pOld, SIpWhiteList *pNew);
|
static bool updateIpWhiteList(SIpWhiteList *pOld, SIpWhiteList *pNew);
|
||||||
|
@ -58,7 +57,7 @@ SHashObj *mndFetchAllIpWhite(SMnode *pMnode);
|
||||||
static int32_t mndProcesSRetrieveIpWhiteReq(SRpcMsg *pReq);
|
static int32_t mndProcesSRetrieveIpWhiteReq(SRpcMsg *pReq);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SHashObj *pIpWhiteList;
|
SHashObj *pIpWhiteTab;
|
||||||
int64_t ver;
|
int64_t ver;
|
||||||
TdThreadRwlock rw;
|
TdThreadRwlock rw;
|
||||||
} SIpWhiteMgt;
|
} SIpWhiteMgt;
|
||||||
|
@ -66,22 +65,23 @@ typedef struct {
|
||||||
static SIpWhiteMgt ipWhiteMgt;
|
static SIpWhiteMgt ipWhiteMgt;
|
||||||
|
|
||||||
void ipWhiteMgtInit() {
|
void ipWhiteMgtInit() {
|
||||||
ipWhiteMgt.pIpWhiteList = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 1, HASH_ENTRY_LOCK);
|
ipWhiteMgt.pIpWhiteTab = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 1, HASH_ENTRY_LOCK);
|
||||||
ipWhiteMgt.ver = 0;
|
ipWhiteMgt.ver = 0;
|
||||||
taosThreadRwlockInit(&ipWhiteMgt.rw, NULL);
|
taosThreadRwlockInit(&ipWhiteMgt.rw, NULL);
|
||||||
}
|
}
|
||||||
void ipWhiteMgtCleanup() {
|
void ipWhiteMgtCleanup() {
|
||||||
destroyIpWhiteTab(ipWhiteMgt.pIpWhiteList);
|
destroyIpWhiteTab(ipWhiteMgt.pIpWhiteTab);
|
||||||
taosThreadRwlockDestroy(&ipWhiteMgt.rw);
|
taosThreadRwlockDestroy(&ipWhiteMgt.rw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t ipWhiteMgtUpdate(char *user, SIpWhiteList *pNew) {
|
int32_t ipWhiteMgtUpdate(char *user, SIpWhiteList *pNew) {
|
||||||
bool update = true;
|
bool update = true;
|
||||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||||
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteList, user, strlen(user));
|
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||||
|
|
||||||
if (ppList == NULL || *ppList == NULL) {
|
if (ppList == NULL || *ppList == NULL) {
|
||||||
SIpWhiteList *p = cloneIpWhiteList(pNew);
|
SIpWhiteList *p = cloneIpWhiteList(pNew);
|
||||||
taosHashPut(ipWhiteMgt.pIpWhiteList, user, strlen(user), &p, sizeof(void *));
|
taosHashPut(ipWhiteMgt.pIpWhiteTab, user, strlen(user), &p, sizeof(void *));
|
||||||
} else {
|
} else {
|
||||||
SIpWhiteList *pOld = *ppList;
|
SIpWhiteList *pOld = *ppList;
|
||||||
if (isIpWhiteListEqual(pOld, pNew)) {
|
if (isIpWhiteListEqual(pOld, pNew)) {
|
||||||
|
@ -89,7 +89,7 @@ int32_t ipWhiteMgtUpdate(char *user, SIpWhiteList *pNew) {
|
||||||
} else {
|
} else {
|
||||||
taosMemoryFree(pOld);
|
taosMemoryFree(pOld);
|
||||||
SIpWhiteList *p = cloneIpWhiteList(pNew);
|
SIpWhiteList *p = cloneIpWhiteList(pNew);
|
||||||
taosHashPut(ipWhiteMgt.pIpWhiteList, user, strlen(user), &p, sizeof(void *));
|
taosHashPut(ipWhiteMgt.pIpWhiteTab, user, strlen(user), &p, sizeof(void *));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (update) ipWhiteMgt.ver++;
|
if (update) ipWhiteMgt.ver++;
|
||||||
|
@ -97,13 +97,81 @@ int32_t ipWhiteMgtUpdate(char *user, SIpWhiteList *pNew) {
|
||||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
int32_t ipWhiteMgtRemove(char *user) {
|
||||||
|
bool update = true;
|
||||||
|
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||||
|
SIpWhiteList **ppList = taosHashGet(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||||
|
if (ppList == NULL || *ppList == NULL) {
|
||||||
|
update = false;
|
||||||
|
} else {
|
||||||
|
taosMemoryFree(*ppList);
|
||||||
|
taosHashRemove(ipWhiteMgt.pIpWhiteTab, user, strlen(user));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (update) ipWhiteMgt.ver++;
|
||||||
|
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isRangeInWhiteList(SIpWhiteList *pList, SIpV4Range *range) {
|
||||||
|
for (int i = 0; i < pList->num; i++) {
|
||||||
|
if (isIpRangeEqual(&pList->pIpRange[i], range)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int32_t ipWhiteUpdateForAllUser(SIpWhiteList *pList) {
|
||||||
|
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||||
|
|
||||||
|
SHashObj *pIpWhiteTab = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), 1, HASH_ENTRY_LOCK);
|
||||||
|
void *pIter = taosHashIterate(ipWhiteMgt.pIpWhiteTab, NULL);
|
||||||
|
|
||||||
|
while (pIter) {
|
||||||
|
SIpWhiteList *p = *(SIpWhiteList **)pIter;
|
||||||
|
SIpWhiteList *clone = cloneIpWhiteList(pList);
|
||||||
|
int32_t idx = 0;
|
||||||
|
for (int i = 0; i < pList->num; i++) {
|
||||||
|
SIpV4Range *e = &pList->pIpRange[i];
|
||||||
|
if (!isRangeInWhiteList(p, e)) {
|
||||||
|
clone->pIpRange[idx] = *e;
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clone->num = idx;
|
||||||
|
|
||||||
|
SIpWhiteList *val = NULL;
|
||||||
|
if (clone->num != 0) {
|
||||||
|
int32_t sz = clone->num + p->num;
|
||||||
|
val = taosMemoryCalloc(1, sizeof(SIpWhiteList) + sz * sizeof(SIpV4Range));
|
||||||
|
memcpy(val->pIpRange, p->pIpRange, sizeof(SIpV4Range) * p->num);
|
||||||
|
memcpy(((char *)val->pIpRange) + sizeof(SIpV4Range) * p->num, (char *)clone->pIpRange,
|
||||||
|
sizeof(SIpV4Range) * clone->num);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
val = cloneIpWhiteList(p);
|
||||||
|
}
|
||||||
|
taosMemoryFree(clone);
|
||||||
|
|
||||||
|
size_t klen;
|
||||||
|
void *key = taosHashGetKey(pIter, &klen);
|
||||||
|
taosHashPut(pIpWhiteTab, key, klen, val, sizeof(void *));
|
||||||
|
}
|
||||||
|
|
||||||
|
destroyIpWhiteTab(ipWhiteMgt.pIpWhiteTab);
|
||||||
|
|
||||||
|
ipWhiteMgt.pIpWhiteTab = pIpWhiteTab;
|
||||||
|
ipWhiteMgt.ver++;
|
||||||
|
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ipWhiteMgtUpdateAll(SMnode *pMnode) {
|
void ipWhiteMgtUpdateAll(SMnode *pMnode) {
|
||||||
ipWhiteMgt.ver++;
|
ipWhiteMgt.ver++;
|
||||||
SHashObj *pNew = mndFetchAllIpWhite(pMnode);
|
SHashObj *pNew = mndFetchAllIpWhite(pMnode);
|
||||||
SHashObj *pOld = ipWhiteMgt.pIpWhiteList;
|
SHashObj *pOld = ipWhiteMgt.pIpWhiteTab;
|
||||||
|
|
||||||
ipWhiteMgt.pIpWhiteList = pNew;
|
ipWhiteMgt.pIpWhiteTab = pNew;
|
||||||
destroyIpWhiteTab(pOld);
|
destroyIpWhiteTab(pOld);
|
||||||
}
|
}
|
||||||
void ipWhiteMgtUpdate2(SMnode *pMnode) {
|
void ipWhiteMgtUpdate2(SMnode *pMnode) {
|
||||||
|
@ -123,15 +191,16 @@ int64_t mndGetIpWhiteVer(SMnode *pMnode) {
|
||||||
|
|
||||||
ver = ipWhiteMgt.ver;
|
ver = ipWhiteMgt.ver;
|
||||||
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
taosThreadRwlockUnlock(&ipWhiteMgt.rw);
|
||||||
|
mInfo("ip-white-mnode ver, %" PRId64 "", ver);
|
||||||
return ver;
|
return ver;
|
||||||
}
|
}
|
||||||
int64_t ipWhiteMgtFillMsg(SUpdateIpWhite *pUpdate) {
|
int64_t ipWhiteMgtFillMsg(SUpdateIpWhite *pUpdate) {
|
||||||
int64_t ver = 0;
|
int64_t ver = 0;
|
||||||
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
taosThreadRwlockWrlock(&ipWhiteMgt.rw);
|
||||||
ver = ipWhiteMgt.ver;
|
ver = ipWhiteMgt.ver;
|
||||||
int32_t num = taosHashGetSize(ipWhiteMgt.pIpWhiteList);
|
int32_t num = taosHashGetSize(ipWhiteMgt.pIpWhiteTab);
|
||||||
pUpdate->pUserIpWhite = taosMemoryCalloc(1, num * sizeof(SUpdateUserIpWhite));
|
pUpdate->pUserIpWhite = taosMemoryCalloc(1, num * sizeof(SUpdateUserIpWhite));
|
||||||
void *pIter = taosHashIterate(ipWhiteMgt.pIpWhiteList, NULL);
|
void *pIter = taosHashIterate(ipWhiteMgt.pIpWhiteTab, NULL);
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while (pIter) {
|
while (pIter) {
|
||||||
SUpdateUserIpWhite *pUser = &pUpdate->pUserIpWhite[i];
|
SUpdateUserIpWhite *pUser = &pUpdate->pUserIpWhite[i];
|
||||||
|
@ -147,7 +216,7 @@ int64_t ipWhiteMgtFillMsg(SUpdateIpWhite *pUpdate) {
|
||||||
memcpy(pUser->pIpRanges, list->pIpRange, list->num * sizeof(SIpV4Range));
|
memcpy(pUser->pIpRanges, list->pIpRange, list->num * sizeof(SIpV4Range));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
pIter = taosHashIterate(ipWhiteMgt.pIpWhiteList, pIter);
|
pIter = taosHashIterate(ipWhiteMgt.pIpWhiteTab, pIter);
|
||||||
}
|
}
|
||||||
pUpdate->numOfUser = i;
|
pUpdate->numOfUser = i;
|
||||||
|
|
||||||
|
@ -327,12 +396,6 @@ static SIpWhiteList *createDefaultIpWhiteList() {
|
||||||
}
|
}
|
||||||
return pWhiteList;
|
return pWhiteList;
|
||||||
}
|
}
|
||||||
static SIpWhiteList *cloneIpWhiteList(SIpWhiteList *pIpWhiteList) {
|
|
||||||
int32_t sz = sizeof(SIpWhiteList) + pIpWhiteList->num * sizeof(SIpV4Range);
|
|
||||||
SIpWhiteList *pNew = taosMemoryCalloc(1, sz);
|
|
||||||
memcpy(pNew, pIpWhiteList, sz);
|
|
||||||
return pNew;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char *pass) {
|
static int32_t mndCreateDefaultUser(SMnode *pMnode, char *acct, char *user, char *pass) {
|
||||||
SUserObj userObj = {0};
|
SUserObj userObj = {0};
|
||||||
|
@ -897,6 +960,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
p->pIpRange[i].ip = pCreate->pIpRanges[i].ip;
|
p->pIpRange[i].ip = pCreate->pIpRanges[i].ip;
|
||||||
p->pIpRange[i].mask = pCreate->pIpRanges[i].mask;
|
p->pIpRange[i].mask = pCreate->pIpRanges[i].mask;
|
||||||
}
|
}
|
||||||
|
p->num = pCreate->numIpRanges;
|
||||||
userObj.pIpWhiteList = p;
|
userObj.pIpWhiteList = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -922,7 +986,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
goto _OVER;
|
goto _OVER;
|
||||||
}
|
}
|
||||||
|
ipWhiteMgtUpdate(userObj.user, userObj.pIpWhiteList);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return 0;
|
return 0;
|
||||||
_OVER:
|
_OVER:
|
||||||
|
@ -1050,7 +1114,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
ipWhiteMgtUpdate(pNew->user, pNew->pIpWhiteList);
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1515,6 +1579,7 @@ static int32_t mndDropUser(SMnode *pMnode, SRpcMsg *pReq, SUserObj *pUser) {
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
ipWhiteMgtRemove(pUser->user);
|
||||||
|
|
||||||
mndTransDrop(pTrans);
|
mndTransDrop(pTrans);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1388,8 +1388,8 @@ void uvHandleUpdate(SSvrMsg* msg, SWorkThrd* thrd) {
|
||||||
for (int i = 0; i < req->numOfUser; i++) {
|
for (int i = 0; i < req->numOfUser; i++) {
|
||||||
SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i];
|
SUpdateUserIpWhite* pUser = &req->pUserIpWhite[i];
|
||||||
|
|
||||||
int32_t sz = sizeof(SIpWhiteList) + pUser->numOfRange * sizeof(SIpV4Range);
|
int32_t sz = pUser->numOfRange * sizeof(SIpV4Range);
|
||||||
SIpWhiteList* pList = taosMemoryCalloc(1, sz);
|
SIpWhiteList* pList = taosMemoryCalloc(1, sz + sizeof(SIpWhiteList));
|
||||||
pList->num = pUser->numOfRange;
|
pList->num = pUser->numOfRange;
|
||||||
|
|
||||||
memcpy(pList->pIpRange, pUser->pIpRanges, sz);
|
memcpy(pList->pIpRange, pUser->pIpRanges, sz);
|
||||||
|
|
Loading…
Reference in New Issue