diff --git a/server/tp_core/core/tp_core.vs2015.vcxproj b/server/tp_core/core/tp_core.vs2015.vcxproj
index 4c383d7..19427d9 100644
--- a/server/tp_core/core/tp_core.vs2015.vcxproj
+++ b/server/tp_core/core/tp_core.vs2015.vcxproj
@@ -100,7 +100,7 @@
Disabled
WIN32;_DEBUG;_CONSOLE;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)
true
- ../../../common/libex/include;../../../external/sqlite;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose
+ ../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose
MultiThreadedDebug
@@ -136,7 +136,7 @@
true
WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;MG_ENABLE_THREADS;MG_DISABLE_HTTP_DIGEST_AUTH;MG_DISABLE_MQTT;MG_DISABLE_SSI;MG_DISABLE_FILESYSTEM;%(PreprocessorDefinitions)
true
- ../../../common/libex/include;../../../external/sqlite;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose
+ ../../../common/libex/include;../../../external/jsoncpp/include;../../../external/mbedtls/include;../../../external/mongoose
MultiThreaded
@@ -182,7 +182,6 @@
-
@@ -206,8 +205,6 @@
-
-
diff --git a/server/tp_core/core/tp_core.vs2015.vcxproj.filters b/server/tp_core/core/tp_core.vs2015.vcxproj.filters
index dc260ca..6ba5552 100644
--- a/server/tp_core/core/tp_core.vs2015.vcxproj.filters
+++ b/server/tp_core/core/tp_core.vs2015.vcxproj.filters
@@ -8,9 +8,6 @@
{0155895f-d6be-4e0f-970d-9b6b5c759502}
-
- {4d2bbfac-6b91-4054-a4e2-38231c443939}
-
{9c2d60b3-2932-485b-bccd-b66886b0286b}
@@ -88,9 +85,6 @@
libex\src
-
- sqlite
-
mongoose
@@ -171,12 +165,6 @@
Resource Files
-
- sqlite
-
-
- sqlite
-
jsoncpp\header
diff --git a/server/tp_core/core/ts_db.cpp b/server/tp_core/core/ts_db.cpp
index d7bb04d..166a5b5 100644
--- a/server/tp_core/core/ts_db.cpp
+++ b/server/tp_core/core/ts_db.cpp
@@ -6,7 +6,6 @@
#include
-//#include
#include
#include
@@ -20,49 +19,49 @@ TsDB::TsDB()
TsDB::~TsDB()
{
- ExThreadSmartLock locker(m_lock);
- sqlite3Map::iterator it;
- for (it = m_sqlite3Map.begin(); it != m_sqlite3Map.end(); it++)
- {
- if (it->second != NULL)
- {
- sqlite3_close(it->second);
- it->second = NULL;
- }
- }
- m_sqlite3Map.clear();
+// ExThreadSmartLock locker(m_lock);
+// sqlite3Map::iterator it;
+// for (it = m_sqlite3Map.begin(); it != m_sqlite3Map.end(); it++)
+// {
+// if (it->second != NULL)
+// {
+// sqlite3_close(it->second);
+// it->second = NULL;
+// }
+// }
+// m_sqlite3Map.clear();
}
-sqlite3* TsDB::get_db()
-{
- ex_astr db_path;
- ex_wstr2astr(g_env.m_db_file, db_path);
-
- ex_u64 _tid = ex_get_thread_id();
-
- {
- ExThreadSmartLock locker(m_lock);
- long tid = (long)_tid;
- sqlite3Map::iterator it = m_sqlite3Map.find(tid);
- if (it != m_sqlite3Map.end())
- return it->second;
-
- sqlite3* sql_db = NULL;
- int ret = sqlite3_open(db_path.c_str(), &sql_db);
- if (SQLITE_OK != ret)
- {
- EXLOGE("[core-db] can not open database: %s\n", sqlite3_errmsg(sql_db));
- sqlite3_close(sql_db);
- sql_db = NULL;
- return NULL;
- }
-
- m_sqlite3Map[tid] = sql_db;
- return sql_db;
- }
-
- return NULL;
-}
+// sqlite3* TsDB::get_db()
+// {
+// ex_astr db_path;
+// ex_wstr2astr(g_env.m_db_file, db_path);
+//
+// ex_u64 _tid = ex_get_thread_id();
+//
+// {
+// ExThreadSmartLock locker(m_lock);
+// long tid = (long)_tid;
+// sqlite3Map::iterator it = m_sqlite3Map.find(tid);
+// if (it != m_sqlite3Map.end())
+// return it->second;
+//
+// sqlite3* sql_db = NULL;
+// int ret = sqlite3_open(db_path.c_str(), &sql_db);
+// if (SQLITE_OK != ret)
+// {
+// EXLOGE("[core-db] can not open database: %s\n", sqlite3_errmsg(sql_db));
+// sqlite3_close(sql_db);
+// sql_db = NULL;
+// return NULL;
+// }
+//
+// m_sqlite3Map[tid] = sql_db;
+// return sql_db;
+// }
+//
+// return NULL;
+// }
bool TsDB::get_auth_info(int auth_id, Json::Value& jret)
{
@@ -74,30 +73,20 @@ bool TsDB::get_auth_info(int auth_id, Json::Value& jret)
ex_astr json_param;
json_param = json_writer.write(jreq);
-
- // char tmp[128] = { 0 };
- // ex_strformat(tmp, 127, "{\"method\":\"get_auth_info\",\"param\":[\"authid\":%d]}", auth_id);
- //
ex_astr param;
- //ts_url_encode("{\"method\":\"get_auth_info\",\"param\":[]}", param);
ts_url_encode(json_param.c_str(), param);
ex_astr url = "http://127.0.0.1:7190/rpc?";
url += param;
ex_astr body;
- if (ts_http_get(url, body))
+ if (!ts_http_get(url, body))
{
- EXLOGV("request `get_auth_info` from web return: ");
- EXLOGV(body.c_str());
- EXLOGV("\n");
+// EXLOGV("request `get_auth_info` from web return: ");
+// EXLOGV(body.c_str());
+// EXLOGV("\n");
+ return false;
}
- // {'account_lock': 0, 'encrypt': 1, 'account_name': 'apexliu', 'host_port': 22, 'cert_id': 0, 'user_name': 'root',
- // 'auth_mode': 1, 'sys_type': 2, 'host_ip': '120.26.109.25', 'user_param': 'ogin:\nassword:',
- // 'user_pswd': '40V4q3cT4/HT59YaSq8IVJjz0tBV2dmPbViZ4nCnWc4=', 'protocol': 2}
-
- // {'user_auth': '40V4q3cT4/HT59YaSq8IVJjz0tBV2dmPbViZ4nCnWc4=', 'protocol': 2, 'auth_mode': 1, 'user_name': 'root', 'account_lock': 0, 'user_param': 'ogin:\nassword:', 'host_ip': '120.26.109.25', 'sys_type': 2, 'encrypt': 1, 'account_name': 'apexliu', 'host_port': 22}
- // {"message": "", "code" : 0, "data" : {"user_auth": "40V4q3cT4/HT59YaSq8IVJjz0tBV2dmPbViZ4nCnWc4=", "protocol": 2, "auth_mode": 1, "user_name": "root", "account_lock": 0, "user_param": "ogin : \nassword : ", "host_ip": "120.26.109.25", "sys_type": 2, "encrypt": 1, "account_name": "apexliu", "host_port": 22}}
Json::Reader jreader;
if (!jreader.parse(body.c_str(), jret))
@@ -125,19 +114,6 @@ bool TsDB::get_auth_info(int auth_id, Json::Value& jret)
return false;
}
-// info.host_ip = jret["host_ip"].asString();
-// info.host_port = jret["host_port"].asInt();
-// info.host_lock = 0;
-// info.sys_type = jret["sys_type"].asInt();
-// info.protocol = jret["protocol"].asInt();
-// info.is_encrypt = true;
-// info.auth_mode = jret["auth_mode"].asInt();
-// info.account_lock = jret["account_lock"].asInt();
-// info.user_name = jret["user_name"].asString();
-// info.user_auth = jret["user_auth"].asString();
-// info.user_param = jret["user_param"].asString();
-// info.account_name = jret["account_name"].asString();
-
return true;
}
@@ -381,521 +357,184 @@ bool TsDB::get_auth_info(int auth_id, Json::Value& jret)
bool TsDB::update_reset_log()
{
-// int result = 0;
-// char * errmsg = NULL;
-//
-// sqlite3* sql_exec = get_db();
-// if (sql_exec == NULL)
-// return false;
-//
-// const char* szSQL = "UPDATE ts_log SET ret_code=7 WHERE ret_code=0;";
-// result = sqlite3_exec(sql_exec, szSQL, NULL, NULL, &errmsg);
-// if (result != 0)
-// {
-// EXLOGE("[db] reset all running session status failed: %s.\n", errmsg);
-// return false;
-// }
-//
-// return true;
-
ex_astr param;
ts_url_encode("{\"method\":\"session_fix\",\"param\":[]}", param);
ex_astr url = "http://127.0.0.1:7190/rpc?";
url += param;
ex_astr body;
- if (ts_http_get(url, body))
- {
- EXLOGV("request `session_fix` from web return: ");
- EXLOGV(body.c_str());
- EXLOGV("\n");
- }
-
- // TODO: 根据返回的JSON数据的code判断是否操作成功
-
- return true;
+ return ts_http_get(url, body);
}
-bool TsDB::session_begin(TS_SESSION_INFO& info, int& sid)
+// bool TsDB::session_begin(TS_SESSION_INFO& info, int& sid)
+// {
+// int result;
+// char * errmsg = NULL;
+// char **dbResult;
+// int nRow, nColumn;
+// int index;
+//
+// sqlite3* sql_exec = get_db();
+// if (sql_exec == NULL)
+// return false;
+//
+// int ret_code = 0;
+// int begin_time = 0;
+// int end_time = 0;
+//
+// struct tm _now;
+// if (!ex_localtime_now(&begin_time, &_now))
+// return false;
+//
+// char szTime[64] = { 0 };
+// ex_strformat(szTime, 64, "%04d-%02d-%02d %02d:%02d:%02d", (1900 + _now.tm_year), (1 + _now.tm_mon), _now.tm_mday, _now.tm_hour, _now.tm_min, _now.tm_sec);
+//
+// char szSQL[1024] = { 0 };
+// ex_strformat(szSQL, 1024,
+// "INSERT INTO ts_log (session_id, account_name,host_ip,sys_type, host_port,auth_type,\
+// user_name,ret_code,begin_time,end_time,log_time, protocol) \
+// VALUES (\'%s\', \'%s\',\'%s\', %d,%d,%d,\'%s\', %d, %d,%d, \'%s\', %d);",
+// info.sid.c_str(), info.account_name.c_str(), info.host_ip.c_str(), info.sys_type,
+// info.host_port, info.auth_mode, info.user_name.c_str(), ret_code, begin_time, end_time,
+// szTime, info.protocol);
+//
+// result = sqlite3_exec(sql_exec, szSQL, NULL, NULL, &errmsg);
+// if (result != 0)
+// {
+// EXLOGE("[db] insert new session failed: %s.\n", errmsg);
+// return false;
+// }
+//
+// ex_strformat(szSQL, 1024, "SELECT last_insert_rowid() as id;");
+// result = sqlite3_get_table(sql_exec, szSQL, &dbResult, &nRow, &nColumn, &errmsg);
+// if (result != 0)
+// {
+// if (dbResult)
+// sqlite3_free_table(dbResult);
+// return false;
+// }
+//
+// index = nColumn;
+// if (nColumn != 1)
+// {
+// if (dbResult)
+// sqlite3_free_table(dbResult);
+// return false;
+// }
+//
+// sid = atoi(dbResult[index]);
+//
+// sqlite3_free_table(dbResult);
+//
+// return true;
+// }
+
+bool TsDB::session_begin(TS_SESSION_INFO& info, int& record_id)
{
- int result;
- char * errmsg = NULL;
- char **dbResult;
- int nRow, nColumn;
- int index;
+ Json::FastWriter json_writer;
+ Json::Value jreq;
- sqlite3* sql_exec = get_db();
- if (sql_exec == NULL)
- return false;
+// ex_strformat(szSQL, 1024,
+// "INSERT INTO ts_log (session_id, account_name,host_ip,sys_type, host_port,auth_type,\
+// user_name,ret_code,begin_time,end_time,log_time, protocol) \
+// VALUES (\'%s\', \'%s\',\'%s\', %d,%d,%d,\'%s\', %d, %d,%d, \'%s\', %d);",
+// info.sid.c_str(), info.account_name.c_str(), info.host_ip.c_str(), info.sys_type,
+// info.host_port, info.auth_mode, info.user_name.c_str(), ret_code, begin_time, end_time,
+// szTime, info.protocol);
- int ret_code = 0;
- int begin_time = 0;
- int end_time = 0;
+ jreq["method"] = "session_begin";
+ jreq["param"]["sid"] = info.sid.c_str();
+ jreq["param"]["account_name"] = info.account_name.c_str();
+ jreq["param"]["host_ip"] = info.host_ip.c_str();
+ jreq["param"]["sys_type"] = info.sys_type;
+ jreq["param"]["host_port"] = info.host_port;
+ jreq["param"]["auth_mode"] = info.auth_mode,
+ jreq["param"]["user_name"] = info.user_name.c_str();
+ jreq["param"]["protocol"] = info.protocol;
- struct tm _now;
- if (!ex_localtime_now(&begin_time, &_now))
- return false;
+ ex_astr json_param;
+ json_param = json_writer.write(jreq);
- char szTime[64] = { 0 };
- ex_strformat(szTime, 64, "%04d-%02d-%02d %02d:%02d:%02d", (1900 + _now.tm_year), (1 + _now.tm_mon), _now.tm_mday, _now.tm_hour, _now.tm_min, _now.tm_sec);
+ ex_astr param;
+ ts_url_encode(json_param.c_str(), param);
+ ex_astr url = "http://127.0.0.1:7190/rpc?";
+ url += param;
- char szSQL[1024] = { 0 };
- ex_strformat(szSQL, 1024,
- "INSERT INTO ts_log (session_id, account_name,host_ip,sys_type, host_port,auth_type,\
-user_name,ret_code,begin_time,end_time,log_time, protocol) \
-VALUES (\'%s\', \'%s\',\'%s\', %d,%d,%d,\'%s\', %d, %d,%d, \'%s\', %d);",
- info.sid.c_str(), info.account_name.c_str(), info.host_ip.c_str(), info.sys_type,
- info.host_port, info.auth_mode, info.user_name.c_str(), ret_code, begin_time, end_time,
- szTime, info.protocol);
-
- result = sqlite3_exec(sql_exec, szSQL, NULL, NULL, &errmsg);
- if (result != 0)
+ ex_astr body;
+ if (!ts_http_get(url, body))
{
- EXLOGE("[db] insert new session failed: %s.\n", errmsg);
+ // EXLOGV("request `get_auth_info` from web return: ");
+ // EXLOGV(body.c_str());
+ // EXLOGV("\n");
return false;
}
- ex_strformat(szSQL, 1024, "SELECT last_insert_rowid() as id;");
- result = sqlite3_get_table(sql_exec, szSQL, &dbResult, &nRow, &nColumn, &errmsg);
- if (result != 0)
- {
- if (dbResult)
- sqlite3_free_table(dbResult);
+ Json::Reader jreader;
+ Json::Value jret;
+
+ if (!jreader.parse(body.c_str(), jret))
return false;
- }
-
- index = nColumn;
- if (nColumn != 1)
- {
- if (dbResult)
- sqlite3_free_table(dbResult);
+ if (!jret.isObject())
+ return false;
+ if (!jret["data"].isObject())
+ return false;
+ if (!jret["data"]["rid"].isUInt())
return false;
- }
- sid = atoi(dbResult[index]);
-
- sqlite3_free_table(dbResult);
+ record_id = jret["data"]["rid"].asUInt();
return true;
}
//session 结束
-bool TsDB::session_end(int id, int ret_code)
+bool TsDB::session_end(int record_id, int ret_code)
{
- int result = 0;
- char * errmsg = NULL;
+// int result = 0;
+// char * errmsg = NULL;
+//
+// sqlite3* sql_exec = get_db();
+// if (sql_exec == NULL)
+// return false;
+//
+// int end_time = 0;
+// if (!ex_localtime_now(&end_time, NULL))
+// {
+// EXLOGE("[db] can not local time.\n");
+// return false;
+// }
+//
+// char szSQL[256] = { 0 };
+// ex_strformat(szSQL, 256, "UPDATE ts_log SET ret_code=%d, end_time=%d WHERE id=%d;", ret_code, end_time, id);
+//
+// result = sqlite3_exec(sql_exec, szSQL, 0, 0, &errmsg);
+// if (result != 0)
+// {
+// EXLOGE("[db] update log failed: %s.\n", errmsg);
+// return false;
+// }
+//
+// return true;
- sqlite3* sql_exec = get_db();
- if (sql_exec == NULL)
- return false;
+ Json::FastWriter json_writer;
+ Json::Value jreq;
+ jreq["method"] = "session_end";
+ jreq["param"]["rid"] = record_id;
+ jreq["param"]["code"] = ret_code;
- int end_time = 0;
- if (!ex_localtime_now(&end_time, NULL))
- {
- EXLOGE("[db] can not local time.\n");
- return false;
- }
+ ex_astr json_param;
+ json_param = json_writer.write(jreq);
- char szSQL[256] = { 0 };
- ex_strformat(szSQL, 256, "UPDATE ts_log SET ret_code=%d, end_time=%d WHERE id=%d;", ret_code, end_time, id);
+ ex_astr param;
+ ts_url_encode(json_param.c_str(), param);
+ ex_astr url = "http://127.0.0.1:7190/rpc?";
+ url += param;
- result = sqlite3_exec(sql_exec, szSQL, 0, 0, &errmsg);
- if (result != 0)
- {
- EXLOGE("[db] update log failed: %s.\n", errmsg);
- return false;
- }
+// ex_astr param;
+// ts_url_encode("{\"method\":\"session_end\",\"param\":[]}", param);
+// ex_astr url = "http://127.0.0.1:7190/rpc?";
+// url += param;
- return true;
+ ex_astr body;
+ return ts_http_get(url, body);
}
-//获取所有的认证ID
-// bool TsDB::get_auth_id_list_by_all(AuthInfo2Vec& auth_info_list)
-// {
-// int result = 0;
-// char * errmsg = NULL;
-// char **dbResult;
-// int nRow, nColumn;
-// int index;
-//
-// sqlite3* sql_exec = get_db();
-// if (sql_exec == NULL)
-// {
-// EXLOGE("[db] can not get db.\n");
-// return false;
-// }
-//
-// const char* szSQL = "SELECT auth_id,a.host_id as host_id, \
-// host_ip,host_pro_type as pro_type,host_lock,host_auth_mode as auth_mode \
-// FROM ts_auth as a LEFT JOIN ts_host_info as b ON a.host_id = b.host_id";
-//
-// result = sqlite3_get_table(sql_exec, szSQL, &dbResult, &nRow, &nColumn, &errmsg);
-// if (result != 0)
-// {
-// EXLOGE("[db] get all auth-id list failed: %s.\n", errmsg);
-// return false;
-// }
-//
-// //查询是否存在表
-// index = nColumn;
-//
-// int i = 0, j = 0;
-// for (i = 0; i < nRow; i++)
-// {
-// mapStringKey mapstringKey;
-// for (j = 0; j < nColumn; j++)
-// {
-// ex_astr temp = dbResult[j];
-// if (dbResult[index] == NULL)
-// mapstringKey[dbResult[j]] = "";
-// else
-// mapstringKey[dbResult[j]] = dbResult[index];
-//
-// ++index;
-// }
-//
-// TS_DB_AUTH_INFO_2 info;
-// mapStringKey::iterator it = mapstringKey.find("auth_id");
-// if (it != mapstringKey.end())
-// info.auth_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("host_id");
-// if (it != mapstringKey.end())
-// info.host_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("host_ip");
-// if (it != mapstringKey.end())
-// info.host_ip = it->second;
-//
-// it = mapstringKey.find("host_lock");
-// if (it != mapstringKey.end())
-// info.host_lock = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("pro_type");
-// if (it != mapstringKey.end())
-// info.pro_type = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("auth_mode");
-// if (it != mapstringKey.end())
-// info.auth_mode = atoi(it->second.c_str());
-//
-// auth_info_list.push_back(info);
-// }
-//
-// sqlite3_free_table(dbResult);
-// return true;
-// }
-
-//通过IP获取认证ID
-// bool TsDB::get_auth_id_list_by_ip(ex_astr host_ip, AuthInfo2Vec& auth_info_list)
-// {
-// int result = 0;
-// char * errmsg = NULL;
-// char **dbResult;
-// int nRow, nColumn;
-// int i, j;
-// int index;
-//
-// sqlite3* sql_exec = get_db();
-// if (sql_exec == NULL)
-// return false;
-//
-// char szSQL[1024] = { 0 };
-// ex_strformat(szSQL, 1024,
-// "SELECT auth_id,a.host_id as host_id, \
-// host_ip,host_pro_type as pro_type,host_lock,host_auth_mode as auth_mode \
-// FROM ts_auth as a LEFT JOIN ts_host_info as b ON a.host_id = b.host_id WHERE b.host_ip = \"%s\";", host_ip.c_str());
-//
-// result = sqlite3_get_table(sql_exec, szSQL, &dbResult, &nRow, &nColumn, &errmsg);
-// if (result != 0)
-// {
-// EXLOGE("[db] get auth-id by ip failed: %s.\n", errmsg);
-// return false;
-// }
-//
-// //查询是否存在表
-// index = nColumn;
-// for (i = 0; i < nRow; i++)
-// {
-// mapStringKey mapstringKey;
-// for (j = 0; j < nColumn; j++)
-// {
-// ex_astr temp = dbResult[j];
-// if (dbResult[index] == NULL)
-// mapstringKey[dbResult[j]] = "";
-// else
-// mapstringKey[dbResult[j]] = dbResult[index];
-//
-// ++index;
-// }
-//
-// TS_DB_AUTH_INFO_2 info;
-// mapStringKey::iterator it = mapstringKey.find("auth_id");
-// if (it != mapstringKey.end())
-// info.auth_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("host_id");
-// if (it != mapstringKey.end())
-// info.host_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("host_ip");
-// if (it != mapstringKey.end())
-// info.host_ip = it->second;
-//
-// it = mapstringKey.find("host_lock");
-// if (it != mapstringKey.end())
-// info.host_lock = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("pro_type");
-// if (it != mapstringKey.end())
-// info.pro_type = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("auth_mode");
-// if (it != mapstringKey.end())
-// info.auth_mode = atoi(it->second.c_str());
-//
-// auth_info_list.push_back(info);
-// }
-//
-// sqlite3_free_table(dbResult);
-// return true;
-// }
-
-//获取所有的认证的信息
-// bool TsDB::get_auth_info_list_by_all(AuthInfo3Vec& auth_info_list)
-// {
-// int result = 0;
-// char * errmsg = NULL;
-// char **dbResult;
-// int nRow, nColumn;
-// int i, j;
-// int index;
-//
-// sqlite3* sql_exec = get_db();
-// if (sql_exec == NULL)
-// return false;
-//
-// const char* szSQL =
-// "SELECT host_id ,host_ip,host_user_name, \
-// host_user_pwd, host_auth_mode as auth_mode,a.cert_id as cert_id, \
-// cert_pri,cert_name,cert_pub from ts_host_info as a LEFT JOIN ts_cert as b \
-// ON a.cert_id = b.cert_id;";
-//
-// result = sqlite3_get_table(sql_exec, szSQL, &dbResult, &nRow, &nColumn, &errmsg);
-// if (result != 0)
-// {
-// EXLOGE("[db] get all auth-info list failed: %s.\n", errmsg);
-// return false;
-// }
-//
-// //查询是否存在表
-// index = nColumn;
-// for (i = 0; i < nRow; i++)
-// {
-// mapStringKey mapstringKey;
-// for (j = 0; j < nColumn; j++)
-// {
-// //ex_astr temp = dbResult[j];
-// if (dbResult[index] == NULL)
-// mapstringKey[dbResult[j]] = "";
-// else
-// mapstringKey[dbResult[j]] = dbResult[index];
-//
-// ++index;
-// }
-//
-// TS_DB_AUTH_INFO_3 info;
-// mapStringKey::iterator it = mapstringKey.find("host_id");
-// if (it != mapstringKey.end())
-// info.host_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("host_ip");
-// if (it != mapstringKey.end())
-// info.host_ip = it->second;
-//
-// it = mapstringKey.find("host_user_name");
-// if (it != mapstringKey.end())
-// info.host_user_name = it->second;
-//
-// it = mapstringKey.find("host_user_pwd");
-// if (it != mapstringKey.end())
-// info.host_user_pwd = it->second;
-//
-// it = mapstringKey.find("auth_mode");
-// if (it != mapstringKey.end())
-// info.auth_mode = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("cert_id");
-// if (it != mapstringKey.end())
-// info.cert_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("cert_name");
-// if (it != mapstringKey.end())
-// info.cert_pub = it->second;
-//
-// it = mapstringKey.find("cert_pri");
-// if (it != mapstringKey.end())
-// info.cert_pri = it->second;
-//
-// it = mapstringKey.find("cert_pub");
-// if (it != mapstringKey.end())
-// info.cert_pub = it->second;
-//
-// auth_info_list.push_back(info);
-// }
-//
-// sqlite3_free_table(dbResult);
-// return true;
-// }
-
-//通过IP获取认证信息
-// bool TsDB::get_auth_info_list_by_ip(ex_astr host_ip, AuthInfo3Vec& auth_info_list)
-// {
-// int result = 0;
-// char * errmsg = NULL;
-// char **dbResult;
-// int nRow, nColumn;
-// int i, j;
-// int index;
-//
-// sqlite3* sql_exec = get_db();
-// if (sql_exec == NULL)
-// return false;
-//
-// char szSQL[1024] = { 0 };
-// ex_strformat(szSQL, 1024,
-// "select host_id ,host_ip,host_user_name, \
-// host_user_pwd, host_auth_mode as auth_mode,a.cert_id as cert_id, \
-// cert_pri,cert_name,cert_pub from ts_host_info as a LEFT JOIN ts_cert as b \
-// ON a.cert_id = b.cert_id where a.host_ip = \"%s\"", host_ip.c_str());
-//
-// result = sqlite3_get_table(sql_exec, szSQL, &dbResult, &nRow, &nColumn, &errmsg);
-// if (result != 0)
-// {
-// EXLOGE("[db] get auth-info by ip failed: %s.\n", errmsg);
-// return false;
-// }
-//
-// //查询是否存在表
-// index = nColumn;
-//
-// for (i = 0; i < nRow; i++)
-// {
-// //typedef std::map mapStringKey;
-// mapStringKey mapstringKey;
-// for (j = 0; j < nColumn; j++)
-// {
-// ex_astr temp = dbResult[j];
-// if (dbResult[index] == NULL)
-// mapstringKey[dbResult[j]] = "";
-// else
-// mapstringKey[dbResult[j]] = dbResult[index];
-//
-// ++index;
-// }
-//
-// TS_DB_AUTH_INFO_3 info;
-// mapStringKey::iterator it = mapstringKey.find("host_id");
-// if (it != mapstringKey.end())
-// info.host_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("host_ip");
-// if (it != mapstringKey.end())
-// info.host_ip = it->second;
-//
-// it = mapstringKey.find("host_user_name");
-// if (it != mapstringKey.end())
-// info.host_user_name = it->second;
-//
-// it = mapstringKey.find("host_user_pwd");
-// if (it != mapstringKey.end())
-// info.host_user_pwd = it->second;
-//
-// it = mapstringKey.find("auth_mode");
-// if (it != mapstringKey.end())
-// info.auth_mode = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("cert_id");
-// if (it != mapstringKey.end())
-// info.cert_id = atoi(it->second.c_str());
-//
-// it = mapstringKey.find("cert_name");
-// if (it != mapstringKey.end())
-// info.cert_pub = it->second;
-//
-// it = mapstringKey.find("cert_pri");
-// if (it != mapstringKey.end())
-// info.cert_pri = it->second;
-//
-// it = mapstringKey.find("cert_pub");
-// if (it != mapstringKey.end())
-// info.cert_pub = it->second;
-//
-// auth_info_list.push_back(info);
-// }
-//
-// sqlite3_free_table(dbResult);
-// return true;
-// }
-
-// bool TsDB::get_server_config(TS_DB_SERVER_CONFIG* server_config)
-// {
-// int result = 0;
-// char * errmsg = NULL;
-// char **dbResult;
-// int nRow, nColumn;
-// int i, j;
-// int index;
-//
-// sqlite3* sql_exec = get_db();
-// if (sql_exec == NULL)
-// return false;
-//
-// char* szSQL = "SELECT name, value FROM ts_config";
-// result = sqlite3_get_table(sql_exec, szSQL, &dbResult, &nRow, &nColumn, &errmsg);
-// if (result != 0)
-// {
-// EXLOGE("[db] get server confit failed: %s.\n", errmsg);
-// return false;
-// }
-//
-// //查询是否存在表
-// index = nColumn;
-// for (i = 0; i < nRow; i++)
-// {
-// mapStringKey mapstringKey;
-// for (j = 0; j < nColumn; j++)
-// {
-// ex_astr temp = dbResult[j];
-// if (dbResult[index] == NULL)
-// mapstringKey[dbResult[j]] = "";
-// else
-// mapstringKey[dbResult[j]] = dbResult[index];
-//
-// ++index;
-// }
-//
-// TS_DB_AUTH_INFO_3 info;
-// mapStringKey::iterator it = mapstringKey.find("name");
-// if (it != mapstringKey.end())
-// {
-// ex_astr temp = it->second;
-// temp.erase(remove_if(temp.begin(), temp.end(), std::ptr_fun(::isspace)), temp.end());
-//
-// mapStringKey::iterator value = mapstringKey.find("value");
-// if (temp.compare("ts_server_rpc_port") == 0)
-// server_config->ts_server_rpc_port = atoi(value->second.c_str());
-// else if (temp.compare("ts_server_rdp_port") == 0)
-// server_config->ts_server_rdp_port = atoi(value->second.c_str());
-// else if (temp.compare("ts_server_ssh_port") == 0)
-// server_config->ts_server_ssh_port = atoi(value->second.c_str());
-// else if (temp.compare("ts_server_telnet_port") == 0)
-// server_config->ts_server_telnet_port = atoi(value->second.c_str());
-// else if (temp.compare("ts_server_rpc_ip") == 0)
-// server_config->ts_server_rpc_ip = value->second.c_str();
-// }
-// }
-//
-// sqlite3_free_table(dbResult);
-// return true;
-// }
diff --git a/server/tp_core/core/ts_db.h b/server/tp_core/core/ts_db.h
index a400d6a..051fcdb 100644
--- a/server/tp_core/core/ts_db.h
+++ b/server/tp_core/core/ts_db.h
@@ -4,63 +4,63 @@
#include "ts_session.h"
#include
-#include
+//#include
#include
-#include