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

@ -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()