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
5b9a9779
Commit
5b9a9779
authored
May 11, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:jumpserver/jumpserver
parents
8526437c
32ab8a16
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
35 deletions
+21
-35
connect.py
connect.py
+16
-27
run_server.py
run_server.py
+4
-7
group_edit.html
templates/jasset/group_edit.html
+1
-1
No files found.
connect.py
View file @
5b9a9779
...
...
@@ -93,9 +93,7 @@ class Tty(object):
self
.
remote_ip
=
''
self
.
login_type
=
login_type
self
.
vim_flag
=
False
self
.
vim_end_flag
=
False
self
.
vim_end_pattern
=
re
.
compile
(
r'\x1b\[\?1049'
,
re
.
X
)
self
.
vim_pattern
=
re
.
compile
(
r'\W?vi[m]?\s.* | \W?fg\s.*'
,
re
.
X
)
self
.
vim_data
=
''
self
.
stream
=
None
self
.
screen
=
None
...
...
@@ -117,7 +115,8 @@ class Tty(object):
return
True
return
False
def
command_parser
(
self
,
command
):
@staticmethod
def
command_parser
(
command
):
"""
处理命令中如果有ps1或者mysql的特殊情况,极端情况下会有ps1和mysql
:param command:要处理的字符传
...
...
@@ -157,14 +156,10 @@ class Tty(object):
else
:
command
=
line_data
break
if
command
!=
''
:
# 判断用户输入的是否是vim 或者fg命令
if
self
.
vim_pattern
.
search
(
command
):
self
.
vim_flag
=
True
# 虚拟屏幕清空
self
.
screen
.
reset
()
except
Exception
:
pass
# 虚拟屏幕清空
self
.
screen
.
reset
()
return
command
def
get_log
(
self
):
...
...
@@ -305,7 +300,6 @@ class SshTty(Tty):
old_tty
=
termios
.
tcgetattr
(
sys
.
stdin
)
pre_timestamp
=
time
.
time
()
data
=
''
input_str
=
''
input_mode
=
False
try
:
tty
.
setraw
(
sys
.
stdin
.
fileno
())
...
...
@@ -325,8 +319,7 @@ class SshTty(Tty):
x
=
self
.
channel
.
recv
(
10240
)
if
len
(
x
)
==
0
:
break
if
self
.
vim_flag
:
self
.
vim_data
+=
x
index
=
0
len_x
=
len
(
x
)
while
index
<
len_x
:
...
...
@@ -347,11 +340,10 @@ class SshTty(Tty):
pre_timestamp
=
now_timestamp
log_file_f
.
flush
()
if
input_mode
and
not
self
.
is_output
(
x
):
self
.
vim_data
+=
x
if
input_mode
:
data
+=
x
input_str
=
''
except
socket
.
timeout
:
pass
...
...
@@ -362,25 +354,22 @@ class SshTty(Tty):
pass
termlog
.
recoder
=
True
input_mode
=
True
input_str
+=
x
if
str
(
x
)
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
# 这个是用来处理用户的复制操作
if
input_str
!=
x
:
data
+=
input_str
if
self
.
vim_flag
:
if
self
.
is_output
(
str
(
x
)):
# 如果len(str(x)) > 1 说明是复制输入的
if
len
(
str
(
x
))
>
1
:
data
=
x
match
=
self
.
vim_end_pattern
.
findall
(
self
.
vim_data
)
if
match
:
if
self
.
vim_end
_flag
or
len
(
match
)
==
2
:
if
self
.
vim
_flag
or
len
(
match
)
==
2
:
self
.
vim_flag
=
False
self
.
vim_end_flag
=
False
else
:
self
.
vim_end_flag
=
True
else
:
self
.
vim_flag
=
True
elif
not
self
.
vim_flag
:
self
.
vim_flag
=
False
data
=
self
.
deal_command
(
data
)[
0
:
200
]
if
len
(
data
)
>
0
:
if
data
is
not
None
:
TtyLog
(
log
=
log
,
datetime
=
datetime
.
datetime
.
now
(),
cmd
=
data
)
.
save
()
data
=
''
input_str
=
''
self
.
vim_data
=
''
input_mode
=
False
...
...
run_server.py
View file @
5b9a9779
...
...
@@ -373,15 +373,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
self
.
termlog
.
recoder
=
True
self
.
term
.
input_mode
=
True
if
str
(
jsondata
[
'data'
])
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
if
self
.
term
.
vim_flag
:
match
=
re
.
compile
(
r'\x1b\[\?1049'
,
re
.
X
)
.
findall
(
self
.
term
.
vim_data
)
if
match
:
if
self
.
term
.
vim_end
_flag
or
len
(
match
)
==
2
:
if
self
.
term
.
vim
_flag
or
len
(
match
)
==
2
:
self
.
term
.
vim_flag
=
False
self
.
term
.
vim_end_flag
=
False
else
:
self
.
term
.
vim_end_flag
=
True
else
:
self
.
term
.
vim_flag
=
True
elif
not
self
.
term
.
vim_flag
:
result
=
self
.
term
.
deal_command
(
self
.
term
.
data
)[
0
:
200
]
if
len
(
result
)
>
0
:
TtyLog
(
log
=
self
.
log
,
datetime
=
datetime
.
datetime
.
now
(),
cmd
=
result
)
.
save
()
...
...
@@ -424,7 +422,6 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
if
not
len
(
recv
):
return
data
+=
recv
if
self
.
term
.
vim_flag
:
self
.
term
.
vim_data
+=
recv
try
:
self
.
write_message
(
data
.
decode
(
'utf-8'
,
'replace'
))
...
...
@@ -436,7 +433,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
pre_timestamp
=
now_timestamp
self
.
log_file_f
.
flush
()
self
.
log_time_f
.
flush
()
if
self
.
term
.
input_mode
and
not
self
.
term
.
is_output
(
data
)
:
if
self
.
term
.
input_mode
:
self
.
term
.
data
+=
data
data
=
''
except
UnicodeDecodeError
:
...
...
templates/jasset/group_edit.html
View file @
5b9a9779
...
...
@@ -57,7 +57,7 @@
{% if smg %}
<div
class=
"alert alert-success text-center"
>
{{ smg }}
</div>
{% endif %}
<form
id=
"assetForm"
method=
"post"
class=
"form-horizontal"
>
<form
id=
"assetForm"
method=
"post"
class=
"form-horizontal"
onkeydown=
"if(event.keyCode==13){return false;}"
>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
主机组名
<span
class=
"red-fonts"
>
*
</span></label>
<div
class=
"col-sm-8"
name=
"group_id"
value=
"{{ group.id }}"
><input
type=
"text"
value=
"{{ group.name }}"
placeholder=
"Name"
name=
"name"
class=
"form-control"
></div>
</div>
...
...
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