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
d86cebf9
Commit
d86cebf9
authored
Mar 25, 2016
by
kelianchun
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #164 from kelianchun/dev
pull issue #120 remove ps1
parents
4f79e909
fd713e0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
14 deletions
+13
-14
connect.py
connect.py
+7
-9
run_server.py
run_server.py
+6
-5
No files found.
connect.py
View file @
d86cebf9
...
...
@@ -92,7 +92,8 @@ class Tty(object):
self
.
remote_ip
=
''
self
.
login_type
=
login_type
self
.
vim_flag
=
False
self
.
ps1_pattern
=
re
.
compile
(
'
\
[?.*@.*
\
]?[
\
$#]
\
s'
)
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
...
...
@@ -122,7 +123,7 @@ class Tty(object):
:return:返回去除PS1或者mysql字符串的结果
"""
result
=
None
match
=
self
.
ps1_pattern
.
split
(
command
)
match
=
re
.
compile
(
'
\
[?.*@.*
\
]?[
\
$#]
\
s'
)
.
split
(
command
)
if
match
:
# 只需要最后的一个PS1后面的字符串
result
=
match
[
-
1
]
.
strip
()
...
...
@@ -303,7 +304,6 @@ class SshTty(Tty):
data
=
''
input_str
=
''
input_mode
=
False
vim_end_flag
=
False
try
:
tty
.
setraw
(
sys
.
stdin
.
fileno
())
tty
.
setcbreak
(
sys
.
stdin
.
fileno
())
...
...
@@ -334,8 +334,6 @@ class SshTty(Tty):
except
OSError
as
msg
:
if
msg
.
errno
==
errno
.
EAGAIN
:
continue
#sys.stdout.write(x)
#sys.stdout.flush()
now_timestamp
=
time
.
time
()
log_time_f
.
write
(
'
%
s
%
s
\n
'
%
(
round
(
now_timestamp
-
pre_timestamp
,
4
),
len
(
x
)))
log_time_f
.
flush
()
...
...
@@ -364,13 +362,13 @@ class SshTty(Tty):
if
input_str
!=
x
:
data
+=
input_str
if
self
.
vim_flag
:
match
=
re
.
compile
(
r'\x1b\[\?1049'
,
re
.
X
)
.
findall
(
self
.
vim_data
)
match
=
self
.
vim_end_pattern
.
findall
(
self
.
vim_data
)
if
match
:
if
vim_end_flag
or
len
(
match
)
==
2
:
if
self
.
vim_end_flag
or
len
(
match
)
==
2
:
self
.
vim_flag
=
False
vim_end_flag
=
False
self
.
vim_end_flag
=
False
else
:
vim_end_flag
=
True
self
.
vim_end_flag
=
True
else
:
data
=
self
.
deal_command
(
data
)[
0
:
200
]
if
len
(
data
)
>
0
:
...
...
run_server.py
View file @
d86cebf9
...
...
@@ -364,12 +364,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
self
.
term
.
input_mode
=
True
if
str
(
jsondata
[
'data'
])
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
if
self
.
term
.
vim_flag
:
match
=
self
.
term
.
ps1_pattern
.
search
(
self
.
term
.
vim_data
)
match
=
re
.
compile
(
r'\x1b\[\?1049'
,
re
.
X
)
.
findall
(
self
.
vim_data
)
if
match
:
self
.
term
.
vim_flag
=
False
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
()
if
self
.
term
.
vim_end_flag
or
len
(
match
)
==
2
:
self
.
term
.
vim_flag
=
False
self
.
term
.
vim_end_flag
=
False
else
:
self
.
term
.
vim_end_flag
=
True
else
:
result
=
self
.
term
.
deal_command
(
self
.
term
.
data
)[
0
:
200
]
if
len
(
result
)
>
0
:
...
...
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