From 333c24437941e9329895701d4bb5cbdd14676004 Mon Sep 17 00:00:00 2001 From: Apex Liu Date: Fri, 3 Nov 2017 18:54:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9A=E6=A0=B8=E5=BF=83?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=B4=A9=E6=BA=83=E6=97=B6=E5=A4=84=E4=BA=8E?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E7=8A=B6=E6=80=81=E7=9A=84=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=85=B6=E7=BB=88=E6=AD=A2=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=8C=E5=9C=A8=E4=BC=9A=E8=AF=9D=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E8=83=BD=E5=A4=9F=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=A4=A7=E7=BA=A6=E7=9A=84=E8=BF=90=E8=A1=8C=E6=97=B6=E9=95=BF?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teleport/static/js/audit/record-list.js | 18 +++++++++----- .../www/teleport/webroot/app/model/record.py | 24 ++++++++++++------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/server/www/teleport/static/js/audit/record-list.js b/server/www/teleport/static/js/audit/record-list.js index fb6b7e9..104b114 100644 --- a/server/www/teleport/static/js/audit/record-list.js +++ b/server/www/teleport/static/js/audit/record-list.js @@ -185,9 +185,9 @@ $app.on_table_host_cell_created = function (tbl, row_id, col_key, cell_obj) { if (action === 'replay') { //$app.dlg_edit_host.show_edit(row_id); - if(row_data.protocol_type === TP_PROTOCOL_TYPE_RDP) { + if (row_data.protocol_type === TP_PROTOCOL_TYPE_RDP) { $tp.notify_error('sorry, not impl.'); - } else if(row_data.protocol_type === TP_PROTOCOL_TYPE_SSH) { + } else if (row_data.protocol_type === TP_PROTOCOL_TYPE_SSH) { window.open('/audit/replay/' + row_data.protocol_type + '/' + row_data.id); } } else if (action === 'cmd') { @@ -282,10 +282,16 @@ $app.on_table_host_render_created = function (render) { _style = 'primary'; return ' ' + tp_second2str(tp_local2utc() - fields.time_begin) + ''; } else { - if (fields.time_end === 0) - return ' 未知'; - else - return tp_second2str(fields.time_end - fields.time_begin); + if (fields.time_end === 0) { + return ' 未知'; + } + else { + if (fields.state === TP_SESS_STAT_ERR_START_RESET) { + return ' ' + tp_second2str(fields.time_end - fields.time_begin) + ''; + } else { + return tp_second2str(fields.time_end - fields.time_begin); + } + } } // if (fields.time_end === 0) { diff --git a/server/www/teleport/webroot/app/model/record.py b/server/www/teleport/webroot/app/model/record.py index 4c5e443..ca2fd61 100644 --- a/server/www/teleport/webroot/app/model/record.py +++ b/server/www/teleport/webroot/app/model/record.py @@ -254,16 +254,24 @@ def delete_log(log_list): def session_fix(): try: - ret = True db = get_db() - sql = 'UPDATE `{}record` SET state={} WHERE state={};'.format(db.table_prefix, TP_SESS_STAT_ERR_RESET, TP_SESS_STAT_RUNNING) - if not db.exec(sql): - ret = False - sql = 'UPDATE `{}record` SET state={} WHERE state={};'.format(db.table_prefix, TP_SESS_STAT_ERR_START_RESET, TP_SESS_STAT_STARTED) - if not db.exec(sql): - ret = False - return ret + + sql_list = [] + + sql = 'UPDATE `{dbtp}record` SET state={new_state}, time_end={time_end} WHERE state={old_state};' \ + ''.format(dbtp=db.table_prefix, new_state=TP_SESS_STAT_ERR_RESET, old_state=TP_SESS_STAT_RUNNING, time_end=tp_timestamp_utc_now()) + sql_list.append(sql) + # if not db.exec(sql): + # ret = False + sql = 'UPDATE `{dbtp}record` SET state={new_state},time_end={time_end} WHERE state={old_state};' \ + ''.format(dbtp=db.table_prefix, new_state=TP_SESS_STAT_ERR_START_RESET, old_state=TP_SESS_STAT_STARTED, time_end=tp_timestamp_utc_now()) + sql_list.append(sql) + return db.transaction(sql_list) + # if not db.exec(sql): + # ret = False + # return ret except: + log.e('\n') return False