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
6dabf865
Commit
6dabf865
authored
Apr 05, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapted code to Tornado 5
parent
12bac55e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
main.py
main.py
+12
-6
No files found.
main.py
View file @
6dabf865
...
...
@@ -11,12 +11,16 @@ import tornado.gen
import
tornado.ioloop
import
tornado.web
import
tornado.websocket
from
tornado.concurrent
import
Future
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
try
:
from
concurrent.futures
import
Future
except
:
from
tornado.concurrent
import
Future
define
(
'address'
,
default
=
'127.0.0.1'
,
help
=
'listen address'
)
define
(
'port'
,
default
=
8888
,
help
=
'listen port'
,
type
=
int
)
...
...
@@ -32,8 +36,8 @@ workers = {}
class
Worker
(
object
):
def
__init__
(
self
,
ssh
,
chan
,
dst_addr
):
self
.
loop
=
IOLoop
.
current
()
def
__init__
(
self
,
loop
,
ssh
,
chan
,
dst_addr
):
self
.
loop
=
loop
self
.
ssh
=
ssh
self
.
chan
=
chan
self
.
dst_addr
=
dst_addr
...
...
@@ -118,6 +122,7 @@ class Worker(object):
class
MixinHandler
(
object
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
loop
=
args
[
0
]
.
_loop
super
(
MixinHandler
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
get_client_addr
(
self
):
...
...
@@ -221,7 +226,7 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
chan
=
ssh
.
invoke_shell
(
term
=
'xterm'
)
chan
.
setblocking
(
0
)
worker
=
Worker
(
ssh
,
chan
,
dst_addr
)
worker
=
Worker
(
s
elf
.
loop
,
s
sh
,
chan
,
dst_addr
)
worker
.
src_addr
=
self
.
get_client_addr
()
return
worker
...
...
@@ -262,7 +267,6 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
class
WsockHandler
(
MixinHandler
,
tornado
.
websocket
.
WebSocketHandler
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
self
.
loop
=
IOLoop
.
current
()
self
.
worker_ref
=
None
super
(
WsockHandler
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -375,10 +379,12 @@ def main():
(
r'/ws'
,
WsockHandler
)
]
loop
=
IOLoop
.
current
()
app
=
tornado
.
web
.
Application
(
handlers
,
**
settings
)
app
.
_loop
=
loop
app
.
listen
(
options
.
port
,
options
.
address
)
logging
.
info
(
'Listening on {}:{}'
.
format
(
options
.
address
,
options
.
port
))
IOLoop
.
current
()
.
start
()
loop
.
start
()
if
__name__
==
'__main__'
:
...
...
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