Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
536be117
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
536be117
编写于
4月 24, 2018
作者:
L
liuzheng712
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: replay api update
make a v2 session replay api, get the json response
上级
02ca8c31
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
1 deletion
+57
-1
apps/terminal/api.py
apps/terminal/api.py
+51
-0
apps/terminal/urls/api_urls.py
apps/terminal/urls/api_urls.py
+6
-1
未找到文件。
apps/terminal/api.py
浏览文件 @
536be117
...
...
@@ -304,6 +304,57 @@ class SessionReplayViewSet(viewsets.ViewSet):
return
HttpResponseNotFound
()
class
SessionReplayV2ViewSet
(
viewsets
.
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
()
if
default_storage
.
exists
(
replay
[
"path"
]):
replay
[
"src"
]
=
default_storage
.
url
(
replay
[
"path"
])
return
Response
(
replay
)
else
:
configs
=
settings
.
TERMINAL_REPLAY_STORAGE
.
items
()
if
not
configs
:
return
HttpResponseNotFound
()
for
name
,
config
in
configs
:
client
=
jms_storage
.
init
(
config
)
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
)
return
HttpResponseNotFound
()
class
TerminalConfig
(
APIView
):
permission_classes
=
(
IsAppUser
,)
...
...
apps/terminal/urls/api_urls.py
浏览文件 @
536be117
...
...
@@ -23,8 +23,13 @@ urlpatterns = [
api
.
SessionReplayViewSet
.
as_view
({
'get'
:
'retrieve'
,
'post'
:
'create'
}),
name
=
'session-replay'
),
url
(
r
'^v1/tasks/kill-session/'
,
api
.
KillSessionAPI
.
as_view
(),
name
=
'kill-session'
),
url
(
r
'^v1/terminal/(?P<terminal>[a-zA-Z0-9\-]{36})/access-key'
,
api
.
TerminalTokenApi
.
as_view
(),
name
=
'terminal-access-key'
),
url
(
r
'^v1/terminal/(?P<terminal>[a-zA-Z0-9\-]{36})/access-key'
,
api
.
TerminalTokenApi
.
as_view
(),
name
=
'terminal-access-key'
),
url
(
r
'^v1/terminal/config'
,
api
.
TerminalConfig
.
as_view
(),
name
=
'terminal-config'
),
# v2: get session's replay
url
(
r
'^v2/sessions/(?P<pk>[0-9a-zA-Z\-]{36})/replay/$'
,
api
.
SessionReplayV2ViewSet
.
as_view
({
'get'
:
'retrieve'
}),
name
=
'session-replay-v2'
),
]
urlpatterns
+=
router
.
urls
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录