Difference between revisions of "RTorrent (简体中文)"

From ArchWiki
Jump to navigation Jump to search
m (moved RTorrent(简体中文) to RTorrent (简体中文): 格式化标题)
(No difference)

Revision as of 22:35, 18 August 2009


Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n links end

介绍

rTorrent 是一个非常简洁、性能高、占用资源低的BT客户端. 它是在C++中使用ncurses编写的, 因此它完全基于文本并在终端中运行. rTorrent is ideal for low-end systems and with the addition of GNU Screen and openssh it is convenient as a remote bittorrent client.

安装

pacman -S rtorrent

配置

在运行rTorrent前,首先要创建默认配置文件,该文件可以从rTorrent 项目主页上找到,并将其另存为.rtorrent.rc放到你的主目录中.

保存后, 使用你喜爱的文本编辑器打开它并进行有必要的改动. Simply uncomment the options you wish to enable/utilize. 如需更详细的资料,请访问rTorrent Common Tasks

推荐配置

下面这些配置的值只是个人观点,这主要取决于你的系统和网络速度. 要寻找最佳配置供你使用请访问下面网站并按照指示操作: Optimize Your BitTorrent Download Speed

# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
max_peers = 52

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
max_peers_seed = 52

# Maximum number of simultanious uploads per torrent.
max_uploads = 8

# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 200
upload_rate = 28

下面的选项将决定你的torrent数据被保存在哪. 如果你想改变默认保存目录,请务必输入正确的绝对路径; rtorrent有一个奇怪的Bug,有时不考虑相对路径(i.e. ~/torrents):

# Default directory to save the downloaded torrents.
directory = /home/[user]/torrents/

This option will allow rTorrent to save the progess of your torrents. 一定要创建一个目录来访问.session (普通用户运行:mkdir ~/.session):

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session = /home/[user]/.session/

The following option will have rTorrent "watch" a particular directory for new .torrent files. Using your browser, when you find a .torrent file you would like to download, just save the file into this directory and rTorrent will automatically start the torrent. Be sure to create the directory that will be watched (simply run as normal user:mkdir ~/watch):

# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule = watch_directory,5,5,load_start=./watch/*.torrent
#schedule = untied_directory,5,5,stop_untied=
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=

This option below will stop rTorrent from downloading any further when disk space is low. This is particuarly useful with a Seedbox where disk space is quite limited. Change the value as you like:

# Close torrents when diskspace is low.
schedule = low_diskspace,5,60,close_low_diskspace=100M

This option will set what port to use for listening. It is recommended to use a port that is higher than 49152. rTorrent allows the use of a single port rather than a range; a single port rather than an actual range is recommended.

# Port range to use for listening.
port_range = 49164-49164

The following option allow for a hash check whenever a torrent is complete or whenever rTorrent is restarted. This will make sure there are no errors with your acquired/seeding files.

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
check_hash = yes

The following option allows for the enabling of encryption. This is very important to enable, if not for yourself, but for others in the torrent swarm; people might need to obscure their bandwidth usage from their ISP. Does not hurt you to enable even if you do not need such protection. More information: Bittorrent Protocol Encryption

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
# encryption = allow_incoming,enable_retry,prefer_plaintext
encryption = allow_incoming,try_outgoing,enable_retry

The following is for DHT support. If you use public trackers, you'll want to enable DHT to acquire more peers. If you use only private trackers, do not enable DHT as this will reduce your speeds and can create a privacy risk. Some private trackers will even warn you if you use DHT.

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
# 
# dht = auto

# UDP port to use for DHT. 
# 
# dht_port = 6881

# Enable peer exchange (for torrents not marked private)
#
# peer_exchange = yes

Be sure to forward the proper port(s) with your router if you use one. A decent guide per router make/model can be found here.

管理

rTorrent依靠用户输入的专有的快捷键. 可在官方网站上查看完整的: rTorrent用户指南

这里是一些最基础的快速参考:

  • Control-q : closes rTorrent, done twice makes the program shutdown without waiting to send stopping information to the trackers.
  • Left arrow : returns to the previous screen.
  • Right arrow : goes to the next screen.
  • a|s|d : increase global upload throttle about 1|5|50 KB/s
  • A|S|D : increase global download throttle about 1|5|50 KB/s
  • z|x|c : decrease global upload throttle about 1|5|50 KB/s
  • Z|X|C : decrease global download throttle about 1|5|50 KB/s
  • Control-S : starts download
  • Control-D : stops an active download, removes a stopped download.
  • + or - : changes the download priority of selected torrent.
  • Backspace : adds the specified .torrent. After pressing this button write full path or URL of .torrent file. You can use Tab and other tricks from bash.

通过Screen使用rTorrent

Screen 是允许CLI应用程序在后台运行并支持X运行的一个程序.

安装:

pacman -S screen

然后复制screenrc到你的用户主目录:

cp /etc/screenrc ~/.screenrc

要总是通过Screen来运行rTorrent,在.screenrc文件中添加以下内容:

screen -t rtorrent rtorrent 

要运行screen和rTorrent, 只要简单的在终端运行screen就可以了. Control-a followed by d will detach screen, and running screen -r will open screen again.

On a remote machine

Most setups of rTorrent on a remote machine involve using Screen. Supposing you have a detached Screen session with rtorrent on the remote machine (and the option to SSH into it), you can gain access to it using:

/usr/bin/ssh -t -p <ssh port on remote machine> <user>@<remote machine> screen -RD

If you want immediate access on startup, you will need to upload a key from your machine to remote host (so you will not be prompted for a password) and setup a terminal to run the command above. An inittab example using rungetty on virtual console 4:

sam:45:respawn:/sbin/rungetty tty4 -u <local user> -- /usr/bin/ssh -t -p <ssh port on remote machine> <remote user>@<remote machine> screen -RD

Screen后台运行rTorrent

I use this on my home server to run rtorrent w/ screen as a daemon. With the username rtorrent Just create an rtorrent file in your /etc/rc.d/ and add the following code.

#!/bin/bash

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

case "$1" in
  start)
    stat_busy "Starting rtorrent"
    su rtorrent -c 'screen -d -m 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|stop|restart}"
esac
exit 0

On a remote computer I use the following script to connect to the server's daemon process:

ssh -t rtorrent@192.168.1.10 'screen -r'

其他提示

  • 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

Be sure to change .screenrc to reflect this change if you use screen:

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



Send Text Message Upon Torrent Completion Using GMail

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

Verizon: 10digitphonenumber@vtext.com
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

If you have Verizon, your cell phone's "email" is 5551234567@vtext.com

  • Install Heirloom's mailx program:
pacman -Sy mailx-heirloom
  • Clear the /etc/nail.rc file and enter:
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 "Torrent Done" | mailx 5551234567@vtext.com
  • And finally, add the important ~/.rtorrent.rc line:
on_finished = move_complete,"execute=/path/to/mail.sh"

Note: The "move complete" won't affect anything. I couldn't get it to work without it.

See Also

Screen Tips

A Detailed Intro to Bittorrent including definition of terms terms