Commit 50b94b03 authored by i317280's avatar i317280

feat: update the record and ws

parent 91576bf7
...@@ -41,7 +41,7 @@ class BaseWebSocketHandler: ...@@ -41,7 +41,7 @@ class BaseWebSocketHandler:
self.app.clients.append(self.client) self.app.clients.append(self.client)
def get_current_user(self): def get_current_user(self):
return User(id='bb318c484f50483ea16589d7f18e9e95', username="admin", name="admin") return User(id='61c39c1f5b5742688180b6dda235aadd', username="admin", name="admin")
def check_origin(self, origin): def check_origin(self, origin):
return True return True
...@@ -89,13 +89,14 @@ class SSHws(Namespace, BaseWebSocketHandler): ...@@ -89,13 +89,14 @@ class SSHws(Namespace, BaseWebSocketHandler):
def on_host(self, message): def on_host(self, message):
# 此处获取主机的信息 # 此处获取主机的信息
print(message) print(message)
uuid = message.get('uuid', None) asset = message.get('uuid', None)
username = message.get('username', None) username = message.get('username', None)
system_user = None system_user = None
if uuid and username: if self.asset and username:
self.asset = self.app.service.get_asset(uuid) # self.asset = self.app.service.get_asset(uuid)
for i in self.asset.system_users_granted: # print(self.asset)
for i in self.asset['system_users_granted']:
if i.username == username: if i.username == username:
system_user = username system_user = username
if system_user: if system_user:
......
...@@ -73,18 +73,33 @@ class CommandRecorder(metaclass=abc.ABCMeta): ...@@ -73,18 +73,33 @@ class CommandRecorder(metaclass=abc.ABCMeta):
class ServerReplayRecorder(ReplayRecorder): class ServerReplayRecorder(ReplayRecorder):
filelist = {}
def record_replay(self, data_set): def record_replay(self, data_set):
""" """
:param data_set: :param data_set:
[{
"session": session.id,
"data": data,
"timestamp": time.time()
},...]
:return: :return:
""" """
# Todo: <liuzheng712@gmail.com> # Todo: <liuzheng712@gmail.com>
super().record_replay(data_set) super().record_replay(data_set)
for data in data_set:
try:
self.filelist[data["session"]].write(data)
except IndexError:
logger.error("session ({})file does not exist!".format(data["session"]))
def session_start(self, session_id): def session_start(self, session_id):
self.filelist[session_id] = open(session_id + '.log', 'a')
print("When session {} start exec".format(session_id)) print("When session {} start exec".format(session_id))
def session_end(self, session_id): def session_end(self, session_id):
self.filelist[session_id].close()
# Todo: upload the file
print("When session {} end start".format(session_id)) print("When session {} end start".format(session_id))
......
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