[#2951] [#1908] [WebUI] Add bind interface option for server

This commit is contained in:
Calum Lind 2017-01-10 20:20:44 +00:00
parent c3a02e5291
commit 8a48ec0126
3 changed files with 25 additions and 16 deletions

View File

@ -102,6 +102,7 @@ CONFIG_DEFAULTS = {
# Server Settings # Server Settings
"base": "/", "base": "/",
"interface": "0.0.0.0",
"port": 8112, "port": 8112,
"https": False, "https": False,
"pkey": "ssl/daemon.pkey", "pkey": "ssl/daemon.pkey",
@ -665,9 +666,8 @@ class DelugeWeb(component.Component):
reactor.run() reactor.run()
def start_normal(self): def start_normal(self):
self.socket = reactor.listenTCP(self.port, self.site) self.socket = reactor.listenTCP(self.port, self.site, interface=self.interface)
log.info("serving on %s:%s view at http://127.0.0.1:%s", "0.0.0.0", log.info("Serving on %s:%s view at http://%s:%s", self.interface, self.port, self.interface, self.port)
self.port, self.port)
def start_ssl(self): def start_ssl(self):
log.debug("Enabling SSL with PKey: %s, Cert: %s", self.pkey, self.cert) log.debug("Enabling SSL with PKey: %s, Cert: %s", self.pkey, self.cert)
@ -680,8 +680,8 @@ class DelugeWeb(component.Component):
options = CertificateOptions(privateKey=private_key, certificate=certificate, method=SSL.SSLv23_METHOD) options = CertificateOptions(privateKey=private_key, certificate=certificate, method=SSL.SSLv23_METHOD)
options.getContext().set_options(SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3) options.getContext().set_options(SSL.OP_NO_SSLv2 | SSL.OP_NO_SSLv3)
self.socket = reactor.listenSSL(self.port, self.site, options) self.socket = reactor.listenSSL(self.port, self.site, options, interface=self.interface)
log.info("Serving on %s:%s view at https://127.0.0.1:%s", "0.0.0.0", self.port, self.port) log.info("Serving on %s:%s view at https://%s:%s", self.interface, self.port, self.interface, self.port)
def stop(self): def stop(self):
log.info("Shutting down webserver") log.info("Shutting down webserver")

View File

@ -59,6 +59,9 @@ class Web(_UI):
group.add_option("-f", "--fork", dest="fork", group.add_option("-f", "--fork", dest="fork",
help="Fork the web interface process into the background", help="Fork the web interface process into the background",
action="store_true", default=False) action="store_true", default=False)
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", group.add_option("-p", "--port", dest="port", type="int",
help="Sets the port to be used for the webserver", help="Sets the port to be used for the webserver",
action="store", default=None) action="store", default=None)
@ -110,6 +113,9 @@ class Web(_UI):
if self.options.base: if self.options.base:
self.server.base = self.options.base self.server.base = self.options.base
if self.options.interface:
self.server.interface = self.options.interface
if self.options.port: if self.options.port:
self.server.port = self.options.port self.server.port = self.options.port

View File

@ -25,6 +25,9 @@ Set the base path that the web ui is running on (proxying)
.B -f, --fork .B -f, --fork
Fork the web interface process into the background Fork the web interface process into the background
.TP .TP
.BI -i\ ip_address \fR,\ \fB--interface= ip_address
Binds the webserver to a specific IP address
.TP
.BI -p\ port \fR,\ \fB--port= port .BI -p\ port \fR,\ \fB--port= port
Sets the port to be used for the webserver Sets the port to be used for the webserver
.TP .TP