Support manual ui_host command line parameter

This commit is contained in:
shortcutme 2017-06-15 19:48:01 +02:00
parent 0d3fa43f00
commit c84fcf2034
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
3 changed files with 13 additions and 3 deletions

View File

@ -181,6 +181,8 @@ class Config(object):
self.parser.add_argument('--ui_ip', help='Web interface bind address', default="127.0.0.1", metavar='ip')
self.parser.add_argument('--ui_port', help='Web interface bind port', default=43110, type=int, metavar='port')
self.parser.add_argument('--ui_restrict', help='Restrict web access', default=False, metavar='ip', nargs='*')
self.parser.add_argument('--ui_host', help='Allow access using this hosts', metavar='host', nargs='*')
self.parser.add_argument('--open_browser', help='Open homepage in web browser automatically',
nargs='?', const="default_browser", metavar='browser_name')
self.parser.add_argument('--homepage', help='Web interface Homepage', default='1HeLLo4uzjaLetFx6NH3PMwFP3qbRbTf3D',

View File

@ -50,7 +50,7 @@ class UiRequest(object):
else:
return False
if config.ui_ip != "127.0.0.1" and self.server.learn_allowed_host:
if self.server.learn_allowed_host:
# Learn the first request's host as allowed one
self.server.learn_allowed_host = False
self.server.allowed_hosts.add(host)

View File

@ -58,8 +58,16 @@ class UiServer:
self.port = config.ui_port
if self.ip == "*":
self.ip = "0.0.0.0" # Bind all
self.allowed_hosts = set(["zero", "localhost:%s" % config.ui_port, "%s:%s" % (config.ui_ip, config.ui_port)])
self.learn_allowed_host = True
if config.ui_host:
self.allowed_hosts = set(config.ui_host)
self.learn_allowed_host = False
elif config.ui_ip == "127.0.0.1":
self.allowed_hosts = set(["zero", "localhost:%s" % config.ui_port, "127.0.0.1:%s" % config.ui_port])
self.learn_allowed_host = False
else:
self.allowed_hosts = set([])
self.learn_allowed_host = True # It will pin to the first http request's host
self.wrapper_nonces = []
self.site_manager = SiteManager.site_manager
self.sites = SiteManager.site_manager.list()