mirror of https://github.com/huashengdun/webssh
Updated get_trusted_downstream
parent
f52b2f5156
commit
e31e9be433
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue