add rpc update interface
This commit is contained in:
parent
9abfbbab5e
commit
05727359ca
|
@ -93,7 +93,7 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) {
|
|||
|
||||
if (pRpc->info.forbiddenIp == 1) {
|
||||
char tbuf[36] = {0};
|
||||
SIpV4Range range = {.ip = pRpc->info.conn.clientIp, .mask = 0};
|
||||
SIpV4Range range = {.ip = pRpc->info.conn.clientIp, .mask = 32};
|
||||
rpcUtilSIpRangeToStr(&range, tbuf);
|
||||
|
||||
dError("User %s host:%s not in ip white list", pRpc->info.conn.user, tbuf);
|
||||
|
|
|
@ -831,95 +831,6 @@ _OVER:
|
|||
return code;
|
||||
}
|
||||
|
||||
// void mndUpdateIpWhiteOfDnode(SMnode *pMnode, char *fqdn, int8_t type) {
|
||||
// if (type == DND_CREATE) {
|
||||
|
||||
// } else if (type == DND_ADD) {
|
||||
|
||||
// } else if (type == DND_DROP) {
|
||||
|
||||
// }
|
||||
// }
|
||||
// SIpWhiteList *mndCreateIpWhiteOfDnode(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;
|
||||
// }
|
||||
|
||||
// SIpWhiteList *mndAddIpWhiteOfDnode(SIpWhiteList *pIpWhiteList, char *fqdn) {
|
||||
// SIpV4Range dst = {.ip = taosGetFqdn(fqdn), .mask = 0};
|
||||
// bool exist = false;
|
||||
// for (int i = 0; i < pIpWhiteList->num; i++) {
|
||||
// SIpV4Range *pRange = &pIpWhiteList->pIpRange[i];
|
||||
// if (pRange->ip == dst.ip && pRange->mask == dst.mask) {
|
||||
// exist = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (exist) {
|
||||
// return cloneIpWhiteList(pIpWhiteList);
|
||||
|
||||
// } else {
|
||||
// SIpWhiteList *pRet = taosMemoryCalloc(1, sizeof(SIpWhiteList) + (pIpWhiteList->num + 1) * sizeof(SIpV4Range));
|
||||
// pRet->num = pIpWhiteList->num + 1;
|
||||
|
||||
// memcpy(pRet->pIpRange, pIpWhiteList->pIpRange, sizeof(SIpV4Range) * pIpWhiteList->num);
|
||||
|
||||
// SIpV4Range *pLast = &pRet->pIpRange[pIpWhiteList->num];
|
||||
// pLast->ip = dst.ip;
|
||||
// pLast->mask = dst.mask;
|
||||
// return pRet;
|
||||
// }
|
||||
// }
|
||||
// SIpWhiteList *mndRmIpWhiteOfDnode(SIpWhiteList *pIpWhiteList, char *fqdn) {
|
||||
// SIpV4Range tgt = {.ip = taosGetFqdn(fqdn), .mask = 0};
|
||||
|
||||
// SIpWhiteList *pRet = taosMemoryCalloc(1, sizeof(SIpWhiteList) + (pIpWhiteList->num) * sizeof(SIpV4Range));
|
||||
// int32_t idx = 0;
|
||||
// for (int i = 0; i < pIpWhiteList->num; i++) {
|
||||
// SIpV4Range *pSrc = &pIpWhiteList->pIpRange[i];
|
||||
// SIpV4Range *pDst = &pIpWhiteList->pIpRange[idx];
|
||||
// if (pSrc->ip != tgt.ip || pSrc->mask != tgt.mask) {
|
||||
// pDst[idx].ip = pSrc[i].ip;
|
||||
// pDst[idx].mask = pSrc[i].mask;
|
||||
// idx++;
|
||||
// }
|
||||
// }
|
||||
// pRet->num = idx;
|
||||
// if (pRet->num == 0) {
|
||||
// taosMemoryFree(pRet);
|
||||
// return NULL;
|
||||
// }
|
||||
|
||||
// return pRet;
|
||||
// }
|
||||
|
||||
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
|
||||
SShowVariablesRsp rsp = {0};
|
||||
int32_t code = -1;
|
||||
|
|
|
@ -198,7 +198,7 @@ int64_t mndGetIpWhiteVer(SMnode *pMnode) {
|
|||
|
||||
bool mndUpdateIpWhiteImpl(SHashObj *pIpWhiteTab, char *user, char *fqdn, int8_t type) {
|
||||
bool update = false;
|
||||
SIpV4Range range = {.ip = taosGetIpv4FromFqdn(fqdn), .mask = 0};
|
||||
SIpV4Range range = {.ip = taosGetIpv4FromFqdn(fqdn), .mask = 32};
|
||||
|
||||
SIpWhiteList **ppList = taosHashGet(pIpWhiteTab, user, strlen(user));
|
||||
SIpWhiteList *pList = NULL;
|
||||
|
@ -508,7 +508,7 @@ static SIpWhiteList *createDefaultIpWhiteList() {
|
|||
struct in_addr addr;
|
||||
if (uv_inet_pton(AF_INET, "127.0.0.1", &addr) == 0) {
|
||||
range->ip = addr.s_addr;
|
||||
range->mask = 0;
|
||||
range->mask = 32;
|
||||
}
|
||||
return pWhiteList;
|
||||
}
|
||||
|
|
|
@ -679,21 +679,23 @@ void subnetIp2int(const char* const ip_addr, uint8_t* dst) {
|
|||
}
|
||||
|
||||
uint32_t subnetIpRang2Int(SIpV4Range* pRange) {
|
||||
SIpV4Range range = {.ip = pRange->ip, .mask = 0};
|
||||
SIpV4Range range = {.ip = pRange->ip, .mask = 32};
|
||||
uint8_t el[4] = {0};
|
||||
char buf[32] = {0};
|
||||
|
||||
transUtilSIpRangeToStr(&range, buf);
|
||||
|
||||
subnetIp2int(buf, el);
|
||||
|
||||
return (el[0] << 24) | (el[1] << 16) | (el[2] << 8) | (el[0]);
|
||||
}
|
||||
int32_t subnetInit(SubnetUtils* pUtils, SIpV4Range* pRange) {
|
||||
if (pRange->mask == 0) {
|
||||
pUtils->address = pRange->ip;
|
||||
if (pRange->mask == 0 || pRange->mask == 32) {
|
||||
pUtils->type = 0;
|
||||
pUtils->address = pRange->ip;
|
||||
return 0;
|
||||
}
|
||||
// pUtils->address = ntohl(pRange->ip);
|
||||
pUtils->address = subnetIpRang2Int(pRange);
|
||||
|
||||
for (int i = 0; i < pRange->mask; i++) {
|
||||
|
@ -717,8 +719,9 @@ int32_t subnetCheckIp(SubnetUtils* pUtils, uint32_t ip) {
|
|||
if (pUtils->type == 0) {
|
||||
return pUtils->address == ip;
|
||||
} else {
|
||||
SIpV4Range range = {.ip = ip, .mask = 0};
|
||||
SIpV4Range range = {.ip = ip, .mask = 32};
|
||||
|
||||
// uint32_t ip = ntohl(ip);
|
||||
uint32_t ip = subnetIpRang2Int(&range);
|
||||
return ip >= pUtils->network && ip <= pUtils->broadcast;
|
||||
}
|
||||
|
@ -731,9 +734,10 @@ int32_t transUtilSIpRangeToStr(SIpV4Range* pRange, char* buf) {
|
|||
addr.s_addr = pRange->ip;
|
||||
|
||||
uv_inet_ntop(AF_INET, &addr, buf, 32);
|
||||
|
||||
len = strlen(buf);
|
||||
|
||||
if (pRange->mask != 0) {
|
||||
if (pRange->mask != 0 && pRange->mask != 32) {
|
||||
len += sprintf(buf + len, "/%d", pRange->mask);
|
||||
}
|
||||
buf[len] = 0;
|
||||
|
|
|
@ -294,7 +294,7 @@ void uvWhiteListUpdate(SWhiteList* pWhite, SHashObj* pTable) {
|
|||
|
||||
static bool uvWhiteListIsDefaultAddr(uint32_t ip) {
|
||||
// 127.0.0.1
|
||||
static SIpV4Range range = {.ip = 16777343, .mask = 0};
|
||||
static SIpV4Range range = {.ip = 16777343, .mask = 32};
|
||||
return range.ip == ip;
|
||||
}
|
||||
bool uvWhiteListFilte(SWhiteList* pWhite, char* user, uint32_t ip, int64_t ver) {
|
||||
|
|
Loading…
Reference in New Issue