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
33703f0c
Commit
33703f0c
authored
Oct 08, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated lookup_hostname
parent
c873b505
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
6 deletions
+9
-6
test_app.py
tests/test_app.py
+2
-1
handler.py
webssh/handler.py
+7
-5
No files found.
tests/test_app.py
View file @
33703f0c
...
@@ -536,4 +536,5 @@ class TestAppWithRejectPolicy(OtherTestBase):
...
@@ -536,4 +536,5 @@ class TestAppWithRejectPolicy(OtherTestBase):
data
=
json
.
loads
(
to_str
(
response
.
body
))
data
=
json
.
loads
(
to_str
(
response
.
body
))
self
.
assertIsNone
(
data
[
'id'
])
self
.
assertIsNone
(
data
[
'id'
])
self
.
assertIsNone
(
data
[
'encoding'
])
self
.
assertIsNone
(
data
[
'encoding'
])
self
.
assertEqual
(
'Connection to 127.0.0.1 is not allowed.'
,
data
[
'status'
])
# noqa
message
=
'Connection to {}:{} is not allowed.'
.
format
(
self
.
body
[
'hostname'
],
self
.
sshserver_port
)
# noqa
self
.
assertEqual
(
message
,
data
[
'status'
])
webssh/handler.py
View file @
33703f0c
...
@@ -152,12 +152,14 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
...
@@ -152,12 +152,14 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
raise
InvalidValueError
(
'Invalid hostname: {}'
.
format
(
value
))
raise
InvalidValueError
(
'Invalid hostname: {}'
.
format
(
value
))
return
value
return
value
def
lookup_hostname
(
self
,
hostname
):
def
lookup_hostname
(
self
,
hostname
,
port
):
if
isinstance
(
self
.
policy
,
paramiko
.
RejectPolicy
):
if
isinstance
(
self
.
policy
,
paramiko
.
RejectPolicy
):
if
self
.
ssh_client
.
_system_host_keys
.
lookup
(
hostname
)
is
None
:
key
=
hostname
if
port
==
22
else
'[{}]:{}'
.
format
(
hostname
,
port
)
if
self
.
ssh_client
.
_host_keys
.
lookup
(
hostname
)
is
None
:
if
self
.
ssh_client
.
_system_host_keys
.
lookup
(
key
)
is
None
:
if
self
.
ssh_client
.
_host_keys
.
lookup
(
key
)
is
None
:
raise
ValueError
(
raise
ValueError
(
'Connection to {} is not allowed.'
.
format
(
hostname
)
'Connection to {}:{} is not allowed.'
.
format
(
hostname
,
port
)
)
)
def
get_port
(
self
):
def
get_port
(
self
):
...
@@ -174,8 +176,8 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
...
@@ -174,8 +176,8 @@ class IndexHandler(MixinHandler, tornado.web.RequestHandler):
def
get_args
(
self
):
def
get_args
(
self
):
hostname
=
self
.
get_hostname
()
hostname
=
self
.
get_hostname
()
self
.
lookup_hostname
(
hostname
)
port
=
self
.
get_port
()
port
=
self
.
get_port
()
self
.
lookup_hostname
(
hostname
,
port
)
username
=
self
.
get_value
(
'username'
)
username
=
self
.
get_value
(
'username'
)
password
=
self
.
get_argument
(
'password'
,
u''
)
password
=
self
.
get_argument
(
'password'
,
u''
)
privatekey
=
self
.
get_privatekey
()
privatekey
=
self
.
get_privatekey
()
...
...
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