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
fd713e0e
Commit
fd713e0e
authored
Mar 25, 2016
by
kelianchun_miller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pull issue #120 remove ps1
parent
4f79e909
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 @
fd713e0e
...
@@ -92,7 +92,8 @@ class Tty(object):
...
@@ -92,7 +92,8 @@ class Tty(object):
self
.
remote_ip
=
''
self
.
remote_ip
=
''
self
.
login_type
=
login_type
self
.
login_type
=
login_type
self
.
vim_flag
=
False
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_pattern
=
re
.
compile
(
r'\W?vi[m]?\s.* | \W?fg\s.*'
,
re
.
X
)
self
.
vim_data
=
''
self
.
vim_data
=
''
self
.
stream
=
None
self
.
stream
=
None
...
@@ -122,7 +123,7 @@ class Tty(object):
...
@@ -122,7 +123,7 @@ class Tty(object):
:return:返回去除PS1或者mysql字符串的结果
:return:返回去除PS1或者mysql字符串的结果
"""
"""
result
=
None
result
=
None
match
=
self
.
ps1_pattern
.
split
(
command
)
match
=
re
.
compile
(
'
\
[?.*@.*
\
]?[
\
$#]
\
s'
)
.
split
(
command
)
if
match
:
if
match
:
# 只需要最后的一个PS1后面的字符串
# 只需要最后的一个PS1后面的字符串
result
=
match
[
-
1
]
.
strip
()
result
=
match
[
-
1
]
.
strip
()
...
@@ -303,7 +304,6 @@ class SshTty(Tty):
...
@@ -303,7 +304,6 @@ class SshTty(Tty):
data
=
''
data
=
''
input_str
=
''
input_str
=
''
input_mode
=
False
input_mode
=
False
vim_end_flag
=
False
try
:
try
:
tty
.
setraw
(
sys
.
stdin
.
fileno
())
tty
.
setraw
(
sys
.
stdin
.
fileno
())
tty
.
setcbreak
(
sys
.
stdin
.
fileno
())
tty
.
setcbreak
(
sys
.
stdin
.
fileno
())
...
@@ -334,8 +334,6 @@ class SshTty(Tty):
...
@@ -334,8 +334,6 @@ class SshTty(Tty):
except
OSError
as
msg
:
except
OSError
as
msg
:
if
msg
.
errno
==
errno
.
EAGAIN
:
if
msg
.
errno
==
errno
.
EAGAIN
:
continue
continue
#sys.stdout.write(x)
#sys.stdout.flush()
now_timestamp
=
time
.
time
()
now_timestamp
=
time
.
time
()
log_time_f
.
write
(
'
%
s
%
s
\n
'
%
(
round
(
now_timestamp
-
pre_timestamp
,
4
),
len
(
x
)))
log_time_f
.
write
(
'
%
s
%
s
\n
'
%
(
round
(
now_timestamp
-
pre_timestamp
,
4
),
len
(
x
)))
log_time_f
.
flush
()
log_time_f
.
flush
()
...
@@ -364,13 +362,13 @@ class SshTty(Tty):
...
@@ -364,13 +362,13 @@ class SshTty(Tty):
if
input_str
!=
x
:
if
input_str
!=
x
:
data
+=
input_str
data
+=
input_str
if
self
.
vim_flag
:
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
match
:
if
vim_end_flag
or
len
(
match
)
==
2
:
if
self
.
vim_end_flag
or
len
(
match
)
==
2
:
self
.
vim_flag
=
False
self
.
vim_flag
=
False
vim_end_flag
=
False
self
.
vim_end_flag
=
False
else
:
else
:
vim_end_flag
=
True
self
.
vim_end_flag
=
True
else
:
else
:
data
=
self
.
deal_command
(
data
)[
0
:
200
]
data
=
self
.
deal_command
(
data
)[
0
:
200
]
if
len
(
data
)
>
0
:
if
len
(
data
)
>
0
:
...
...
run_server.py
View file @
fd713e0e
...
@@ -364,12 +364,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
...
@@ -364,12 +364,13 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
self
.
term
.
input_mode
=
True
self
.
term
.
input_mode
=
True
if
str
(
jsondata
[
'data'
])
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
if
str
(
jsondata
[
'data'
])
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
if
self
.
term
.
vim_flag
:
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
:
if
match
:
self
.
term
.
vim_flag
=
False
if
self
.
term
.
vim_end_flag
or
len
(
match
)
==
2
:
result
=
self
.
term
.
deal_command
(
self
.
term
.
data
)[
0
:
200
]
self
.
term
.
vim_flag
=
False
if
len
(
result
)
>
0
:
self
.
term
.
vim_end_flag
=
False
TtyLog
(
log
=
self
.
log
,
datetime
=
datetime
.
datetime
.
now
(),
cmd
=
result
)
.
save
()
else
:
self
.
term
.
vim_end_flag
=
True
else
:
else
:
result
=
self
.
term
.
deal_command
(
self
.
term
.
data
)[
0
:
200
]
result
=
self
.
term
.
deal_command
(
self
.
term
.
data
)[
0
:
200
]
if
len
(
result
)
>
0
:
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