Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
webssh
Overview
Overview
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
郑天保
webssh
Commits
08af39dc
Commit
08af39dc
authored
Nov 11, 2017
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handled ERRNO_CONNRESET
parent
f9a66a9e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
main.py
main.py
+15
-3
No files found.
main.py
View file @
08af39dc
import
io
import
logging
import
os.path
import
socket
import
traceback
import
uuid
import
weakref
...
...
@@ -9,7 +8,9 @@ import paramiko
import
tornado.web
import
tornado.websocket
from
tornado.ioloop
import
IOLoop
from
tornado.iostream
import
_ERRNO_CONNRESET
from
tornado.options
import
define
,
options
,
parse_command_line
from
tornado.util
import
errno_from_exception
define
(
'address'
,
default
=
'127.0.0.1'
,
help
=
'listen address'
)
...
...
@@ -56,7 +57,13 @@ class Worker(object):
def
on_read
(
self
):
logging
.
debug
(
'worker {} on read'
.
format
(
self
.
id
))
try
:
data
=
self
.
chan
.
recv
(
BUF_SIZE
)
except
(
OSError
,
IOError
)
as
e
:
logging
.
error
(
e
)
if
errno_from_exception
(
e
)
in
_ERRNO_CONNRESET
:
self
.
close
()
else
:
logging
.
debug
(
'"{}" from {}'
.
format
(
data
,
self
.
dst_addr
))
if
not
data
:
self
.
close
()
...
...
@@ -72,15 +79,20 @@ class Worker(object):
logging
.
debug
(
'worker {} on write'
.
format
(
self
.
id
))
if
not
self
.
data_to_dst
:
return
data
=
''
.
join
(
self
.
data_to_dst
)
self
.
data_to_dst
=
[]
logging
.
debug
(
'"{}" to {}'
.
format
(
data
,
self
.
dst_addr
))
try
:
sent
=
self
.
chan
.
send
(
data
)
except
socket
.
error
as
e
:
except
(
OSError
,
IOError
)
as
e
:
logging
.
error
(
e
)
if
errno_from_exception
(
e
)
in
_ERRNO_CONNRESET
:
self
.
close
()
else
:
self
.
loop
.
update_handler
(
self
.
fd
,
IOLoop
.
WRITE
)
else
:
self
.
data_to_dst
=
[]
data
=
data
[
sent
:]
if
data
:
self
.
data_to_dst
.
append
(
data
)
...
...
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