diff --git a/client/tp_assist/ts_const.h b/client/tp_assist/ts_const.h index 09f0495..00da1ca 100644 --- a/client/tp_assist/ts_const.h +++ b/client/tp_assist/ts_const.h @@ -6,7 +6,6 @@ #define TS_TRAY_MSG L"Teleport助手正常工作中" #define TS_HTTP_RPC_PORT 50022 -//#define TS_HTTP_RPC_HOST "0.0.0.0" #define TS_HTTP_RPC_HOST "127.0.0.1" #endif // __TS_CONST_H__ diff --git a/client/tp_assist/ts_http_rpc.cpp b/client/tp_assist/ts_http_rpc.cpp index 658d038..97ceb56 100644 --- a/client/tp_assist/ts_http_rpc.cpp +++ b/client/tp_assist/ts_http_rpc.cpp @@ -198,8 +198,6 @@ bool TsHttpRpc::init(const char* ip, int port) nc->user_data = this; mg_set_protocol_http_websocket(nc); - mg_enable_multithreading(nc); - m_content_type_map[".js"] = "application/javascript"; m_content_type_map[".png"] = "image/png"; diff --git a/server/tp_core/core/main.cpp b/server/tp_core/core/main.cpp index e6e43d8..98b3886 100644 --- a/server/tp_core/core/main.cpp +++ b/server/tp_core/core/main.cpp @@ -142,12 +142,6 @@ int _app_main(int argc, wchar_t** argv) } #endif -// if (!g_env.check_db_file()) -// { -// EXLOGE("[tpcore] env init failed.\n"); -// return 1; -// } - if (!g_is_debug) { if (!_run_daemon()) diff --git a/server/tp_core/core/tp_core.vs2015.vcxproj b/server/tp_core/core/tp_core.vs2015.vcxproj index 47469d7..0a42984 100644 --- a/server/tp_core/core/tp_core.vs2015.vcxproj +++ b/server/tp_core/core/tp_core.vs2015.vcxproj @@ -108,6 +108,7 @@ libcmt.lib + Debug diff --git a/server/tp_core/core/ts_env.cpp b/server/tp_core/core/ts_env.cpp index 35cbc15..f9b59d4 100644 --- a/server/tp_core/core/ts_env.cpp +++ b/server/tp_core/core/ts_env.cpp @@ -105,20 +105,5 @@ bool TsEnv::init(void) rpc_bind_port = TS_HTTP_RPC_PORT; } -// m_db_file = base_path; -// ex_path_join(m_db_file, false, L"data", L"ts_db.db", NULL); - - return true; } - -// bool TsEnv::check_db_file(void) -// { -// if (!ex_is_file_exists(m_db_file.c_str())) -// { -// EXLOGE("[core] can not found database file.\n"); -// return false; -// } -// -// return true; -// } diff --git a/server/tp_core/core/ts_env.h b/server/tp_core/core/ts_env.h index 6779627..335523e 100644 --- a/server/tp_core/core/ts_env.h +++ b/server/tp_core/core/ts_env.h @@ -10,7 +10,6 @@ public: ~TsEnv(); bool init(void); -// bool check_db_file(void); ExIniFile& get_ini(void) { return m_ini; } @@ -20,8 +19,6 @@ public: ex_wstr m_etc_path; ex_wstr m_replay_path; - //ex_wstr m_db_file; - ex_astr rpc_bind_ip; int rpc_bind_port; diff --git a/server/tp_core/core/ts_http_rpc.cpp b/server/tp_core/core/ts_http_rpc.cpp index c3708f1..00715a6 100644 --- a/server/tp_core/core/ts_http_rpc.cpp +++ b/server/tp_core/core/ts_http_rpc.cpp @@ -58,10 +58,8 @@ void TsHttpRpc::_thread_loop(void) { EXLOGV("[core-rpc] TeleportServer-HTTP-RPC ready on %s:%d\n", m_host_ip.c_str(), m_host_port); - for (;;) + while(!m_stop_flag) { - if (m_stop_flag) - break; mg_mgr_poll(&m_mg_mgr, 500); } @@ -86,7 +84,6 @@ bool TsHttpRpc::init(void) else ex_strformat(addr, 128, "%s:%d", m_host_ip.c_str(), m_host_port); - mg_mgr_init(&m_mg_mgr, NULL); nc = mg_bind(&m_mg_mgr, addr, _mg_event_handler); if (NULL == nc) { @@ -97,7 +94,12 @@ bool TsHttpRpc::init(void) nc->user_data = this; mg_set_protocol_http_websocket(nc); - mg_enable_multithreading(nc); + + // 导致内存泄露的地方(每次请求约消耗1KB内存) + // DO NOT USE MULTITHREADING OF MG. + // cpq (one of the authors of MG) commented on 3 Feb: Multithreading support has been removed. + // https://github.com/cesanta/mongoose/commit/707b9ed2d6f177b3ad8787cb16a1bff90ddad992 + //mg_enable_multithreading(nc); return true; } diff --git a/server/tp_core/core/ts_main.cpp b/server/tp_core/core/ts_main.cpp index 013a053..ba8436d 100644 --- a/server/tp_core/core/ts_main.cpp +++ b/server/tp_core/core/ts_main.cpp @@ -3,53 +3,12 @@ #include "ts_http_rpc.h" #include "ts_web_rpc.h" #include "ts_env.h" -//#include "ts_http_client.h" -//#include "ts_ver.h" -//#include "ts_crypto.h" - -//#include "../common/protocol_interface.h" - #include #include -//#include bool g_exit_flag = false; -//static unsigned char ToHex(unsigned char x) -//{ -// return x > 9 ? x + 55 : x + 48; -//} -// -//ex_astr UrlEncode(const ex_astr& str) -//{ -// ex_astr strTemp = ""; -// size_t length = str.length(); -// for (size_t i = 0; i < length; i++) -// { -// if (isalnum((unsigned char)str[i]) || -// (str[i] == '-') || -// (str[i] == '_') || -// (str[i] == '.') || -// (str[i] == '~')) -// { -// strTemp += str[i]; -// } -// else if (str[i] == ' ') -// { -// strTemp += "+"; -// } -// else -// { -// strTemp += '%'; -// strTemp += ToHex((unsigned char)str[i] >> 4); -// strTemp += ToHex((unsigned char)str[i] % 16); -// } -// } -// -// return strTemp; -//} - bool tpp_take_session(const ex_astr& sid, TS_SESSION_INFO& info) { return g_session_mgr.take_session(sid, info); @@ -257,13 +216,15 @@ int ts_main(void) g_exit_flag = true; } - - ts_web_rpc_register_core(); - - EXLOGV("[core] ---- initialized, ready for service ----\n"); - while (!g_exit_flag) + if (!g_exit_flag) { - ex_sleep_ms(1000); + ts_web_rpc_register_core(); + + EXLOGV("[core] ---- initialized, ready for service ----\n"); + while (!g_exit_flag) + { + ex_sleep_ms(1000); + } } g_tpp_mgr.stop_all(); diff --git a/server/www/teleport/static/js/ui/controls.js b/server/www/teleport/static/js/ui/controls.js index 345c217..fbe5382 100644 --- a/server/www/teleport/static/js/ui/controls.js +++ b/server/www/teleport/static/js/ui/controls.js @@ -1056,16 +1056,16 @@ ywl.create_table_render = function (tbl, on_created) { return g.group_name; }; - _tbl_render.command_info = function (row_id, fields) { - var command = get_command_name_by_id(fields.cmd_id); - if (command === null) - return '鍛戒护 ' + fields.cmd_id; - else - //return '' + command.cmd_desc + ''; - return '' + command.cmd_desc + ''; - //var info = command.cmd_name + ' '+ command.cmd_desc; - //return info; - }; +// _tbl_render.command_info = function (row_id, fields) { +// var command = get_command_name_by_id(fields.cmd_id); +// if (command === null) +// return '鍛戒护 ' + fields.cmd_id; +// else +// //return '' + command.cmd_desc + ''; +// return '' + command.cmd_desc + ''; +// //var info = command.cmd_name + ' '+ command.cmd_desc; +// //return info; +// }; _tbl_render.user_info = function (row_id, fields) { var user_info = get_user_info_by_id(fields.u_id); if (user_info === null) @@ -1075,36 +1075,36 @@ ywl.create_table_render = function (tbl, on_created) { //var info = command.cmd_name + ' '+ command.cmd_desc; //return info; }; - _tbl_render.event_type = function (row_id, fields) { - var _e_id = fields.id1 + '-' + fields.id2 + '-' + fields.id3 + '-' + fields.id4; - var content = ''; - if (_e_id == '3-1-1-100') { - content = '绯荤粺鎬ц兘鐩戞帶'; - return ' ' + content + ''; - } else if (_e_id == '3-1-1-107') { - content = 'TCP鐩戝惉鐧藉悕鍗曠洃鎺'; - return ' ' + content + ''; - } else if (_e_id == '3-1-1-108') { - content = 'UDP鐧藉悕鍗曠洃鎺'; - return ' ' + content + ''; - } else if (_e_id == '3-1-1-109') { - content = 'TCP杩炴帴鐧藉悕鍗曠洃鎺'; - return ' ' + content + ''; - } else if (_e_id == '3-1-1-110') { - content = '杩涚▼鐧藉悕鍗曠洃鎺'; - return ' ' + content + ''; - } else if (_e_id == '3-1-1-7') { - content = '绯荤粺鐢ㄦ埛鐩戞帶'; - return ' ' + content + ''; - } else { - content = '鏈煡'; - return ' ' + content + ''; - } - - - //var info = command.cmd_name + ' '+ command.cmd_desc; - //return info; - }; +// _tbl_render.event_type = function (row_id, fields) { +// var _e_id = fields.id1 + '-' + fields.id2 + '-' + fields.id3 + '-' + fields.id4; +// var content = ''; +// if (_e_id == '3-1-1-100') { +// content = '绯荤粺鎬ц兘鐩戞帶'; +// return ' ' + content + ''; +// } else if (_e_id == '3-1-1-107') { +// content = 'TCP鐩戝惉鐧藉悕鍗曠洃鎺'; +// return ' ' + content + ''; +// } else if (_e_id == '3-1-1-108') { +// content = 'UDP鐧藉悕鍗曠洃鎺'; +// return ' ' + content + ''; +// } else if (_e_id == '3-1-1-109') { +// content = 'TCP杩炴帴鐧藉悕鍗曠洃鎺'; +// return ' ' + content + ''; +// } else if (_e_id == '3-1-1-110') { +// content = '杩涚▼鐧藉悕鍗曠洃鎺'; +// return ' ' + content + ''; +// } else if (_e_id == '3-1-1-7') { +// content = '绯荤粺鐢ㄦ埛鐩戞帶'; +// return ' ' + content + ''; +// } else { +// content = '鏈煡'; +// return ' ' + content + ''; +// } +// +// +// //var info = command.cmd_name + ' '+ command.cmd_desc; +// //return info; +// }; _tbl_render.event_code = function (row_id, fields) { var _e_id = fields.id1 + '-' + fields.id2 + '-' + fields.id3 + '-' + fields.id4; var _e_info = get_event_code_by_id(_e_id); diff --git a/server/www/teleport/view/log/record-ssh-cmd.mako b/server/www/teleport/view/log/record-ssh-cmd.mako index 6dce187..80ce064 100644 --- a/server/www/teleport/view/log/record-ssh-cmd.mako +++ b/server/www/teleport/view/log/record-ssh-cmd.mako @@ -71,7 +71,7 @@ ywl.add_page_options(${page_param}); - var danger_cmd = ['rm', 'su', 'sudo']; + var danger_cmd = ['rm', 'su', 'sudo', 'kill']; var info_cmd = ['exit']; ywl.on_init = function (cb_stack, cb_args) {