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
f510d762
Commit
f510d762
authored
Dec 18, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
[Update] Merge
parents
0bdbaa3b
68315b89
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
140 additions
and
120 deletions
+140
-120
app.py
coco/app.py
+10
-0
interactive.py
coco/interactive.py
+18
-5
logger.py
coco/logger.py
+1
-1
utils.py
coco/utils.py
+5
-1
coco.mo
locale/en/LC_MESSAGES/coco.mo
+0
-0
coco.po
locale/en/LC_MESSAGES/coco.po
+41
-50
coco.mo
locale/zh_CN/LC_MESSAGES/coco.mo
+0
-0
coco.po
locale/zh_CN/LC_MESSAGES/coco.po
+65
-63
No files found.
coco/app.py
View file @
f510d762
...
...
@@ -56,6 +56,7 @@ class Coco:
return
self
.
_task_handler
@staticmethod
@ignore_error
def
load_extra_conf_from_server
():
configs
=
app_service
.
load_config_from_server
()
logger
.
debug
(
"Loading config from server: {}"
.
format
(
...
...
@@ -63,8 +64,17 @@ class Coco:
))
config
.
update
(
configs
)
def
keep_load_extra_conf
(
self
):
def
func
():
while
True
:
self
.
load_extra_conf_from_server
()
time
.
sleep
(
60
*
10
)
thread
=
threading
.
Thread
(
target
=
func
)
thread
.
start
()
def
bootstrap
(
self
):
self
.
load_extra_conf_from_server
()
self
.
keep_load_extra_conf
()
self
.
keep_heartbeat
()
self
.
monitor_sessions
()
self
.
monitor_sessions_replay
()
...
...
coco/interactive.py
View file @
f510d762
...
...
@@ -42,7 +42,7 @@ class InteractiveServer:
self
.
total_assets
=
0
# 用户被授权的所有资产
self
.
total_count
=
0
# 分页展示中的资产总数量
self
.
node_tree
=
None
# 授权节点树
self
.
get_user_assets_
paging_
async
()
self
.
get_user_assets_async
()
self
.
get_user_nodes_async
()
@property
...
...
@@ -161,7 +161,7 @@ class InteractiveServer:
self
.
display_assets
(
assets
)
def
refresh_assets_nodes
(
self
):
self
.
get_user_assets_
paging_
async
()
self
.
get_user_assets_async
()
self
.
get_user_nodes_async
()
def
search_assets
(
self
,
q
):
...
...
@@ -201,6 +201,8 @@ class InteractiveServer:
def
display_assets
(
self
,
assets
=
None
):
if
assets
is
None
:
while
not
self
.
assets
and
not
self
.
finish
:
time
.
sleep
(
0.2
)
assets
=
self
.
assets
self
.
display_assets_paging
(
assets
)
...
...
@@ -279,7 +281,8 @@ class InteractiveServer:
self
.
client
.
send
(
wr
(
prompt
,
before
=
1
))
def
get_user_action
(
self
):
opt
=
net_input
(
self
.
client
,
prompt
=
':'
)
opt
=
net_input
(
self
.
client
,
prompt
=
':'
,
only_one_char
=
True
)
print
(
opt
)
if
opt
in
(
'p'
,
'P'
):
return
PAGE_UP
elif
opt
in
(
'b'
,
'q'
):
...
...
@@ -324,10 +327,20 @@ class InteractiveServer:
# Get assets
#
def
get_user_assets_paging_async
(
self
):
thread
=
threading
.
Thread
(
target
=
self
.
get_user_assets_paging
)
def
get_user_assets_async
(
self
):
if
self
.
need_paging
:
thread
=
threading
.
Thread
(
target
=
self
.
get_user_assets_paging
)
else
:
thread
=
threading
.
Thread
(
target
=
self
.
get_user_assets_direct
)
thread
.
start
()
def
get_user_assets_direct
(
self
):
assets
=
app_service
.
get_user_assets
(
self
.
client
.
user
)
assets
=
self
.
filter_system_users
(
assets
)
self
.
assets
=
assets
self
.
total_assets
=
len
(
assets
)
self
.
finish
=
True
def
get_user_assets_paging
(
self
):
while
not
self
.
closed
:
assets
,
total
=
app_service
.
get_user_assets_paging
(
...
...
coco/logger.py
View file @
f510d762
...
...
@@ -10,7 +10,7 @@ from .config import config as app_config
def
create_logger
():
level
=
app_config
[
'LOG_LEVEL'
]
log_dir
=
app_config
.
get
(
'LOG_DIR'
)
log_dir
=
app_config
[
'LOG_DIR'
]
log_path
=
os
.
path
.
join
(
log_dir
,
'coco.log'
)
main_setting
=
{
'handlers'
:
[
'console'
,
'file'
],
...
...
coco/utils.py
View file @
f510d762
...
...
@@ -294,7 +294,7 @@ def get_logger(file_name):
return
logging
.
getLogger
(
'coco.'
+
file_name
)
def
net_input
(
client
,
prompt
=
'Opt> '
,
sensitive
=
False
,
before
=
0
,
after
=
0
):
def
net_input
(
client
,
prompt
=
'Opt> '
,
sensitive
=
False
,
before
=
0
,
after
=
0
,
only_one_char
=
False
):
"""实现了一个ssh input, 提示用户输入, 获取并返回
:return user input string
...
...
@@ -303,6 +303,10 @@ def net_input(client, prompt='Opt> ', sensitive=False, before=0, after=0):
parser
=
TtyIOParser
()
client
.
send
(
wrap_with_line_feed
(
prompt
,
before
=
before
,
after
=
after
))
if
only_one_char
:
data
=
client
.
recv
(
1
)
return
data
.
decode
()
while
True
:
data
=
client
.
recv
(
10
)
if
len
(
data
)
==
0
:
...
...
locale/en/LC_MESSAGES/coco.mo
View file @
f510d762
No preview for this file type
locale/en/LC_MESSAGES/coco.po
View file @
f510d762
...
...
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-1
0-31 11:49
+0800\n"
"POT-Creation-Date: 2018-1
2-18 20:03
+0800\n"
"PO-Revision-Date: 2018-08-10 10:42+0800\n"
"Last-Translator: BaiJiangjie <bugatti_it@163.com>\n"
"Language-Team: Language locale/en/LC\n"
...
...
@@ -16,11 +16,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: coco/app.py:1
3
5
#: coco/app.py:1
4
5
msgid "Connect idle more than {} minutes, disconnect"
msgstr ""
#: coco/interactive.py:8
0
#: coco/interactive.py:8
4
#, python-brace-format
msgid ""
"\n"
...
...
@@ -28,136 +28,127 @@ msgid ""
"{end}{R}{R}"
msgstr ""
#: coco/interactive.py:8
2
#: coco/interactive.py:8
6
#, python-brace-format
msgid ""
"{T}1) Enter {green}ID{end} directly login or enter {green}part IP, Hostname, "
"Comment{end} to search login(if unique).{R}"
msgstr ""
#: coco/interactive.py:8
3
#: coco/interactive.py:8
7
#, python-brace-format
msgid ""
"{T}2) Enter {green}/{end} + {green}IP, Hostname{end} or {green}Comment {end} "
"search, such as: /ip.{R}"
msgstr ""
#: coco/interactive.py:8
4
#: coco/interactive.py:8
8
#, python-brace-format
msgid "{T}3) Enter {green}p{end} to display the host you have permission.{R}"
msgstr ""
#: coco/interactive.py:8
5
#: coco/interactive.py:8
9
#, python-brace-format
msgid ""
"{T}4) Enter {green}g{end} to display the node that you have permission.{R}"
msgstr ""
#: coco/interactive.py:
86
#: coco/interactive.py:
90
#, python-brace-format
msgid ""
"{T}5) Enter {green}g{end} + {green}NodeID{end} to display the host under the "
"node, such as g1.{R}"
msgstr ""
#: coco/interactive.py:
87
#: coco/interactive.py:
91
#, python-brace-format
msgid "{T}6) Enter {green}s{end} Chinese-english switch.{R}"
msgstr ""
#: coco/interactive.py:
88
#: coco/interactive.py:
92
#, python-brace-format
msgid "{T}7) Enter {green}h{end} help.{R}"
msgstr ""
#: coco/interactive.py:
89
#: coco/interactive.py:
93
#, python-brace-format
msgid "{T}8) Enter {green}r{end} to refresh your assets and nodes.{R}"
msgstr ""
#: coco/interactive.py:9
0
#: coco/interactive.py:9
4
#, python-brace-format
msgid "{T}0) Enter {green}q{end} exit.{R}"
msgstr ""
#: coco/interactive.py:159
msgid "No"
msgstr ""
#: coco/interactive.py:166
msgid "Name"
#: coco/interactive.py:155
msgid "Terminal does not support login rdp, please use web terminal to access"
msgstr ""
#: coco/interactive.py:
166
msgid "Assets"
#: coco/interactive.py:
212
msgid "
No
Assets"
msgstr ""
#: coco/interactive.py:
172
msgid "T
otal: {}
"
#: coco/interactive.py:
275
msgid "T
ips: Enter the asset ID and log directly into the asset.
"
msgstr ""
#: coco/interactive.py:
177
msgid "
Node [ ID.Name(Asset) ]
"
#: coco/interactive.py:
276
msgid "
Page up: P/p
"
msgstr ""
#: coco/interactive.py:
179
msgid "
Enter g+NodeID to display the host under the node, such as g1.
"
#: coco/interactive.py:
277
msgid "
Page down: Enter|N/n
"
msgstr ""
#: coco/interactive.py:
186
msgid "
There is no matched node, please re-enter
"
#: coco/interactive.py:
278
msgid "
BACK: b/q
"
msgstr ""
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "ID"
msgstr ""
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "Hostname"
msgstr ""
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "IP"
msgstr ""
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "LoginAs"
msgstr ""
#: coco/interactive.py:
211
#: coco/interactive.py:
313
msgid "Comment"
msgstr ""
#: coco/interactive.py:
221
#: coco/interactive.py:
322
msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}"
msgstr ""
#: coco/interactive.py:
296
msgid "
Select a login::
"
#: coco/interactive.py:
394
msgid "
No Nodes
"
msgstr ""
#: coco/interactive.py:319
msgid ""
"Terminal does not support login Windows, please use web terminal to access"
#: coco/interactive.py:398
msgid "Node: [ ID.Name(Asset amount) ]"
msgstr ""
#: coco/interactive.py:40
1
msgid "Tips: Enter
the asset ID and log directly into the asset.
"
#: coco/interactive.py:40
0
msgid "Tips: Enter
g+NodeID to display the host under the node, such as g1
"
msgstr ""
#: coco/interactive.py:402
msgid "Page up: P/p"
msgstr ""
#: coco/interactive.py:403
msgid "Page down: Enter|N/n"
#: coco/interactive.py:408
msgid "There is no matched node, please re-enter"
msgstr ""
#: coco/interactive.py:4
04
msgid "
BACK: B/b
"
#: coco/interactive.py:4
38
msgid "
Select a login::
"
msgstr ""
#: coco/interactive.py:4
25
#: coco/interactive.py:4
61
msgid "No system user"
msgstr ""
...
...
locale/zh_CN/LC_MESSAGES/coco.mo
View file @
f510d762
No preview for this file type
locale/zh_CN/LC_MESSAGES/coco.po
View file @
f510d762
...
...
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-1
0-31 11:49
+0800\n"
"POT-Creation-Date: 2018-1
2-18 20:04
+0800\n"
"PO-Revision-Date: 2018-08-10 10:42+0800\n"
"Last-Translator: BaiJiangjie <bugatti_it@163.com>\n"
"Language-Team: Language locale/zh\n"
...
...
@@ -16,11 +16,11 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: coco/app.py:1
3
5
#: coco/app.py:1
4
5
msgid "Connect idle more than {} minutes, disconnect"
msgstr "空闲时间超过 {} 分钟,断开连接"
#: coco/interactive.py:8
0
#: coco/interactive.py:8
4
#, python-brace-format
msgid ""
"\n"
...
...
@@ -30,7 +30,7 @@ msgstr ""
"\n"
"{T}{T}{title} {user}, 欢迎使用Jumpserver开源跳板机系统 {end}{R}{R}"
#: coco/interactive.py:8
2
#: coco/interactive.py:8
6
#, python-brace-format
msgid ""
"{T}1) Enter {green}ID{end} directly login or enter {green}part IP, Hostname, "
...
...
@@ -39,7 +39,7 @@ msgstr ""
"{T}1) 输入 {green}ID{end} 直接登录 或 输入{green}部分 IP,主机名,备注{end} 进"
"行搜索登录(如果唯一).{R}"
#: coco/interactive.py:8
3
#: coco/interactive.py:8
7
#, python-brace-format
msgid ""
"{T}2) Enter {green}/{end} + {green}IP, Hostname{end} or {green}Comment {end} "
...
...
@@ -48,127 +48,120 @@ msgstr ""
"{T}2) 输入 {green}/{end} + {green}IP, 主机名{end} or {green}备注 {end}搜索. "
"如: /ip{R}"
#: coco/interactive.py:8
4
#: coco/interactive.py:8
8
#, python-brace-format
msgid "{T}3) Enter {green}p{end} to display the host you have permission.{R}"
msgstr "{T}3) 输入 {green}p{end} 显示您有权限的主机.{R}"
#: coco/interactive.py:8
5
#: coco/interactive.py:8
9
#, python-brace-format
msgid ""
"{T}4) Enter {green}g{end} to display the node that you have permission.{R}"
msgstr "{T}4) 输入 {green}g{end} 显示您有权限的节点.{R}"
#: coco/interactive.py:86
#: coco/interactive.py:90
#, python-brace-format
msgid ""
"{T}5) Enter {green}g{end} + {green}NodeID{end} to display the host under the "
"node, such as g1.{R}"
msgstr "{T}5) 输入 {green}g{end} + {green}节点ID{end} 显示节点下主机. 如: g1{R}"
msgstr ""
"{T}5) 输入 {green}g{end} + {green}节点ID{end} 显示节点下主机. 如: g1{R}"
#: coco/interactive.py:
87
#: coco/interactive.py:
91
#, python-brace-format
msgid "{T}6) Enter {green}s{end} Chinese-english switch.{R}"
msgstr "{T}6) 输入 {green}s{end} 中/英文切换.{R}"
#: coco/interactive.py:
88
#: coco/interactive.py:
92
#, python-brace-format
msgid "{T}7) Enter {green}h{end} help.{R}"
msgstr "{T}7) 输入 {green}h{end} 帮助.{R}"
#: coco/interactive.py:
89
#: coco/interactive.py:
93
#, python-brace-format
msgid "{T}8) Enter {green}r{end} to refresh your assets and nodes.{R}"
msgstr "{T}0) 输入 {green}r{end} 刷新最新的机器和节点信息.{R}"
#: coco/interactive.py:9
0
#: coco/interactive.py:9
4
#, python-brace-format
msgid "{T}0) Enter {green}q{end} exit.{R}"
msgstr "{T}0) 输入 {green}q{end} 退出.{R}"
#: coco/interactive.py:159
msgid "No"
msgstr "无"
#: coco/interactive.py:166
msgid "Name"
msgstr "名称"
#: coco/interactive.py:155
msgid "Terminal does not support login rdp, please use web terminal to access"
msgstr "终端不支持登录windows, 请使用web terminal访问"
#: coco/interactive.py:
166
msgid "Assets"
msgstr "资产"
#: coco/interactive.py:
212
msgid "
No
Assets"
msgstr "
没有
资产"
#: coco/interactive.py:
172
msgid "T
otal: {}
"
msgstr "
总共: {}
"
#: coco/interactive.py:
275
msgid "T
ips: Enter the asset ID and log directly into the asset.
"
msgstr "
提示: 输入资产ID,直接登录资产.
"
#: coco/interactive.py:
177
msgid "
Node: [ ID.Name(Asset amount) ]
"
msgstr "
节点: [ ID.名称(资产数量) ]
"
#: coco/interactive.py:
276
msgid "
Page up: P/p
"
msgstr "
上一页: P/p
"
#: coco/interactive.py:
179
msgid "
Tips: Enter g+NodeID to display the host under the node, such as g1
"
msgstr "
提示: 输入 g+节点ID 显示节点下主机. 如: g1
"
#: coco/interactive.py:
277
msgid "
Page down: Enter|N/n
"
msgstr "
下一页: Enter|N/n
"
#: coco/interactive.py:
186
msgid "
There is no matched node, please re-enter
"
msgstr "
没有匹配分组,请重新输入
"
#: coco/interactive.py:
278
msgid "
BACK: b/q
"
msgstr "
返回: B/b
"
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "ID"
msgstr ""
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "Hostname"
msgstr "主机名"
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "IP"
msgstr ""
#: coco/interactive.py:
197
#: coco/interactive.py:
299
msgid "LoginAs"
msgstr "登录用户"
#: coco/interactive.py:
211
#: coco/interactive.py:
313
msgid "Comment"
msgstr "备注"
#: coco/interactive.py:
221
#: coco/interactive.py:
322
msgid "Page: {}, Count: {}, Total Page: {}, Total Count: {}"
msgstr "页码: {}, 数量: {}, 总页数: {}, 总数量: {}"
#: coco/interactive.py:296
msgid "Select a login:: "
msgstr "选择一个登录:"
#: coco/interactive.py:319
msgid ""
"Terminal does not support login Windows, please use web terminal to access"
msgstr "终端不支持登录windows, 请使用web terminal访问"
#: coco/interactive.py:394
msgid "No Nodes"
msgstr "没有节点"
#: coco/interactive.py:
401
msgid "
Tips: Enter the asset ID and log directly into the asset.
"
msgstr "
提示: 输入资产ID,直接登录资产.
"
#: coco/interactive.py:
398
msgid "
Node: [ ID.Name(Asset amount) ]
"
msgstr "
节点: [ ID.名称(资产数量) ]
"
#: coco/interactive.py:40
2
msgid "
Page up: P/p
"
msgstr "
上一页: P/p
"
#: coco/interactive.py:40
0
msgid "
Tips: Enter g+NodeID to display the host under the node, such as g1
"
msgstr "
提示: 输入 g+节点ID 显示节点下主机. 如: g1
"
#: coco/interactive.py:40
3
msgid "
Page down: Enter|N/n
"
msgstr "
下一页: Enter|N/n
"
#: coco/interactive.py:40
8
msgid "
There is no matched node, please re-enter
"
msgstr "
没有匹配分组,请重新输入
"
#: coco/interactive.py:4
04
msgid "
BACK: B/b
"
msgstr "
返回: B/b
"
#: coco/interactive.py:4
38
msgid "
Select a login::
"
msgstr "
选择一个登录:
"
#: coco/interactive.py:4
25
#: coco/interactive.py:4
61
msgid "No system user"
msgstr "没有系统用户"
#: coco/models.py:247
msgid "Command `{}` is forbidden ........"
msgstr ""
msgstr "
命令 `{}` 是被禁止的 ...
"
#: coco/proxy.py:89
msgid "No permission"
...
...
@@ -182,5 +175,14 @@ msgstr "开始连接到 {}@{} {:.1f}"
msgid "Terminated by administrator"
msgstr "被管理员中断"
#~ msgid "No"
#~ msgstr "无"
#~ msgid "Name"
#~ msgstr "名称"
#~ msgid "Total: {}"
#~ msgstr "总共: {}"
#~ msgid "Total: {} Match: {}"
#~ msgstr "总共: {} 匹配: {}"
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