Page 1 of 1

[Patch attached] Allow changing what address the webui binds

Posted: Sat Sep 14, 2013 5:37 am
by nightfly
Allow configuring which interface the webui is bound to with an 'address' option

Default to only listening on 127.0.0.1

Not really sure how you guys like to get patches

Code: Select all

diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py
index 072de51..a917551 100644
--- a/deluge/ui/web/server.py
+++ b/deluge/ui/web/server.py
@@ -80,6 +80,7 @@
 
     # Server Settings
     "base": "/",
+    "interface":"127.0.0.1",
     "port": 8112,
     "https": False,
     "pkey": "ssl/daemon.pkey",
@@ -607,6 +608,7 @@ def __init__(self):
         self.socket = None
         self.top_level = TopLevel()
         self.site = server.Site(self.top_level)
+        self.interface = self.config["interface"]
         self.port = self.config["port"]
         self.https = self.config["https"]
         self.pkey = self.config["pkey"]
@@ -649,15 +651,15 @@ def start(self, start_reactor=True):
             reactor.run()
 
     def start_normal(self):
-        self.socket = reactor.listenTCP(self.port, self.site)
-        log.info("serving on %s:%s view at http://127.0.0.1:%s", "0.0.0.0",
-                 self.port, self.port)
+        self.socket = reactor.listenTCP(self.port, self.site, **{'interface': self.interface})
+        log.info("serving on %s:%s view at http://%s:%s",
+                 self.interface, self.port, self.interface, self.port)
 
     def start_ssl(self):
         check_ssl_keys()
-        self.socket = reactor.listenSSL(self.port, self.site, ServerContextFactory())
-        log.info("serving on %s:%s view at https://127.0.0.1:%s", "0.0.0.0",
-                 self.port, self.port)
+        self.socket = reactor.listenSSL(self.port, self.site, ServerContextFactory(), **{'interface': self.interface})
+        log.info("serving on %s:%s view at https://%s:%s",
+                 self.interface, self.port, self.interface, self.port)
 
     def stop(self):
         log.info("Shutting down webserver")
diff --git a/deluge/ui/web/web.py b/deluge/ui/web/web.py
index 40b4eb0..e000af8 100644
--- a/deluge/ui/web/web.py
+++ b/deluge/ui/web/web.py
@@ -70,6 +70,9 @@ def __init__(self):
             group.add_option("-g", "--group", dest="group", type="str",
                 help="Group to switch to. Only use it when starting as root",
                 action="store", default=None)
+        group.add_option("-a", "--address", dest="address", type="str",
+            help="Sets the address to be used for the webserver",
+            action="store", default=None)
         group.add_option("-p", "--port", dest="port", type="int",
             help="Sets the port to be used for the webserver",
             action="store", default=None)
@@ -134,6 +137,9 @@ def start(self):
         if self.options.base:
             self.server.base = self.options.base
 
+        if self.options.address:
+            self.server.interface = self.options.address
+
         if self.options.port:
             self.server.port = self.options.port
 

Re: [Patch attached] Allow changing what address the webui b

Posted: Sat Sep 14, 2013 12:37 pm
by Cas
There is actually a patch in the ticket system that either is/will be applied to develop code base.