提交 d774aa39 编写于 作者: S slguan

[TBASE-1241]

上级 1475d520
...@@ -2643,9 +2643,6 @@ int tscBuildConnectMsg(SSqlObj *pSql) { ...@@ -2643,9 +2643,6 @@ int tscBuildConnectMsg(SSqlObj *pSql) {
strcpy(pConnect->db, db); strcpy(pConnect->db, db);
strcpy(pConnect->clientVersion, version); strcpy(pConnect->clientVersion, version);
pConnect->usePublicIp = (int8_t)tsUsePublicIp;
pConnect->isCluster = (int8_t)tsIsCluster;
memset(pConnect->reserved, 0, sizeof(pConnect->reserved));
pMsg += sizeof(SConnectMsg); pMsg += sizeof(SConnectMsg);
......
...@@ -224,7 +224,9 @@ typedef struct { ...@@ -224,7 +224,9 @@ typedef struct {
uint32_t destId; uint32_t destId;
char meterId[TSDB_UNI_LEN]; char meterId[TSDB_UNI_LEN];
uint16_t port; // for UDP only uint16_t port; // for UDP only
char empty[1]; uint8_t usePublicIp : 1;
uint8_t isCluster : 1;
uint8_t empty : 6;
uint8_t msgType; uint8_t msgType;
int32_t msgLen; int32_t msgLen;
uint8_t content[0]; uint8_t content[0];
...@@ -352,9 +354,6 @@ typedef struct { ...@@ -352,9 +354,6 @@ typedef struct {
typedef struct { typedef struct {
char clientVersion[TSDB_VERSION_LEN]; char clientVersion[TSDB_VERSION_LEN];
char db[TSDB_METER_ID_LEN]; char db[TSDB_METER_ID_LEN];
int8_t usePublicIp;
int8_t isCluster;
int8_t reserved[14];
} SConnectMsg; } SConnectMsg;
typedef struct { typedef struct {
...@@ -667,8 +666,11 @@ typedef struct { ...@@ -667,8 +666,11 @@ typedef struct {
typedef struct { typedef struct {
uint32_t destId; uint32_t destId;
char meterId[TSDB_UNI_LEN]; char meterId[TSDB_UNI_LEN];
char empty[3]; uint16_t port; // for UDP only
char msgType; uint8_t usePublicIp : 1;
uint8_t isCluster : 1;
uint8_t empty : 6;
uint8_t msgType;
int32_t msgLen; int32_t msgLen;
uint8_t content[0]; uint8_t content[0];
} SIntMsg; } SIntMsg;
......
...@@ -246,6 +246,8 @@ char *taosBuildReqHeader(void *param, char type, char *msg) { ...@@ -246,6 +246,8 @@ char *taosBuildReqHeader(void *param, char type, char *msg) {
pHeader->destId = pConn->peerId; pHeader->destId = pConn->peerId;
pHeader->port = 0; pHeader->port = 0;
pHeader->uid = (uint32_t)pConn + (uint32_t)getpid(); 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)); memcpy(pHeader->meterId, pConn->meterId, tListLen(pHeader->meterId));
......
...@@ -223,7 +223,8 @@ typedef struct _connObj { ...@@ -223,7 +223,8 @@ typedef struct _connObj {
char writeAuth : 1; // write flag char writeAuth : 1; // write flag
char killConnection : 1; // kill the connection flag char killConnection : 1; // kill the connection flag
char usePublicIp : 1; // if the connection request is publicIp char usePublicIp : 1; // if the connection request is publicIp
char reserved : 4; char isCluster : 1;
char reserved : 3;
uint32_t queryId; // query ID to be killed uint32_t queryId; // query ID to be killed
uint32_t streamId; // stream ID to be killed uint32_t streamId; // stream ID to be killed
uint32_t ip; // shell IP uint32_t ip; // shell IP
......
...@@ -1201,8 +1201,8 @@ int mgmtProcessConnectMsg(char *pMsg, int msgLen, SConnObj *pConn) { ...@@ -1201,8 +1201,8 @@ int mgmtProcessConnectMsg(char *pMsg, int msgLen, SConnObj *pConn) {
goto _rsp; goto _rsp;
} }
if (pConnectMsg->isCluster != tsIsCluster) { if (pConn->isCluster != tsIsCluster) {
mError("Cluster Edition and lite Edition cannot be interconnected, client:%d server:%d", pConnectMsg->isCluster, tsIsCluster); mError("Cluster Edition and lite Edition cannot be interconnected, client:%d server:%d", pConn->isCluster, tsIsCluster);
code = TSDB_CODE_INVALID_CLIENT_VERSION; code = TSDB_CODE_INVALID_CLIENT_VERSION;
goto _rsp; goto _rsp;
} }
...@@ -1246,17 +1246,13 @@ _rsp: ...@@ -1246,17 +1246,13 @@ _rsp:
pMsg += sizeof(SConnectRsp); pMsg += sizeof(SConnectRsp);
#ifdef CLUSTER #ifdef CLUSTER
if (pConnectMsg->usePublicIp) { int size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList);
pConn->usePublicIp = 1; if (pConn->usePublicIp) {
int size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList);
memcpy(pMsg, pSdbPublicIpList, size); memcpy(pMsg, pSdbPublicIpList, size);
pMsg += size; } else {
}
else {
int size = pSdbIpList->numOfIps * 4 + sizeof(SIpList);
memcpy(pMsg, pSdbIpList, size); memcpy(pMsg, pSdbIpList, size);
pMsg += size;
} }
pMsg += size;
#endif #endif
// set the time resolution: millisecond or microsecond // set the time resolution: millisecond or microsecond
...@@ -1305,8 +1301,16 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) { ...@@ -1305,8 +1301,16 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) {
pConn = connList + pMsg->destId; pConn = connList + pMsg->destId;
pConn->thandle = thandle; pConn->thandle = thandle;
strcpy(pConn->user, pMsg->meterId); strcpy(pConn->user, pMsg->meterId);
uint32_t ip = taosGetRpcLocalIp(thandle);
if (ip == tsPublicIp) {
pConn->usePublicIp = true;
}
} }
pConn->usePublicIp = pMsg->usePublicIp;
pConn->isCluster = pMsg->isCluster;
if (pMsg->msgType == TSDB_MSG_TYPE_CONNECT) { if (pMsg->msgType == TSDB_MSG_TYPE_CONNECT) {
(*mgmtProcessShellMsg[pMsg->msgType])((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pConn); (*mgmtProcessShellMsg[pMsg->msgType])((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pConn);
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册