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
ca56fd97
Commit
ca56fd97
authored
Dec 17, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of github.com:jumpserver/coco into dev
parents
a2c6f101
9abb0b35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
config.py
coco/config.py
+1
-0
interactive.py
coco/interactive.py
+20
-6
models.py
coco/models.py
+5
-0
No files found.
coco/config.py
View file @
ca56fd97
...
@@ -318,6 +318,7 @@ default_config = {
...
@@ -318,6 +318,7 @@ default_config = {
'REPLAY_STORAGE'
:
{
'TYPE'
:
'server'
},
'REPLAY_STORAGE'
:
{
'TYPE'
:
'server'
},
'LANGUAGE_CODE'
:
'zh'
,
'LANGUAGE_CODE'
:
'zh'
,
'SECURITY_MAX_IDLE_TIME'
:
60
,
'SECURITY_MAX_IDLE_TIME'
:
60
,
'ASSET_LIST_PAGE_SIZE'
:
'auto'
,
}
}
config
=
Config
(
root_path
,
default_config
)
config
=
Config
(
root_path
,
default_config
)
...
...
coco/interactive.py
View file @
ca56fd97
...
@@ -24,6 +24,7 @@ PAGE_DOWN = 'down'
...
@@ -24,6 +24,7 @@ PAGE_DOWN = 'down'
PAGE_UP
=
'up'
PAGE_UP
=
'up'
BACK
=
'back'
BACK
=
'back'
PROXY
=
'proxy'
PROXY
=
'proxy'
PAGE_SIZE_ALL
=
100000000
class
InteractiveServer
:
class
InteractiveServer
:
...
@@ -47,7 +48,14 @@ class InteractiveServer:
...
@@ -47,7 +48,14 @@ class InteractiveServer:
@property
@property
def
page_size
(
self
):
def
page_size
(
self
):
return
self
.
client
.
request
.
meta
[
'height'
]
-
8
_page_size
=
config
[
'ASSET_LIST_PAGE_SIZE'
]
if
_page_size
.
isdigit
():
return
int
(
_page_size
)
elif
_page_size
==
'auto'
:
return
self
.
client
.
request
.
meta
[
'height'
]
-
8
else
:
return
PAGE_SIZE_ALL
@property
@property
def
search_result
(
self
):
def
search_result
(
self
):
...
@@ -58,10 +66,6 @@ class InteractiveServer:
...
@@ -58,10 +66,6 @@ class InteractiveServer:
@search_result.setter
@search_result.setter
def
search_result
(
self
,
value
):
def
search_result
(
self
,
value
):
if
not
value
:
self
.
_search_result
=
value
return
value
=
self
.
filter_system_users
(
value
)
self
.
_search_result
=
value
self
.
_search_result
=
value
def
display_logo
(
self
):
def
display_logo
(
self
):
...
@@ -122,6 +126,7 @@ class InteractiveServer:
...
@@ -122,6 +126,7 @@ class InteractiveServer:
def
search_assets
(
self
,
q
):
def
search_assets
(
self
,
q
):
if
not
self
.
finish
:
if
not
self
.
finish
:
assets
=
app_service
.
get_search_user_granted_assets
(
self
.
client
.
user
,
q
)
assets
=
app_service
.
get_search_user_granted_assets
(
self
.
client
.
user
,
q
)
assets
=
self
.
filter_system_users
(
assets
)
return
assets
return
assets
assets
=
self
.
assets_list
assets
=
self
.
assets_list
result
=
[]
result
=
[]
...
@@ -194,7 +199,7 @@ class InteractiveServer:
...
@@ -194,7 +199,7 @@ class InteractiveServer:
self
.
display_nodes_tree
()
self
.
display_nodes_tree
()
return
return
assets
=
self
.
nodes
[
_id
-
1
]
.
assets_granted
assets
=
self
.
nodes
[
_id
-
1
]
.
assets_granted
self
.
display_result_paging
(
assets
)
self
.
display_result_paging
(
assets
)
def
display_search_result
(
self
):
def
display_search_result
(
self
):
...
@@ -234,6 +239,7 @@ class InteractiveServer:
...
@@ -234,6 +239,7 @@ class InteractiveServer:
def
get_user_nodes
(
self
):
def
get_user_nodes
(
self
):
self
.
nodes
=
app_service
.
get_user_asset_groups
(
self
.
client
.
user
)
self
.
nodes
=
app_service
.
get_user_asset_groups
(
self
.
client
.
user
)
self
.
filter_nodes_assets_system_user
()
self
.
sort_nodes
()
self
.
sort_nodes
()
self
.
construct_nodes_tree
()
self
.
construct_nodes_tree
()
...
@@ -265,6 +271,10 @@ class InteractiveServer:
...
@@ -265,6 +271,10 @@ class InteractiveServer:
asset
.
system_users_granted
=
system_users_cleaned
asset
.
system_users_granted
=
system_users_cleaned
return
assets
return
assets
def
filter_nodes_assets_system_user
(
self
):
for
node
in
self
.
nodes
:
node
.
assets_granted
=
self
.
filter_system_users
(
node
.
assets_granted
)
def
get_user_assets_paging
(
self
):
def
get_user_assets_paging
(
self
):
while
not
self
.
closed
:
while
not
self
.
closed
:
assets
,
total
=
app_service
.
get_user_assets_paging
(
assets
,
total
=
app_service
.
get_user_assets_paging
(
...
@@ -278,6 +288,7 @@ class InteractiveServer:
...
@@ -278,6 +288,7 @@ class InteractiveServer:
if
not
self
.
total_assets
:
if
not
self
.
total_assets
:
self
.
total_assets
=
total
self
.
total_assets
=
total
self
.
total_count
=
total
self
.
total_count
=
total
assets
=
self
.
filter_system_users
(
assets
)
self
.
assets_list
.
extend
(
assets
)
self
.
assets_list
.
extend
(
assets
)
self
.
offset
+=
self
.
limit
self
.
offset
+=
self
.
limit
...
@@ -393,6 +404,9 @@ class InteractiveServer:
...
@@ -393,6 +404,9 @@ class InteractiveServer:
page
-=
1
page
-=
1
left
-=
self
.
page_size
left
-=
self
.
page_size
else
:
else
:
if
self
.
page_size
==
PAGE_SIZE_ALL
:
# 如果全部显示左下标不做修改
continue
# PAGE_DOWN
# PAGE_DOWN
page
+=
1
page
+=
1
left
+=
len
(
result
)
left
+=
len
(
result
)
...
...
coco/models.py
View file @
ca56fd97
...
@@ -360,6 +360,11 @@ class TelnetServer(BaseServer):
...
@@ -360,6 +360,11 @@ class TelnetServer(BaseServer):
self
.
system_user
=
system_user
self
.
system_user
=
system_user
super
(
TelnetServer
,
self
)
.
__init__
(
chan
=
sock
)
super
(
TelnetServer
,
self
)
.
__init__
(
chan
=
sock
)
@property
def
closed
(
self
):
""" self.chan: socket object """
return
getattr
(
self
.
chan
,
'_closed'
,
False
)
class
Server
(
BaseServer
):
class
Server
(
BaseServer
):
"""
"""
...
...
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