webssh

Web based ssh client https://github.com/huashengdun/webssh webssh.huashengdun.org/
git clone http://git.hanabi.in/repos/webssh.git
Log | Files | Refs | README | LICENSE

commit e31e9be433f239c8001f0d7bc34633df133f06b0
parent f52b2f51564b30b7f0416e1295e13cb2413127ea
Author: Sheng <webmaster0115@gmail.com>
Date:   Sat, 20 Oct 2018 15:30:11 +0800

Updated get_trusted_downstream

Diffstat:
Mtests/test_settings.py | 22+++++++++++-----------
Mwebssh/settings.py | 12++++++------
2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/tests/test_settings.py b/tests/test_settings.py @@ -122,21 +122,21 @@ class TestSettings(unittest.TestCase): self.assertIsNotNone(ssl_ctx) def test_get_trusted_downstream(self): - options.tdstream = '' - tdstream = set() - self.assertEqual(get_trusted_downstream(options), tdstream) + tdstream = '' + result = set() + self.assertEqual(get_trusted_downstream(tdstream), result) - 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) + tdstream = '1.1.1.1, 2.2.2.2' + result = set(['1.1.1.1', '2.2.2.2']) + self.assertEqual(get_trusted_downstream(tdstream), result) - 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) + tdstream = '1.1.1.1, 2.2.2.2, 2.2.2.2' + result = set(['1.1.1.1', '2.2.2.2']) + self.assertEqual(get_trusted_downstream(tdstream), result) - options.tdstream = '1.1.1.1, 2.2.2.' + tdstream = '1.1.1.1, 2.2.2.' with self.assertRaises(ValueError): - get_trusted_downstream(options), tdstream + get_trusted_downstream(tdstream) def test_detect_is_open_to_public(self): options.fbidhttp = True diff --git a/webssh/settings.py b/webssh/settings.py @@ -58,7 +58,7 @@ def get_server_settings(options): settings = dict( xheaders=options.xheaders, max_body_size=max_body_size, - trusted_downstream=get_trusted_downstream(options) + trusted_downstream=get_trusted_downstream(options.tdstream) ) return settings @@ -108,14 +108,14 @@ def get_ssl_context(options): return ssl_ctx -def get_trusted_downstream(options): - tdstream = set() - for ip in options.tdstream.split(','): +def get_trusted_downstream(tdstream): + result = set() + for ip in tdstream.split(','): ip = ip.strip() if ip: to_ip_address(ip) - tdstream.add(ip) - return tdstream + result.add(ip) + return result def detect_is_open_to_public(options):