mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
@@ -28,7 +28,7 @@ import paramiko
|
||||
from flask_socketio import SocketIO, emit, send
|
||||
|
||||
|
||||
class ssh_terminal:
|
||||
class ssh_terminal(object):
|
||||
|
||||
__debug_file = 'logs/terminal.log'
|
||||
__log_type = 'SSH终端'
|
||||
@@ -59,6 +59,14 @@ class ssh_terminal:
|
||||
ht = threading.Thread(target=self.heartbeat)
|
||||
ht.start()
|
||||
|
||||
@classmethod
|
||||
def instance(cls, *args, **kwargs):
|
||||
if not hasattr(ssh_terminal, "_instance"):
|
||||
with ssh_terminal._instance_lock:
|
||||
if not hasattr(ssh_terminal, "_instance"):
|
||||
ssh_terminal._instance = ssh_terminal(*args, **kwargs)
|
||||
return ssh_terminal._instance
|
||||
|
||||
def debug(self, msg):
|
||||
msg = "{} - {}:{} => {} \n".format(mw.formatDate(),
|
||||
self.__host, self.__port, msg)
|
||||
|
||||
+2
-7
@@ -596,8 +596,6 @@ def index(reqClass=None, reqAction=None, reqData=None):
|
||||
|
||||
##################### ssh start ###########################
|
||||
shell = None
|
||||
shell_client = None
|
||||
|
||||
|
||||
@socketio.on('webssh_websocketio')
|
||||
def webssh_websocketio(data):
|
||||
@@ -605,11 +603,8 @@ def webssh_websocketio(data):
|
||||
emit('server_response', {'data': '会话丢失,请重新登陆面板!\r\n'})
|
||||
return
|
||||
|
||||
global shell_client
|
||||
if not shell_client:
|
||||
import ssh_terminal
|
||||
shell_client = ssh_terminal.ssh_terminal()
|
||||
|
||||
import ssh_terminal
|
||||
shell_client = ssh_terminal.instance()
|
||||
shell_client.run(request.sid, data)
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user