提交 cbbe8c16 编写于 作者: S slguan

fix compile errors

上级 ce0f8aae
...@@ -2601,7 +2601,7 @@ int tscProcessRetrieveMetricRsp(SSqlObj *pSql) { ...@@ -2601,7 +2601,7 @@ int tscProcessRetrieveMetricRsp(SSqlObj *pSql) {
int tscProcessEmptyResultRsp(SSqlObj *pSql) { return tscLocalResultCommonBuilder(pSql, 0); } int tscProcessEmptyResultRsp(SSqlObj *pSql) { return tscLocalResultCommonBuilder(pSql, 0); }
int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
SConnectMsg *pConnect; SCMConnectMsg *pConnect;
char * pMsg, *pStart; char * pMsg, *pStart;
SSqlCmd *pCmd = &pSql->cmd; SSqlCmd *pCmd = &pSql->cmd;
...@@ -2609,7 +2609,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -2609,7 +2609,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pMsg = pCmd->payload + tsRpcHeadSize; pMsg = pCmd->payload + tsRpcHeadSize;
pStart = pMsg; pStart = pMsg;
pConnect = (SConnectMsg *)pMsg; pConnect = (SCMConnectMsg *)pMsg;
char *db; // ugly code to move the space char *db; // ugly code to move the space
db = strstr(pObj->db, TS_PATH_DELIMITER); db = strstr(pObj->db, TS_PATH_DELIMITER);
...@@ -2618,7 +2618,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) { ...@@ -2618,7 +2618,7 @@ int tscBuildConnectMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
strcpy(pConnect->clientVersion, version); strcpy(pConnect->clientVersion, version);
pMsg += sizeof(SConnectMsg); pMsg += sizeof(SCMConnectMsg);
pCmd->payloadLen = pMsg - pStart; pCmd->payloadLen = pMsg - pStart;
pCmd->msgType = TSDB_MSG_TYPE_CONNECT; pCmd->msgType = TSDB_MSG_TYPE_CONNECT;
...@@ -3313,12 +3313,10 @@ int tscProcessShowRsp(SSqlObj *pSql) { ...@@ -3313,12 +3313,10 @@ int tscProcessShowRsp(SSqlObj *pSql) {
int tscProcessConnectRsp(SSqlObj *pSql) { int tscProcessConnectRsp(SSqlObj *pSql) {
char temp[TSDB_TABLE_ID_LEN * 2]; char temp[TSDB_TABLE_ID_LEN * 2];
SConnectRsp *pConnect;
STscObj *pObj = pSql->pTscObj; STscObj *pObj = pSql->pTscObj;
SSqlRes *pRes = &pSql->res; SSqlRes *pRes = &pSql->res;
pConnect = (SConnectRsp *)pRes->pRsp; SCMConnectRsp *pConnect = (SCMConnectRsp *)pRes->pRsp;
strcpy(pObj->acctId, pConnect->acctId); // copy acctId from response strcpy(pObj->acctId, pConnect->acctId); // copy acctId from response
int32_t len = sprintf(temp, "%s%s%s", pObj->acctId, TS_PATH_DELIMITER, pObj->db); int32_t len = sprintf(temp, "%s%s%s", pObj->acctId, TS_PATH_DELIMITER, pObj->db);
...@@ -3326,11 +3324,11 @@ int tscProcessConnectRsp(SSqlObj *pSql) { ...@@ -3326,11 +3324,11 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
strncpy(pObj->db, temp, tListLen(pObj->db)); strncpy(pObj->db, temp, tListLen(pObj->db));
SIpList * pIpList; SIpList * pIpList;
char *rsp = pRes->pRsp + sizeof(SConnectRsp); char *rsp = pRes->pRsp + sizeof(SCMConnectRsp);
pIpList = (SIpList *)rsp; pIpList = (SIpList *)rsp;
tscSetMgmtIpList(pIpList); tscSetMgmtIpList(pIpList);
strcpy(pObj->sversion, pConnect->version); strcpy(pObj->sversion, pConnect->serverVersion);
pObj->writeAuth = pConnect->writeAuth; pObj->writeAuth = pConnect->writeAuth;
pObj->superAuth = pConnect->superAuth; pObj->superAuth = pConnect->superAuth;
taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer);
......
...@@ -254,8 +254,6 @@ typedef struct _user_obj { ...@@ -254,8 +254,6 @@ typedef struct _user_obj {
char reserved[16]; char reserved[16];
char updateEnd[1]; char updateEnd[1];
struct _user_obj *prev, *next; struct _user_obj *prev, *next;
int8_t writeAuth;
int8_t superAuth;
} SUserObj; } SUserObj;
typedef struct { typedef struct {
......
...@@ -342,14 +342,12 @@ typedef struct { ...@@ -342,14 +342,12 @@ typedef struct {
char serverVersion[TSDB_MSG_DEF_VERSION_LEN]; char serverVersion[TSDB_MSG_DEF_VERSION_LEN];
int8_t writeAuth; int8_t writeAuth;
int8_t superAuth; int8_t superAuth;
int8_t usePublicIp;
int16_t index; int16_t index;
int16_t numOfIps; int16_t numOfIps;
uint16_t port; uint16_t port;
uint32_t ip[TSDB_MSG_DEF_MAX_MPEERS]; uint32_t ip[TSDB_MSG_DEF_MAX_MPEERS];
} SCMConnectRsp; } SCMConnectRsp;
typedef struct { typedef struct {
int32_t maxUsers; int32_t maxUsers;
int32_t maxDbs; int32_t maxDbs;
......
...@@ -1315,32 +1315,32 @@ int32_t mgmtRetriveUserAuthInfo(char *user, char *spi, char *encrypt, char *secr ...@@ -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) { int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *ahandle, int32_t code) {
SCMConnectMsg *pConnectMsg = (SCMConnectMsg *) pCont; SCMConnectMsg *pConnectMsg = (SCMConnectMsg *) pCont;
uint32_t destIp = 0; SRpcConnInfo connInfo;
uint32_t srcIp = 0; rpcGetConnInfo(ahandle, &connInfo);
SUserObj *pUser = mgmtGetUser(pConnectMsg->head.userId); SUserObj *pUser = mgmtGetUser(connInfo.user);
if (pUser == NULL) { 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); rpcSendResponse(ahandle, TSDB_CODE_INVALID_USER, NULL, 0);
return TSDB_CODE_INVALID_USER; return TSDB_CODE_INVALID_USER;
} }
if (mgmtCheckExpired()) { 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); rpcSendResponse(ahandle, TSDB_CODE_GRANT_EXPIRED, NULL, 0);
return TSDB_CODE_GRANT_EXPIRED; return TSDB_CODE_GRANT_EXPIRED;
} }
SAcctObj *pAcct = mgmtGetAcct(pUser->acct); SAcctObj *pAcct = mgmtGetAcct(pUser->acct);
if (pAcct == NULL) { 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); rpcSendResponse(ahandle, TSDB_CODE_INVALID_ACCT, NULL, 0);
return TSDB_CODE_INVALID_ACCT; return TSDB_CODE_INVALID_ACCT;
} }
code = taosCheckVersion(pConnectMsg->clientVersion, version, 3); code = taosCheckVersion(pConnectMsg->clientVersion, version, 3);
if (code != TSDB_CODE_SUCCESS) { 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); rpcSendResponse(ahandle, code, NULL, 0);
return code; return code;
} }
...@@ -1350,7 +1350,7 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a ...@@ -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); sprintf(dbName, "%x%s%s", pAcct->acctId, TS_PATH_DELIMITER, pConnectMsg->db);
SDbObj *pDb = mgmtGetDb(dbName); SDbObj *pDb = mgmtGetDb(dbName);
if (pDb == NULL) { 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); rpcSendResponse(ahandle, TSDB_CODE_INVALID_DB, NULL, 0);
return TSDB_CODE_INVALID_DB; return TSDB_CODE_INVALID_DB;
} }
...@@ -1358,22 +1358,21 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a ...@@ -1358,22 +1358,21 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a
SCMConnectRsp *pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp)); SCMConnectRsp *pConnectRsp = rpcMallocCont(sizeof(SCMConnectRsp));
if (pConnectRsp == NULL) { 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); rpcSendResponse(ahandle, TSDB_CODE_SERV_OUT_OF_MEMORY, NULL, 0);
return TSDB_CODE_SERV_OUT_OF_MEMORY; return TSDB_CODE_SERV_OUT_OF_MEMORY;
} }
sprintf(pConnectRsp->acctId, "%x", pAcct->acctId); sprintf(pConnectRsp->acctId, "%x", pAcct->acctId);
strcpy(pConnectRsp->serverVersion, version); strcpy(pConnectRsp->serverVersion, version);
pConnectRsp->writeAuth = pConn->writeAuth; pConnectRsp->writeAuth = pUser->writeAuth;
pConnectRsp->superAuth = pConn->superAuth; pConnectRsp->superAuth = pUser->superAuth;
pConnectRsp->index = 0; pConnectRsp->index = 0;
pConnectRsp->usePublicIp = (destIp == tsPublicIpInt ? 1 : 0);
if (pSdbPublicIpList != NULL && pSdbIpList != NULL) { if (pSdbPublicIpList != NULL && pSdbIpList != NULL) {
pConnectRsp->numOfIps = htons(pSdbPublicIpList->numOfIps); pConnectRsp->numOfIps = htons(pSdbPublicIpList->numOfIps);
pConnectRsp->port = htons(tsMgmtShellPort); pConnectRsp->port = htons(tsMgmtShellPort);
if (pConnectRsp->usePublicIp) { if (connInfo.serverIp == tsPublicIpInt) {
for (int i = 0; i < pSdbPublicIpList->numOfIps; ++i) { for (int i = 0; i < pSdbPublicIpList->numOfIps; ++i) {
pConnectRsp->ip[i] = htonl(pSdbPublicIpList->ip[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 ...@@ -1387,7 +1386,7 @@ int32_t mgmtProcessConnectMsg(int8_t type, void *pCont, int32_t contLen, void *a
pConnectRsp->port = htons(tsMgmtShellPort); 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; return TSDB_CODE_SUCCESS;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册