提交 04b5df62 编写于 作者: S slguan

[TBASE-1241]

上级 d774aa39
......@@ -224,9 +224,7 @@ typedef struct {
uint32_t destId;
char meterId[TSDB_UNI_LEN];
uint16_t port; // for UDP only
uint8_t usePublicIp : 1;
uint8_t isCluster : 1;
uint8_t empty : 6;
char empty[1];
uint8_t msgType;
int32_t msgLen;
uint8_t content[0];
......@@ -666,11 +664,8 @@ typedef struct {
typedef struct {
uint32_t destId;
char meterId[TSDB_UNI_LEN];
uint16_t port; // for UDP only
uint8_t usePublicIp : 1;
uint8_t isCluster : 1;
uint8_t empty : 6;
uint8_t msgType;
char empty[3];
char msgType;
int32_t msgLen;
uint8_t content[0];
} SIntMsg;
......
......@@ -80,6 +80,7 @@ extern short tsNumOfVnodesPerCore;
extern short tsNumOfTotalVnodes;
extern short tsCheckHeaderFile;
extern uint32_t tsServerIp;
extern uint32_t tsPublicIpInt;
extern int tsSessionsPerVnode;
extern int tsAverageCacheBlocks;
......@@ -151,7 +152,6 @@ extern int tsAdminRowLimit;
extern int tsTscEnableRecordSql;
extern int tsAnyIp;
extern int tsUsePublicIp;
extern int tsIsCluster;
extern char tsMonitorDbName[];
......
......@@ -109,6 +109,8 @@ int taosSetSecurityInfo(int cid, int sid, char *id, int spi, int encrypt, char *
void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint16_t *peerPort, int *cid, int *sid);
uint32_t taosGetRpcLocalIp(void *thandle);
int taosGetOutType(void *thandle);
#ifdef __cplusplus
......
......@@ -246,8 +246,6 @@ char *taosBuildReqHeader(void *param, char type, char *msg) {
pHeader->destId = pConn->peerId;
pHeader->port = 0;
pHeader->uid = (uint32_t)pConn + (uint32_t)getpid();
pHeader->usePublicIp = (tsUsePublicIp == 0 ? 0 : 1);
pHeader->isCluster = (tsIsCluster == 0 ? 0 : 1);
memcpy(pHeader->meterId, pConn->meterId, tListLen(pHeader->meterId));
......@@ -1412,6 +1410,11 @@ void taosGetRpcConnInfo(void *thandle, uint32_t *peerId, uint32_t *peerIp, uint1
*sid = pConn->sid;
}
uint32_t taosGetRpcLocalIp(void *thandle) {
SRpcConn *pConn = (SRpcConn *)thandle;
return pConn->peerIp;
}
int taosGetOutType(void *thandle) {
SRpcConn *pConn = (SRpcConn *)thandle;
if (pConn == NULL) return -1;
......
......@@ -222,9 +222,8 @@ typedef struct _connObj {
char superAuth : 1; // super user flag
char writeAuth : 1; // write flag
char killConnection : 1; // kill the connection flag
char usePublicIp : 1; // if the connection request is publicIp
char isCluster : 1;
char reserved : 3;
uint8_t usePublicIp : 1; // if the connection request is publicIp
uint8_t reserved : 4;
uint32_t queryId; // query ID to be killed
uint32_t streamId; // stream ID to be killed
uint32_t ip; // shell IP
......
......@@ -1201,12 +1201,6 @@ int mgmtProcessConnectMsg(char *pMsg, int msgLen, SConnObj *pConn) {
goto _rsp;
}
if (pConn->isCluster != tsIsCluster) {
mError("Cluster Edition and lite Edition cannot be interconnected, client:%d server:%d", pConn->isCluster, tsIsCluster);
code = TSDB_CODE_INVALID_CLIENT_VERSION;
goto _rsp;
}
if (pConnectMsg->db[0]) {
sprintf(dbName, "%x%s%s", pAcct->acctId, TS_PATH_DELIMITER, pConnectMsg->db);
pDb = mgmtGetDb(dbName);
......@@ -1226,7 +1220,12 @@ int mgmtProcessConnectMsg(char *pMsg, int msgLen, SConnObj *pConn) {
pConn->pAcct = pAcct;
pConn->pDb = pDb;
pConn->pUser = pUser;
uint32_t peerIp = taosGetRpcLocalIp(pConn->thandle);
pConn->usePublicIp = (peerIp == tsPublicIpInt ? 1 : 0);
mgmtEstablishConn(pConn);
mPrint("pConn:%p is created, peerIp:%s publicIp:%s usePublicIp:%u",
pConn, taosIpStr(peerIp), taosIpStr(tsPublicIpInt), pConn->usePublicIp);
_rsp:
pStart = taosBuildRspMsgWithSize(pConn->thandle, TSDB_MSG_TYPE_CONNECT_RSP, 128);
......@@ -1302,15 +1301,12 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
pConn->thandle = thandle;
strcpy(pConn->user, pMsg->meterId);
uint32_t ip = taosGetRpcLocalIp(thandle);
if (ip == tsPublicIp) {
pConn->usePublicIp = true;
}
uint32_t peerIp = taosGetRpcLocalIp(thandle);
pConn->usePublicIp = (peerIp == tsPublicIpInt ? 1 : 0);
mPrint("pConn:%p is rebuild, peerIp:%s publicIp:%s usePublicIp:%u",
pConn, taosIpStr(peerIp), taosIpStr(tsPublicIpInt), pConn->usePublicIp);
}
pConn->usePublicIp = pMsg->usePublicIp;
pConn->isCluster = pMsg->isCluster;
if (pMsg->msgType == TSDB_MSG_TYPE_CONNECT) {
(*mgmtProcessShellMsg[pMsg->msgType])((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pConn);
} else {
......
......@@ -164,7 +164,7 @@ int tsAdminRowLimit = 10240;
int tsTscEnableRecordSql = 0;
int tsEnableCoreFile = 0;
int tsAnyIp = 1;
int tsUsePublicIp = 0;
uint32_t tsPublicIpInt = 0;
#ifdef CLUSTER
int tsIsCluster = 1;
......@@ -789,9 +789,6 @@ static void doInitGlobalConfig() {
0, 1, 0, TSDB_CFG_UTYPE_NONE);
#endif
tsInitConfigOption(cfg++, "usePublicIp", &tsUsePublicIp, TSDB_CFG_VTYPE_INT,
TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT,
0, 1, 0, TSDB_CFG_UTYPE_NONE);
// version info
tsInitConfigOption(cfg++, "gitinfo", gitinfo, TSDB_CFG_VTYPE_STRING,
TSDB_CFG_CTYPE_B_SHOW | TSDB_CFG_CTYPE_B_CLIENT,
......@@ -916,6 +913,7 @@ bool tsReadGlobalConfig() {
if (tsPublicIp[0] == 0) {
strcpy(tsPublicIp, tsPrivateIp);
}
tsPublicIpInt = inet_addr(tsPublicIp);
if (tsLocalIp[0] == 0) {
strcpy(tsLocalIp, tsPrivateIp);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册