Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
coco
Commits
50b94b03
Commit
50b94b03
authored
Dec 16, 2017
by
i317280
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update the record and ws
parent
91576bf7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
httpd.py
coco/httpd.py
+6
-5
record.py
coco/record.py
+15
-0
No files found.
coco/httpd.py
View file @
50b94b03
...
...
@@ -41,7 +41,7 @@ class BaseWebSocketHandler:
self
.
app
.
clients
.
append
(
self
.
client
)
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
):
return
True
...
...
@@ -89,13 +89,14 @@ class SSHws(Namespace, BaseWebSocketHandler):
def
on_host
(
self
,
message
):
# 此处获取主机的信息
print
(
message
)
uuid
=
message
.
get
(
'uuid'
,
None
)
asset
=
message
.
get
(
'uuid'
,
None
)
username
=
message
.
get
(
'username'
,
None
)
system_user
=
None
if
uuid
and
username
:
self
.
asset
=
self
.
app
.
service
.
get_asset
(
uuid
)
for
i
in
self
.
asset
.
system_users_granted
:
if
self
.
asset
and
username
:
# self.asset = self.app.service.get_asset(uuid)
# print(self.asset)
for
i
in
self
.
asset
[
'system_users_granted'
]:
if
i
.
username
==
username
:
system_user
=
username
if
system_user
:
...
...
coco/record.py
View file @
50b94b03
...
...
@@ -73,18 +73,33 @@ class CommandRecorder(metaclass=abc.ABCMeta):
class
ServerReplayRecorder
(
ReplayRecorder
):
filelist
=
{}
def
record_replay
(
self
,
data_set
):
"""
:param data_set:
[{
"session": session.id,
"data": data,
"timestamp": time.time()
},...]
:return:
"""
# Todo: <liuzheng712@gmail.com>
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
):
self
.
filelist
[
session_id
]
=
open
(
session_id
+
'.log'
,
'a'
)
print
(
"When session {} start exec"
.
format
(
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
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment