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
178e7c24
Commit
178e7c24
authored
Dec 25, 2017
by
liuzheng712
Committed by
i317280
Dec 26, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Docker] Add docker file
parent
0d48a80f
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
165 deletions
+31
-165
.dockerignore
.dockerignore
+3
-0
Dockerfile
Dockerfile
+3
-2
httpd.py
coco/httpd.py
+6
-158
recorder.py
coco/recorder.py
+1
-1
conf_docker.py
conf_docker.py
+14
-3
conf_example.py
conf_example.py
+4
-1
run_server.py
run_server.py
+0
-0
No files found.
.dockerignore
0 → 100644
View file @
178e7c24
.git
logs/*
keys/*
Dockerfile
View file @
178e7c24
...
...
@@ -5,12 +5,12 @@ COPY . /opt/coco
WORKDIR
/opt/coco
RUN
cd
requirements
&&
yum
-y
install
$(
cat
rpm_requirements.txt
)
&&
\
pip
install
-r
requirements.txt
-i
https://pypi.tuna.tsinghua.edu.cn/simple
pip
install
-r
requirements.txt
VOLUME
/opt/coco/logs
VOLUME
/opt/coco/keys
RUN
cp
conf
ig_docker.py config
.py
RUN
cp
conf
_docker.py conf
.py
EXPOSE
2222
CMD
python run_server.py
\ No newline at end of file
coco/httpd.py
View file @
178e7c24
...
...
@@ -106,13 +106,14 @@ class SSHws(Namespace, BaseWebSocketHandler):
self
.
clients
[
request
.
sid
][
"request"
]
.
meta
[
'height'
]
=
message
.
get
(
'rows'
,
24
)
self
.
clients
[
request
.
sid
][
"request"
]
.
change_size_event
.
set
()
def
on_room
(
self
,
message
):
if
message
==
'get'
:
self
.
emit
(
'
room'
,
self
.
clients
[
request
.
sid
][
"room"
]
,
room
=
self
.
clients
[
request
.
sid
][
"room"
])
el
if
message
==
'join'
:
pass
def
on_room
(
self
,
sessionid
):
if
sessionid
not
in
self
.
clients
.
keys
()
:
self
.
emit
(
'
error'
,
"no such session"
,
room
=
self
.
clients
[
request
.
sid
][
"room"
])
el
se
:
self
.
emit
(
'room'
,
self
.
clients
[
sessionid
][
"room"
],
room
=
self
.
clients
[
request
.
sid
][
"room"
])
def
on_join
(
self
,
room
):
self
.
on_leave
(
self
.
clients
[
request
.
id
][
"room"
])
self
.
clients
[
request
.
sid
][
"room"
]
=
room
self
.
rooms
[
room
][
"member"
]
.
append
(
request
.
sid
)
join_room
(
room
=
room
)
...
...
@@ -162,156 +163,3 @@ class HttpServer:
def
shutdown
(
self
):
pass
if
__name__
==
"__main__"
:
app
=
Flask
(
__name__
,
template_folder
=
'/Users/liuzheng/gitproject/Jumpserver/webterminal/dist'
)
@app.route
(
'/luna/<path:path>'
)
def
send_js
(
path
):
return
send_from_directory
(
'/Users/liuzheng/gitproject/Jumpserver/webterminal/dist'
,
path
)
@app.route
(
'/'
)
@app.route
(
'/luna/'
)
def
index
():
return
render_template
(
'index.html'
)
@app.route
(
'/api/perms/v1/user/my/asset-groups-assets/'
)
def
asset_groups_assets
():
assets
=
[
{
"id"
:
0
,
"name"
:
"ungrouped"
,
"assets"
:
[]
},
{
"id"
:
1
,
"name"
:
"Default"
,
"comment"
:
"Default asset group"
,
"assets"
:
[
{
"id"
:
2
,
"hostname"
:
"192.168.1.6"
,
"ip"
:
"192.168.2.6"
,
"port"
:
22
,
"system"
:
"windows"
,
"uuid"
:
"xxxxxx"
,
"system_users"
:
[
{
"id"
:
1
,
"name"
:
"web"
,
"username"
:
"web"
,
"protocol"
:
"ssh"
,
"auth_method"
:
"P"
,
"auto_push"
:
True
}
]
},
{
"id"
:
4
,
"hostname"
:
"testserver123"
,
"ip"
:
"123.57.183.135"
,
"port"
:
8022
,
"system"
:
"linux"
,
"uuid"
:
"linux-xxlkjadf"
,
"system_users"
:
[
{
"id"
:
1
,
"name"
:
"web"
,
"username"
:
"web"
,
"protocol"
:
"ssh"
,
"auth_method"
:
"P"
,
"auto_push"
:
True
}
]
}
]
},
{
"id"
:
4
,
"name"
:
"java"
,
"comment"
:
""
,
"assets"
:
[
{
"id"
:
2
,
"hostname"
:
"192.168.1.6"
,
"ip"
:
"192.168.2.6"
,
"uuid"
:
"sadcascas"
,
"system"
:
"linux"
,
"port"
:
22
,
"system_users"
:
[
{
"id"
:
1
,
"name"
:
"web"
,
"username"
:
"web"
,
"protocol"
:
"ssh"
,
"auth_method"
:
"P"
,
"auto_push"
:
True
}
]
}
]
},
{
"id"
:
3
,
"name"
:
"数据库"
,
"comment"
:
""
,
"assets"
:
[
{
"id"
:
2
,
"hostname"
:
"192.168.1.6"
,
"ip"
:
"192.168.2.6"
,
"port"
:
22
,
"uuid"
:
"sadcascascasdcas"
,
"system"
:
"linux"
,
"system_users"
:
[
{
"id"
:
1
,
"name"
:
"web"
,
"username"
:
"web"
,
"protocol"
:
"ssh"
,
"auth_method"
:
"P"
,
"auto_push"
:
True
}
]
}
]
},
{
"id"
:
2
,
"name"
:
"运维组"
,
"comment"
:
""
,
"assets"
:
[
{
"id"
:
2
,
"hostname"
:
"192.168.1.6"
,
"ip"
:
"192.168.2.6"
,
"port"
:
22
,
"uuid"
:
"zxcasd"
,
"system"
:
"linux"
,
"system_users"
:
[
{
"id"
:
1
,
"name"
:
"web"
,
"username"
:
"web"
,
"protocol"
:
"ssh"
,
"auth_method"
:
"P"
,
"auto_push"
:
True
}
]
}
]
}
]
return
jsonify
(
assets
)
print
(
'socketio'
)
socketio
=
SocketIO
()
socketio
.
init_app
(
app
)
socketio
.
on_namespace
(
SSHws
(
'/ssh'
))
socketio
.
run
(
app
)
coco/recorder.py
View file @
178e7c24
...
...
@@ -128,7 +128,7 @@ class ServerReplayRecorder(ReplayRecorder):
logger
.
error
(
"Failed to push {}'s {}"
.
format
(
session_id
,
"record"
))
def
push_to_server
(
self
,
session_id
):
return
self
.
app
.
service
.
push_session_replay
(
os
.
path
.
join
(
self
.
app
.
config
[
'LOG_DIR'
],
session_id
+
'.replay'
),
return
self
.
app
.
service
.
push_session_replay
(
os
.
path
.
join
(
self
.
app
.
config
[
'LOG_DIR'
],
session_id
+
'.replay
.gz
'
),
session_id
)
def
__del__
(
self
):
...
...
conf_docker.py
View file @
178e7c24
...
...
@@ -8,11 +8,14 @@ BASE_DIR = os.path.dirname(__file__)
class
Config
:
# 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
APP_NAME
=
"coco"
"""
Coco config file
"""
# 默认的名字
# APP_NAME = "localhost"
# Jumpserver项目的url, api请求注册会使用
CORE_HOST
=
os
.
environ
.
get
(
"CORE_HOST"
)
or
'http://
127.0.0.1
:8080'
CORE_HOST
=
os
.
environ
.
get
(
"CORE_HOST"
)
or
'http://
jumpserver
:8080'
# 启动时绑定的ip, 默认 0.0.0.0
# BIND_HOST = '0.0.0.0'
...
...
@@ -56,3 +59,10 @@ class Config:
# Admin的名字,出问题会提示给用户
# ADMINS = ''
class
ConfigDocker
(
Config
):
pass
config
=
ConfigDocker
()
\ No newline at end of file
conf_example.py
View file @
178e7c24
...
...
@@ -8,8 +8,11 @@ BASE_DIR = os.path.dirname(__file__)
class
Config
:
"""
Coco config file
"""
# 项目名称, 会用来向Jumpserver注册, 识别而已, 不能重复
APP_NAME
=
"coco
"
# APP_NAME = "localhost
"
# Jumpserver项目的url, api请求注册会使用
# CORE_HOST = os.environ.get("CORE_HOST") or 'http://127.0.0.1:8080'
...
...
manage
.py
→
run_server
.py
View file @
178e7c24
File moved
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