Commit f20f84b6 authored by i317280's avatar i317280

fix: record the replay log

parent 8a8c81b6
...@@ -120,7 +120,7 @@ class SSHws(Namespace, BaseWebSocketHandler): ...@@ -120,7 +120,7 @@ class SSHws(Namespace, BaseWebSocketHandler):
def on_leave(self, room): def on_leave(self, room):
if self.rooms[room]["admin"] == request.sid: if self.rooms[room]["admin"] == request.sid:
self.emit("data", "\nAdmin leave", room=room) self.emit("data", "\nAdmin leave", room=room)
self.rooms.remove(room) del self.rooms[room]
leave_room(room=room) leave_room(room=room)
def on_disconnect(self): def on_disconnect(self):
......
...@@ -98,7 +98,7 @@ class ServerReplayRecorder(ReplayRecorder): ...@@ -98,7 +98,7 @@ class ServerReplayRecorder(ReplayRecorder):
:return: :return:
""" """
# Todo: <liuzheng712@gmail.com> # Todo: <liuzheng712@gmail.com>
self.file.write(data) self.file.write(str(data))
def session_start(self, session_id): def session_start(self, session_id):
self.file = open(os.path.join( self.file = open(os.path.join(
......
...@@ -8,13 +8,11 @@ import datetime ...@@ -8,13 +8,11 @@ import datetime
import selectors import selectors
import time import time
BUF_SIZE = 1024 BUF_SIZE = 1024
logger = logging.getLogger(__file__) logger = logging.getLogger(__file__)
class Session: class Session:
def __init__(self, client, server, command_recorder=None, replay_recorder=None): def __init__(self, client, server, command_recorder=None, replay_recorder=None):
self.id = str(uuid.uuid4()) self.id = str(uuid.uuid4())
self.client = client # Master of the session, it's a client sock self.client = client # Master of the session, it's a client sock
...@@ -123,6 +121,7 @@ class Session: ...@@ -123,6 +121,7 @@ class Session:
events = self.sel.select() events = self.sel.select()
for sock in [key.fileobj for key, _ in events]: for sock in [key.fileobj for key, _ in events]:
data = sock.recv(BUF_SIZE) data = sock.recv(BUF_SIZE)
self.put_replay(data)
if sock == self.server: if sock == self.server:
if len(data) == 0: if len(data) == 0:
msg = "Server close the connection" msg = "Server close the connection"
...@@ -184,8 +183,3 @@ class Session: ...@@ -184,8 +183,3 @@ class Session:
def __del__(self): def __del__(self):
logger.info("Session {} object has been GC") logger.info("Session {} object has been GC")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment