commit e020064d31ee93e85fda73dc7a89ac55b97f4aa4
Author: Arturo Filastò <art...@filasto.net>
Date:   Fri Aug 26 18:44:53 2016 +0200

    Bind by default to localhost. Add support for disabling the web UI.
    
    * Expose these options via configuration options
    This fixes #589
---
 ooni/agent/agent.py             |  9 +++++----
 ooni/scripts/ooniprobe_agent.py |  6 +++---
 ooni/settings.py                | 10 +++++++++-
 ooni/ui/web/web.py              |  3 ++-
 4 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/ooni/agent/agent.py b/ooni/agent/agent.py
index 0311cef..01e2162 100644
--- a/ooni/agent/agent.py
+++ b/ooni/agent/agent.py
@@ -14,10 +14,11 @@ class AgentService(service.MultiService):
         self.scheduler_service = SchedulerService(director)
         self.scheduler_service.setServiceParent(self)
 
-        self.web_ui_service = WebUIService(director,
-                                           self.scheduler_service,
-                                           web_ui_port)
-        self.web_ui_service.setServiceParent(self)
+        if not config.advanced.disabled_webui:
+            self.web_ui_service = WebUIService(director,
+                                               self.scheduler_service,
+                                               web_ui_port)
+            self.web_ui_service.setServiceParent(self)
 
 
     def startService(self):
diff --git a/ooni/scripts/ooniprobe_agent.py b/ooni/scripts/ooniprobe_agent.py
index 30df9b9..08fba89 100644
--- a/ooni/scripts/ooniprobe_agent.py
+++ b/ooni/scripts/ooniprobe_agent.py
@@ -11,14 +11,12 @@ from ooni.utils import log
 from ooni.settings import config
 from ooni.agent.agent import AgentService
 
-WEB_UI_PORT = 8842
-WEB_UI_URL = "http://127.0.0.1:{0}".format(WEB_UI_PORT)
 
 class StartOoniprobeAgentPlugin:
     tapname = "ooniprobe"
 
     def makeService(self, so):
-        return AgentService(WEB_UI_PORT)
+        return AgentService(config.advanced.webui_port)
 
 class OoniprobeTwistdConfig(twistd.ServerOptions):
     subCommands = [
@@ -70,6 +68,8 @@ def start_agent(options=None):
         "StartOoniprobeAgent": StartOoniprobeAgentPlugin()
     }
     print("Starting ooniprobe agent.")
+    WEB_UI_URL = "http://{0}:{1}".format(
+        config.advanced.webui_address, config.advanced.webui_port)
     print("To view the GUI go to %s" % WEB_UI_URL)
     log.start()
     twistd.runApp(twistd_config)
diff --git a/ooni/settings.py b/ooni/settings.py
index 3da1da7..2bacd57 100644
--- a/ooni/settings.py
+++ b/ooni/settings.py
@@ -65,6 +65,11 @@ advanced:
     # insecure_backend: false
     # The preferred backend type, can be one of onion, https or cloudfront
     preferred_backend: {preferred_backend}
+    # The port and address for the Web UI
+    #webui_port: 8842
+    #webui_address: "127.0.0.1"
+    # Should the Web UI be disabled
+    #disable_webui: false
 tor:
     #socks_port: 8801
     #control_port: 8802
@@ -121,7 +126,10 @@ defaults = {
         "reporting_retries": 5,
         "reporting_concurrency": 7,
         "insecure_backend": False,
-        "preferred_backend": "onion"
+        "preferred_backend": "onion",
+        "webui_port": 8842,
+        "webui_address": "127.0.0.1",
+        "webui_disabled": False
     },
     "tor": {
         "socks_port": None,
diff --git a/ooni/ui/web/web.py b/ooni/ui/web/web.py
index 10bbef1..f36e0a2 100644
--- a/ooni/ui/web/web.py
+++ b/ooni/ui/web/web.py
@@ -19,7 +19,8 @@ class WebUIService(service.MultiService):
         web_ui_api = WebUIAPI(config, self.director, self.scheduler)
         self._port = reactor.listenTCP(
             self.port_number,
-            server.Site(web_ui_api.app.resource())
+            server.Site(web_ui_api.app.resource()),
+            interface=config.advanced.webui_address
         )
 
     def stopService(self):



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to