Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
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
jumpserver
Commits
d2b0aba6
Commit
d2b0aba6
authored
May 07, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 修改replay api
parent
7f670ab7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
34 deletions
+19
-34
api.py
apps/terminal/api.py
+18
-32
session.py
apps/terminal/views/session.py
+1
-2
No files found.
apps/terminal/api.py
View file @
d2b0aba6
...
...
@@ -304,40 +304,24 @@ class SessionReplayViewSet(viewsets.ViewSet):
return
HttpResponseNotFound
()
class
SessionReplayV2ViewSet
(
viewsets
.
ViewSet
):
class
SessionReplayV2ViewSet
(
SessionReplay
ViewSet
):
serializer_class
=
ReplaySerializer
permission_classes
=
(
IsSuperUserOrAppUser
,)
session
=
None
def
gen_session_path
(
self
):
date
=
self
.
session
.
date_start
.
strftime
(
'
%
Y-
%
m-
%
d'
)
replay
=
{
"id"
:
self
.
session
.
id
,
# "width": 100,
# "heith": 100
}
if
self
.
session
.
protocol
==
"ssh"
:
replay
[
'type'
]
=
"json"
replay
[
'path'
]
=
os
.
path
.
join
(
date
,
str
(
self
.
session
.
id
)
+
'.gz'
)
return
replay
elif
self
.
session
.
protocol
==
"rdp"
:
replay
[
'type'
]
=
"mp4"
replay
[
'path'
]
=
os
.
path
.
join
(
date
,
str
(
self
.
session
.
id
)
+
'.mp4'
)
return
replay
else
:
return
replay
def
retrieve
(
self
,
request
,
*
args
,
**
kwargs
):
session_id
=
kwargs
.
get
(
'pk'
)
self
.
session
=
get_object_or_404
(
Session
,
id
=
session_id
)
replay
=
self
.
gen_session_path
()
if
replay
.
get
(
"path"
,
""
)
==
""
:
return
HttpResponseNotFound
()
path
=
self
.
gen_session_path
()
data
=
{
'type'
:
'guacamole'
if
self
.
session
.
protocol
==
'rdp'
else
'json'
,
'src'
:
''
,
}
if
default_storage
.
exists
(
replay
[
"path"
]):
replay
[
"src"
]
=
default_storage
.
url
(
replay
[
"path"
])
return
Response
(
replay
)
if
default_storage
.
exists
(
path
):
url
=
default_storage
.
url
(
path
)
data
[
'src'
]
=
url
return
Response
(
data
)
else
:
configs
=
settings
.
TERMINAL_REPLAY_STORAGE
.
items
()
if
not
configs
:
...
...
@@ -345,13 +329,15 @@ class SessionReplayV2ViewSet(viewsets.ViewSet):
for
name
,
config
in
configs
:
client
=
jms_storage
.
init
(
config
)
date
=
self
.
session
.
date_start
.
strftime
(
'
%
Y-
%
m-
%
d'
)
file_path
=
os
.
path
.
join
(
date
,
str
(
self
.
session
.
id
)
+
'.replay.gz'
)
target_path
=
default_storage
.
base_location
+
'/'
+
path
target_path
=
default_storage
.
base_location
+
'/'
+
replay
[
"path"
]
if
client
and
client
.
has_file
(
replay
[
"path"
])
and
\
client
.
download_file
(
replay
[
"path"
],
target_path
):
replay
[
"src"
]
=
default_storage
.
url
(
replay
[
"path"
])
return
Response
(
replay
)
if
client
and
client
.
has_file
(
file_path
)
and
\
client
.
download_file
(
file_path
,
target_path
):
url
=
default_storage
.
url
(
path
)
data
[
'src'
]
=
url
return
Response
(
data
)
return
HttpResponseNotFound
()
...
...
apps/terminal/views/session.py
View file @
d2b0aba6
...
...
@@ -47,8 +47,7 @@ class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView):
filter_kwargs
[
'system_user'
]
=
self
.
system_user
if
filter_kwargs
:
self
.
queryset
=
self
.
queryset
.
filter
(
**
filter_kwargs
)
# Todo: 暂时隐藏rdp
return
self
.
queryset
.
filter
(
protocol
=
'ssh'
)
return
self
.
queryset
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
...
...
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