diff --git a/src/Config.py b/src/Config.py index e31b23bb..434ce059 100644 --- a/src/Config.py +++ b/src/Config.py @@ -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', diff --git a/src/Ui/UiRequest.py b/src/Ui/UiRequest.py index fb5e0502..689a8bc2 100644 --- a/src/Ui/UiRequest.py +++ b/src/Ui/UiRequest.py @@ -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) diff --git a/src/Ui/UiServer.py b/src/Ui/UiServer.py index d9170cb1..d623c2c3 100644 --- a/src/Ui/UiServer.py +++ b/src/Ui/UiServer.py @@ -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()