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
499f3b6d
Commit
499f3b6d
authored
Oct 15, 2018
by
Sheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lowercase all option names
parent
12f4c0d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
52 deletions
+52
-52
test_app.py
tests/test_app.py
+10
-10
test_settings.py
tests/test_settings.py
+24
-24
main.py
webssh/main.py
+3
-3
settings.py
webssh/settings.py
+15
-15
No files found.
tests/test_app.py
View file @
499f3b6d
...
...
@@ -43,9 +43,9 @@ class TestAppBasic(AsyncHTTPTestCase):
loop
=
self
.
io_loop
options
.
debug
=
False
options
.
policy
=
random
.
choice
([
'warning'
,
'autoadd'
])
options
.
host
F
ile
=
''
options
.
sys
HostF
ile
=
''
options
.
proxies
=
''
options
.
host
f
ile
=
''
options
.
sys
hostf
ile
=
''
options
.
tdstream
=
''
app
=
make_app
(
make_handlers
(
loop
,
options
),
get_app_settings
(
options
))
return
app
...
...
@@ -442,9 +442,9 @@ class OtherTestBase(AsyncHTTPTestCase):
headers
=
{
'Cookie'
:
'_xsrf=yummy'
}
debug
=
False
policy
=
None
host
F
ile
=
''
sys
HostF
ile
=
''
proxies
=
''
host
f
ile
=
''
sys
hostf
ile
=
''
tdstream
=
''
body
=
{
'hostname'
:
'127.0.0.1'
,
'port'
:
''
,
...
...
@@ -458,9 +458,9 @@ class OtherTestBase(AsyncHTTPTestCase):
loop
=
self
.
io_loop
options
.
debug
=
self
.
debug
options
.
policy
=
self
.
policy
if
self
.
policy
else
random
.
choice
([
'warning'
,
'autoadd'
])
# noqa
options
.
host
File
=
self
.
hostF
ile
options
.
sys
HostFile
=
self
.
sysHostF
ile
options
.
proxies
=
self
.
proxies
options
.
host
file
=
self
.
hostf
ile
options
.
sys
hostfile
=
self
.
syshostf
ile
options
.
tdstream
=
self
.
tdstream
app
=
make_app
(
make_handlers
(
loop
,
options
),
get_app_settings
(
options
))
return
app
...
...
@@ -542,7 +542,7 @@ class TestAppMiscell(OtherTestBase):
class
TestAppWithRejectPolicy
(
OtherTestBase
):
policy
=
'reject'
host
F
ile
=
make_tests_data_path
(
'known_hosts_example'
)
host
f
ile
=
make_tests_data_path
(
'known_hosts_example'
)
@tornado.testing.gen_test
def
test_app_with_hostname_not_in_hostkeys
(
self
):
...
...
tests/test_settings.py
View file @
499f3b6d
...
...
@@ -32,8 +32,8 @@ class TestSettings(unittest.TestCase):
sys
.
stdout
=
sys_stdout
def
test_get_host_keys_settings
(
self
):
options
.
host
F
ile
=
''
options
.
sys
HostF
ile
=
''
options
.
host
f
ile
=
''
options
.
sys
hostf
ile
=
''
dic
=
get_host_keys_settings
(
options
)
filename
=
os
.
path
.
join
(
base_dir
,
'known_hosts'
)
...
...
@@ -44,33 +44,33 @@ class TestSettings(unittest.TestCase):
load_host_keys
(
os
.
path
.
expanduser
(
'~/.ssh/known_hosts'
))
)
options
.
host
F
ile
=
make_tests_data_path
(
'known_hosts_example'
)
options
.
sys
HostF
ile
=
make_tests_data_path
(
'known_hosts_example2'
)
options
.
host
f
ile
=
make_tests_data_path
(
'known_hosts_example'
)
options
.
sys
hostf
ile
=
make_tests_data_path
(
'known_hosts_example2'
)
dic2
=
get_host_keys_settings
(
options
)
self
.
assertEqual
(
dic2
[
'host_keys'
],
load_host_keys
(
options
.
host
F
ile
))
self
.
assertEqual
(
dic2
[
'host_keys_filename'
],
options
.
host
F
ile
)
self
.
assertEqual
(
dic2
[
'host_keys'
],
load_host_keys
(
options
.
host
f
ile
))
self
.
assertEqual
(
dic2
[
'host_keys_filename'
],
options
.
host
f
ile
)
self
.
assertEqual
(
dic2
[
'system_host_keys'
],
load_host_keys
(
options
.
sys
HostF
ile
))
load_host_keys
(
options
.
sys
hostf
ile
))
def
test_get_policy_setting
(
self
):
options
.
policy
=
'warning'
options
.
host
F
ile
=
''
options
.
sys
HostF
ile
=
''
options
.
host
f
ile
=
''
options
.
sys
hostf
ile
=
''
settings
=
get_host_keys_settings
(
options
)
instance
=
get_policy_setting
(
options
,
settings
)
self
.
assertIsInstance
(
instance
,
paramiko
.
client
.
WarningPolicy
)
options
.
policy
=
'autoadd'
options
.
host
F
ile
=
''
options
.
sys
HostF
ile
=
''
options
.
host
f
ile
=
''
options
.
sys
hostf
ile
=
''
settings
=
get_host_keys_settings
(
options
)
instance
=
get_policy_setting
(
options
,
settings
)
self
.
assertIsInstance
(
instance
,
paramiko
.
client
.
AutoAddPolicy
)
os
.
unlink
(
settings
[
'host_keys_filename'
])
options
.
policy
=
'reject'
options
.
host
F
ile
=
''
options
.
sys
HostF
ile
=
''
options
.
host
f
ile
=
''
options
.
sys
hostf
ile
=
''
settings
=
get_host_keys_settings
(
options
)
try
:
instance
=
get_policy_setting
(
options
,
settings
)
...
...
@@ -122,18 +122,18 @@ class TestSettings(unittest.TestCase):
self
.
assertIsNotNone
(
ssl_ctx
)
def
test_get_trusted_downstream
(
self
):
options
.
proxies
=
''
proxies
=
set
()
self
.
assertEqual
(
get_trusted_downstream
(
options
),
proxies
)
options
.
tdstream
=
''
tdstream
=
set
()
self
.
assertEqual
(
get_trusted_downstream
(
options
),
tdstream
)
options
.
proxies
=
'1.1.1.1, 2.2.2.2'
proxies
=
set
([
'1.1.1.1'
,
'2.2.2.2'
])
self
.
assertEqual
(
get_trusted_downstream
(
options
),
proxies
)
options
.
tdstream
=
'1.1.1.1, 2.2.2.2'
tdstream
=
set
([
'1.1.1.1'
,
'2.2.2.2'
])
self
.
assertEqual
(
get_trusted_downstream
(
options
),
tdstream
)
options
.
proxies
=
'1.1.1.1, 2.2.2.2, 2.2.2.2'
proxies
=
set
([
'1.1.1.1'
,
'2.2.2.2'
])
self
.
assertEqual
(
get_trusted_downstream
(
options
),
proxies
)
options
.
tdstream
=
'1.1.1.1, 2.2.2.2, 2.2.2.2'
tdstream
=
set
([
'1.1.1.1'
,
'2.2.2.2'
])
self
.
assertEqual
(
get_trusted_downstream
(
options
),
tdstream
)
options
.
proxies
=
'1.1.1.1, 2.2.2.'
options
.
tdstream
=
'1.1.1.1, 2.2.2.'
with
self
.
assertRaises
(
ValueError
):
get_trusted_downstream
(
options
),
proxies
get_trusted_downstream
(
options
),
tdstream
webssh/main.py
View file @
499f3b6d
...
...
@@ -36,9 +36,9 @@ def main():
logging
.
info
(
'Listening on {}:{}'
.
format
(
options
.
address
,
options
.
port
))
if
ssl_ctx
:
server_settings
.
update
(
ssl_options
=
ssl_ctx
)
app
.
listen
(
options
.
ssl
Port
,
options
.
sslA
ddress
,
**
server_settings
)
logging
.
info
(
'Listening on ssl {}:{}'
.
format
(
options
.
ssl
A
ddress
,
options
.
ssl
P
ort
))
app
.
listen
(
options
.
ssl
port
,
options
.
ssla
ddress
,
**
server_settings
)
logging
.
info
(
'Listening on ssl {}:{}'
.
format
(
options
.
ssl
a
ddress
,
options
.
ssl
p
ort
))
loop
.
start
()
...
...
webssh/settings.py
View file @
499f3b6d
...
...
@@ -19,17 +19,17 @@ def print_version(flag):
define
(
'address'
,
default
=
'127.0.0.1'
,
help
=
'Listen address'
)
define
(
'port'
,
type
=
int
,
default
=
8888
,
help
=
'Listen port'
)
define
(
'ssl
A
ddress'
,
default
=
'0.0.0.0'
,
help
=
'SSL listen address'
)
define
(
'ssl
P
ort'
,
type
=
int
,
default
=
4433
,
help
=
'SSL listen port'
)
define
(
'ssl
a
ddress'
,
default
=
'0.0.0.0'
,
help
=
'SSL listen address'
)
define
(
'ssl
p
ort'
,
type
=
int
,
default
=
4433
,
help
=
'SSL listen port'
)
define
(
'certfile'
,
default
=
''
,
help
=
'SSL certificate file'
)
define
(
'keyfile'
,
default
=
''
,
help
=
'SSL private key file'
)
define
(
'debug'
,
type
=
bool
,
default
=
False
,
help
=
'Debug mode'
)
define
(
'policy'
,
default
=
'warning'
,
help
=
'Missing host key policy, reject|autoadd|warning'
)
define
(
'host
F
ile'
,
default
=
''
,
help
=
'User defined host keys file'
)
define
(
'sys
HostF
ile'
,
default
=
''
,
help
=
'System wide host keys file'
)
define
(
'
proxies
'
,
default
=
''
,
help
=
'trusted downstream, separated by comma'
)
define
(
'wp
I
ntvl'
,
type
=
int
,
default
=
0
,
help
=
'Websocket ping interval'
)
define
(
'host
f
ile'
,
default
=
''
,
help
=
'User defined host keys file'
)
define
(
'sys
hostf
ile'
,
default
=
''
,
help
=
'System wide host keys file'
)
define
(
'
tdstream
'
,
default
=
''
,
help
=
'trusted downstream, separated by comma'
)
define
(
'wp
i
ntvl'
,
type
=
int
,
default
=
0
,
help
=
'Websocket ping interval'
)
define
(
'version'
,
type
=
bool
,
help
=
'Show version information'
,
callback
=
print_version
)
...
...
@@ -44,7 +44,7 @@ def get_app_settings(options):
settings
=
dict
(
template_path
=
os
.
path
.
join
(
base_dir
,
'webssh'
,
'templates'
),
static_path
=
os
.
path
.
join
(
base_dir
,
'webssh'
,
'static'
),
websocket_ping_interval
=
options
.
wp
I
ntvl
,
websocket_ping_interval
=
options
.
wp
i
ntvl
,
debug
=
options
.
debug
,
xsrf_cookies
=
True
)
...
...
@@ -61,16 +61,16 @@ def get_server_settings(options):
def
get_host_keys_settings
(
options
):
if
not
options
.
host
F
ile
:
if
not
options
.
host
f
ile
:
host_keys_filename
=
os
.
path
.
join
(
base_dir
,
'known_hosts'
)
else
:
host_keys_filename
=
options
.
host
F
ile
host_keys_filename
=
options
.
host
f
ile
host_keys
=
load_host_keys
(
host_keys_filename
)
if
not
options
.
sys
HostF
ile
:
if
not
options
.
sys
hostf
ile
:
filename
=
os
.
path
.
expanduser
(
'~/.ssh/known_hosts'
)
else
:
filename
=
options
.
sys
HostF
ile
filename
=
options
.
sys
hostf
ile
system_host_keys
=
load_host_keys
(
filename
)
settings
=
dict
(
...
...
@@ -106,10 +106,10 @@ def get_ssl_context(options):
def
get_trusted_downstream
(
options
):
proxies
=
set
()
for
ip
in
options
.
proxies
.
split
(
','
):
tdstream
=
set
()
for
ip
in
options
.
tdstream
.
split
(
','
):
ip
=
ip
.
strip
()
if
ip
:
to_ip_address
(
ip
)
proxies
.
add
(
ip
)
return
proxies
tdstream
.
add
(
ip
)
return
tdstream
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