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
b69bdefc
Commit
b69bdefc
authored
Aug 26, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed log message
parent
1a3880ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
8 deletions
+16
-8
handler.py
webssh/handler.py
+16
-8
No files found.
webssh/handler.py
View file @
b69bdefc
...
@@ -52,10 +52,10 @@ class MixinHandler(object):
...
@@ -52,10 +52,10 @@ class MixinHandler(object):
self
.
_reason
=
info
.
split
(
':'
,
1
)[
-
1
]
.
strip
()
self
.
_reason
=
info
.
split
(
':'
,
1
)[
-
1
]
.
strip
()
super
(
MixinHandler
,
self
)
.
write_error
(
status_code
,
**
kwargs
)
super
(
MixinHandler
,
self
)
.
write_error
(
status_code
,
**
kwargs
)
def
get_value
(
self
,
name
):
def
get_value
(
self
,
name
,
formater
=
'Missing value {}'
):
value
=
self
.
get_argument
(
name
)
value
=
self
.
get_argument
(
name
)
if
not
value
:
if
not
value
:
raise
InvalidException
(
'Missing value {}'
.
format
(
name
))
raise
InvalidException
(
formater
.
format
(
name
))
return
value
return
value
def
get_real_client_addr
(
self
):
def
get_real_client_addr
(
self
):
...
@@ -249,6 +249,8 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
...
@@ -249,6 +249,8 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
class
WsockHandler
(
MixinHandler
,
tornado
.
websocket
.
WebSocketHandler
):
class
WsockHandler
(
MixinHandler
,
tornado
.
websocket
.
WebSocketHandler
):
formater
=
'Bad Request (Missing value {})'
def
initialize
(
self
,
loop
):
def
initialize
(
self
,
loop
):
self
.
loop
=
loop
self
.
loop
=
loop
self
.
worker_ref
=
None
self
.
worker_ref
=
None
...
@@ -260,10 +262,9 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler):
...
@@ -260,10 +262,9 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler):
self
.
src_addr
=
self
.
get_client_addr
()
self
.
src_addr
=
self
.
get_client_addr
()
logging
.
info
(
'Connected from {}:{}'
.
format
(
*
self
.
src_addr
))
logging
.
info
(
'Connected from {}:{}'
.
format
(
*
self
.
src_addr
))
try
:
try
:
worker_id
=
self
.
get_value
(
'id'
)
worker_id
=
self
.
get_value
(
'id'
,
formater
=
self
.
formater
)
except
(
tornado
.
web
.
MissingArgumentError
,
InvalidException
)
as
exc
:
except
(
tornado
.
web
.
MissingArgumentError
,
InvalidException
)
as
exc
:
self
.
close
(
reason
=
str
(
exc
))
self
.
close
(
reason
=
str
(
exc
)
.
split
(
':'
,
1
)[
-
1
]
.
strip
())
raise
else
:
else
:
worker
=
workers
.
get
(
worker_id
)
worker
=
workers
.
get
(
worker_id
)
if
worker
and
worker
.
src_addr
[
0
]
==
self
.
src_addr
[
0
]:
if
worker
and
worker
.
src_addr
[
0
]
==
self
.
src_addr
[
0
]:
...
@@ -299,9 +300,16 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler):
...
@@ -299,9 +300,16 @@ class WsockHandler(MixinHandler, tornado.websocket.WebSocketHandler):
worker
.
on_write
()
worker
.
on_write
()
def
on_close
(
self
):
def
on_close
(
self
):
logging
.
info
(
'Disconnected from {}:{}'
.
format
(
*
self
.
src_addr
))
if
self
.
close_reason
:
logging
.
info
(
'Disconnecting to {}:{} with reason: {reason}'
.
format
(
*
self
.
src_addr
,
reason
=
self
.
close_reason
)
)
else
:
self
.
close_reason
=
'client disconnected'
logging
.
info
(
'Disconnected from {}:{}'
.
format
(
*
self
.
src_addr
))
worker
=
self
.
worker_ref
()
if
self
.
worker_ref
else
None
worker
=
self
.
worker_ref
()
if
self
.
worker_ref
else
None
if
worker
:
if
worker
:
if
self
.
close_reason
is
None
:
self
.
close_reason
=
'client disconnected'
worker
.
close
(
reason
=
self
.
close_reason
)
worker
.
close
(
reason
=
self
.
close_reason
)
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