pull/585/head
Mr Chen 11 months ago
parent be69e5838e
commit 190b858e46
  1. 10
      class/core/ssh_terminal.py
  2. 9
      route/__init__.py

@ -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)

@ -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

Loading…
Cancel
Save