Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
coco
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
coco
Commits
3e4529a0
Unverified
Commit
3e4529a0
authored
Aug 05, 2019
by
BaiJiangJie
Committed by
GitHub
Aug 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #257 from jumpserver/dev_bai
[Update] 优化telnet连接逻辑
parents
1919898d
5db8340f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
17 deletions
+23
-17
connection.py
coco/connection.py
+23
-17
No files found.
coco/connection.py
View file @
3e4529a0
...
...
@@ -300,25 +300,31 @@ class TelnetConnection:
logger
.
info
(
msg
)
return
None
,
msg
if
data
.
startswith
(
telnetlib
.
IAC
):
self
.
option_negotiate
(
data
)
else
:
result
=
self
.
login_auth
(
data
)
if
result
:
msg
=
'Successful asset connection.<{}>/<{}>/<{}>.'
.
format
(
self
.
client
.
user
,
self
.
system_user
.
username
,
self
.
asset
.
hostname
)
logger
.
info
(
msg
)
return
self
.
sock
,
None
elif
result
is
False
:
self
.
sock
.
close
()
msg
=
'Authentication failed.
\r\n
'
logger
.
info
(
msg
)
return
None
,
msg
elif
result
is
None
:
# 将数据以 \r\n 进行分割
_data_list
=
data
.
split
(
b
'
\r\n
'
)
for
_data
in
_data_list
:
if
not
_data
:
continue
if
_data
.
startswith
(
telnetlib
.
IAC
):
self
.
option_negotiate
(
_data
)
else
:
result
=
self
.
login_auth
(
_data
)
if
result
:
msg
=
'Successful asset connection.<{}>/<{}>/<{}>.'
.
format
(
self
.
client
.
user
,
self
.
system_user
.
username
,
self
.
asset
.
hostname
)
logger
.
info
(
msg
)
return
self
.
sock
,
None
elif
result
is
False
:
self
.
sock
.
close
()
msg
=
'Authentication failed.
\r\n
'
logger
.
info
(
msg
)
return
None
,
msg
elif
result
is
None
:
continue
def
option_negotiate
(
self
,
data
):
"""
Telnet server option negotiate before connection
...
...
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