diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 3fac0c74f2c868470d5b318e41d4099a1872e157..801256644c56d0f26e651f11769dd21cc3bc9a1f 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2643,9 +2643,6 @@ int tscBuildConnectMsg(SSqlObj *pSql) { strcpy(pConnect->db, db); strcpy(pConnect->clientVersion, version); - pConnect->usePublicIp = (int8_t)tsUsePublicIp; - pConnect->isCluster = (int8_t)tsIsCluster; - memset(pConnect->reserved, 0, sizeof(pConnect->reserved)); pMsg += sizeof(SConnectMsg); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index ae58c43477e7b4cb1adfe814aa7bfa944f799076..1d20ad76eda9d992cf04f400e2f0a32d708b2245 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -224,7 +224,9 @@ typedef struct { uint32_t destId; char meterId[TSDB_UNI_LEN]; uint16_t port; // for UDP only - char empty[1]; + uint8_t usePublicIp : 1; + uint8_t isCluster : 1; + uint8_t empty : 6; uint8_t msgType; int32_t msgLen; uint8_t content[0]; @@ -352,9 +354,6 @@ typedef struct { typedef struct { char clientVersion[TSDB_VERSION_LEN]; char db[TSDB_METER_ID_LEN]; - int8_t usePublicIp; - int8_t isCluster; - int8_t reserved[14]; } SConnectMsg; typedef struct { @@ -667,8 +666,11 @@ typedef struct { typedef struct { uint32_t destId; char meterId[TSDB_UNI_LEN]; - char empty[3]; - char msgType; + uint16_t port; // for UDP only + uint8_t usePublicIp : 1; + uint8_t isCluster : 1; + uint8_t empty : 6; + uint8_t msgType; int32_t msgLen; uint8_t content[0]; } SIntMsg; diff --git a/src/rpc/src/trpc.c b/src/rpc/src/trpc.c index 9f006ab05a9612a1ca2f6f8e3e790156938bf423..7b5229ddc79f6f959f8c296f4d4bb738cca74417 100755 --- a/src/rpc/src/trpc.c +++ b/src/rpc/src/trpc.c @@ -246,6 +246,8 @@ 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)); diff --git a/src/system/detail/inc/mgmt.h b/src/system/detail/inc/mgmt.h index b59c5cf61c876c6b9429af09f08ec90c4d3566ac..e3392740250d05ae394c53bbc800d3f76e113583 100644 --- a/src/system/detail/inc/mgmt.h +++ b/src/system/detail/inc/mgmt.h @@ -223,7 +223,8 @@ typedef struct _connObj { char writeAuth : 1; // write flag char killConnection : 1; // kill the connection flag 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 streamId; // stream ID to be killed uint32_t ip; // shell IP diff --git a/src/system/detail/src/mgmtShell.c b/src/system/detail/src/mgmtShell.c index 576353d758fe12882415ecd01bffefb97656aa6a..43342185301099097067fcd46bd42d9a0d088d69 100644 --- a/src/system/detail/src/mgmtShell.c +++ b/src/system/detail/src/mgmtShell.c @@ -1201,8 +1201,8 @@ int mgmtProcessConnectMsg(char *pMsg, int msgLen, SConnObj *pConn) { goto _rsp; } - if (pConnectMsg->isCluster != tsIsCluster) { - mError("Cluster Edition and lite Edition cannot be interconnected, client:%d server:%d", pConnectMsg->isCluster, tsIsCluster); + 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; } @@ -1246,17 +1246,13 @@ _rsp: pMsg += sizeof(SConnectRsp); #ifdef CLUSTER - if (pConnectMsg->usePublicIp) { - pConn->usePublicIp = 1; - int size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList); + int size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList); + if (pConn->usePublicIp) { memcpy(pMsg, pSdbPublicIpList, size); - pMsg += size; - } - else { - int size = pSdbIpList->numOfIps * 4 + sizeof(SIpList); + } else { memcpy(pMsg, pSdbIpList, size); - pMsg += size; } + pMsg += size; #endif // set the time resolution: millisecond or microsecond @@ -1305,8 +1301,16 @@ void *mgmtProcessMsgFromShell(char *msg, void *ahandle, void *thandle) { pConn = connList + pMsg->destId; pConn->thandle = thandle; 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) { (*mgmtProcessShellMsg[pMsg->msgType])((char *)pMsg->content, pMsg->msgLen - sizeof(SIntMsg), pConn); } else {