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
6a72d9c0
Unverified
Commit
6a72d9c0
authored
Jul 13, 2018
by
老广
Committed by
GitHub
Jul 13, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #68 from jumpserver/telnet_settimeout
[Update] 设置telnet连接timeout
parents
f46cd8cd
80afe455
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
7 deletions
+10
-7
connection.py
coco/connection.py
+2
-1
httpd.py
coco/httpd.py
+1
-1
interactive.py
coco/interactive.py
+1
-1
proxy.py
coco/proxy.py
+3
-2
session.py
coco/session.py
+3
-2
No files found.
coco/connection.py
View file @
6a72d9c0
...
...
@@ -166,7 +166,7 @@ class TelnetConnection:
self
.
sock
=
None
self
.
sel
=
selectors
.
DefaultSelector
()
self
.
incorrect_pattern
=
re
.
compile
(
r'incorrect|failed|失败'
,
re
.
I
r'incorrect|failed|失败
|错误
'
,
re
.
I
)
self
.
username_pattern
=
re
.
compile
(
r'login:\s*$|username:\s*$|用户名:\s*$|账\s*号:\s*$'
,
re
.
I
...
...
@@ -181,6 +181,7 @@ class TelnetConnection:
def
get_socket
(
self
):
logger
.
info
(
'Get telnet server socket. {}'
.
format
(
self
.
client
.
user
))
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
self
.
sock
.
settimeout
(
10
)
self
.
sock
.
connect
((
self
.
asset
.
ip
,
self
.
asset
.
port
))
# Send SGA and ECHO options to Telnet Server
self
.
sock
.
send
(
telnetlib
.
IAC
+
telnetlib
.
DO
+
telnetlib
.
SGA
)
...
...
coco/httpd.py
View file @
6a72d9c0
...
...
@@ -127,7 +127,7 @@ class ProxyNamespace(BaseNamespace):
child
,
parent
=
socket
.
socketpair
()
client
=
Client
(
parent
,
room
[
"request"
])
forwarder
=
ProxyServer
(
client
)
forwarder
=
ProxyServer
(
client
,
login_from
=
'WT'
)
room
[
"client"
]
=
client
room
[
"forwarder"
]
=
forwarder
room
[
"proxy"
]
=
WSProxy
(
self
,
child
,
room
[
"id"
])
...
...
coco/interactive.py
View file @
6a72d9c0
...
...
@@ -260,7 +260,7 @@ class InteractiveServer:
if
system_user
is
None
:
self
.
client
.
send
(
_
(
"没有系统用户"
))
return
forwarder
=
ProxyServer
(
self
.
client
)
forwarder
=
ProxyServer
(
self
.
client
,
login_from
=
'ST'
)
forwarder
.
proxy
(
asset
,
system_user
)
def
interact
(
self
):
...
...
coco/proxy.py
View file @
6a72d9c0
...
...
@@ -23,9 +23,10 @@ AUTO_LOGIN = 'auto'
class
ProxyServer
:
def
__init__
(
self
,
client
):
def
__init__
(
self
,
client
,
login_from
):
self
.
client
=
client
self
.
server
=
None
self
.
login_from
=
login_from
self
.
connecting
=
True
self
.
stop_event
=
threading
.
Event
()
...
...
@@ -62,7 +63,7 @@ class ProxyServer:
command_recorder
=
current_app
.
new_command_recorder
()
replay_recorder
=
current_app
.
new_replay_recorder
()
session
=
Session
(
self
.
client
,
self
.
server
,
self
.
client
,
self
.
server
,
self
.
login_from
,
command_recorder
=
command_recorder
,
replay_recorder
=
replay_recorder
,
)
...
...
coco/session.py
View file @
6a72d9c0
...
...
@@ -14,10 +14,11 @@ logger = get_logger(__file__)
class
Session
:
def
__init__
(
self
,
client
,
server
,
command_recorder
=
None
,
replay_recorder
=
None
):
def
__init__
(
self
,
client
,
server
,
login_from
,
command_recorder
=
None
,
replay_recorder
=
None
):
self
.
id
=
str
(
uuid
.
uuid4
())
self
.
client
=
client
# Master of the session, it's a client sock
self
.
server
=
server
# Server channel
self
.
login_from
=
login_from
# Login from
self
.
_watchers
=
[]
# Only watch session
self
.
_sharers
=
[]
# Join to the session, read and write
self
.
replaying
=
True
...
...
@@ -174,7 +175,7 @@ class Session:
"user"
:
self
.
client
.
user
.
username
,
"asset"
:
self
.
server
.
asset
.
hostname
,
"system_user"
:
self
.
server
.
system_user
.
username
,
"login_from"
:
"ST"
,
"login_from"
:
self
.
login_from
,
"remote_addr"
:
self
.
client
.
addr
[
0
],
"is_finished"
:
True
if
self
.
stop_evt
.
is_set
()
else
False
,
"date_last_active"
:
self
.
date_last_active
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
)
+
" +0000"
,
...
...
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