diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 7f3f0273dbc2672bd8e720e507e8e3a224eb21ed..fb68f6dfaf5c6192714514989a1ab92412a03899 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -2601,7 +2601,7 @@ int tscProcessRetrieveMetricRsp(SSqlObj *pSql) { int tscProcessEmptyResultRsp(SSqlObj *pSql) { return tscLocalResultCommonBuilder(pSql, 0); } int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { - SConnectMsg *pConnect; + SCMConnectMsg *pConnect; char * pMsg, *pStart; SSqlCmd *pCmd = &pSql->cmd; @@ -2609,7 +2609,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { pMsg = pCmd->payload + tsRpcHeadSize; pStart = pMsg; - pConnect = (SConnectMsg *)pMsg; + pConnect = (SCMConnectMsg *)pMsg; char *db; // ugly code to move the space db = strstr(pObj->db, TS_PATH_DELIMITER); @@ -2618,7 +2618,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { strcpy(pConnect->clientVersion, version); - pMsg += sizeof(SConnectMsg); + pMsg += sizeof(SCMConnectMsg); pCmd->payloadLen = pMsg - pStart; pCmd->msgType = TSDB_MSG_TYPE_CONNECT; @@ -3312,13 +3312,11 @@ int tscProcessShowRsp(SSqlObj *pSql) { } int tscProcessConnectRsp(SSqlObj *pSql) { - char temp[TSDB_TABLE_ID_LEN * 2]; - SConnectRsp *pConnect; - + char temp[TSDB_TABLE_ID_LEN * 2]; STscObj *pObj = pSql->pTscObj; SSqlRes *pRes = &pSql->res; - pConnect = (SConnectRsp *)pRes->pRsp; + SCMConnectRsp *pConnect = (SCMConnectRsp *)pRes->pRsp; strcpy(pObj->acctId, pConnect->acctId); // copy acctId from response int32_t len = sprintf(temp, "%s%s%s", pObj->acctId, TS_PATH_DELIMITER, pObj->db); @@ -3326,11 +3324,11 @@ int tscProcessConnectRsp(SSqlObj *pSql) { strncpy(pObj->db, temp, tListLen(pObj->db)); SIpList * pIpList; - char *rsp = pRes->pRsp + sizeof(SConnectRsp); + char *rsp = pRes->pRsp + sizeof(SCMConnectRsp); pIpList = (SIpList *)rsp; tscSetMgmtIpList(pIpList); - strcpy(pObj->sversion, pConnect->version); + strcpy(pObj->sversion, pConnect->serverVersion); pObj->writeAuth = pConnect->writeAuth; pObj->superAuth = pConnect->superAuth; taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); diff --git a/src/inc/mnode.h b/src/inc/mnode.h index cce403e2bf826cd430ebeb615ba877b96aae1d2f..794e41cc6c741848e26af4f0ab88968fbfc26d6a 100644 --- a/src/inc/mnode.h +++ b/src/inc/mnode.h @@ -254,8 +254,6 @@ typedef struct _user_obj { char reserved[16]; char updateEnd[1]; struct _user_obj *prev, *next; - int8_t writeAuth; - int8_t superAuth; } SUserObj; typedef struct { diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 3de7834b3d8d170b9770738c70754ed509d84e33..bf4787c449e6796d1b28e8a728a87d2be69ebe28 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -342,14 +342,12 @@ typedef struct { char serverVersion[TSDB_MSG_DEF_VERSION_LEN]; int8_t writeAuth; int8_t superAuth; - int8_t usePublicIp; int16_t index; int16_t numOfIps; uint16_t port; uint32_t ip[TSDB_MSG_DEF_MAX_MPEERS]; } SCMConnectRsp; - typedef struct { int32_t maxUsers; int32_t maxDbs; diff --git a/src/mnode/src/mgmtShell.c b/src/mnode/src/mgmtShell.c index f46d0e9a378fd2d7a8d85d269a20306596d514e0..82a1d6dd1fc0a6e01ad67873cfd8de2c8b63c58a 100644 --- a/src/mnode/src/mgmtShell.c +++ b/src/mnode/src/mgmtShell.c @@ -1315,32 +1315,32 @@ int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secr int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *ahandle, int32_t code) { SCMConnectMsg *pConnectMsg = (SCMConnectMsg *) pCont; - uint32_t destIp = 0; - uint32_t srcIp = 0; + SRpcConnInfo connInfo; + rpcGetConnInfo(ahandle, &connInfo); - SUserObj *pUser = mgmtGetUser(pConnectMsg->head.userId); + SUserObj *pUser = mgmtGetUser(connInfo.user); if (pUser == NULL) { - mLError("user:%s login from %s to %s, code:%d", pConnectMsg->head.userId, taosIpStr(srcIp), taosIpStr(destIp), code); + mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0); return TSDB_CODE_INVALID_USER; } if (mgmtCheckExpired()) { - mLError("user:%s login from %s to %s, code:%d", pConnectMsg->head.userId, taosIpStr(srcIp), taosIpStr(destIp), code); + mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); rpcSendResponse(ahandle, TSDB_CODE_GRANT_EXPIRED, NULL, 0); return TSDB_CODE_GRANT_EXPIRED; } SAcctObj *pAcct = mgmtGetAcct(pUser->acct); if (pAcct == NULL) { - mLError("user:%s login from %s to %s, code:%d", pConnectMsg->head.userId, taosIpStr(srcIp), taosIpStr(destIp), code); + mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); rpcSendResponse(ahandle, TSDB_CODE_INVALID_ACCT, NULL, 0); return TSDB_CODE_INVALID_ACCT; } code = taosCheckVersion(pConnectMsg->clientVersion, version, 3); if (code != TSDB_CODE_SUCCESS) { - mLError("user:%s login from %s to %s, code:%d", pConnectMsg->head.userId, taosIpStr(srcIp), taosIpStr(destIp), code); + mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); rpcSendResponse(ahandle, code, NULL, 0); return code; } @@ -1350,7 +1350,7 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a sprintf(dbName, "%x%s%s", pAcct->acctId, TS_PATH_DELIMITER, pConnectMsg->db); SDbObj *pDb = mgmtGetDb(dbName); if (pDb == NULL) { - mLError("user:%s login from %s to %s, code:%d", pConnectMsg->head.userId, taosIpStr(srcIp), taosIpStr(destIp), code); + mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); rpcSendResponse(ahandle, TSDB_CODE_INVALID_DB, NULL, 0); return TSDB_CODE_INVALID_DB; } @@ -1358,22 +1358,21 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a SCMConnectRsp *pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp)); if (pConnectRsp == NULL) { - mLError("user:%s login from %s to %s, code:%d", pConnectMsg->head.userId, taosIpStr(srcIp), taosIpStr(destIp), code); + mLError("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); rpcSendResponse(ahandle, TSDB_CODE_SERV_OUT_OF_MEMORY, NULL, 0); return TSDB_CODE_SERV_OUT_OF_MEMORY; } sprintf(pConnectRsp->acctId, "%x", pAcct->acctId); strcpy(pConnectRsp->serverVersion, version); - pConnectRsp->writeAuth = pConn->writeAuth; - pConnectRsp->superAuth = pConn->superAuth; + pConnectRsp->writeAuth = pUser->writeAuth; + pConnectRsp->superAuth = pUser->superAuth; pConnectRsp->index = 0; - pConnectRsp->usePublicIp = (destIp == tsPublicIpInt ? 1 : 0); if (pSdbPublicIpList != NULL && pSdbIpList != NULL) { pConnectRsp->numOfIps = htons(pSdbPublicIpList->numOfIps); pConnectRsp->port = htons(tsMgmtShellPort); - if (pConnectRsp->usePublicIp) { + if (connInfo.serverIp == tsPublicIpInt) { for (int i = 0; i < pSdbPublicIpList->numOfIps; ++i) { pConnectRsp->ip[i] = htonl(pSdbPublicIpList->ip[i]); } @@ -1387,7 +1386,7 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a pConnectRsp->port = htons(tsMgmtShellPort); } - mLPrint("user:%s login from %s to %s, code:%d", pConnectMsg->head.userId, taosIpStr(srcIp), taosIpStr(destIp), code); + mLPrint("user:%s login from %s, code:%d", connInfo.user, taosIpStr(connInfo.clientIp), code); return TSDB_CODE_SUCCESS; }