Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enh/ip white list #22828

Merged
merged 92 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
44dcee0
add rpc update interface
Sep 1, 2023
bf41ee6
add rpc update interface
Sep 1, 2023
2045fd4
add rpc update interface
Sep 1, 2023
30e6a9f
add rpc update interface
Sep 1, 2023
f11763f
add rpc update interface
Sep 2, 2023
b8e9b00
add rpc update interface
Sep 2, 2023
b485a61
add rpc update interface
Sep 2, 2023
e368262
add rpc update interface
Sep 2, 2023
59ce623
add rpc update interface
Sep 4, 2023
685bdea
add rpc update interface
Sep 4, 2023
6257bf1
add rpc update interface
Sep 5, 2023
e539eeb
add rpc update interface
Sep 5, 2023
6f6c517
add rpc update interface
Sep 5, 2023
393ef21
add rpc update interface
Sep 6, 2023
b5d40d0
add rpc update interface
Sep 6, 2023
ac82200
add rpc update interface
Sep 6, 2023
ad5639d
add rpc update interface
Sep 6, 2023
bc27d24
add rpc update interface
Sep 6, 2023
147de26
add rpc update interface
Sep 7, 2023
f4f97a6
add rpc update interface
Sep 7, 2023
8c5fa35
add rpc update interface
Sep 7, 2023
60d6a62
add rpc update interface
Sep 7, 2023
27e3ee8
add rpc update interface
Sep 7, 2023
5670619
add rpc update interface
Sep 8, 2023
1b87d8d
enhance: add hb whitelist version and notify taosadapter
shenglian-zhou Sep 8, 2023
25bc0b2
add rpc update interface
Sep 10, 2023
8ea284f
add rpc update interface
Sep 10, 2023
d121b56
add rpc update interface
Sep 10, 2023
9781766
add rpc update interface
Sep 10, 2023
30a60be
add rpc update interface
Sep 11, 2023
569283f
enhance: add hb whitelist version and notify taosadapter
shenglian-zhou Sep 8, 2023
2a30e12
add rpc update interface
Sep 11, 2023
9abfbba
add rpc update interface
Sep 11, 2023
0572735
add rpc update interface
Sep 11, 2023
d549a47
add rpc update interface
Sep 11, 2023
9da204e
enhance: update notification and get user whitelist api
shenglian-zhou Sep 11, 2023
43a6cdd
Merge branch 'szhou/enh/ipWhiteList' of github.com:taosdata/TDengine …
shenglian-zhou Sep 11, 2023
39d04ed
add rpc update interface
Sep 11, 2023
0a8b1eb
add rpc update interface
Sep 11, 2023
9efa9ee
add rpc update interface
Sep 11, 2023
d9eed32
add rpc update interface
Sep 12, 2023
f29880f
add rpc update interface
Sep 12, 2023
a902421
add user ip white ver
Sep 12, 2023
4d16cfa
add rpc update interface
Sep 12, 2023
64caae8
enhance: add hb whitelist version and notify taosadapter
shenglian-zhou Sep 8, 2023
8db96a0
enhance: update notification and get user whitelist api
shenglian-zhou Sep 11, 2023
53894f1
enhance: add hb whitelist version and notify taosadapter
shenglian-zhou Sep 8, 2023
21dd7a8
Merge branch 'szhou/enh/ipWhiteList' of github.com:taosdata/TDengine …
shenglian-zhou Sep 12, 2023
d5f1662
enh: enterprise version and community version split
shenglian-zhou Sep 12, 2023
e3a6b92
fix: fix minior bugs
shenglian-zhou Sep 12, 2023
7ce8f69
Merge branch 'enh/dev3New' into enh/ipWhiteList
Sep 12, 2023
a44d0bc
Merge branch 'szhou/enh/ipWhiteList' into enh/ipWhiteList
shenglian-zhou Sep 12, 2023
65fe665
fix: get user whitelist version from user object
shenglian-zhou Sep 12, 2023
70a014d
enh: begin writing test
shenglian-zhou Sep 12, 2023
d6f4c40
fix mem leak
Sep 12, 2023
5468c71
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 12, 2023
8f5dd5a
fix case error
Sep 13, 2023
0152646
fix case error
Sep 13, 2023
fa302ac
Merge branch '3.0' into enh/ipWhiteList
yihaoDeng Sep 13, 2023
808630f
update test case
Sep 13, 2023
c0a8f81
update test case
Sep 13, 2023
6cfab63
update test case
Sep 13, 2023
4faa791
refactor code
Sep 13, 2023
772e9c6
update test case
Sep 13, 2023
f29b3b2
update test case
Sep 13, 2023
e781522
update test case
Sep 13, 2023
3c84d8b
Merge branch 'enh/ipWhiteList' of github.com:taosdata/TDengine into s…
shenglian-zhou Sep 14, 2023
7ec3102
update test case
Sep 14, 2023
4931bfa
enhance: add test for api
shenglian-zhou Sep 14, 2023
da55d7e
update test case
Sep 14, 2023
903c628
update test case
Sep 14, 2023
aa1cc01
update test case
Sep 14, 2023
94236b8
fix: pass some test
shenglian-zhou Sep 14, 2023
a15a41f
Merge branch 'enh/ipWhiteList' of github.com:taosdata/TDengine into s…
shenglian-zhou Sep 14, 2023
0a016b1
fix: test case printf
shenglian-zhou Sep 14, 2023
7aa3bd9
fix: remove whitelistttest executable
shenglian-zhou Sep 14, 2023
6dfb939
enhance: enhance test case
shenglian-zhou Sep 14, 2023
2a40113
fix: entprise version compilation
shenglian-zhou Sep 14, 2023
2002ed8
add more error code
Sep 14, 2023
e36dc50
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
59020ff
fix: for community version, use 0.0.0.0/0 as whitelist
shenglian-zhou Sep 14, 2023
972a6a1
Merge branch 'enh/ipWhiteList' of github.com:taosdata/TDengine into e…
shenglian-zhou Sep 14, 2023
2d1d74d
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
011aee7
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
a7d4547
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
02f5f4f
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
2af180c
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
0e496ab
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
250fed4
Merge branch 'enh/ipWhiteList' of https://github.com/taosdata/TDengin…
Sep 14, 2023
167be7c
rm dup ip
Sep 14, 2023
79fe29c
fix compile error
Sep 15, 2023
2fe725d
fix test case
Sep 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/client/taos.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ typedef enum {

typedef enum {
TAOS_NOTIFY_PASSVER = 0,
TAOS_NOTIFY_WHITELIST_VER = 1
} TAOS_NOTIFY_TYPE;

#define RET_MSG_LENGTH 1024
Expand Down Expand Up @@ -236,6 +237,9 @@ DLL_EXPORT void taos_set_hb_quit(int8_t quitByKill);

DLL_EXPORT int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type);

typedef void (*__taos_async_whitelist_fn_t)(void *param, int code, TAOS *taos, int numOfWhiteLists, uint64_t* pWhiteLists);
DLL_EXPORT void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *param);

/* --------------------------schemaless INTERFACE------------------------------- */

DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
Expand Down
57 changes: 54 additions & 3 deletions include/common/tmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ typedef struct {
int32_t authVer;
char sVer[TSDB_VERSION_LEN];
char sDetailVer[128];
int64_t whiteListVer;
} SConnectRsp;

int32_t tSerializeSConnectRsp(void* buf, int32_t bufLen, SConnectRsp* pRsp);
Expand All @@ -875,11 +876,17 @@ typedef struct {
int32_t tSerializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);
int32_t tDeserializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq);

typedef struct SIpV4Range {
uint32_t ip;
uint32_t mask;
typedef struct SIpV4Range{
uint32_t ip;
uint32_t mask;
} SIpV4Range;

typedef struct {
int32_t num;
SIpV4Range pIpRange[];
} SIpWhiteList;

SIpWhiteList* cloneIpWhiteList(SIpWhiteList* pIpWhiteList);
typedef struct {
int8_t createType;
int8_t superUser; // denote if it is a super user or not
Expand All @@ -895,6 +902,30 @@ int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq
int32_t tDeserializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq);
void tFreeSCreateUserReq(SCreateUserReq* pReq);

typedef struct {
int64_t ver;
char user[TSDB_USER_LEN];
int32_t numOfRange;
SIpV4Range* pIpRanges;
} SUpdateUserIpWhite;
typedef struct {
int64_t ver;
int numOfUser;
SUpdateUserIpWhite* pUserIpWhite;
} SUpdateIpWhite;

int32_t tSerializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
int32_t tDeserializeSUpdateIpWhite(void* buf, int32_t bufLen, SUpdateIpWhite* pReq);
void tFreeSUpdateIpWhiteReq(SUpdateIpWhite* pReq);
SUpdateIpWhite* cloneSUpdateIpWhiteReq(SUpdateIpWhite* pReq);

typedef struct {
int64_t ipWhiteVer;
} SRetrieveIpWhiteReq;

int32_t tSerializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);
int32_t tDeserializeRetrieveIpWhite(void* buf, int32_t bufLen, SRetrieveIpWhiteReq* pReq);

typedef struct {
int8_t alterType;
int8_t superUser;
Expand Down Expand Up @@ -935,12 +966,30 @@ typedef struct {
SHashObj* readTbs;
SHashObj* writeTbs;
SHashObj* useDbs;
int64_t whiteListVer;
} SGetUserAuthRsp;

int32_t tSerializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
int32_t tDeserializeSGetUserAuthRsp(void* buf, int32_t bufLen, SGetUserAuthRsp* pRsp);
void tFreeSGetUserAuthRsp(SGetUserAuthRsp* pRsp);

typedef struct {
char user[TSDB_USER_LEN];
} SGetUserWhiteListReq;

int32_t tSerializeSGetUserWhiteListReq(void* buf, int32_t bufLen, SGetUserWhiteListReq* pReq);
int32_t tDeserializeSGetUserWhiteListReq(void* buf, int32_t bufLen, SGetUserWhiteListReq* pReq);

typedef struct {
char user[TSDB_USER_LEN];
int32_t numWhiteLists;
SIpV4Range* pWhiteLists;
} SGetUserWhiteListRsp;

int32_t tSerializeSGetUserWhiteListRsp(void* buf, int32_t bufLen, SGetUserWhiteListRsp* pRsp);
int32_t tDeserializeSGetUserWhiteListRsp(void* buf, int32_t bufLen, SGetUserWhiteListRsp* pRsp);
void tFreeSGetUserWhiteListRsp(SGetUserWhiteListRsp* pRsp);

/*
* for client side struct, only column id, type, bytes are necessary
* But for data in vnode side, we need all the following information.
Expand Down Expand Up @@ -1455,6 +1504,7 @@ typedef struct {
SClusterCfg clusterCfg;
SArray* pVloads; // array of SVnodeLoad
int32_t statusSeq;
int64_t ipWhiteVer;
} SStatusReq;

int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
Expand Down Expand Up @@ -1485,6 +1535,7 @@ typedef struct {
SDnodeCfg dnodeCfg;
SArray* pDnodeEps; // Array of SDnodeEp
int32_t statusSeq;
int64_t ipWhiteVer;
} SStatusRsp;

int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
Expand Down
1 change: 1 addition & 0 deletions include/common/tmsgcb.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef struct {
void* data;
void* mgmt;
void* clientRpc;
void* serverRpc;
PutToQueueFp putToQueueFp;
GetQueueSizeFp qsizeFp;
SendReqFp sendReqFp;
Expand Down
2 changes: 2 additions & 0 deletions include/common/tmsgdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ enum { // WARN: new msg should be appended to segment tail
TD_DEF_MSG_TYPE(TDMT_MND_UPTIME_TIMER, "uptime-timer", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, "lost-consumer-clear", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_HEARTBEAT, "stream-heartbeat", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_RETRIEVE_IP_WHITE, "retrieve-ip-white", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_GET_USER_WHITELIST, "get-user-whitelist", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL)

TD_DEF_MSG_TYPE(TDMT_MND_BALANCE_VGROUP_LEADER, "balance-vgroup-leader", NULL, NULL)
Expand Down
8 changes: 8 additions & 0 deletions include/libs/transport/trpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef struct {
int64_t applyIndex;
uint64_t applyTerm;
char user[TSDB_USER_LEN];

} SRpcConnInfo;

typedef struct SRpcHandleInfo {
Expand All @@ -60,6 +61,8 @@ typedef struct SRpcHandleInfo {
STraceId traceId;

SRpcConnInfo conn;
int8_t forbiddenIp;

} SRpcHandleInfo;

typedef struct SRpcMsg {
Expand Down Expand Up @@ -162,6 +165,11 @@ int rpcSendRequestWithCtx(void *thandle, const SEpSet *pEpSet, SRpcMsg *pMsg,
int rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
int rpcSetDefaultAddr(void *thandle, const char *ip, const char *fqdn);
void *rpcAllocHandle();
void rpcSetIpWhite(void *thandl, void *arg);

int32_t rpcUtilSIpRangeToStr(SIpV4Range *pRange, char *buf);

int32_t rpcUtilSWhiteListToStr(SIpWhiteList *pWhiteList, char **ppBuf);

#ifdef __cplusplus
}
Expand Down
6 changes: 6 additions & 0 deletions include/util/taoserror.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ int32_t* taosGetErrno();
#define TSDB_CODE_INVALID_DATA_FMT TAOS_DEF_ERROR_CODE(0, 0x0132)
#define TSDB_CODE_INVALID_CFG_VALUE TAOS_DEF_ERROR_CODE(0, 0x0133)

#define TSDB_CODE_IP_NOT_IN_WHITE_LIST TAOS_DEF_ERROR_CODE(0, 0x0134)

//client
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
#define TSDB_CODE_TSC_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0201)
Expand Down Expand Up @@ -245,6 +247,10 @@ int32_t* taosGetErrno();
#define TSDB_CODE_MND_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0357)
#define TSDB_CODE_MND_USER_NOT_AVAILABLE TAOS_DEF_ERROR_CODE(0, 0x0358)
#define TSDB_CODE_MND_PRIVILEDGE_EXIST TAOS_DEF_ERROR_CODE(0, 0x0359)
#define TSDB_CODE_MND_USER_HOST_EXIST TAOS_DEF_ERROR_CODE(0, 0x035A)
#define TSDB_CODE_MND_USER_HOST_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x035B)
#define TSDB_CODE_MND_TOO_MANY_USER_HOST TAOS_DEF_ERROR_CODE(0, 0x035C)
#define TSDB_CODE_MND_USER_LOCAL_HOST_NOT_DROP TAOS_DEF_ERROR_CODE(0, 0x035D)

// mnode-stable-part1
#define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360)
Expand Down
5 changes: 3 additions & 2 deletions include/util/tdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ typedef enum ELogicConditionType {
#define TSDB_UNI_LEN 24
#define TSDB_USER_LEN TSDB_UNI_LEN

#define TSDB_POINTER_PRINT_BYTES 18 // 0x1122334455667788
#define TSDB_POINTER_PRINT_BYTES 18 // 0x1122334455667788
// ACCOUNT is a 32 bit positive integer
// this is the length of its string representation, including the terminator zero
#define TSDB_ACCT_ID_LEN 11
Expand All @@ -202,6 +202,7 @@ typedef enum ELogicConditionType {
#define TSDB_DB_NAME_LEN 65
#define TSDB_DB_FNAME_LEN (TSDB_ACCT_ID_LEN + TSDB_DB_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_PRIVILEDGE_CONDITION_LEN 48 * 1024
#define TSDB_PRIVILEDGE_HOST_LEN 48 * 1024

#define TSDB_FUNC_NAME_LEN 65
#define TSDB_FUNC_COMMENT_LEN 1024 * 1024
Expand Down Expand Up @@ -417,7 +418,7 @@ typedef enum ELogicConditionType {
#define TSDB_EXPLAIN_RESULT_ROW_SIZE (16 * 1024)
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY_PLAN"

#define TSDB_MAX_FIELD_LEN 65519 // 16384:65519
#define TSDB_MAX_FIELD_LEN 65519 // 16384:65519
#define TSDB_MAX_BINARY_LEN TSDB_MAX_FIELD_LEN // 16384-8:65519
#define TSDB_MAX_NCHAR_LEN TSDB_MAX_FIELD_LEN // 16384-8:65519
#define TSDB_MAX_GEOMETRY_LEN TSDB_MAX_FIELD_LEN // 16384-8:65519
Expand Down
7 changes: 7 additions & 0 deletions source/client/inc/clientInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ typedef struct {
__taos_notify_fn_t fp;
} SPassInfo;

typedef struct {
int64_t ver;
void* param;
__taos_notify_fn_t fp;
} SWhiteListInfo;

typedef struct STscObj {
char user[TSDB_USER_LEN];
char pass[TSDB_PASSWORD_LEN];
Expand All @@ -152,6 +158,7 @@ typedef struct STscObj {
SAppInstInfo* pAppInfo;
SHashObj* pRequests;
SPassInfo passInfo;
SWhiteListInfo whiteListInfo;
} STscObj;

typedef struct STscDbg {
Expand Down
13 changes: 13 additions & 0 deletions source/client/src/clientHb.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ static int32_t hbUpdateUserAuthInfo(SAppHbMgr *pAppHbMgr, SUserAuthBatchRsp *bat
atomic_load_32(&passInfo->ver), pTscObj->id);
}
}

if (pTscObj->whiteListInfo.fp) {
SWhiteListInfo *whiteListInfo = &pTscObj->whiteListInfo;
int64_t oldVer = atomic_load_64(&whiteListInfo->ver);
if (oldVer < pRsp->whiteListVer) {
atomic_store_64(&whiteListInfo->ver, pRsp->whiteListVer);
if (whiteListInfo->fp) {
(*whiteListInfo->fp)(whiteListInfo->param, &pRsp->whiteListVer, TAOS_NOTIFY_WHITELIST_VER);
}
tscDebug("update whitelist version of user %s from %"PRId64" to %"PRId64", tscRid:%" PRIi64, pRsp->user, oldVer,
atomic_load_64(&whiteListInfo->ver), pTscObj->id);
}
}
releaseTscObj(pReq->connKey.tscRid);
}
}
Expand Down
114 changes: 114 additions & 0 deletions source/client/src/clientMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type)
taosThreadMutexUnlock(&pObj->mutex);
break;
}
case TAOS_NOTIFY_WHITELIST_VER: {
taosThreadMutexLock(&pObj->mutex);
pObj->whiteListInfo.fp = fp;
pObj->whiteListInfo.param = param;
taosThreadMutexUnlock(&pObj->mutex);
break;
}
default: {
terrno = TSDB_CODE_INVALID_PARA;
releaseTscObj(*(int64_t *)taos);
Expand All @@ -151,6 +158,113 @@ int taos_set_notify_cb(TAOS *taos, __taos_notify_fn_t fp, void *param, int type)
return 0;
}

typedef struct SFetchWhiteListInfo{
int64_t connId;
__taos_async_whitelist_fn_t userCbFn;
void* userParam;
} SFetchWhiteListInfo;

int32_t fetchWhiteListCallbackFn(void* param, SDataBuf* pMsg, int32_t code) {
SFetchWhiteListInfo* pInfo = (SFetchWhiteListInfo*)param;
TAOS* taos = &pInfo->connId;
if (code != TSDB_CODE_SUCCESS) {
pInfo->userCbFn(pInfo->userParam, code, taos, 0, NULL);
taosMemoryFree(pMsg->pData);
taosMemoryFree(pMsg->pEpSet);
taosMemoryFree(pInfo);
return code;
}

SGetUserWhiteListRsp wlRsp;
tDeserializeSGetUserWhiteListRsp(pMsg->pData, pMsg->len, &wlRsp);

uint64_t* pWhiteLists = taosMemoryMalloc(wlRsp.numWhiteLists * sizeof(uint64_t));
if (pWhiteLists == NULL) {
taosMemoryFree(pMsg->pData);
taosMemoryFree(pMsg->pEpSet);
taosMemoryFree(pInfo);
tFreeSGetUserWhiteListRsp(&wlRsp);
}

for (int i = 0; i < wlRsp.numWhiteLists; ++i) {
pWhiteLists[i] = ((uint64_t)wlRsp.pWhiteLists[i].mask << 32) | wlRsp.pWhiteLists[i].ip;
}

pInfo->userCbFn(pInfo->userParam, code, taos, wlRsp.numWhiteLists, pWhiteLists);

taosMemoryFree(pWhiteLists);
taosMemoryFree(pMsg->pData);
taosMemoryFree(pMsg->pEpSet);
taosMemoryFree(pInfo);
tFreeSGetUserWhiteListRsp(&wlRsp);
return code;
}

void taos_fetch_whitelist_a(TAOS *taos, __taos_async_whitelist_fn_t fp, void *param) {
if (NULL == taos) {
fp(param, TSDB_CODE_INVALID_PARA, taos, 0, NULL);
return;
}

int64_t connId = *(int64_t*)taos;

STscObj *pTsc = acquireTscObj(connId);
if (NULL == pTsc) {
fp(param, TSDB_CODE_TSC_DISCONNECTED, taos, 0, NULL);
return;
}

SGetUserWhiteListReq req;
memcpy(req.user, pTsc->user, TSDB_USER_LEN);
int32_t msgLen = tSerializeSGetUserWhiteListReq(NULL, 0, &req);
void* pReq = taosMemoryMalloc(msgLen);
if (pReq == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
releaseTscObj(connId);
return;
}

if (tSerializeSGetUserWhiteListReq(pReq, msgLen, &req) < 0) {
fp(param, TSDB_CODE_INVALID_PARA, taos, 0, NULL);
taosMemoryFree(pReq);
releaseTscObj(connId);
return;
}

SFetchWhiteListInfo* pParam = taosMemoryMalloc(sizeof(SFetchWhiteListInfo));
if (pParam == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
taosMemoryFree(pReq);
releaseTscObj(connId);
return;
}

pParam->connId = connId;
pParam->userCbFn = fp;
pParam->userParam = param;
SMsgSendInfo* pSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if (pSendInfo == NULL) {
fp(param, TSDB_CODE_OUT_OF_MEMORY, taos, 0, NULL);
taosMemoryFree(pParam);
taosMemoryFree(pReq);
releaseTscObj(connId);
return;
}

pSendInfo->msgInfo = (SDataBuf){.pData = pReq, .len = msgLen, .handle = NULL};
pSendInfo->requestId = generateRequestId();
pSendInfo->requestObjRefId = 0;
pSendInfo->param = pParam;
pSendInfo->fp = fetchWhiteListCallbackFn;
pSendInfo->msgType = TDMT_MND_GET_USER_WHITELIST;

int64_t transportId = 0;
SEpSet epSet = getEpSet_s(&pTsc->pAppInfo->mgmtEp);
asyncSendMsgToServer(pTsc->pAppInfo->pTransporter, &epSet, &transportId, pSendInfo);
releaseTscObj(connId);
return;
}

void taos_close_internal(void *taos) {
if (taos == NULL) {
return;
Expand Down
1 change: 1 addition & 0 deletions source/client/src/clientMsgHandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
pTscObj->connType = connectRsp.connType;
pTscObj->passInfo.ver = connectRsp.passVer;
pTscObj->authVer = connectRsp.authVer;
pTscObj->whiteListInfo.ver = connectRsp.whiteListVer;

hbRegisterConn(pTscObj->pAppInfo->pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType);

Expand Down