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
20ff5171
Commit
20ff5171
authored
Jan 02, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge with dev
parents
a51bce5c
fc76e6b8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
166 deletions
+11
-166
httpd.py
coco/httpd.py
+6
-158
interactive.py
coco/interactive.py
+1
-4
recorder.py
coco/recorder.py
+1
-1
session.py
coco/session.py
+3
-3
No files found.
coco/httpd.py
View file @
20ff5171
...
@@ -106,13 +106,14 @@ class SSHws(Namespace, BaseWebSocketHandler):
...
@@ -106,13 +106,14 @@ class SSHws(Namespace, BaseWebSocketHandler):
self
.
clients
[
request
.
sid
][
"request"
]
.
meta
[
'height'
]
=
message
.
get
(
'rows'
,
24
)
self
.
clients
[
request
.
sid
][
"request"
]
.
meta
[
'height'
]
=
message
.
get
(
'rows'
,
24
)
self
.
clients
[
request
.
sid
][
"request"
]
.
change_size_event
.
set
()
self
.
clients
[
request
.
sid
][
"request"
]
.
change_size_event
.
set
()
def
on_room
(
self
,
message
):
def
on_room
(
self
,
sessionid
):
if
message
==
'get'
:
if
sessionid
not
in
self
.
clients
.
keys
()
:
self
.
emit
(
'
room'
,
self
.
clients
[
request
.
sid
][
"room"
]
,
room
=
self
.
clients
[
request
.
sid
][
"room"
])
self
.
emit
(
'
error'
,
"no such session"
,
room
=
self
.
clients
[
request
.
sid
][
"room"
])
el
if
message
==
'join'
:
el
se
:
pass
self
.
emit
(
'room'
,
self
.
clients
[
sessionid
][
"room"
],
room
=
self
.
clients
[
request
.
sid
][
"room"
])
def
on_join
(
self
,
room
):
def
on_join
(
self
,
room
):
self
.
on_leave
(
self
.
clients
[
request
.
id
][
"room"
])
self
.
clients
[
request
.
sid
][
"room"
]
=
room
self
.
clients
[
request
.
sid
][
"room"
]
=
room
self
.
rooms
[
room
][
"member"
]
.
append
(
request
.
sid
)
self
.
rooms
[
room
][
"member"
]
.
append
(
request
.
sid
)
join_room
(
room
=
room
)
join_room
(
room
=
room
)
...
@@ -162,156 +163,3 @@ class HttpServer:
...
@@ -162,156 +163,3 @@ class HttpServer:
def
shutdown
(
self
):
def
shutdown
(
self
):
pass
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/interactive.py
View file @
20ff5171
...
@@ -53,10 +53,7 @@ class InteractiveServer:
...
@@ -53,10 +53,7 @@ class InteractiveServer:
3) 输入 {green}P/p{end} 显示您有权限的主机.
\r
3) 输入 {green}P/p{end} 显示您有权限的主机.
\r
4) 输入 {green}G/g{end} 显示您有权限的主机组.
\r
4) 输入 {green}G/g{end} 显示您有权限的主机组.
\r
5) 输入 {green}G/g{end} + {green}组ID{end} 显示该组下主机. 如: g1
\r
5) 输入 {green}G/g{end} + {green}组ID{end} 显示该组下主机. 如: g1
\r
6) 输入 {green}E/e{end} 批量执行命令.(未完成)
\r
6) 输入 {green}H/h{end} 帮助.
\r
7) 输入 {green}U/u{end} 批量上传文件.(未完成)
\r
8) 输入 {green}D/d{end} 批量下载文件.(未完成)
\r
9) 输入 {green}H/h{end} 帮助.
\r
0) 输入 {green}Q/q{end} 退出.
\r\n
"""
)
.
format
(
0) 输入 {green}Q/q{end} 退出.
\r\n
"""
)
.
format
(
title
=
"
\033
[1;32m"
,
green
=
"
\033
[32m"
,
title
=
"
\033
[1;32m"
,
green
=
"
\033
[32m"
,
end
=
"
\033
[0m"
,
user
=
self
.
client
.
user
end
=
"
\033
[0m"
,
user
=
self
.
client
.
user
...
...
coco/recorder.py
View file @
20ff5171
...
@@ -128,7 +128,7 @@ class ServerReplayRecorder(ReplayRecorder):
...
@@ -128,7 +128,7 @@ class ServerReplayRecorder(ReplayRecorder):
logger
.
error
(
"Failed to push {}'s {}"
.
format
(
session_id
,
"record"
))
logger
.
error
(
"Failed to push {}'s {}"
.
format
(
session_id
,
"record"
))
def
push_to_server
(
self
,
session_id
):
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
)
session_id
)
def
__del__
(
self
):
def
__del__
(
self
):
...
...
coco/session.py
View file @
20ff5171
...
@@ -21,7 +21,7 @@ class Session:
...
@@ -21,7 +21,7 @@ class Session:
self
.
_sharers
=
[]
# Join to the session, read and write
self
.
_sharers
=
[]
# Join to the session, read and write
self
.
replaying
=
True
self
.
replaying
=
True
self
.
date_created
=
datetime
.
datetime
.
now
()
self
.
date_created
=
datetime
.
datetime
.
now
()
self
.
date_
finishe
d
=
None
self
.
date_
en
d
=
None
self
.
stop_evt
=
threading
.
Event
()
self
.
stop_evt
=
threading
.
Event
()
self
.
sel
=
selectors
.
DefaultSelector
()
self
.
sel
=
selectors
.
DefaultSelector
()
self
.
_command_recorder
=
command_recorder
self
.
_command_recorder
=
command_recorder
...
@@ -160,7 +160,7 @@ class Session:
...
@@ -160,7 +160,7 @@ class Session:
logger
.
info
(
"Close the session: {} "
.
format
(
self
.
id
))
logger
.
info
(
"Close the session: {} "
.
format
(
self
.
id
))
self
.
stop_evt
.
set
()
self
.
stop_evt
.
set
()
self
.
post_bridge
()
self
.
post_bridge
()
self
.
date_
finishe
d
=
datetime
.
datetime
.
now
()
self
.
date_
en
d
=
datetime
.
datetime
.
now
()
self
.
server
.
close
()
self
.
server
.
close
()
def
to_json
(
self
):
def
to_json
(
self
):
...
@@ -172,7 +172,7 @@ class Session:
...
@@ -172,7 +172,7 @@ class Session:
"login_from"
:
"ST"
,
"login_from"
:
"ST"
,
"is_finished"
:
True
if
self
.
stop_evt
.
is_set
()
else
False
,
"is_finished"
:
True
if
self
.
stop_evt
.
is_set
()
else
False
,
"date_start"
:
self
.
date_created
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"date_start"
:
self
.
date_created
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
),
"date_
finished"
:
self
.
date_finished
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
self
.
date_finishe
d
else
None
"date_
end"
:
self
.
date_end
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
if
self
.
date_en
d
else
None
}
}
def
__str__
(
self
):
def
__str__
(
self
):
...
...
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