Merge pull request #3112 from taosdata/master

Merge from master into develop
This commit is contained in:
Shengliang Guan 2020-08-18 13:56:25 +08:00 committed by GitHub
commit 436f4b788f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 189 additions and 73 deletions

View File

@ -118,6 +118,7 @@ static void balanceSwapVnodeGid(SVnodeGid *pVnodeGid1, SVnodeGid *pVnodeGid2) {
} }
int32_t balanceAllocVnodes(SVgObj *pVgroup) { int32_t balanceAllocVnodes(SVgObj *pVgroup) {
static int32_t randIndex = 0;
int32_t dnode = 0; int32_t dnode = 0;
int32_t vnodes = 0; int32_t vnodes = 0;
@ -160,7 +161,7 @@ int32_t balanceAllocVnodes(SVgObj *pVgroup) {
*/ */
if (pVgroup->numOfVnodes == 1) { if (pVgroup->numOfVnodes == 1) {
} else if (pVgroup->numOfVnodes == 2) { } else if (pVgroup->numOfVnodes == 2) {
if (rand() % 2 == 0) { if (randIndex++ % 2 == 0) {
balanceSwapVnodeGid(pVgroup->vnodeGid, pVgroup->vnodeGid + 1); balanceSwapVnodeGid(pVgroup->vnodeGid, pVgroup->vnodeGid + 1);
} }
} else { } else {

View File

@ -3,6 +3,7 @@ taos_init
taos_cleanup taos_cleanup
taos_options taos_options
taos_connect taos_connect
taos_connect_auth
taos_close taos_close
taos_stmt_init taos_stmt_init
taos_stmt_prepare taos_stmt_prepare

View File

@ -16,6 +16,7 @@
#include "hash.h" #include "hash.h"
#include "os.h" #include "os.h"
#include "qAst.h" #include "qAst.h"
#include "tkey.h"
#include "tcache.h" #include "tcache.h"
#include "tnote.h" #include "tnote.h"
#include "trpc.h" #include "trpc.h"
@ -47,8 +48,8 @@ static bool validPassword(const char* passwd) {
return validImpl(passwd, TSDB_PASSWORD_LEN - 1); return validImpl(passwd, TSDB_PASSWORD_LEN - 1);
} }
SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, const char *db, uint16_t port, SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, const char *auth, const char *db,
void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) { uint16_t port, void (*fp)(void *, TAOS_RES *, int), void *param, void **taos) {
taos_init(); taos_init();
if (!validUserName(user)) { if (!validUserName(user)) {
@ -56,9 +57,28 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
return NULL; return NULL;
} }
if (!validPassword(pass)) { char secretEncrypt[32] = {0};
terrno = TSDB_CODE_TSC_INVALID_PASS_LENGTH; int secretEncryptLen = 0;
return NULL; if (auth == NULL) {
if (!validPassword(pass)) {
terrno = TSDB_CODE_TSC_INVALID_PASS_LENGTH;
return NULL;
}
taosEncryptPass((uint8_t *)pass, strlen(pass), secretEncrypt);
} else {
int outlen = 0;
int len = (int)strlen(auth);
char *base64 = (char *)base64_decode(auth, len, &outlen);
if (base64 == NULL || outlen == 0) {
tscError("invalid auth info:%s", auth);
free(base64);
terrno = TSDB_CODE_TSC_INVALID_PASS_LENGTH;
return NULL;
} else {
memcpy(secretEncrypt, base64, outlen);
free(base64);
}
secretEncryptLen = outlen;
} }
if (ip) { if (ip) {
@ -67,7 +87,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
} }
void *pDnodeConn = NULL; void *pDnodeConn = NULL;
if (tscInitRpc(user, pass, &pDnodeConn) != 0) { if (tscInitRpc(user, secretEncrypt, &pDnodeConn) != 0) {
terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL; terrno = TSDB_CODE_RPC_NETWORK_UNAVAIL;
return NULL; return NULL;
} }
@ -82,7 +102,8 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
pObj->signature = pObj; pObj->signature = pObj;
tstrncpy(pObj->user, user, sizeof(pObj->user)); tstrncpy(pObj->user, user, sizeof(pObj->user));
taosEncryptPass((uint8_t *)pass, strlen(pass), pObj->pass); secretEncryptLen = MIN(secretEncryptLen, sizeof(pObj->pass));
memcpy(pObj->pass, secretEncrypt, secretEncryptLen);
if (db) { if (db) {
int32_t len = (int32_t)strlen(db); int32_t len = (int32_t)strlen(db);
@ -144,13 +165,10 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
tsem_post(&pSql->rspSem); tsem_post(&pSql->rspSem);
} }
TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) { TAOS *taos_connect_internal(const char *ip, const char *user, const char *pass, const char *auth, const char *db,
tscDebug("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db); uint16_t port) {
if (user == NULL) user = TSDB_DEFAULT_USER; STscObj *pObj = NULL;
if (pass == NULL) pass = TSDB_DEFAULT_PASS; SSqlObj *pSql = taosConnectImpl(ip, user, pass, auth, db, port, syncConnCallback, NULL, (void **)&pObj);
STscObj* pObj = NULL;
SSqlObj *pSql = taosConnectImpl(ip, user, pass, db, port, syncConnCallback, NULL, (void**) &pObj);
if (pSql != NULL) { if (pSql != NULL) {
pSql->fp = syncConnCallback; pSql->fp = syncConnCallback;
pSql->param = pSql; pSql->param = pSql;
@ -182,23 +200,38 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
return NULL; return NULL;
} }
TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t userLen, TAOS *taos_connect(const char *ip, const char *user, const char *pass, const char *db, uint16_t port) {
const char *pass, uint8_t passLen, const char *db, uint8_t dbLen, uint16_t port) { tscDebug("try to create a connection to %s:%u, user:%s db:%s", ip, port, user, db);
char ipBuf[TSDB_EP_LEN] = {0}; if (user == NULL) user = TSDB_DEFAULT_USER;
char userBuf[TSDB_USER_LEN] = {0}; if (pass == NULL) pass = TSDB_DEFAULT_PASS;
char passBuf[TSDB_PASSWORD_LEN] = {0};
char dbBuf[TSDB_DB_NAME_LEN] = {0}; return taos_connect_internal(ip, user, pass, NULL, db, port);
strncpy(ipBuf, ip, MIN(TSDB_EP_LEN - 1, ipLen));
strncpy(userBuf, user, MIN(TSDB_USER_LEN - 1, userLen));
strncpy(passBuf, pass, MIN(TSDB_PASSWORD_LEN - 1,passLen));
strncpy(dbBuf, db, MIN(TSDB_DB_NAME_LEN - 1, dbLen));
return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port);
} }
TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port) {
tscDebug("try to create a connection to %s:%u by auth, user:%s db:%s", ip, port, user, db);
if (user == NULL) user = TSDB_DEFAULT_USER;
if (auth == NULL) return NULL;
return taos_connect_internal(ip, user, NULL, auth, db, port);
}
TAOS *taos_connect_c(const char *ip, uint8_t ipLen, const char *user, uint8_t userLen, const char *pass,
uint8_t passLen, const char *db, uint8_t dbLen, uint16_t port) {
char ipBuf[TSDB_EP_LEN] = {0};
char userBuf[TSDB_USER_LEN] = {0};
char passBuf[TSDB_PASSWORD_LEN] = {0};
char dbBuf[TSDB_DB_NAME_LEN] = {0};
strncpy(ipBuf, ip, MIN(TSDB_EP_LEN - 1, ipLen));
strncpy(userBuf, user, MIN(TSDB_USER_LEN - 1, userLen));
strncpy(passBuf, pass, MIN(TSDB_PASSWORD_LEN - 1, passLen));
strncpy(dbBuf, db, MIN(TSDB_DB_NAME_LEN - 1, dbLen));
return taos_connect(ipBuf, userBuf, passBuf, dbBuf, port);
}
TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int), TAOS *taos_connect_a(char *ip, char *user, char *pass, char *db, uint16_t port, void (*fp)(void *, TAOS_RES *, int),
void *param, void **taos) { void *param, void **taos) {
SSqlObj* pSql = taosConnectImpl(ip, user, pass, db, port, fp, param, taos); SSqlObj* pSql = taosConnectImpl(ip, user, pass, NULL, db, port, fp, param, taos);
if (pSql == NULL) { if (pSql == NULL) {
return NULL; return NULL;
} }

View File

@ -47,10 +47,8 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr); taosTmrReset(tscCheckDiskUsage, 1000, NULL, tscTmr, &tscCheckDiskUsageTmr);
} }
int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) { int32_t tscInitRpc(const char *user, const char *secretEncrypt, void **pDnodeConn) {
SRpcInit rpcInit; SRpcInit rpcInit;
char secretEncrypt[32] = {0};
taosEncryptPass((uint8_t *)secret, strlen(secret), secretEncrypt);
if (*pDnodeConn == NULL) { if (*pDnodeConn == NULL) {
memset(&rpcInit, 0, sizeof(rpcInit)); memset(&rpcInit, 0, sizeof(rpcInit));
@ -60,11 +58,11 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
rpcInit.cfp = tscProcessMsgFromServer; rpcInit.cfp = tscProcessMsgFromServer;
rpcInit.sessions = tsMaxConnections; rpcInit.sessions = tsMaxConnections;
rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.connType = TAOS_CONN_CLIENT;
rpcInit.user = (char*)user; rpcInit.user = (char *)user;
rpcInit.idleTime = 2000; rpcInit.idleTime = 2000;
rpcInit.ckey = "key"; rpcInit.ckey = "key";
rpcInit.spi = 1; rpcInit.spi = 1;
rpcInit.secret = secretEncrypt; rpcInit.secret = (char *)secretEncrypt;
*pDnodeConn = rpcOpen(&rpcInit); *pDnodeConn = rpcOpen(&rpcInit);
if (*pDnodeConn == NULL) { if (*pDnodeConn == NULL) {

View File

@ -113,6 +113,7 @@ extern char tsInternalPass[];
extern int32_t tsMonitorInterval; extern int32_t tsMonitorInterval;
// internal // internal
extern int32_t tsPrintAuth;
extern int32_t tscEmbedded; extern int32_t tscEmbedded;
extern char configDir[]; extern char configDir[];
extern char tsVnodeDir[]; extern char tsVnodeDir[];

View File

@ -146,6 +146,7 @@ char tsInternalPass[] = "secretkey";
int32_t tsMonitorInterval = 30; // seconds int32_t tsMonitorInterval = 30; // seconds
// internal // internal
int32_t tsPrintAuth = 0;
int32_t tscEmbedded = 0; int32_t tscEmbedded = 0;
char configDir[TSDB_FILENAME_LEN] = {0}; char configDir[TSDB_FILENAME_LEN] = {0};
char tsVnodeDir[TSDB_FILENAME_LEN] = {0}; char tsVnodeDir[TSDB_FILENAME_LEN] = {0};

View File

@ -23,7 +23,9 @@
// TODO refactor to set the tz value through parameter // TODO refactor to set the tz value through parameter
void tsSetTimeZone() { void tsSetTimeZone() {
SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone"); SGlobalCfg *cfg_timezone = taosGetConfigOption("timezone");
uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]); if (cfg_timezone != NULL) {
uInfo("timezone is set to %s by %s", tsTimezone, tsCfgStatusStr[cfg_timezone->cfgStatus]);
}
#ifdef WINDOWS #ifdef WINDOWS
char winStr[TSDB_LOCALE_LEN * 2]; char winStr[TSDB_LOCALE_LEN * 2];

View File

@ -449,7 +449,12 @@ static int32_t dnodeProcessConfigDnodeMsg(SRpcMsg *pMsg) {
} }
void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet) { void dnodeUpdateMnodeEpSetForPeer(SRpcEpSet *pEpSet) {
dInfo("mnode EP list for is changed, numOfEps:%d inUse:%d", pEpSet->numOfEps, pEpSet->inUse); if (pEpSet->numOfEps <= 0) {
dError("mnode EP list for peer is changed, but content is invalid, discard it");
return;
}
dInfo("mnode EP list for peer is changed, numOfEps:%d inUse:%d", pEpSet->numOfEps, pEpSet->inUse);
for (int i = 0; i < pEpSet->numOfEps; ++i) { for (int i = 0; i < pEpSet->numOfEps; ++i) {
pEpSet->port[i] -= TSDB_PORT_DNODEDNODE; pEpSet->port[i] -= TSDB_PORT_DNODEDNODE;
dInfo("mnode index:%d %s:%u", i, pEpSet->fqdn[i], pEpSet->port[i]) dInfo("mnode index:%d %s:%u", i, pEpSet->fqdn[i], pEpSet->port[i])
@ -710,10 +715,10 @@ static void dnodeSendStatusMsg(void *handle, void *tmrId) {
pStatus->clusterCfg.statusInterval = htonl(tsStatusInterval); pStatus->clusterCfg.statusInterval = htonl(tsStatusInterval);
pStatus->clusterCfg.maxtablesPerVnode = htonl(tsMaxTablePerVnode); pStatus->clusterCfg.maxtablesPerVnode = htonl(tsMaxTablePerVnode);
pStatus->clusterCfg.maxVgroupsPerDb = htonl(tsMaxVgroupsPerDb); pStatus->clusterCfg.maxVgroupsPerDb = htonl(tsMaxVgroupsPerDb);
strcpy(pStatus->clusterCfg.arbitrator, tsArbitrator); tstrncpy(pStatus->clusterCfg.arbitrator, tsArbitrator, TSDB_EP_LEN);
strcpy(pStatus->clusterCfg.timezone, tsTimezone); tstrncpy(pStatus->clusterCfg.timezone, tsTimezone, 64);
strcpy(pStatus->clusterCfg.locale, tsLocale); tstrncpy(pStatus->clusterCfg.locale, tsLocale, TSDB_LOCALE_LEN);
strcpy(pStatus->clusterCfg.charset, tsCharset); tstrncpy(pStatus->clusterCfg.charset, tsCharset, TSDB_LOCALE_LEN);
vnodeBuildStatusMsg(pStatus); vnodeBuildStatusMsg(pStatus);
contLen = sizeof(SDMStatusMsg) + pStatus->openVnodes * sizeof(SVnodeLoad); contLen = sizeof(SDMStatusMsg) + pStatus->openVnodes * sizeof(SVnodeLoad);

View File

@ -52,6 +52,8 @@ int32_t main(int32_t argc, char *argv[]) {
} else if (strcmp(argv[i], "-k") == 0) { } else if (strcmp(argv[i], "-k") == 0) {
grantParseParameter(); grantParseParameter();
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-A") == 0) {
tsPrintAuth = 1;
} }
#ifdef TAOS_MEM_CHECK #ifdef TAOS_MEM_CHECK
else if (strcmp(argv[i], "--alloc-random-fail") == 0) { else if (strcmp(argv[i], "--alloc-random-fail") == 0) {

View File

@ -39,6 +39,7 @@ typedef struct SShellArguments {
char* host; char* host;
char* password; char* password;
char* user; char* user;
char* auth;
char* database; char* database;
char* timezone; char* timezone;
bool is_raw_time; bool is_raw_time;

View File

@ -32,16 +32,16 @@ void insertChar(Command *cmd, char *c, int size);
void printHelp() { void printHelp() {
char indent[10] = " "; char indent[10] = " ";
printf("taos shell is used to test the TDEngine database\n"); printf("taos shell is used to test the TDengine database\n");
printf("%s%s\n", indent, "-h"); printf("%s%s\n", indent, "-h");
printf("%s%s%s\n", indent, indent, "TDEngine server IP address to connect. The default host is localhost."); printf("%s%s%s\n", indent, indent, "TDengine server IP address to connect. The default host is localhost.");
printf("%s%s\n", indent, "-p"); printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "The password to use when connecting to the server."); printf("%s%s%s\n", indent, indent, "The password to use when connecting to the server.");
printf("%s%s\n", indent, "-P"); printf("%s%s\n", indent, "-P");
printf("%s%s%s\n", indent, indent, "The TCP/IP port number to use for the connection"); printf("%s%s%s\n", indent, indent, "The TCP/IP port number to use for the connection");
printf("%s%s\n", indent, "-u"); printf("%s%s\n", indent, "-u");
printf("%s%s%s\n", indent, indent, "The TDEngine user name to use when connecting to the server."); printf("%s%s%s\n", indent, indent, "The user name to use when connecting to the server.");
printf("%s%s\n", indent, "-c"); printf("%s%s\n", indent, "-c");
printf("%s%s%s\n", indent, indent, "Configuration directory."); printf("%s%s%s\n", indent, indent, "Configuration directory.");
printf("%s%s\n", indent, "-s"); printf("%s%s\n", indent, "-s");

View File

@ -38,6 +38,7 @@ SShellHistory history;
#define DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30 #define DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30
extern int32_t tsMaxBinaryDisplayWidth; extern int32_t tsMaxBinaryDisplayWidth;
extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *auth, const char *db, uint16_t port);
/* /*
* FUNCTION: Initialize the shell. * FUNCTION: Initialize the shell.
@ -70,7 +71,13 @@ TAOS *shellInit(SShellArguments *args) {
tsTableMetaKeepTimer = 3000; tsTableMetaKeepTimer = 3000;
// Connect to the database. // Connect to the database.
TAOS *con = taos_connect(args->host, args->user, args->password, args->database, args->port); TAOS *con = NULL;
if (args->auth == NULL) {
con = taos_connect(args->host, args->user, args->password, args->database, args->port);
} else {
con = taos_connect_auth(args->host, args->user, args->auth, args->database, args->port);
}
if (con == NULL) { if (con == NULL) {
printf("taos connect failed, reason: %s.\n\n", tstrerror(terrno)); printf("taos connect failed, reason: %s.\n\n", tstrerror(terrno));
fflush(stdout); fflush(stdout);

View File

@ -33,10 +33,11 @@ const char *argp_program_bug_address = "<support@taosdata.com>";
static char doc[] = ""; static char doc[] = "";
static char args_doc[] = ""; static char args_doc[] = "";
static struct argp_option options[] = { static struct argp_option options[] = {
{"host", 'h', "HOST", 0, "TDEngine server IP address to connect. The default host is localhost."}, {"host", 'h', "HOST", 0, "TDengine server IP address to connect. The default host is localhost."},
{"password", 'p', "PASSWORD", OPTION_ARG_OPTIONAL, "The password to use when connecting to the server."}, {"password", 'p', "PASSWORD", OPTION_ARG_OPTIONAL, "The password to use when connecting to the server."},
{"port", 'P', "PORT", 0, "The TCP/IP port number to use for the connection."}, {"port", 'P', "PORT", 0, "The TCP/IP port number to use for the connection."},
{"user", 'u', "USER", 0, "The TDEngine user name to use when connecting to the server."}, {"user", 'u', "USER", 0, "The user name to use when connecting to the server."},
{"user", 'A', "Auth", 0, "The user auth to use when connecting to the server."},
{"config-dir", 'c', "CONFIG_DIR", 0, "Configuration directory."}, {"config-dir", 'c', "CONFIG_DIR", 0, "Configuration directory."},
{"commands", 's', "COMMANDS", 0, "Commands to run without enter the shell."}, {"commands", 's', "COMMANDS", 0, "Commands to run without enter the shell."},
{"raw-time", 'r', 0, 0, "Output time as uint64_t."}, {"raw-time", 'r', 0, 0, "Output time as uint64_t."},
@ -76,6 +77,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case 'u': case 'u':
arguments->user = arg; arguments->user = arg;
break; break;
case 'A':
arguments->auth = arg;
break;
case 'c': case 'c':
if (wordexp(arg, &full_path, 0) != 0) { if (wordexp(arg, &full_path, 0) != 0) {
fprintf(stderr, "Invalid path %s\n", arg); fprintf(stderr, "Invalid path %s\n", arg);

View File

@ -21,16 +21,18 @@ extern char configDir[];
void printHelp() { void printHelp() {
char indent[10] = " "; char indent[10] = " ";
printf("taos shell is used to test the TDEngine database\n"); printf("taos shell is used to test the TDengine database\n");
printf("%s%s\n", indent, "-h"); printf("%s%s\n", indent, "-h");
printf("%s%s%s\n", indent, indent, "TDEngine server IP address to connect. The default host is localhost."); printf("%s%s%s\n", indent, indent, "TDengine server IP address to connect. The default host is localhost.");
printf("%s%s\n", indent, "-p"); printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "The password to use when connecting to the server."); printf("%s%s%s\n", indent, indent, "The password to use when connecting to the server.");
printf("%s%s\n", indent, "-P"); printf("%s%s\n", indent, "-P");
printf("%s%s%s\n", indent, indent, "The TCP/IP port number to use for the connection"); printf("%s%s%s\n", indent, indent, "The TCP/IP port number to use for the connection");
printf("%s%s\n", indent, "-u"); printf("%s%s\n", indent, "-u");
printf("%s%s%s\n", indent, indent, "The TDEngine user name to use when connecting to the server."); printf("%s%s%s\n", indent, indent, "The user name to use when connecting to the server.");
printf("%s%s\n", indent, "-A");
printf("%s%s%s\n", indent, indent, "The user auth to use when connecting to the server.");
printf("%s%s\n", indent, "-c"); printf("%s%s\n", indent, "-c");
printf("%s%s%s\n", indent, indent, "Configuration directory."); printf("%s%s%s\n", indent, indent, "Configuration directory.");
printf("%s%s\n", indent, "-s"); printf("%s%s\n", indent, "-s");
@ -79,6 +81,13 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
fprintf(stderr, "option -u requires an argument\n"); fprintf(stderr, "option -u requires an argument\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} else if (strcmp(argv[i], "-A") == 0) {
if (i < argc - 1) {
arguments->auth = argv[++i];
} else {
fprintf(stderr, "option -A requires an argument\n");
exit(EXIT_FAILURE);
}
} else if (strcmp(argv[i], "-c") == 0) { } else if (strcmp(argv[i], "-c") == 0) {
if (i < argc - 1) { if (i < argc - 1) {
if (strlen(argv[++i]) >= TSDB_FILENAME_LEN) { if (strlen(argv[++i]) >= TSDB_FILENAME_LEN) {

View File

@ -85,9 +85,9 @@ typedef struct DemoArguments {
#ifdef LINUX #ifdef LINUX
/* The options we understand. */ /* The options we understand. */
static struct argp_option options[] = { static struct argp_option options[] = {
{0, 'h', "host", 0, "The host to connect to TDEngine. Default is localhost.", 0}, {0, 'h', "host", 0, "The host to connect to TDengine. Default is localhost.", 0},
{0, 'p', "port", 0, "The TCP/IP port number to use for the connection. Default is 0.", 1}, {0, 'p', "port", 0, "The TCP/IP port number to use for the connection. Default is 0.", 1},
{0, 'u', "user", 0, "The TDEngine user name to use when connecting to the server. Default is 'root'.", 2}, {0, 'u', "user", 0, "The TDengine user name to use when connecting to the server. Default is 'root'.", 2},
{0, 'P', "password", 0, "The password to use when connecting to the server. Default is 'taosdata'.", 3}, {0, 'P', "password", 0, "The password to use when connecting to the server. Default is 'taosdata'.", 3},
{0, 'd', "database", 0, "Destination database. Default is 'test'.", 3}, {0, 'd', "database", 0, "Destination database. Default is 'test'.", 3},
{0, 'm', "table_prefix", 0, "Table prefix name. Default is 't'.", 3}, {0, 'm', "table_prefix", 0, "Table prefix name. Default is 't'.", 3},
@ -264,11 +264,11 @@ typedef struct DemoArguments {
void printHelp() { void printHelp() {
char indent[10] = " "; char indent[10] = " ";
printf("%s%s\n", indent, "-h"); printf("%s%s\n", indent, "-h");
printf("%s%s%s\n", indent, indent, "host, The host to connect to TDEngine. Default is localhost."); printf("%s%s%s\n", indent, indent, "host, The host to connect to TDengine. Default is localhost.");
printf("%s%s\n", indent, "-p"); printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "port, The TCP/IP port number to use for the connection. Default is 0."); printf("%s%s%s\n", indent, indent, "port, The TCP/IP port number to use for the connection. Default is 0.");
printf("%s%s\n", indent, "-u"); printf("%s%s\n", indent, "-u");
printf("%s%s%s\n", indent, indent, "user, The TDEngine user name to use when connecting to the server. Default is 'root'."); printf("%s%s%s\n", indent, indent, "user, The user name to use when connecting to the server. Default is 'root'.");
printf("%s%s\n", indent, "-p"); printf("%s%s\n", indent, "-p");
printf("%s%s%s\n", indent, indent, "password, The password to use when connecting to the server. Default is 'taosdata'."); printf("%s%s%s\n", indent, indent, "password, The password to use when connecting to the server. Default is 'taosdata'.");
printf("%s%s\n", indent, "-d"); printf("%s%s\n", indent, "-d");

View File

@ -73,9 +73,9 @@ static int32_t mnodeDbActionInsert(SSdbOper *pOper) {
pthread_mutex_lock(&pDb->mutex); pthread_mutex_lock(&pDb->mutex);
pDb->vgListSize = VG_LIST_SIZE; pDb->vgListSize = VG_LIST_SIZE;
pDb->vgList = calloc(pDb->vgListSize, sizeof(SVgObj *)); pDb->vgList = calloc(pDb->vgListSize, sizeof(SVgObj *));
pDb->numOfVgroups = 0;
pthread_mutex_unlock(&pDb->mutex); pthread_mutex_unlock(&pDb->mutex);
pDb->numOfVgroups = 0;
pDb->numOfTables = 0; pDb->numOfTables = 0;
pDb->numOfSuperTables = 0; pDb->numOfSuperTables = 0;
@ -927,7 +927,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SCMAlterDbMsg *pAlter) {
if (quorum >= 0 && quorum != pDb->cfg.quorum) { if (quorum >= 0 && quorum != pDb->cfg.quorum) {
mDebug("db:%s, quorum:%d change to %d", pDb->name, pDb->cfg.quorum, quorum); mDebug("db:%s, quorum:%d change to %d", pDb->name, pDb->cfg.quorum, quorum);
newCfg.compression = quorum; newCfg.quorum = quorum;
} }
return newCfg; return newCfg;

View File

@ -58,7 +58,8 @@ int32_t mnodeProcessPeerReq(SMnodeMsg *pMsg) {
rpcRsp->rsp = epSet; rpcRsp->rsp = epSet;
rpcRsp->len = sizeof(SRpcEpSet); rpcRsp->len = sizeof(SRpcEpSet);
mDebug("%p, msg:%s in mpeer queue, will be redireced inUse:%d", pMsg->rpcMsg.ahandle, taosMsg[pMsg->rpcMsg.msgType], epSet->inUse); mDebug("%p, msg:%s in mpeer queue, will be redireced, numOfEps:%d inUse:%d", pMsg->rpcMsg.ahandle,
taosMsg[pMsg->rpcMsg.msgType], epSet->numOfEps, epSet->inUse);
for (int32_t i = 0; i < epSet->numOfEps; ++i) { for (int32_t i = 0; i < epSet->numOfEps; ++i) {
mDebug("mnode index:%d ep:%s:%d", i, epSet->fqdn[i], htons(epSet->port[i])); mDebug("mnode index:%d ep:%s:%d", i, epSet->fqdn[i], htons(epSet->port[i]));
} }

View File

@ -20,6 +20,7 @@
#include "tglobal.h" #include "tglobal.h"
#include "tgrant.h" #include "tgrant.h"
#include "tdataformat.h" #include "tdataformat.h"
#include "tkey.h"
#include "mnode.h" #include "mnode.h"
#include "dnode.h" #include "dnode.h"
#include "mnodeDef.h" #include "mnodeDef.h"
@ -100,6 +101,32 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
static void mnodePrintUserAuth() {
FILE *fp = fopen("auth.txt", "w");
if (!fp) {
mDebug("failed to auth.txt for write");
return;
}
void * pIter = NULL;
SUserObj *pUser = NULL;
while (1) {
pIter = mnodeGetNextUser(pIter, &pUser);
if (pUser == NULL) break;
char *base64 = base64_encode((const unsigned char *)pUser->pass, TSDB_KEY_LEN * 2);
fprintf(fp, "user:%24s auth:%s\n", pUser->user, base64);
free(base64);
mnodeDecUserRef(pUser);
}
fflush(fp);
sdbFreeIter(pIter);
fclose(fp);
}
static int32_t mnodeUserActionRestored() { static int32_t mnodeUserActionRestored() {
int32_t numOfRows = sdbGetNumOfRows(tsUserSdb); int32_t numOfRows = sdbGetNumOfRows(tsUserSdb);
if (numOfRows <= 0 && dnodeIsFirstDeploy()) { if (numOfRows <= 0 && dnodeIsFirstDeploy()) {
@ -111,6 +138,11 @@ static int32_t mnodeUserActionRestored() {
mnodeDecAcctRef(pAcct); mnodeDecAcctRef(pAcct);
} }
if (tsPrintAuth != 0) {
mInfo("print user auth, for -A parameter is set");
mnodePrintUserAuth();
}
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }

View File

@ -170,6 +170,7 @@ static void taosGetSystemTimezone() {
fclose(f); fclose(f);
buf[sizeof(buf) - 1] = 0;
char *lineEnd = strstr(buf, "\n"); char *lineEnd = strstr(buf, "\n");
if (lineEnd != NULL) { if (lineEnd != NULL) {
*lineEnd = 0; *lineEnd = 0;

View File

@ -210,10 +210,14 @@ void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int num
} }
} }
#if 0
// todo refactor // todo refactor
if (tscResultsetFetchCompleted(result)) { if (tscResultsetFetchCompleted(result)) {
httpDebug("context:%p, fd:%d, ip:%s, user:%s, resultset fetch completed", pContext, pContext->fd, pContext->ipstr,
pContext->user);
isContinue = false; isContinue = false;
} }
#endif
if (isContinue) { if (isContinue) {
// retrieve next batch of rows // retrieve next batch of rows

View File

@ -70,14 +70,27 @@ int32_t mqttInitSystem() {
recntStatus.port = strbetween("'1883'", "'", "'"); recntStatus.port = strbetween("'1883'", "'", "'");
} }
topicPath = strbetween(strstr(url, strstr(_begin_hostname, ":") != NULL ? recntStatus.port : recntStatus.hostname), char* portStr = recntStatus.hostname;
"/", "/"); if (_begin_hostname != NULL) {
char* _topic = "+/+/+/"; char* colonStr = strstr(_begin_hostname, ":");
int _tpsize = strlen(topicPath) + strlen(_topic) + 1; if (colonStr != NULL) {
recntStatus.topic = calloc(1, _tpsize); portStr = recntStatus.port;
sprintf(recntStatus.topic, "/%s/%s", topicPath, _topic); }
recntStatus.client_id = strlen(tsMqttBrokerClientId) < 3 ? tsMqttBrokerClientId : "taos_mqtt"; }
mqttConnect = NULL;
char* topicStr = strstr(url, portStr);
if (topicStr != NULL) {
topicPath = strbetween(topicStr, "/", "/");
char* _topic = "+/+/+/";
int _tpsize = strlen(topicPath) + strlen(_topic) + 1;
recntStatus.topic = calloc(1, _tpsize);
sprintf(recntStatus.topic, "/%s/%s", topicPath, _topic);
recntStatus.client_id = strlen(tsMqttBrokerClientId) < 3 ? tsMqttBrokerClientId : "taos_mqtt";
mqttConnect = NULL;
} else {
topicPath = NULL;
}
return rc; return rc;
} }

View File

@ -371,7 +371,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
serverAdd.sin_addr.s_addr = ip; serverAdd.sin_addr.s_addr = ip;
serverAdd.sin_port = (uint16_t)htons(port); serverAdd.sin_port = (uint16_t)htons(port);
if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) { if ((sockFd = (int)socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 2) {
uError("failed to open TCP socket: %d (%s)", errno, strerror(errno)); uError("failed to open TCP socket: %d (%s)", errno, strerror(errno));
return -1; return -1;
} }
@ -382,7 +382,7 @@ SOCKET taosOpenTcpServerSocket(uint32_t ip, uint16_t port) {
uError("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno)); uError("setsockopt SO_REUSEADDR failed: %d (%s)", errno, strerror(errno));
taosCloseSocket(sockFd); taosCloseSocket(sockFd);
return -1; return -1;
}; }
/* bind socket to server address */ /* bind socket to server address */
if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) { if (bind(sockFd, (struct sockaddr *)&serverAdd, sizeof(serverAdd)) < 0) {

View File

@ -1,7 +1,7 @@
char version[12] = "2.0.0.6"; char version[12] = "2.0.1.0";
char compatible_version[12] = "2.0.0.0"; char compatible_version[12] = "2.0.0.0";
char gitinfo[48] = "e9a20fafbe9e3b0b12cbdf55604163b4b9a41b41"; char gitinfo[48] = "7ac6c2b8de3cd66e180132fc1cf77715237308a1";
char gitinfoOfInternal[48] = "dd679db0b9edeedad68574c1e031544711a9831f"; char gitinfoOfInternal[48] = "e1e64838ece2b6dbe964ec3a39953455f354d930";
char buildinfo[64] = "Built by at 2020-08-12 07:59"; char buildinfo[64] = "Built by root at 2020-08-17 11:13";
void libtaos_2_0_0_6_Linux_x64() {}; void libtaos_2_0_1_0_Linux_x64() {};