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
0c9db2ab
Commit
0c9db2ab
authored
Oct 10, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set default port 22 on server side
parent
66891cb7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
18 deletions
+10
-18
test_app.py
tests/test_app.py
+0
-8
handler.py
webssh/handler.py
+8
-4
main.js
webssh/static/js/main.js
+2
-6
No files found.
tests/test_app.py
View file @
0c9db2ab
...
...
@@ -92,10 +92,6 @@ class TestAppBasic(AsyncHTTPTestCase):
response
=
self
.
sync_post
(
body
)
self
.
assert_response
(
b
'Missing argument hostname'
,
response
)
body
=
'hostname=127.0.0.1&username=admin&password&_xsrf=yummy'
response
=
self
.
sync_post
(
body
)
self
.
assert_response
(
b
'Missing argument port'
,
response
)
body
=
'hostname=127.0.0.1&port=7000&password&_xsrf=yummy'
response
=
self
.
sync_post
(
body
)
self
.
assert_response
(
b
'Missing argument username'
,
response
)
...
...
@@ -104,10 +100,6 @@ class TestAppBasic(AsyncHTTPTestCase):
response
=
self
.
sync_post
(
body
)
self
.
assert_response
(
b
'Missing value hostname'
,
response
)
body
=
'hostname=127.0.0.1&port=&username=&password&_xsrf=yummy'
response
=
self
.
sync_post
(
body
)
self
.
assert_response
(
b
'Missing value port'
,
response
)
body
=
'hostname=127.0.0.1&port=7000&username=&password&_xsrf=yummy'
response
=
self
.
sync_post
(
body
)
self
.
assert_response
(
b
'Missing value username'
,
response
)
...
...
webssh/handler.py
View file @
0c9db2ab
...
...
@@ -30,6 +30,7 @@ except ImportError:
DELAY
=
3
KEY_MAX_SIZE
=
16384
DEFAULT_PORT
=
22
class
InvalidValueError
(
Exception
):
...
...
@@ -154,11 +155,14 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
return
value
def
get_port
(
self
):
value
=
self
.
get_value
(
'port'
)
value
=
self
.
get_argument
(
'port'
,
u''
)
if
not
value
:
return
DEFAULT_PORT
port
=
to_int
(
value
)
if
port
and
is_valid_port
(
port
):
r
eturn
port
r
aise
InvalidValueError
(
'Invalid port: {}'
.
format
(
value
))
if
port
is
None
or
not
is_valid_port
(
port
):
r
aise
InvalidValueError
(
'Invalid port: {}'
.
format
(
value
))
r
eturn
port
def
lookup_hostname
(
self
,
hostname
,
port
):
key
=
hostname
if
port
==
22
else
'[{}]:{}'
.
format
(
hostname
,
port
)
...
...
webssh/static/js/main.js
View file @
0c9db2ab
...
...
@@ -387,11 +387,7 @@ jQuery(function($){
attr
=
attrs
[
i
];
val
=
data
.
get
(
attr
);
if
(
typeof
val
===
'string'
)
{
val
=
val
.
trim
();
if
(
attr
===
'port'
&&
val
===
''
)
{
val
=
22
;
}
data
.
set
(
attr
,
val
);
data
.
set
(
attr
,
val
.
trim
());
}
}
}
...
...
@@ -410,7 +406,7 @@ jQuery(function($){
if
(
!
hostname
)
{
msg
=
'Need value hostname'
;
}
else
if
(
!
port
)
{
msg
=
'
Need value port
'
;
msg
=
''
;
}
else
if
(
!
username
)
{
msg
=
'Need value username'
;
}
else
if
(
!
hostname_tester
.
test
(
hostname
))
{
...
...
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