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