mirror of https://github.com/jumpserver/jumpserver
Merge pull request #139 from jumpserver/issue_52_bugfix
Issue 52 bugfix: 修复录像播放,web terminal hang住bugpull/140/head
commit
fcb3fd7186
|
@ -10,7 +10,6 @@ import os.path
|
||||||
import threading
|
import threading
|
||||||
import re
|
import re
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
from django.core.signals import request_started, request_finished
|
from django.core.signals import request_started, request_finished
|
||||||
|
|
||||||
import tornado.ioloop
|
import tornado.ioloop
|
||||||
|
@ -371,9 +370,10 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
|
||||||
vim_data = self.term.deal_command(self.term.vim_data)[0:200]
|
vim_data = self.term.deal_command(self.term.vim_data)[0:200]
|
||||||
if len(data) > 0:
|
if len(data) > 0:
|
||||||
TtyLog(log=self.log, datetime=datetime.datetime.now(), cmd=vim_data).save()
|
TtyLog(log=self.log, datetime=datetime.datetime.now(), cmd=vim_data).save()
|
||||||
|
vim_data = self.term.deal_command(self.term.vim_data)[0:200]
|
||||||
|
if len(vim_data) > 0:
|
||||||
TtyLog(log=self.log, datetime=datetime.datetime.now(),
|
TtyLog(log=self.log, datetime=datetime.datetime.now(),
|
||||||
cmd=self.term.deal_command(self.term.data)[0:200]).save()
|
cmd=vim_data).save()
|
||||||
self.term.vim_data = ''
|
self.term.vim_data = ''
|
||||||
self.term.data = ''
|
self.term.data = ''
|
||||||
self.term.input_mode = False
|
self.term.input_mode = False
|
||||||
|
@ -412,7 +412,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
|
||||||
if self.term.vim_flag:
|
if self.term.vim_flag:
|
||||||
self.term.vim_data += recv
|
self.term.vim_data += recv
|
||||||
try:
|
try:
|
||||||
self.write_message(json.dumps({'data': data}))
|
self.write_message(data.decode('utf-8', 'replace'))
|
||||||
now_timestamp = time.time()
|
now_timestamp = time.time()
|
||||||
self.log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(data)))
|
self.log_time_f.write('%s %s\n' % (round(now_timestamp-pre_timestamp, 4), len(data)))
|
||||||
self.log_file_f.write(data)
|
self.log_file_f.write(data)
|
||||||
|
@ -460,7 +460,7 @@ def main():
|
||||||
}
|
}
|
||||||
tornado_app = tornado.web.Application(
|
tornado_app = tornado.web.Application(
|
||||||
[
|
[
|
||||||
(r'/monitor', MonitorHandler),
|
(r'/ws/monitor', MonitorHandler),
|
||||||
(r'/ws/terminal', WebTerminalHandler),
|
(r'/ws/terminal', WebTerminalHandler),
|
||||||
(r'/kill', WebTerminalKillHandler),
|
(r'/kill', WebTerminalKillHandler),
|
||||||
(r'/ws/exec', ExecHandler),
|
(r'/ws/exec', ExecHandler),
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by liuzheng on 3/3/16.
|
* Created by liuzheng on 3/3/16.
|
||||||
*/
|
*/
|
||||||
|
@ -35,13 +36,12 @@ WSSHClient.prototype.connect = function (options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this._connection.onmessage = function (evt) {
|
this._connection.onmessage = function (evt) {
|
||||||
|
try{
|
||||||
|
options.onData(evt.data);
|
||||||
|
} catch (e) {
|
||||||
var data = JSON.parse(evt.data.toString());
|
var data = JSON.parse(evt.data.toString());
|
||||||
if (data.error !== undefined) {
|
|
||||||
options.onError(data.error);
|
options.onError(data.error);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
options.onData(data.data);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this._connection.onclose = function (evt) {
|
this._connection.onclose = function (evt) {
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
var protocol = 'ws://';
|
var protocol = 'ws://';
|
||||||
}
|
}
|
||||||
|
|
||||||
var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '/monitor';
|
var endpoint = protocol + document.URL.match(RegExp('//(.*?)/'))[1] + '/ws/monitor';
|
||||||
var file_path = obj.attr('file_path');
|
var file_path = obj.attr('file_path');
|
||||||
var socket = new WebSocket(endpoint + '?file_path=' + file_path);
|
var socket = new WebSocket(endpoint + '?file_path=' + file_path);
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue