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
ba08602e
Commit
ba08602e
authored
Nov 26, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加登陆方式
parent
19dcf171
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
13 deletions
+21
-13
connect.py
connect.py
+10
-8
models.py
jlog/models.py
+1
-0
run_websocket.py
run_websocket.py
+1
-0
log_offline.html
templates/jlog/log_offline.html
+5
-3
log_online.html
templates/jlog/log_online.html
+4
-2
No files found.
connect.py
View file @
ba08602e
...
@@ -67,6 +67,7 @@ class Tty(object):
...
@@ -67,6 +67,7 @@ class Tty(object):
self
.
user
=
user
self
.
user
=
user
self
.
role
=
role
self
.
role
=
role
self
.
ssh
=
None
self
.
ssh
=
None
self
.
remote_ip
=
''
self
.
connect_info
=
None
self
.
connect_info
=
None
self
.
login_type
=
'ssh'
self
.
login_type
=
'ssh'
self
.
vim_flag
=
False
self
.
vim_flag
=
False
...
@@ -192,17 +193,18 @@ class Tty(object):
...
@@ -192,17 +193,18 @@ class Tty(object):
if
self
.
login_type
==
'ssh'
:
# 如果是ssh连接过来,记录connect.py的pid,web terminal记录为日志的id
if
self
.
login_type
==
'ssh'
:
# 如果是ssh连接过来,记录connect.py的pid,web terminal记录为日志的id
pid
=
os
.
getpid
()
pid
=
os
.
getpid
()
remote_ip
=
os
.
popen
(
"who -m | awk '{ print $5 }'"
)
.
read
()
.
strip
(
'()
\n
'
)
# 获取远端IP
self
.
remote_ip
=
os
.
popen
(
"who -m | awk '{ print $5 }'"
)
.
read
()
.
strip
(
'()
\n
'
)
# 获取远端IP
log
=
Log
(
user
=
self
.
username
,
host
=
self
.
asset_name
,
remote_ip
=
remote_ip
,
log_path
=
log_file_path
,
start_time
=
date_today
,
pid
=
pid
)
else
:
else
:
remote_ip
=
'Web'
pid
=
0
log
=
Log
(
user
=
self
.
username
,
host
=
self
.
asset_name
,
remote_ip
=
remote_ip
,
log_path
=
log_file_path
,
start_time
=
date_today
,
pid
=
0
)
log
=
Log
(
user
=
self
.
username
,
host
=
self
.
asset_name
,
remote_ip
=
self
.
remote_ip
,
login_type
=
self
.
login_type
,
log
.
save
()
log_path
=
log_file_path
,
start_time
=
date_today
,
pid
=
pid
)
log
.
pid
=
log
.
id
log
.
save
()
log
.
save
()
if
self
.
login_type
==
'web'
:
log
.
pid
=
log
.
id
log
.
save
()
log_file_f
.
write
(
'Start at
%
s
\n
'
%
datetime
.
datetime
.
now
())
log_file_f
.
write
(
'Start at
%
s
\n
'
%
datetime
.
datetime
.
now
())
return
log_file_f
,
log_time_f
,
log
return
log_file_f
,
log_time_f
,
log
...
...
jlog/models.py
View file @
ba08602e
...
@@ -5,6 +5,7 @@ class Log(models.Model):
...
@@ -5,6 +5,7 @@ class Log(models.Model):
user
=
models
.
CharField
(
max_length
=
20
,
null
=
True
)
user
=
models
.
CharField
(
max_length
=
20
,
null
=
True
)
host
=
models
.
CharField
(
max_length
=
20
,
null
=
True
)
host
=
models
.
CharField
(
max_length
=
20
,
null
=
True
)
remote_ip
=
models
.
CharField
(
max_length
=
100
)
remote_ip
=
models
.
CharField
(
max_length
=
100
)
login_type
=
models
.
CharField
(
max_length
=
100
)
log_path
=
models
.
CharField
(
max_length
=
100
)
log_path
=
models
.
CharField
(
max_length
=
100
)
start_time
=
models
.
DateTimeField
(
null
=
True
)
start_time
=
models
.
DateTimeField
(
null
=
True
)
pid
=
models
.
IntegerField
()
pid
=
models
.
IntegerField
()
...
...
run_websocket.py
View file @
ba08602e
...
@@ -267,6 +267,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
...
@@ -267,6 +267,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
logger
.
debug
(
'Websocket: request web terminal Host:
%
s User:
%
s Role:
%
s'
%
(
asset
.
hostname
,
self
.
user
.
username
,
logger
.
debug
(
'Websocket: request web terminal Host:
%
s User:
%
s Role:
%
s'
%
(
asset
.
hostname
,
self
.
user
.
username
,
login_role
.
name
))
login_role
.
name
))
self
.
term
=
WebTty
(
self
.
user
,
asset
,
login_role
)
self
.
term
=
WebTty
(
self
.
user
,
asset
,
login_role
)
self
.
term
.
remote_ip
=
self
.
request
.
remote_ip
self
.
term
.
get_connection
()
self
.
term
.
get_connection
()
self
.
term
.
channel
=
self
.
term
.
ssh
.
invoke_shell
(
term
=
'xterm'
)
self
.
term
.
channel
=
self
.
term
.
ssh
.
invoke_shell
(
term
=
'xterm'
)
WebTerminalHandler
.
tasks
.
append
(
MyThread
(
target
=
self
.
forward_outbound
))
WebTerminalHandler
.
tasks
.
append
(
MyThread
(
target
=
self
.
forward_outbound
))
...
...
templates/jlog/log_offline.html
View file @
ba08602e
...
@@ -102,10 +102,11 @@
...
@@ -102,10 +102,11 @@
<th
class=
"text-center"
>
用户名
</th>
<th
class=
"text-center"
>
用户名
</th>
<th
class=
"text-center"
>
登录主机
</th>
<th
class=
"text-center"
>
登录主机
</th>
<th
class=
"text-center"
>
来源IP
</th>
<th
class=
"text-center"
>
来源IP
</th>
<th
class=
"text-center"
>
登陆方式
</th>
{% ifnotequal session_role_id 0 %}
{% ifnotequal session_role_id 0 %}
<th
class=
"text-center"
>
命令
统计
</th>
<th
class=
"text-center"
>
命令
</th>
{% endifnotequal %}
{% endifnotequal %}
<th
class=
"text-center"
>
回放
录像
</th>
<th
class=
"text-center"
>
录像
</th>
<th
class=
"text-center"
>
登录时间
</th>
<th
class=
"text-center"
>
登录时间
</th>
<th
class=
"text-center"
>
结束时间
</th>
<th
class=
"text-center"
>
结束时间
</th>
...
@@ -119,8 +120,9 @@
...
@@ -119,8 +120,9 @@
<td
class=
"text-center username"
>
{{ post.user }}
</td>
<td
class=
"text-center username"
>
{{ post.user }}
</td>
<td
class=
"text-center ip"
>
{{ post.host }}
</td>
<td
class=
"text-center ip"
>
{{ post.host }}
</td>
<td
class=
"text-center remote_ip"
>
{{ post.remote_ip }}
</td>
<td
class=
"text-center remote_ip"
>
{{ post.remote_ip }}
</td>
<td
class=
"text-center"
>
{{ post.login_type }}
</td>
{% ifnotequal session_role_id 0 %}
{% ifnotequal session_role_id 0 %}
<td
class=
"text-center"
><a
href=
"/jlog/history/?id={{ post.id }}"
class=
"log_command"
>
命令
统计
</a></td>
<td
class=
"text-center"
><a
href=
"/jlog/history/?id={{ post.id }}"
class=
"log_command"
>
统计
</a></td>
{% endifnotequal %}
{% endifnotequal %}
<td
class=
"text-center"
><a
value=
"/jlog/record/?id={{ post.id }}"
class=
"log_record"
>
回放
</a></td>
<td
class=
"text-center"
><a
value=
"/jlog/record/?id={{ post.id }}"
class=
"log_record"
>
回放
</a></td>
<td
class=
"text-center start_time"
>
{{ post.start_time|date:"Y-m-d H:i:s"}}
</td>
<td
class=
"text-center start_time"
>
{{ post.start_time|date:"Y-m-d H:i:s"}}
</td>
...
...
templates/jlog/log_online.html
View file @
ba08602e
...
@@ -79,7 +79,8 @@
...
@@ -79,7 +79,8 @@
<th
class=
"text-center"
>
用户名
</th>
<th
class=
"text-center"
>
用户名
</th>
<th
class=
"text-center"
>
登录主机
</th>
<th
class=
"text-center"
>
登录主机
</th>
<th
class=
"text-center"
>
来源IP
</th>
<th
class=
"text-center"
>
来源IP
</th>
<th
class=
"text-center"
>
统计命令
</th>
<th
class=
"text-center"
>
登录方式
</th>
<th
class=
"text-center"
>
命令
</th>
<th
class=
"text-center"
>
实时监控
</th>
<th
class=
"text-center"
>
实时监控
</th>
<th
class=
"text-center"
>
阻断
</th>
<th
class=
"text-center"
>
阻断
</th>
<th
class=
"text-center"
>
登录时间
</th>
<th
class=
"text-center"
>
登录时间
</th>
...
@@ -92,7 +93,8 @@
...
@@ -92,7 +93,8 @@
<td
id=
"username"
class=
"text-center"
>
{{ post.user }}
</td>
<td
id=
"username"
class=
"text-center"
>
{{ post.user }}
</td>
<td
id=
"ip"
class=
"text-center"
>
{{ post.host }}
</td>
<td
id=
"ip"
class=
"text-center"
>
{{ post.host }}
</td>
<td
id=
"remote_ip"
class=
"text-center"
>
{{ post.remote_ip }}
</td>
<td
id=
"remote_ip"
class=
"text-center"
>
{{ post.remote_ip }}
</td>
<td
class=
"text-center"
><a
href=
"/jlog/history/?id={{ post.id }}"
class=
"log_command"
>
命令统计
</a></td>
<td
class=
"text-center"
>
{{ post.login_type }}
</td>
<td
class=
"text-center"
><a
href=
"/jlog/history/?id={{ post.id }}"
class=
"log_command"
>
统计
</a></td>
<td
class=
"text-center"
><a
class=
"monitor"
file_path=
"{{ post.log_path }}"
>
监控
</a></td>
<td
class=
"text-center"
><a
class=
"monitor"
file_path=
"{{ post.log_path }}"
>
监控
</a></td>
<td
class=
"text-center"
><input
type=
"button"
id=
"cut"
class=
"btn btn-danger btn-xs"
name=
"cut"
value=
"阻断"
onclick=
'cut("{{ post.pid }}", "{{ post.remote_ip }}")'
/></td>
<td
class=
"text-center"
><input
type=
"button"
id=
"cut"
class=
"btn btn-danger btn-xs"
name=
"cut"
value=
"阻断"
onclick=
'cut("{{ post.pid }}", "{{ post.remote_ip }}")'
/></td>
<td
class=
"text-center"
id=
"start_time"
>
{{ post.start_time|date:"Y-m-d H:i:s" }}
</td>
<td
class=
"text-center"
id=
"start_time"
>
{{ post.start_time|date:"Y-m-d H:i:s" }}
</td>
...
...
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