DEPRECATED: This patch has been superseded by the inclusion of this feature within Deluge 1.3.14 and later (finally!). The info and patches below still apply to 1.3.x prior to revision 14, but it is best to upgrade if possible.
The current release of Deluge, 1.3.11, as well as the development trunk do not contain a way to force the WebUI to bind only to a single interface or IP address. deluged does include both
--ui-interface options. However, these both specify the IP address of the interface to listen on for BitTorrent connections and JSON-RPC connections respectively.
The result of this being that the Deluge WebUI will instead bind to 0.0.0.0, or all available interfaces on your machine.
jacob@ikumi:~$ sudo netstat -tlpn | grep deluged tcp 0 0 0.0.0.0:8112 0.0.0.0:* LISTEN 1144/deluged.pid tcp 0 0 22.214.171.124:4433 0.0.0.0:* LISTEN 1144/deluged.pid tcp 0 0 126.96.36.199:58846 0.0.0.0:* LISTEN 1144/deluged.pid tcp 0 0 188.8.131.52:63617 0.0.0.0:* LISTEN 1144/deluged.pid
The first line of the above output of netstat shows the undesirable results of being unable to specify the WebUI interface IP address. While not a problem in most circumstances, if you have a server with many IP addresses, you generally don't want an application such as Deluge occupying the same port on an entire /29 net block. You may have already noticed this issue if you have attempted to run multiple instances of Deluge, both using the default port 8112 for the WebUI, as you would have received an error when trying to bind to the address, as it's already occupied. Of course, you could just change each instance to use its own unique port number.
Making the changes
A git-diff patch to apply the necessary changes automagically to the source is probably the best/easiest solution. Patch and application instructions are provided in the next section
Ensure you have a copy of the Deluge source code, preferably cloned from the git repo. Full instructions on fetching, building and installing Deluge from source can be found here.
git clone git://deluge-torrent.org/deluge.git
Be sure that you have checked out the current stable branch of Deluge.
git checkout -b 1.3-stable origin/1.3-stable
Searching through the source, we can see the file where the listener is bound is located in
self.socket = reactor.listenTCP(self.port, self.site)
Since Deluge uses the Twisted library to handle communication, the documentation is readily available for reference. Checking the (rather terse) documentation page for listenTCP, we can see that there are two additional arguments that can be passed to the Twisted listener object. We can modify our listenTCP call to include the interface we want to use, instead of using the default listen-to-all-the-things mode.
self.socket = reactor.listenTCP(self.port, self.site, 50, self.iface)
The third argument is backlog-- we don't really care about this, so we'll use the default value of 50 (see the linked documentation).
self.iface is our new property we'll be using for the interface. Note that the same change can be made for the SSL listener:
self.socket = reactor.listenSSL(self.port, self.site, ServerContextFactory(), 50, self.iface)
listenSSL has an additional ServerContextFactory() argument which was a part of the original call.
Adding our new config value
We also need to initialize the
iface attribute to the value specified in the webui.conf file parsed by deluged. To do so, find the __init__ method, and you will notice the section where the other attributes are being initialized-- add our new option to the list:
self.iface = self.config["iface"]
It's also probably a good idea to set a default value, in case one isn't specified in the config file, otherwise Twisted might freak out. Find the
CONFIG_DEFAULTS object and add a default value for
Rather than editing the source (for fun or out of curiosity), the easiest way would be to just apply the patch.
Patch (diff): https://ycc.io/patch/deluge_1313_webui_ip.diff
Updated for v1.3.13
To apply the patch, you should have a clean, working copy/clone of the source. Change the the directory where the source is located and run the following:
wget https://ycc.io/patch/deluge_1313_webui_ip.diff git apply deluge_1313_webui_ip.diff
Building & Installing
Full build and installation instructions can be found on Deluge's website, so here is the tl;dr version:
python setup.py build sudo python setup.py install
cd deluge/plugins for i in */setup.py; do python $i bdist_egg ; done ; rm -Rf *.egg-info ; rm -Rf build ; mv dist/*.egg ./
You can then either symlink, or copy the plugins to
~/.config/deluge/plugins for the user deluge will be running under.
If you receive errors about setuptools, then you will need to install them first, then rebuild/reinstall.
- For Debian/Ubuntu/Mint:
sudo apt-get install python-setuptools
- For RedHat/CentOS/Fedora: (as root)
yum -y install python-setuptools
After the build and installation are complete, ensure that you stop and restart deluged completely. I would also recommend enabling debug mode initially in case any problems arise.
Where do I change the IP?
Note that since our new option isn't integrated into the GUI, you will have to manually edit the config file to change it. On most systems, this is located in
~/.config/deluge/web.conf. This is a JSON file, so you can simply add a value like the following:
The config parser in Deluge will pick this up and use it for the WebUI IP address! You can still retain the old functionality by using "0.0.0.0" to bind to all IP addresses, if you'd like.