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
7294bbb2
Commit
7294bbb2
authored
Aug 16, 2018
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] Session online/offline 添加remote_addr搜索功能
parent
35f64674
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
2 deletions
+19
-2
domain.py
apps/assets/models/domain.py
+1
-1
session_list.html
apps/terminal/templates/terminal/session_list.html
+8
-0
utils.py
apps/terminal/utils.py
+4
-0
session.py
apps/terminal/views/session.py
+6
-1
No files found.
apps/assets/models/domain.py
View file @
7294bbb2
...
...
@@ -43,7 +43,7 @@ class Gateway(AssetUser):
ip
=
models
.
GenericIPAddressField
(
max_length
=
32
,
verbose_name
=
_
(
'IP'
),
db_index
=
True
)
port
=
models
.
IntegerField
(
default
=
22
,
verbose_name
=
_
(
'Port'
))
protocol
=
models
.
CharField
(
choices
=
PROTOCOL_CHOICES
,
max_length
=
16
,
default
=
SSH_PROTOCOL
,
verbose_name
=
_
(
"Protocol"
))
domain
=
models
.
ForeignKey
(
Domain
,
verbose_name
=
_
(
"Domain"
))
domain
=
models
.
ForeignKey
(
Domain
,
on_delete
=
models
.
DO_NOTHING
,
verbose_name
=
_
(
"Domain"
))
comment
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
"Comment"
))
is_active
=
models
.
BooleanField
(
default
=
True
,
verbose_name
=
_
(
"Is active"
))
...
...
apps/terminal/templates/terminal/session_list.html
View file @
7294bbb2
...
...
@@ -52,6 +52,14 @@
{% endfor %}
</select>
</div>
<div
class=
"input-group"
>
<select
class=
"select2 form-control"
name=
"remote_addr"
>
<option
value=
""
>
{% trans 'Remote addr' %}
</option>
{% for ra in remote_addr_list %}
<option
value=
"{{ ra }}"
{%
if
ra =
=
remote_addr
%}
selected
{%
endif
%}
>
{{ ra }}
</option>
{% endfor %}
</select>
</div>
{#
<div
class=
"input-group"
>
#}
{#
<input
type=
"text"
class=
"form-control input-sm"
name=
"keyword"
placeholder=
"Keyword"
value=
"{{ keyword }}"
>
#}
{#
</div>
#}
...
...
apps/terminal/utils.py
View file @
7294bbb2
...
...
@@ -18,6 +18,10 @@ def get_session_system_user_list():
return
set
(
list
(
Session
.
objects
.
values_list
(
'system_user'
,
flat
=
True
)))
def
get_session_remote_addr_list
():
return
set
(
list
(
Session
.
objects
.
values_list
(
'remote_addr'
,
flat
=
True
)))
def
get_user_list_from_cache
():
return
cache
.
get
(
USERS_CACHE_KEY
)
...
...
apps/terminal/views/session.py
View file @
7294bbb2
...
...
@@ -27,7 +27,7 @@ class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView):
template_name
=
'terminal/session_list.html'
context_object_name
=
'session_list'
paginate_by
=
settings
.
DISPLAY_PER_PAGE
user
=
asset
=
system_user
=
''
user
=
asset
=
system_user
=
remote_addr
=
''
date_from
=
date_to
=
None
def
get_queryset
(
self
):
...
...
@@ -35,6 +35,7 @@ class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView):
self
.
user
=
self
.
request
.
GET
.
get
(
'user'
)
self
.
asset
=
self
.
request
.
GET
.
get
(
'asset'
)
self
.
system_user
=
self
.
request
.
GET
.
get
(
'system_user'
)
self
.
remote_addr
=
self
.
request
.
GET
.
get
(
'remote_addr'
)
filter_kwargs
=
dict
()
filter_kwargs
[
'date_start__gt'
]
=
self
.
date_from
...
...
@@ -45,6 +46,8 @@ class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView):
filter_kwargs
[
'asset'
]
=
self
.
asset
if
self
.
system_user
:
filter_kwargs
[
'system_user'
]
=
self
.
system_user
if
self
.
remote_addr
:
filter_kwargs
[
'remote_addr'
]
=
self
.
remote_addr
if
filter_kwargs
:
self
.
queryset
=
self
.
queryset
.
filter
(
**
filter_kwargs
)
return
self
.
queryset
...
...
@@ -54,11 +57,13 @@ class SessionListView(AdminUserRequiredMixin, DatetimeSearchMixin, ListView):
'user_list'
:
utils
.
get_session_user_list
(),
'asset_list'
:
utils
.
get_session_asset_list
(),
'system_user_list'
:
utils
.
get_session_system_user_list
(),
'remote_addr_list'
:
utils
.
get_session_remote_addr_list
(),
'date_from'
:
self
.
date_from
,
'date_to'
:
self
.
date_to
,
'user'
:
self
.
user
,
'asset'
:
self
.
asset
,
'system_user'
:
self
.
system_user
,
'remote_addr'
:
self
.
remote_addr
,
}
kwargs
.
update
(
context
)
return
super
()
.
get_context_data
(
**
kwargs
)
...
...
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