Deluge connection management. Connecting GTK UI Deluge to a remote daemon. Torrent client for high load

In the past few years, file sharing on the Web has steadily shifted towards peer-to-peer networks, and in particular, torrent exchangers. It is no longer a secret for most users that almost anything can be downloaded from trackers like torrents.ru or tfile.ru - from new films and audio industry to the latest releases. software... Leaving aside the legal aspect of the exchange of certain types of products, I note that most of the existing Linux distributions begin to distribute their new versions precisely from torrent networks. And if so, then the sacred duty of every self-respecting Linux user is to master this, no doubt, very convenient way file sharing (you can read more about torrent networks, for example, in Wikipedia - http://ru.wikipedia.org/wiki/BitTorrent).

Let's start our acquaintance with the Deluge torrent client supplied directly with the Runtu distribution. This very interesting project has been developing very actively recently and constantly pleases users with new "chips".

Launch Deluge. (Programs-Internet Client of BitTorrent Deluge Protocol)
The setup wizard is launched at the first start and we are invited to customize the client to our liking. Please note that many additional functions are enabled by activating the corresponding plugins. But this is a little later. In the meantime, press the "next" button and configure the ports of incoming connections. It is best to leave this as it is, but some ISPs force certain port ranges to be blocked. In this case, you need to specify a different range in the interval between 49152 and 65535. You can also enable the "use random ports" option, but it is better not to do this, because in this case, we will not be able to "keep our finger on the pulse" of the file sharing process, which is undoubtedly a very important aspect of system security.

So, let's move on to the next point.
To automate the process, it is convenient to configure the client so that all downloaded torrents are saved in a specific directory. I have allocated for these purposes a separate HDD with mount point / home /% username% / torrents.
The disk was formatted by me in the RaiserFS file system for an obvious reason - less load on the hard disk. However, this is already a matter of personal preference. If you are going to download a lot of small files, then it is more convenient to use Ext2-3 ... But this is a topic for a separate conversation and a reason for more than one holivar between fans of certain file systems. Let's skip this part and just set up the directory. It is highly recommended to create a subdirectory / home /% username% / torrents / 1gotovo so that in the future our client will transfer all finished downloads to this subdirectory, reducing the time that you will spend on parsing content of hard disk.
Naturally, you can assign your own names to directories. It's just that in the future I will consider exactly the above configuration.
So, set up the directory and click the "next" button.

In no case should you rush on this settings page, because the speed of your torrents distribution depends on it, which, in turn, directly affects your ratio on trackers. We select the speed of our outgoing connection. This value must be specified in the connection parameters for your Internet connection tariff. In my case, this is 1 megabit per second. For such an outgoing connection speed, I empirically established the optimal value of the following parameters:
- maximum connections - 600
- maximum recoil speed -1 (unlimited)
- the maximum number of channels of return - 30
- Maximum active torrents - 20
- Maximum half-open connections - 40
The last point may be confusing, since the number of downloads is doubled. But this is only at first glance. In my case, a computer with a torrent client works around the clock in automatic mode, and as a result, periodically there is a situation when one or more half-open connections "hang". This is not a particular problem in the case of Linux, since the lifetime of such connections is short, but the download speed in this case drops. And if so, it is better to foresee the "reserve" in advance. the main thing is not to overdo it, because if this value is made too high, then the system becomes an easy prey for the DDoS attackers.
Configure, click "Next" and see the last page of the configuration wizard.

There is only one point with a request to help in the development of the client. Nothing criminal will be sent, and therefore I personally do not see anything special in leaving the "daw" on. But - this is the personal choice of each user. We make a choice, press the "Apply" button and enjoy the view of the running and minimally configured client.
Now is the time to customize it to your personal needs.
We immediately open the list of available modules. (Edit-
Briefly about each module present in my Deluge assembly. Surely this list will be the same in your case:

Blocklist Importer. As the name implies, the module allows you to block lists of IP addresses. I don't turn it on unless absolutely necessary.
- Desired Ratio. Allows you to set the desired ratio for each torrent. What is it for? - you ask - I will answer: everything is extremely simple. With the help of this module, you can not really care about your own total ratio on the torrent tracker. It is enough to indicate to this module the coefficient 2-5 (depending on the demand for distribution) and forget about it for a while.
- Event logging. Event log support module. A useful thing if you have to work in a not very secure network. In other cases, it is largely meaningless.
- Flex RSS. RSS Downloader for Deluge. Why is she here? ;) There are more elegant and efficient solutions :)
- Move torrent. Allows you to move completed downloads to the selected directory. We indicate in the "Parameters" the previously created 1gotovo directory and continue our acquaintance.
- Network Activity Graph. Enables the display of a graph of network activity. In my opinion, the component is optional. Especially in the case when the client works with minimal user participation - this is what we strive for, right?
- Network Health Monitor. Another visual component. If you want "life" on the screen, you can turn it on. Generally optional.
- Sheduler. Scheduler. That says it all. Allows you to configure the parameters of the bandwidth available to the client depending on the day of the week and time of day. The most convenient thing in cases where, in addition to the torrent client, there are other applications that need access to the Internet.
- Speed ​​Limiter. Speed ​​limiter for each individual torrent. at first glance, the advantages of its presence are not obvious. However, sometimes it turns out to be necessary to download one torrent in the shortest possible time. It doesn't make sense to disable the rest of the downloads, because one torrent will still not be able to handle the entire channel width, but lowering the limit for the rest of the torrents is quite a reasonable decision. And the wolves are fed and the sheep are safe.
- Torrent Creator. A module for creating torrents. that is, their own distributions. If you need it, turn it on. Not needed - do not include.
- Torrent Files. An extremely useful module. Allows you to work with files inside the torrent. Prioritize each file, and also - allows you to enable and disable the download of individual torrent files.
- Torrent Notification. Reminder for the system tray. Those striving to automate the process are not needed.
- Torrents Peers. A module for displaying all peers for each torrent. The information is quite extensive, but - again - we strive to reduce our presence in the client's work. Verdict - no module needed.
- Torrents Search. Torrent search engine. My personal opinion is an absolutely meaningless thing in our realities. Google faster and more correct.
- Web Seed. Allows you to add web shares to torrents. Who needs it - turn it on. In the general case, it is a useless thing.
- Web User Interface. A module for managing downloads via the web interface. On this moment Deluge's web interface is pretty basic and not abundant additional functions... However, this is a pretty good way remote control the client. And given the speed of the project's development, we can assume that soon the web interface will become even more convenient and informative.

At the very least, we figured out the modules. Moving on to the final client setup.
Open the program settings dialog -> "Downloads" tab.
Dowload Location - By default, this parameter is enabled as "Ask *** each download". This option does not suit us - after all, every time we climb file system no one wants to show the way to save. Switch to "save all downloads to:" and specify our "torrents" directory as the save path
There is an item below that is also worth setting up. Namely - save all torrent files to a specific directory. The point is that by default the client saves these files to their working directory. And this is not very convenient. It is easier and more efficient to create a separate directory for these files and reconfigure this setting to specify a new save path. This will allow us to control current downloads and, if necessary, delete unnecessary ones.

The Autoload item is also quite interesting. it allows you to automatically run torrent files located in a specific directory. What is it for? Well, in my case, for example, it is very convenient to remotely save torrent files to this directory from another computer and no longer worry about their future fate. The client will pick up the new download himself, save it himself and, after completion, move it to a shared directory (remember the MoveTorrent module), from which I (again remotely) can pick up the files I need.

This is followed by setting the behavior of the program directly in relation to downloads. Here we can specify the maximum simultaneous number of them, increase the download priority of the first and last parts, configure the type of disk space reservation (full or compact - in the first case, the volume is reserved sufficient to accommodate the entire torrent, in the second - only for the currently downloaded torrent) parts), and also - to set the "default" start of the torrent download in "pause" mode. The last point will be of interest to those users who prefer to first "send" a bunch of downloads to the client, and only then - to figure out which of them is more important at the moment and which should be launched first, and which should be left off for now.

Go to the "Network" tab. Here we can change the parameters of the working ports of the program (however, we have already done this with the help of the wizard), enable / disable DHT (a hash table that allows you to significantly increase the number of peers), UPnP (I personally do not need it, and therefore remains disabled), mapping of NAT ports (it is better to enable it - there will be no big harm, and the connection speed with peers will grow), peer exchange (if anyone does not know, this is interesting function exchange of peers bypassing the server. ATTENTION! if you use local trackers, traffic from which is not counted, DISABLE this function so as not to get into traffic!) and search for local peers (that is, peers located on the same subnet with your computer). Pay special attention to the terms of use of specific trackers - some of them strongly recommend not to use DHT and peer exchange to prevent your passkey from being hijacked. I strongly advise you to heed their recommendation ...
The next section is "Encryption". Turn on both "Incoming" and "Outgoing". There is no need for our valiant management "K" to delve into your traffic. ;) And, of course, we set up the encryption of the entire stream at any level.

Let's move on to setting up hands. We enable the first option "Move torrents to the bottom of the queue at the start of distribution". So we can visually separate distributions and active downloads at any time. It is also worth enabling the second option "Add new torrents above the completed ones". To avoid confusion when adding new torrents.
The next four points are needed only for those who do not intend to actively increase their own ratio, or those who strive for the absolute automation of the process.
The third and fourth points respectively adjust the stop and automatic deletion of torrents after they reach the assigned ratio value (the ratio of the traffic sent to the received one). The fifth and sixth - do the same, but according to the distribution time (the time is indicated in hours). That is, you can set up your downloads in such a way that after they reach a ratio higher than 2 or the distribution time is more than 72 hours, the torrents are automatically stopped and deleted. Please note that the FILES that you downloaded will remain on your hard drive! Only torrent files are deleted.
We pass to the section " throughput"Actually, everything should be fine with us, since we used the setup wizard. If not, we set it up (see above). Do not limit the use of the channel to the torrent unless absolutely necessary. Let the value remain -1. Avoid many underwater stones in the process.

The section "proxy servers" is necessary for those who use proxies. If you do, you don't need my help in setting up. If not, it's better to just switch to the next section.

"Other". Actually, here we can only be interested in the item "Icon in the system tray" and the option to notify about the release of new versions. The rest I personally consider useless for use on a personal computer. However, this is a matter of individual preference. You can use the password protection function of the system tray icon or use the advanced boot progress indicator - all to your taste ...
Actually, that's all. If desired, you can also change the display of columns to the program window, as well as their relative position. You can turn off the toolbar or the torrent extended information panel. but these are the little things that do not affect the operation of the program at all. Use it for your pleasure.

Deluge client on the BitTorrent server and manage it via web interface (WebUI). Unfortunately WebUI does not support all Deluge features. Especially in terms of plugins, most of which cannot be configured via WebUI. Fortunately, Deluge's graphical (GTK UI) interface allows you to connect to and control a remote server client as easily as a local client.
We have: Remote server(v local network) running Debian 7 and the Deluge daemon installed on it paired with WebUI, as well as a home computer under Linux management Mint 14 (Ubuntu 12.10). We will skip the server-side installation process, as it is detailed in the Deluge section. Moving on to the settings and installation of the client side on your home PC.
It is worth noting that the presence of WebUI on the server is not necessary, but it will not be superfluous if you plan to connect to Deluge not only from home. In this regard, you can start the settings in three ways, having previously installed GTK UI on your local computer:
aptitude install deluge deluge-gtk
Then we start the daemon on the server and set the login and password for remote access. The command must be executed on behalf of the user from whom the Deluge Daemon is running.
echo "username: password: level" >> ~ / .config / deluge / auth
Where "username" is the user, "password" is the password, and "levil" is the access level. User and password can be arbitrary. They do not need to be the same as the username the daemon is running as. The daemon must be running.
Access levels:

  • 1 - read only.
  • 5 - user.
  • 10 - Administrator.
1. The first method assumes the presence of WebUI on the server. In the settings you need to enable remote access to the daemon in order to enable us to connect to Deluge remotely.

2. In the second method, we are using the Deluge Console. To do this, you need to install it on the server.
aptitude install deluge-console
Launch the console
deluge-console
In it we command:
config -s allow_remote True config allow_remote
Exit the console:
exit
All actions with the console must also be performed on behalf of the user from whom Deluge is running.
Restart the daemon:
/etc/init.d/deluge-daemon restart
3. In the third method, we use an SSH tunnel from the home computer to the server. In this case, it is not necessary to enable remote access on the server side. Open a local terminal and write the following:
ssh -fNL 127.0.0.2:58846:localhost:58846 server
Where "server" is the ip-address of our server. We use 127.0.0.2 instead of localhost so that the client knows we are connecting to a remote daemon. If you get the error "bind: Can" t assign requested address ", then execute the following command (add an alias to the local loop):
sudo ifconfig lo0 add 127.0.0.2
Then we repeat the previous command.
Next, launch GTK UI on the local computer and in the interface settings, uncheck the box opposite the Classic Mode, and then restart the UI. Now, when starting GTK UI, we see the Connection Manager pop-up window. We delete the local daemon from the list and register the address of the remote one. Depending on the method chosen earlier, in the Hostname field we write either the ip of our server where Deluge is located, or, in the case of an ssh tunnel, 127.0.0.2. We do not touch the port if we did not change the daemon port during the server-side configuration. Username and password - we specify the data that we specified in the ~ / .config / deluge / auth file.


That's all. If everything is done correctly, then we can safely connect to the daemon through the local GTK UI, in which everything that we could not use through the WebUI will be available to us.
The screenshot shows two connections. The first is remote, requiring the previously enabled option to allow remote access to the daemon. The second is a connection using an ssh tunnel. Green check marks mean connections are available.


Important! The versions of the server and client parts of the programs must be of the same line. For example, on my server the version of the program is 1.3.3, on home computer- 1.3.5. This is fine. If the server is running version 1.2.X, and on PC 1.3.X (or vice versa), then even if the construction works (which is unlikely), problems are inevitable.

All subsequent steps are described using Fedora as an example, but can be adapted for any other distribution.

Installation

Installation is the easiest thing that can be.

$ sudo dnf install deluge-daemon deluge-console

We install the console client, as well as the cli for it.

That's all for now. The client is ready to go. It can already be turned on and used.

$ sudo systemctl enable deluge-daemon $ sudo systemctl start deluge-daemon

But there are many problems with this configuration:

  • no logs
  • incorrect distribution by server ports

Do you need it? 🙂

Logs

Once installed, the daemon is ready to start. But the configuration that the distribution vendors offer is not entirely successful. There is no logging of what is happening in it.

To do this, we need to install logrotate.

$ sudo dnf install logrotate

Configure it to support the new rotation rules. To do this, create a file /etc/logrotate.d/deluge something like the following

/var/log/deluge/*.log (rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate initctl restart deluged> / dev / null 2> & 1 || true initctl restart deluge-web> / dev / null 2> & 1 || true endscript)

And also a folder for storing logs. And we will give her the rights she needs.

$ sudo mkdir / var / log / deluge / $ sudo chown deluge: deluge / var / log / deluge

Now it remains to enable logging support for the daemon.

Create a new daemon description for systemd in /etc/systemd/system/deluged.service

Description = Deluge Bittorrent Client Daemon After = network.target Type = simple User = deluge Group = deluge UMask = 007 ExecStart = / usr / bin / deluged -d -l /var/log/deluge/daemon.log -L warning Restart = always TimeoutStopSec = 300 WantedBy = multi-user.target

Fine. It remains to configure iptables and deluge itself.

Setting up iptables

In some cases, it is enough just to open required ports

$ sudo iptables -A INPUT -p tcp --dport 56881: 56889 -j ACCEPT $ sudo iptables -A INPUT -p udp --dport 56881: 56889 -j ACCEPT

But in some configurations, there may be problems with the conntrack mechanism, which marks a number of packets as invalid (especially for dht traffic).

Therefore, it is worth disabling conntrack for all deluge connections.

$ sudo iptables -t raw -I PREROUTING -p udp --dport 56881: 57200 -j NOTRACK $ sudo iptables -t raw -I OUTPUT -p udp --sport 56881: 57200 -j NOTRACK $ sudo iptables -t raw -I PREROUTING -p tcp --dport 56881: 57200 -j NOTRACK $ sudo iptables -t raw -I OUTPUT -p tcp --sport 56881: 57200 -j NOTRACK $ sudo iptables -I INPUT -p icmp --icmp-type 3 - j ACCEPT $ sudo iptables -I INPUT -p icmp --icmp-type 4 -j ACCEPT $ sudo iptables -I INPUT -p icmp --icmp-type 11 -j ACCEPT $ sudo iptables -I INPUT -p icmp --icmp -type 12 -j ACCEPT

$ sudo /usr/libexec/iptables/iptables.init save

Local authorization

In order for us to successfully use the deluge-console, local authorization must be enabled for our user.

Those. there should be a ~ / .config / deluge / auth file containing a login-password line

Localclient: here_long_hash: 10

You can copy this file from the /var/lib/deluge/.config/deluge directory

$ sudo cat /var/lib/deluge/.config/deluge/auth >> ~ / .config / deluge / auth

Starting and configuring the daemon

$ sudo systemctl enable deluged $ sudo systemctl start deluged

Thus, we started the daemon, the config of which was described earlier.

I went up to 12.04 and the Flood broke. I want to remove it and then add it again. How to remove Deluge?

  1. Tried: Search in Ubuntu Software Center
    Error: the button reads "Install" (but it's already installed!)
  2. Tried: sudo apt-get remove --purge deluge
    Failed: Output read Removing deluge ... but I can still find it when I search for my dash

If sudo apt-get remove --purge deluge succeeded, then the deluge package was removed successfully.

If the menu items are still displayed in a dash, this does not necessarily mean that the program is still installed, only links to it remain somewhere. Perhaps the dash keeps its own cache of what's in your menu and it takes a while to figure out that a change has been made.

Feel free to go ahead and reinstall the flood to see if it works.

For future reference, you should look for dotfiles in ~ / or ~ / config which are Deluge related. This is the most likely storage location for your account... Try to clear or rename this. This might fix your original problem (instead of reinstalling it).

Have you tried complete removal using synaptic package manager?

Install synaptic synaptic sudo apt-get install synaptic

I had the same problem removing the flood. I realized that I had the GTK version installed, so simply uninstalling deluge failed. I used sudo apt-get remove --purge deluge-gtk

According to the OP using sudo apt-get remove --purge deluge is the correct way

If you installed from source, or need to find leftover Deluge files, the Deluge Widgets Guide has information: RemovingFromSystem

Most probable cause the one that still appears in Dash is linked to the leftover deluge.desktop file.

You can use locate deluge which will quickly display each file / folder named flood, and you will be able to determine if the application was actually uninstalled.

If you installed Deluge from source code, you will have to manually delete the files. The main folder of the flood application is usually installed in the folder site python or folder dist-packages, which should be visible on the output of the above command. You also need to remove the flood binaries from / usr / local / bin / or / usr / bin / .

As neon_overload mentions, if you are having problems with Deluge, backup and removing the old configuration can help fix upgrade issues. Default location: ~ / .config / deluge

Sudo apt-get remove --purge deluge

Obviously, you realize that when you search for "The Flood" you will still get it on screen.

These are the leftover flood files - to completely remove them from your system,

Sudo apt autoremove deluge

Search and no flood will appear ... .. Magic