rTorrent

From ArchWiki
Revision as of 20:25, 2 December 2011 by Filam (Talk | contribs) (Send Text Message Upon Torrent Completion Using GMail: Simplify section title)

Jump to: navigation, search

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.


Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어


External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

rTorrent is a quick and efficient BitTorrent client that uses the libtorrent library. It is written in C++ and uses the ncurses programming library, which means it uses a text user interface. When combined with GNU Screen and Secure Shell, it becomes a convenient remote Bitorrent client.

Installation

Install the rtorrent package that is available in the community repository:

# pacman -S rtorrent

Alternatively, install rtorrent-svnAUR or rtorrent-extendedAUR from the AUR.

Configuration

Before running rTorrent, download the default configuration file from the rTorrent project page and copy it to Template:Filename (see: Direct download).

Peer and connection thresholds

The values for the following options are dependent on the system's hardware and Internet connection speed. To find the optimal values read: Optimize Your BitTorrent Download Speed

min_peers = 40
max_peers = 52

min_peers_seed = 10
max_peers_seed = 52

max_uploads = 8

download_rate = 200
upload_rate = 28

Create and manage files

The directory option will determine where your torrent data will be saved. Be sure to enter the absolute path, as rTorrent may not follow relative paths:

directory = /home/[user]/torrents/

The session option allows rTorrent to save the progess of your torrents. It is recommended to create a directory called .session (e.g. $ mkdir ~/.session).

session = /home/[user]/.session/

The schedule option has rTorrent watch a particular directory for new torrent files. Saving a torrent file to this directory will automatically start the download. Remember to create the directory that will be watched (e.g. $ mkdir ~/watch). Also, be careful when using this option as rTorrent will move the torrent file to your session folder and rename it to its hash value.

schedule = watch_directory,5,5,load_start=/home/[user]/watch/*.torrent
schedule = untied_directory,5,5,stop_untied=
schedule = tied_directory,5,5,start_tied=

The following schedule option is intended to stop rTorrent from downloading data when disk space is low.

schedule = low_diskspace,5,60,close_low_diskspace=100M

Port configuration

The port_range option sets which port(s) to use for listening. It is recommended to use a port that is higher than 49152 (see: List of port numbers). Although, rTorrent allows a range of ports, a single port is recommended.

port_range = 49164-49164

Additionally, make sure port forwarding is enabled for the proper port(s) (see: Port Forward Guides).

Additional settings

The check_hash option executes a hash check when a torrent download is complete or rTorrent is started. When starting, it checks for errors in your completed files.

check_hash = yes

The encryption option enables or disables encryption. It is very important to enable this option, not only for yourself, but also for your peers in the torrent swarm. Some users need to obscure their bandwidth usage from their ISP. And it does not hurt to enable it even if you do not need the added security.

encryption = allow_incoming,try_outgoing,enable_retry

Template:Wikipedia

This final dht option enables DHT support. DHT is common among public trackers and will allow the client to acquire more peers.

dht = auto
dht_port = 6881
peer_exchange = yes
Note: More detailed configuration questions and examples are available at Common Tasks in rTorrent for Dummies.

Key bindings

Cmd Action
Ctrl-q Quit application
Left Returns to the previous screen
Right Goes to the next screen
Backspace Adds the specified *.torrent

rTorrent relies exclusively on keyboard shortcuts for user input. A quick reference is available in the table on the right. A complete guide is available on the rTorrent wiki (see: rTorrent User Guide).

Note: Striking Template:Keypress twice in quick succession will make rTorrent shutdown without waiting to send a stop announce to the connected trackers.

Redundant mapping

Template:Keypress is often used for terminal control to stop screen output while Template:Keypress is used to start it. These mappings may interfere with rTorrent. Check to see if these terminal options are bound to a mapping:

$ stty -a
...
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
...

To remove the mappings, change the terminal characteristics to undefine the aforementioned special characters (i.e. stop and start):

# stty stop undef
# stty start undef

To remove these mappings automatically at startup you may add the two preceding commands to your Template:Filename file.

Additional Tips

Seperate session with Screen

GNU Screen is a wrapper that allows separation between the text program and the shell from which it was launched.

Screen flow-control interferes with the Template:Keypress mapping (see: Redundant mapping). To disable it add the following to Template:Filename:

defflow off

To automatically start rTorrent within Screen, add the following to the Template:Filename configuration file:

screen -t rtorrent rtorrent 

Run as a daemon

Alternatively, Screen and rTorrent can be run together as a daemon (see also: Arch Linux Forums thread, Gentoo Discussion Forums thread).

To use this script with Tmux replace line 9 with su rtorrent -c 'tmux -d -s rtorrent rtorrent' &> /dev/null (see: rTorrent daemon with tmux).

With root permissions create the following file:

/etc/rc.d/rtorrent
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
  start)
    stat_busy "Starting rtorrent"
    su user -c 'screen -d -m -S rtorrent rtorrent' &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      add_daemon rtorrent
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping rtorrent"
    killall -w -s 2 /usr/bin/rtorrent &> /dev/null
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon rtorrent
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start

Make the file executable:

sudo chmod +x /etc/rc.d/rtorrent

Creating a Template:Filename file with relative paths in a user's home directory will break the rc.d script. To run multiple instances of rTorrent with relative paths under different users replace line 9 in Template:Filename with the following:

   su username -c 'cd /home/username && screen -d -m -S rtorrent rtorrent' &> /dev/null

Alternatively, you can set absolute paths in the configuration file.

To run the daemon user multiple users create one rc.d script for each user. Then replace line 9 in Template:Filename with the following:

   su username -c 'killall -w -s 2 /usr/bin/rtorrent' &> /dev/null

To connect to the daemon process on a remote machine use SSH:

ssh -t rtorrent@192.168.1.10 'screen -r'

For more information about daemon scripts see: Writing rc.d scripts

Alternate scripts can be found on the Gentoo Wiki Archives, Joyent CodeSnippets and ByteTouch.

Pre-allocation

The rTorrent package in the community repository lacks pre-allocation. Compiling rTorrent with pre-allocation allows files to be allocated before downloading the torrent. The major benefit is that it limits and avoids fragmentation of the filesystem. However, this introduces a delay during the pre-allocation if the filesystem does not support the fallocate syscall natively.

Therefore this switch is recommended for xfs, ext4 and btrfs filesystems, which have native fallocate syscall support. They will see no delay during preallocation and no fragmented filesystem. Pre-allocation on others filesystems will cause a delay but will not fragment the files.

To make pre-allocation available, recompile libtorrent from the ABS tree with the following new switch:

 ./configure --prefix=/usr --disable-debug --with-posix-fallocate

To enable it, add the following to your Template:Filename:

 # Preallocate files; reduces defragmentation on filesystems.
 system.file_allocate.set = yes

Manage completed files

Note: Currently, this part requires either the svn version of rtorrent/libtorrent or having applied the patch to 0.8.6 that adds 'equal'.
Note: If you're having trouble with this tip, it's probably easier to follow this

It is possible to have rtorrent sort completed torrent data to specific folders based on which 'watch' folder you drop the *.torrent into while continuing to seed. Many examples show how to do this with torrents downloaded by rtorrent. The problem is when you try to drop in 100% done torrent data and then have rtorrent check the data and resume. It will not be sorted.

As a solution, use the following example in your ~/.rtorrent.rc. Make sure to change the paths.

Template error: are you trying to use the = sign? Visit Help:Template#Escape template-breaking characters for workarounds.

You can add additional watch folders and rules should you like to sort your torrents into special folders.

For example, if you would like the torrents to download in:

/home/user/torrents/incomplete

and then sort the torrent data based on which folder you dropped the *.torrent into:

/home/user/torrents/watch => /home/user/torrents/complete
/home/user/torrents/watch/iso => /home/user/torrents/complete/iso
/home/user/torrents/watch/music => /home/user/torrents/complete/music

You can have the following in your .rtorrent.rc:

Template error: are you trying to use the = sign? Visit Help:Template#Escape template-breaking characters for workarounds.

Also see pyroscope especially the rtcontrol examples. There is an AUR package.

Notificaion with Google Mail

Cell phone providers allow you to "email" your phone:

Verizon: 10digitphonenumber@vtext.com
AT&T: 10digitphonenumber@txt.att.net
Former AT&T customers: 10digitphonenumber@mmode.com
Sprint: 10digitphonenumber@messaging.sprintpcs.com
T-Mobile: 10digitphonenumber@tmomail.net
Nextel: 10digitphonenumber@messaging.nextel.com
Cingular: 10digitphonenumber@cingularme.com
Virgin Mobile: 10digitphonenumber@vmobl.com
Alltel: 10digitphonenumber@alltelmessage.com OR
10digitphonenumber@message.alltel.com
CellularOne: 10digitphonenumber@mobile.celloneusa.com
Omnipoint: 10digitphonenumber@omnipointpcs.com
Qwest: 10digitphonenumber@qwestmp.com
Telus: 10digitphonenumber@msg.telus.com
Rogers Wireless: 10digitphonenumber@pcs.rogers.com
Fido: 10digitphonenumber@fido.ca
Bell Mobility: 10digitphonenumber@txt.bell.ca
Koodo Mobile: 10digitphonenumber@msg.koodomobile.com
MTS: 10digitphonenumber@text.mtsmobility.com
President's Choice: 10digitphonenumber@txt.bell.ca
Sasktel: 10digitphonenumber@sms.sasktel.com
Solo: 10digitphonenumber@txt.bell.ca
  • Install Heirloom's mailx program:
pacman -S mailx-heirloom
  • Clear the /etc/mail.rc file and enter:
Note: Older versions of Heirloom's mailx use /etc/nail.rc.
set sendmail="/usr/bin/mailx"
set smtp=smtp.gmail.com:587
set smtp-use-starttls
set ssl-verify=ignore
set ssl-auth=login
set smtp-auth-user=USERNAME@gmail.com
set smtp-auth-password=PASSWORD

Now to send the text, we must pipe a message to the mailx program.

  • Make a bash script (/path/to/mail.sh):
echo "$@: Done" | mailx 5551234567@vtext.com

Where the $@ is a variable holding all the arguments passed to our script.

  • And finally, add the important ~/.rtorrent.rc line:
system.method.set_key = event.download.finished,notify_me,"execute=/path/to/mail.sh,$d.get_name="

Breaking it down:

notify_me is the command id, which may be used by other commands, it can be just about anything you like, so long as it is unique.

execute= is the rtorrent command, in this case to execute a shell command.

/path/to/mail.sh is the name of our script (or whatever command you want to execute) followed by a comma separated list of all the switches/arguments to be passed.

$d.get_name= 'd' is an alias to whatever download triggered the command, get_name is a function which returns the name of our download, and the '$' tells rTorrent to replace the command with its output before it calls execute.

The end result? When that torrent, 'All Live Nudibranches', that we started before leaving for work finishes, we will be texted:

All Live Nudibranches: Done

Make "active" tab show only active torrents

The rtorrent doesn't list the active tab properly by default, add this line to your .rtorrent.rc to show only active torrents

schedule = filter_active,30,30,"view_filter = active,\"or={d.get_up_rate=,d.get_down_rate=}\""

Now press 9 in your rtorrent client to see the changes in action.

Troubleshooting

CA certificates

To use rTorrent with a tracker that uses HTTPS, do the following as root:

cd /etc/ssl/certs
wget --no-check-certificate https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Global_eBusiness_CA-1.cer
mv Equifax_Secure_Global_eBusiness_CA-1.cer Equifax_Secure_Global_eBusiness_CA-1.pem
c_rehash

And from now on run rTorrent with:

rtorrent -o http_capath=/etc/ssl/certs

If you use GNU Screen, update the Template:Filename configuration file to reflect this change:

screen -t rtorrent rtorrent -o http_capath=/etc/ssl/certs

In rTorrent 0.8.9, set network.http.ssl_verify_peer.set=0 to fix the problem.[1]

For more information see: rTorrent Error & CA Certificate and rTorrent Certificates Problem

Web interface

There are numerous web interfaces and front ends for rTorrent including:

  • WTorrent is a web interface to rtorrent programmed in php using Smarty templates and XMLRPC for PHP library.
  • nTorrent is a graphical user interface client to rtorrent (a cli torrent client) written in Java.
  • rTWi is a simple rTorrent web interface written in PHP.
  • Rtgui is a web based front end for rTorrent written in PHP and uses XML-RPC to communicate with the rTorrent client.
  • rutorrent and Forum - A web-based front-end with an interface very similar to uTorrent which supports many plugins and advanced features (see also: Guide for rTorrent + ruTorrent Installation).
Note: rTorrent is currently built using XML-RPC for C/C++, which is required for some web interfaces (e.g. rutorrent).

XMLRPC interface

If you want to use rtorrent with some web interfaces (e.g. rutorrent) you need to add the following line to the configuration file:

scgi_port = localhost:5000

For more information see: Using XMLRPC with rtorrent

See also


Forum threads

References