From 83b9ba01bcb1fb999f52ee296651e11843aa1985 Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Sun, 19 Nov 2017 22:51:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87=E6=94=B9=E8=BF=9B=E6=A0=B8?= =?UTF-8?q?=E5=BF=83=E6=9C=8D=E5=8A=A1=E5=85=B3=E4=BA=8Esession=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=83=A8=E5=88=86=EF=BC=8C=E4=BB=A5=E5=8F=8Assh?= =?UTF-8?q?=E8=BD=AC=E5=8F=91=E6=A8=A1=E5=9D=97=E5=85=B3=E4=BA=8E=E5=BD=95?= =?UTF-8?q?=E5=83=8F=E8=AE=B0=E5=BD=95=E9=83=A8=E5=88=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/tp_core/core/ts_session.cpp | 4 +-- server/tp_core/core/ts_session.h | 4 ++- server/tp_core/protocol/ssh/ssh_proxy.cpp | 2 +- server/tp_core/protocol/ssh/ssh_session.cpp | 6 +++- .../teleport/static/js/audit/record-list.js | 23 +++++++++++---- server/www/teleport/static/js/auth/login.js | 2 +- .../teleport/static/js/ops/session-list.js | 29 +++++++++---------- .../teleport/static/js/teleport/controls.js | 2 +- server/www/teleport/view/auth/login.mako | 2 +- .../www/teleport/webroot/app/model/record.py | 2 +- 10 files changed, 46 insertions(+), 30 deletions(-) diff --git a/server/tp_core/core/ts_session.cpp b/server/tp_core/core/ts_session.cpp index f2996c4..30bc324 100644 --- a/server/tp_core/core/ts_session.cpp +++ b/server/tp_core/core/ts_session.cpp @@ -28,7 +28,7 @@ void TsSessionManager::_thread_loop(void) ex_sleep_ms(1000); if (m_stop_flag) return; - _check_connect_info(); + _remove_expired_connect_info(); } } @@ -38,7 +38,7 @@ void TsSessionManager::_set_stop_flag(void) } -void TsSessionManager::_check_connect_info(void) +void TsSessionManager::_remove_expired_connect_info(void) { // 超过30秒未进行连接的connect-info会被移除 diff --git a/server/tp_core/core/ts_session.h b/server/tp_core/core/ts_session.h index 8d39af5..6b7354c 100644 --- a/server/tp_core/core/ts_session.h +++ b/server/tp_core/core/ts_session.h @@ -73,7 +73,9 @@ protected: private: void _gen_session_id(ex_astr& sid, const TS_CONNECT_INFO* info, int len); - void _check_connect_info(void); + + // 定时检查,超过30秒未进行连接的connect-info会被移除 + void _remove_expired_connect_info(void); private: ExThreadLock m_lock; diff --git a/server/tp_core/protocol/ssh/ssh_proxy.cpp b/server/tp_core/protocol/ssh/ssh_proxy.cpp index 789080e..9bb35f4 100644 --- a/server/tp_core/protocol/ssh/ssh_proxy.cpp +++ b/server/tp_core/protocol/ssh/ssh_proxy.cpp @@ -176,7 +176,7 @@ void SshProxy::_dump_sftp_sessions() ts_sftp_sessions::iterator it = m_sftp_sessions.begin(); for (; it != m_sftp_sessions.end(); ++it) { - EXLOGD("ssh-proxy session: sid: %s\n", it->first.c_str()); + EXLOGD("[ssh] ssh-proxy session: sid: %s\n", it->first.c_str()); } } diff --git a/server/tp_core/protocol/ssh/ssh_session.cpp b/server/tp_core/protocol/ssh/ssh_session.cpp index cc12880..bdcf7d9 100644 --- a/server/tp_core/protocol/ssh/ssh_session.cpp +++ b/server/tp_core/protocol/ssh/ssh_session.cpp @@ -226,7 +226,7 @@ void SshSession::save_record() { int SshSession::_on_auth_password_request(ssh_session session, const char *user, const char *password, void *userdata) { - // 这里拿到的user就是我们要的session-id,password可以用ticket来填充,作为额外判断用户是否被允许访问的依据。 + // 这里拿到的user就是我们要的session-id。 SshSession *_this = (SshSession *)userdata; _this->m_sid = user; EXLOGV("[ssh] authenticating, session-id: %s\n", _this->m_sid.c_str()); @@ -436,6 +436,10 @@ ssh_channel SshSession::_on_new_channel_request(ssh_session session, void *userd // 客户端尝试打开一个通道(然后才能通过这个通道发控制命令或者收发数据) EXLOGV("[ssh] client open channel\n"); + // TODO: 记录会话开始,应该在这里进行,这样可以为每一个通道记录不同的日志,避免类似SecureCRT多标签页使用“复制会话”这样的功能将多个标签页中的记录混杂在一起。 + // TODO: 每个通道应该记录单独的录像文件 + + SshSession *_this = (SshSession *)userdata; ssh_channel cli_channel = ssh_channel_new(session); diff --git a/server/www/teleport/static/js/audit/record-list.js b/server/www/teleport/static/js/audit/record-list.js index 104b114..4b928c5 100644 --- a/server/www/teleport/static/js/audit/record-list.js +++ b/server/www/teleport/static/js/audit/record-list.js @@ -42,10 +42,19 @@ $app.create_controls = function (cb_stack) { { title: 'ID', key: 'id', - sort: true, - sort_asc: false, + // sort: true, + // sort_asc: false, fields: {id: 'id'} }, + { + title: '浼氳瘽ID', + key: 'sid', + // sort: true, + // sort_asc: false, + render: 'sid', + width: 60, + fields: {sid: 'sid'} + }, { title: '鐢ㄦ埛', key: 'user', @@ -237,6 +246,10 @@ $app.on_table_host_render_created = function (render) { return _ret.join(''); }; + render.sid = function(row_id, fields) { + return ''+fields.sid+''; + }; + render.user = function (row_id, fields) { if (_.isNull(fields.user_surname) || fields.user_surname.length === 0 || fields.user_username === fields.user_surname) { return fields.user_username; @@ -357,14 +370,14 @@ $app.on_table_host_render_created = function (render) { var ret = []; if (fields.state >= TP_SESS_STAT_STARTED || fields.state === TP_SESS_STAT_ERR_RESET) { - //if (fields.time_end === 0) { if (fields.state === TP_SESS_STAT_STARTED) { ret.push(' 鍚屾 '); } else { - ret.push(' 鎾斁 '); + // if (fields.protocol_sub_type !== TP_PROTOCOL_TYPE_SSH_SFTP) + ret.push(' 鍥炴斁 '); } if (fields.protocol_sub_type !== TP_PROTOCOL_TYPE_RDP_DESKTOP) { - ret.push(' 鏃ュ織 '); + ret.push(' 鏃ュ織 '); } } diff --git a/server/www/teleport/static/js/auth/login.js b/server/www/teleport/static/js/auth/login.js index dd9ab9d..c88dfc3 100644 --- a/server/www/teleport/static/js/auth/login.js +++ b/server/www/teleport/static/js/auth/login.js @@ -11,7 +11,7 @@ var BLUR_BG_IMG = [ 'login-bg-7.png' ]; var SLOGAN = [ - '鎴戞劅璋㈤偅娈垫椂鍏夛紝
鍥犱负涓嶆浘鎶婃垜鎵撳掔殑锛
鏈缁堣鎴戝彉寰楁洿鍔犲己澶э紒', + '鎰熻阿閭f鏃跺厜锛
鍥犱负涓嶆浘鎶婃垜浠墦鍊掔殑锛
鏈缁堣鎴戜滑鍙樺緱鏇村姞寮哄ぇ锛', '瀹佹効鍦ㄥ仛浜嬩腑鐘敊锛
涔熶笉瑕佷负浜嗕笉鐘敊鑰屼粈涔堥兘涓嶅仛銆', '浠庡嚭鐢熷埌姝伙紝
鍙湁900涓湀锛
鎵浠ヨ櫄鑰楁瘡涓鍒嗛挓锛
閮芥槸宸ㄥぇ鐨勬氮璐癸紒', '娌℃湁鎾锛屼綍鏉ユ敹鑾凤紱
娌℃湁杈涘姵锛屼綍鏉ユ垚鍔燂紱
娌℃湁纾ㄩ毦锛屼綍鏉ヨ崳鑰锛
娌℃湁鎸姌锛屼綍鏉ヨ緣鐓屻', diff --git a/server/www/teleport/static/js/ops/session-list.js b/server/www/teleport/static/js/ops/session-list.js index 5033f5f..8951308 100644 --- a/server/www/teleport/static/js/ops/session-list.js +++ b/server/www/teleport/static/js/ops/session-list.js @@ -49,7 +49,7 @@ $app.create_controls = function (cb_stack) { //sort: true, //header_render: 'filter_search_host', render: 'user', - fields: {user_name: 'user_name', user_surname: 'user_surname'} + fields: {user_username: 'user_username', user_surname: 'user_surname'} }, { title: '鏉ユ簮', @@ -65,7 +65,7 @@ $app.create_controls = function (cb_stack) { //sort: true, //header_render: 'filter_search_host', render: 'remote', - fields: {account_name: 'account_name', real_host_ip: 'real_host_ip', host_ip: 'host_ip', host_port: 'host_port'} + fields: {acc_username: 'acc_username', host_ip: 'host_ip', conn_ip: 'conn_ip', conn_port: 'conn_port'} }, { title: '杩滅▼鍗忚', @@ -128,20 +128,19 @@ $app.create_controls = function (cb_stack) { //------------------------------- // 鐢ㄦ埛鍒楄〃鐩稿叧杩囨护鍣 //------------------------------- - $app.table_session_filter_search_host = $tp.create_table_header_filter_search($app.table_session, { + $tp.create_table_header_filter_search($app.table_session, { name: 'search_host', place_holder: '鎼滅储锛氫富鏈篒P/鍚嶇О/鎻忚堪/璧勪骇缂栧彿/绛夌瓑...' }); // 浠巆ookie涓鍙栫敤鎴峰垎椤甸檺鍒剁殑閫夋嫨 - var _per_page = Cookies.get($app.page_id('ops_session') + '_per_page'); - $app.table_session_paging = $tp.create_table_paging($app.table_session, 'table-session-paging', + $tp.create_table_paging($app.table_session, 'table-session-paging', { - per_page: _per_page, + per_page: Cookies.get($app.page_id('ops_session') + '_per_page'), on_per_page_changed: function (per_page) { Cookies.set($app.page_id('ops_session') + '_per_page', per_page, {expires: 365}); } }); - $app.table_session_pagination = $tp.create_table_pagination($app.table_session, 'table-session-pagination'); + $tp.create_table_pagination($app.table_session, 'table-session-pagination'); //------------------------------- // 椤甸潰鎺т欢浜嬩欢缁戝畾 @@ -253,22 +252,20 @@ $app.on_table_session_render_created = function (render) { }; render.user = function (row_id, fields) { - if (_.isNull(fields.user_surname) || fields.user_surname.length === 0 || fields.user_name === fields.user_surname) { - return fields.user_name; + if (_.isNull(fields.user_surname) || fields.user_surname.length === 0 || fields.user_username === fields.user_surname) { + return fields.user_username; } else { - return fields.user_name + ' (' + fields.user_surname + ')'; + return fields.user_username + ' (' + fields.user_surname + ')'; } }; render.remote = function (row_id, fields) { - if (fields.real_host_ip === fields.host_ip) { - return fields.account_name + '@' + fields.real_host_ip;// + ':' + fields.host_port; - } else { - return fields.account_name + '@' + fields.real_host_ip;// + '(' + fields.host_ip + ':' + fields.host_port + ')'; - } + if (fields.host_ip === fields.conn_ip) + return fields.acc_username + '@' + fields.host_ip + ':' + fields.conn_port; + else + return '
' + fields.acc_username + '@' + fields.host_ip + '
'; }; - // fields: {protocol_type: 'protocol_type', protocol_sub_type: 'protocol_sub_type'} render.protocol = function (row_id, fields) { switch (fields.protocol_sub_type) { case 100: diff --git a/server/www/teleport/static/js/teleport/controls.js b/server/www/teleport/static/js/teleport/controls.js index 84f85d1..786f7b9 100644 --- a/server/www/teleport/static/js/teleport/controls.js +++ b/server/www/teleport/static/js/teleport/controls.js @@ -259,7 +259,7 @@ $tp.create_table = function (options) { if (_tbl.options.data_source && _tbl.options.data_source.exclude) args.exclude = _tbl.options.data_source.exclude; - console.log('when load, args:', args); + // console.log('when load, args:', args); // console.log('when load, order:', _order); // console.log('when load, limit:', _limit); diff --git a/server/www/teleport/view/auth/login.mako b/server/www/teleport/view/auth/login.mako index bc6bb24..a40bff2 100644 --- a/server/www/teleport/view/auth/login.mako +++ b/server/www/teleport/view/auth/login.mako @@ -31,7 +31,7 @@
- +
diff --git a/server/www/teleport/webroot/app/model/record.py b/server/www/teleport/webroot/app/model/record.py index 21a22f0..5f8327c 100644 --- a/server/www/teleport/webroot/app/model/record.py +++ b/server/www/teleport/webroot/app/model/record.py @@ -16,7 +16,7 @@ import tornado.gen def get_records(sql_filter, sql_order, sql_limit, sql_restrict, sql_exclude): s = SQL(get_db()) - s.select_from('record', ['id', 'user_id', 'host_id', 'acc_id', 'state', 'user_username', 'user_surname', 'host_ip', 'conn_ip', 'conn_port', 'client_ip', 'acc_username', 'protocol_type', 'protocol_sub_type', 'time_begin', 'time_end'], alt_name='r') + s.select_from('record', ['id', 'sid', 'user_id', 'host_id', 'acc_id', 'state', 'user_username', 'user_surname', 'host_ip', 'conn_ip', 'conn_port', 'client_ip', 'acc_username', 'protocol_type', 'protocol_sub_type', 'time_begin', 'time_end'], alt_name='r') str_where = '' _where = list()