From 49d4bb49697289ffd9052a3a43d2a74a452a18f6 Mon Sep 17 00:00:00 2001 From: Friedrich Gonzalez Date: Wed, 19 Feb 2014 11:17:22 +0000 Subject: [PATCH] [#1908] [WebUI] Add bind interface option for server --- deluge/ui/web/server.py | 12 ++++++------ deluge/ui/web/web.py | 6 ++++++ docs/man/deluge-web.1 | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index d55591798..7f1b211fe 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -80,6 +80,7 @@ CONFIG_DEFAULTS = { # Server Settings "base": "/", + "interface": "0.0.0.0", "port": 8112, "https": False, "pkey": "ssl/daemon.pkey", @@ -607,6 +608,7 @@ class DelugeWeb(component.Component): 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,13 @@ class DelugeWeb(component.Component): 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 40b4eb01f..25a1401b6 100644 --- a/deluge/ui/web/web.py +++ b/deluge/ui/web/web.py @@ -70,6 +70,9 @@ class Web(_UI): 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("-i", "--interface", dest="interface", + type="str", help="Binds the webserver to a specific IP address", + 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 @@ class Web(_UI): if self.options.base: self.server.base = self.options.base + if self.options.interface: + self.server.interface = self.options.interface + if self.options.port: self.server.port = self.options.port diff --git a/docs/man/deluge-web.1 b/docs/man/deluge-web.1 index b758e79dc..0634c8447 100644 --- a/docs/man/deluge-web.1 +++ b/docs/man/deluge-web.1 @@ -22,6 +22,9 @@ Set the base path that the ui is running on (proxying) .B -f, --fork Fork the web interface process into the background .TP +.B -i INTERFACE, --interface=INTERFACE +Binds the webserver to a specific IP address +.TP .B -p PORT, --port=PORT Sets the port to be used for the webserver .TP