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
5f364170
Commit
5f364170
authored
Sep 01, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase buffer size for channel
parent
41740690
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
sshserver.py
tests/sshserver.py
+12
-1
test_app.py
tests/test_app.py
+29
-1
worker.py
webssh/worker.py
+3
-1
No files found.
tests/sshserver.py
View file @
5f364170
...
...
@@ -65,7 +65,7 @@ class Server(paramiko.ServerInterface):
def
check_auth_password
(
self
,
username
,
password
):
print
(
'Auth attempt with username: {!r} & password: {!r}'
.
format
(
username
,
password
))
# noqa
if
(
username
in
[
'robey'
,
'bar'
])
and
(
password
==
'foo'
):
if
(
username
in
[
'robey'
,
'bar'
,
'foo'
])
and
(
password
==
'foo'
):
return
paramiko
.
AUTH_SUCCESSFUL
return
paramiko
.
AUTH_FAILED
...
...
@@ -150,6 +150,17 @@ def run_ssh_server(port=2200, running=True):
if
username
==
'bar'
:
msg
=
chan
.
recv
(
1024
)
chan
.
send
(
msg
)
elif
username
==
'foo'
:
lst
=
[]
while
True
:
msg
=
chan
.
recv
(
32
*
1024
)
lst
.
append
(
msg
)
if
msg
.
endswith
(
b
'
\r\n\r\n
'
):
break
data
=
b
''
.
join
(
lst
)
while
data
:
s
=
chan
.
send
(
data
)
data
=
data
[
s
:]
chan
.
close
()
t
.
close
()
...
...
tests/test_app.py
View file @
5f364170
...
...
@@ -487,4 +487,32 @@ class TestAppInDebug(OtherTestBase):
class
TestAppMiscell
(
OtherTestBase
):
debug
=
False
@tornado.testing.gen_test
def
test_app_for_sending_message_with_large_size
(
self
):
url
=
self
.
get_url
(
'/'
)
client
=
self
.
get_http_client
()
body
=
urlencode
(
dict
(
self
.
body
,
username
=
'foo'
))
response
=
yield
client
.
fetch
(
url
,
method
=
'POST'
,
body
=
body
,
headers
=
self
.
headers
)
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNone
(
data
[
'status'
])
self
.
assertIsNotNone
(
data
[
'id'
])
self
.
assertIsNotNone
(
data
[
'encoding'
])
url
=
url
.
replace
(
'http'
,
'ws'
)
ws_url
=
url
+
'ws?id='
+
data
[
'id'
]
ws
=
yield
tornado
.
websocket
.
websocket_connect
(
ws_url
)
msg
=
yield
ws
.
read_message
()
self
.
assertEqual
(
to_str
(
msg
,
data
[
'encoding'
]),
banner
)
send
=
'h'
*
(
64
*
1024
)
+
'
\r\n\r\n
'
yield
ws
.
write_message
(
json
.
dumps
({
'data'
:
send
}))
lst
=
[]
while
True
:
msg
=
yield
ws
.
read_message
()
lst
.
append
(
msg
)
if
msg
.
endswith
(
b
'
\r\n\r\n
'
):
break
recv
=
b
''
.
join
(
lst
)
.
decode
(
data
[
'encoding'
])
self
.
assertEqual
(
send
,
recv
)
ws
.
close
()
webssh/worker.py
View file @
5f364170
...
...
@@ -6,7 +6,7 @@ from tornado.iostream import _ERRNO_CONNRESET
from
tornado.util
import
errno_from_exception
BUF_SIZE
=
1024
BUF_SIZE
=
32
*
1024
workers
=
{}
...
...
@@ -46,6 +46,8 @@ class Worker(object):
if
self
.
mode
!=
mode
:
self
.
loop
.
update_handler
(
self
.
fd
,
mode
)
self
.
mode
=
mode
if
mode
==
IOLoop
.
WRITE
:
self
.
loop
.
call_later
(
0.1
,
self
,
self
.
fd
,
IOLoop
.
WRITE
)
def
on_read
(
self
):
logging
.
debug
(
'worker {} on read'
.
format
(
self
.
id
))
...
...
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