Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
midoks committed May 31, 2024
1 parent be69e58 commit 190b858
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 9 additions & 1 deletion class/core/ssh_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from flask_socketio import SocketIO, emit, send


class ssh_terminal:
class ssh_terminal(object):

__debug_file = 'logs/terminal.log'
__log_type = 'SSH终端'
Expand Down Expand Up @@ -59,6 +59,14 @@ def __init__(self):
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)
Expand Down
9 changes: 2 additions & 7 deletions route/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,20 +596,15 @@ def index(reqClass=None, reqAction=None, reqData=None):

##################### ssh start ###########################
shell = None
shell_client = None


@socketio.on('webssh_websocketio')
def webssh_websocketio(data):
if not isLogined():
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

Expand Down

0 comments on commit 190b858

Please sign in to comment.