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
0c20d632
Unverified
Commit
0c20d632
authored
7 years ago
by
liuzheng712
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
parent
754028bb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
8 deletions
+32
-8
.gitignore
.gitignore
+0
-2
httpd.py
coco/httpd.py
+7
-3
models.py
coco/models.py
+6
-1
recorder.py
coco/recorder.py
+17
-2
requirements.txt
requirements/requirements.txt
+2
-0
No files found.
.gitignore
View file @
0c20d632
...
...
@@ -8,5 +8,3 @@ logs/*
conf.py
host_rsa_key
sessions/*
Dockerfile
conf_docker.py
This diff is collapsed.
Click to expand it.
coco/httpd.py
View file @
0c20d632
...
...
@@ -94,11 +94,13 @@ class SSHws(Namespace, BaseWebSocketHandler):
child
,
parent
=
socket
.
socketpair
()
self
.
clients
[
request
.
sid
][
"client"
][
connection
]
=
Client
(
parent
,
self
.
clients
[
request
.
sid
][
"request"
])
self
.
clients
[
request
.
sid
][
"proxy"
][
connection
]
=
WSProxy
(
self
,
child
,
self
.
clients
[
request
.
sid
][
"room"
],
connection
)
self
.
app
.
clients
.
append
(
self
.
clients
[
request
.
sid
][
"client"
][
connection
])
self
.
clients
[
request
.
sid
][
"forwarder"
][
connection
]
=
ProxyServer
(
self
.
app
,
self
.
clients
[
request
.
sid
][
"client"
][
connection
])
self
.
clients
[
request
.
sid
][
"forwarder"
][
connection
]
=
ProxyServer
(
self
.
app
,
self
.
clients
[
request
.
sid
][
"client"
][
connection
]
)
self
.
socketio
.
start_background_task
(
self
.
clients
[
request
.
sid
][
"forwarder"
][
connection
]
.
proxy
,
asset
,
system_user
)
...
...
@@ -135,6 +137,8 @@ class SSHws(Namespace, BaseWebSocketHandler):
def
on_disconnect
(
self
):
self
.
on_leave
(
self
.
clients
[
request
.
sid
][
"room"
])
try
:
for
connection
in
self
.
clients
[
request
.
sid
][
"client"
]:
self
.
on_logout
(
connection
)
del
self
.
clients
[
request
.
sid
]
except
:
pass
...
...
@@ -142,7 +146,7 @@ class SSHws(Namespace, BaseWebSocketHandler):
pass
def
on_logout
(
self
,
connection
):
print
(
"logout"
,
connection
)
logger
.
debug
(
"{} logout"
.
format
(
connection
)
)
if
connection
:
self
.
clients
[
request
.
sid
][
"proxy"
][
connection
]
.
close
()
del
self
.
clients
[
request
.
sid
][
"proxy"
][
connection
]
...
...
This diff is collapsed.
Click to expand it.
coco/models.py
View file @
0c20d632
...
...
@@ -212,7 +212,10 @@ class WSProxy:
def
forward
(
self
):
while
not
self
.
stop_event
.
is_set
():
data
=
self
.
child
.
recv
(
BUF_SIZE
)
try
:
data
=
self
.
child
.
recv
(
BUF_SIZE
)
except
OSError
:
continue
if
len
(
data
)
==
0
:
self
.
close
()
self
.
ws
.
emit
(
"data"
,
{
'data'
:
data
.
decode
(
"utf-8"
),
'room'
:
self
.
connection
},
room
=
self
.
room
)
...
...
@@ -225,3 +228,5 @@ class WSProxy:
def
close
(
self
):
self
.
stop_event
.
set
()
self
.
child
.
close
()
self
.
ws
.
on_logout
(
self
.
connection
)
logger
.
debug
(
"Proxy {} closed"
.
format
(
self
))
This diff is collapsed.
Click to expand it.
coco/recorder.py
View file @
0c20d632
...
...
@@ -9,6 +9,7 @@ import os
import
gzip
import
json
import
shutil
import
boto3
# AWS S3 sdk
from
jms_es_sdk
import
ESStore
...
...
@@ -238,6 +239,20 @@ class ESCommandRecorder(CommandRecorder, metaclass=Singleton):
print
(
"{} has been gc"
.
format
(
self
))
class
S3ReplayRecorder
(
ServerReplayRecorder
):
def
__init__
(
self
,
app
):
super
()
.
__init__
(
app
)
self
.
bucket
=
app
.
config
[
"REPLAY_RECORD_ENGINE"
]
.
get
(
"BUCKET"
,
"jumpserver"
)
self
.
s3
=
boto3
.
client
(
's3'
)
def
push_to_server
(
self
,
session_id
):
self
.
s3
.
upload_file
(
os
.
path
.
join
(
self
.
app
.
config
[
'LOG_DIR'
],
session_id
+
'.replay.gz'
),
self
.
bucket
,
time
.
strftime
(
'
%
Y-
%
m-
%
d'
,
time
.
localtime
(
self
.
starttime
))
+
'/'
+
session_id
+
'.replay.gz'
)
def
get_command_recorder_class
(
config
):
command_storage
=
config
[
"COMMAND_STORAGE"
]
...
...
@@ -249,7 +264,7 @@ def get_command_recorder_class(config):
def
get_replay_recorder_class
(
config
):
replay_engine
=
config
[
"REPLAY_RECORD_ENGINE"
]
if
replay_engine
==
"s
erver
"
:
return
S
erver
ReplayRecorder
if
replay_engine
==
"s
3
"
:
return
S
3
ReplayRecorder
else
:
return
ServerReplayRecorder
This diff is collapsed.
Click to expand it.
requirements/requirements.txt
View file @
0c20d632
asn1crypto==0.23.0
bcrypt==3.1.4
boto3==1.5.18
botocore==1.8.32
certifi==2017.11.5
cffi==1.11.2
chardet==3.0.4
...
...
This diff is collapsed.
Click to expand it.
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