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
ce02d430
Commit
ce02d430
authored
9 years ago
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
deal_command添加到静态方法中
parent
4abf2b06
master
auditor_jym
audits
dev
dev_beta
dev_beta_db
gengmei
lagacy-0.4.0
node_service
password
rbac
restrict_access
test
v52
wph
1.5.2
1.5.1
1.5.0
1.4.10
1.4.9
1.4.8
1.4.7
1.4.6
1.4.5
1.4.4
1.4.3
1.4.2
1.4.1
1.4.0
1.3.3
1.3.2
1.3.1
1.3.0
1.2.1
1.2.0
1.1.1
1.1.0
1.0.0
0.3.3
0.3.2
0.3.2-rc2
0.3.1
0.3.0-beta
v1.4.10
v1.4.7
v1.4.4
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
33 deletions
+34
-33
connect.py
connect.py
+32
-31
jumpserver.conf
jumpserver.conf
+1
-1
run_websocket.py
run_websocket.py
+1
-1
No files found.
connect.py
View file @
ce02d430
...
...
@@ -25,7 +25,7 @@ from jumpserver.settings import LOG_DIR
login_user
=
get_object
(
User
,
username
=
getpass
.
getuser
())
VIM_FLAG
=
False
try
:
import
termios
...
...
@@ -68,12 +68,40 @@ def check_vim_status(command, ssh):
return
False
def
deal_command
(
str_r
,
ssh
):
class
Tty
(
object
):
"""
A virtual tty class
一个虚拟终端类,实现连接ssh和记录日志,基类
"""
def
__init__
(
self
,
username
,
asset_name
):
self
.
username
=
username
self
.
asset_name
=
asset_name
self
.
ip
=
None
self
.
port
=
22
self
.
channel
=
None
#self.asset = get_object(Asset, name=asset_name)
#self.user = get_object(User, username=username)
self
.
role
=
None
self
.
ssh
=
None
self
.
connect_info
=
None
self
.
login_type
=
'ssh'
@staticmethod
def
is_output
(
strings
):
newline_char
=
[
'
\n
'
,
'
\r
'
,
'
\r\n
'
]
for
char
in
newline_char
:
if
char
in
strings
:
return
True
return
False
@staticmethod
def
deal_command
(
str_r
,
ssh
):
"""
处理命令中特殊字符
"""
t
=
time
.
time
()
str_r
=
re
.
sub
(
'
\x07
'
,
''
,
str_r
)
#删除响铃
patch_char
=
re
.
compile
(
'
\x08\x1b
\
[C'
)
#删除方向左右一起的按键
while
patch_char
.
search
(
str_r
):
...
...
@@ -190,33 +218,6 @@ def deal_command(str_r, ssh):
else
:
return
''
class
Tty
(
object
):
"""
A virtual tty class
一个虚拟终端类,实现连接ssh和记录日志,基类
"""
def
__init__
(
self
,
username
,
asset_name
):
self
.
username
=
username
self
.
asset_name
=
asset_name
self
.
ip
=
None
self
.
port
=
22
self
.
channel
=
None
#self.asset = get_object(Asset, name=asset_name)
#self.user = get_object(User, username=username)
self
.
role
=
None
self
.
ssh
=
None
self
.
connect_info
=
None
self
.
login_type
=
'ssh'
@staticmethod
def
is_output
(
strings
):
newline_char
=
[
'
\n
'
,
'
\r
'
,
'
\r\n
'
]
for
char
in
newline_char
:
if
char
in
strings
:
return
True
return
False
@staticmethod
def
remove_control_char
(
str_r
):
"""
...
...
@@ -402,7 +403,7 @@ class SshTty(Tty):
input_mode
=
True
if
str
(
x
)
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
data
=
self
.
remove_control_char
(
data
)
data
=
self
.
deal_command
(
data
,
self
.
ssh
)
TtyLog
(
log
=
log
,
datetime
=
datetime
.
datetime
.
now
(),
cmd
=
data
)
.
save
()
data
=
''
...
...
This diff is collapsed.
Click to expand it.
jumpserver.conf
View file @
ce02d430
...
...
@@ -13,7 +13,7 @@ password = mysql234
database
=
jumpserver
[
websocket
]
web_socket_host
=
127
.
0
.
0
.
1
:
3000
web_socket_host
=
j
:
3000
[
mail
]
mail_enable
=
1
...
...
This diff is collapsed.
Click to expand it.
run_websocket.py
View file @
ce02d430
...
...
@@ -236,7 +236,7 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
if
data
.
get
(
'data'
):
self
.
term
.
input_mode
=
True
if
str
(
data
[
'data'
])
in
[
'
\r
'
,
'
\n
'
,
'
\r\n
'
]:
TtyLog
(
log
=
self
.
log
,
datetime
=
datetime
.
datetime
.
now
(),
cmd
=
self
.
term
.
remove_control_char
(
self
.
term
.
data
))
.
save
()
TtyLog
(
log
=
self
.
log
,
datetime
=
datetime
.
datetime
.
now
(),
cmd
=
self
.
term
.
deal_command
(
self
.
term
.
data
,
self
.
term
.
ssh
))
.
save
()
self
.
term
.
data
=
''
self
.
term
.
input_mode
=
False
self
.
term
.
channel
.
send
(
data
[
'data'
])
...
...
This diff is collapsed.
Click to expand it.
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