RTorrent

出自 Arch Linux 中文维基

本文內容或本節內容已經過期。

原因: 請提供模板的第一個位置參數以概括原因。 (在Talk:RTorrent討論)

本文或本節需要翻譯。要貢獻翻譯,請訪問簡體中文翻譯團隊

附註: Last updated in 2011(在 Talk:RTorrent# 中討論)

rTorrent 是一個非常簡潔、優秀、非常輕量的BT客戶端. 它使用了 ncurses 庫以 C++ 編寫, 因此它完全基於文本並在終端中運行. 將 rTorrent 用在安裝有 GNU ScreenSecure Shell 的低端系統上作為遠程的 BT 客戶端是非常理想的。

安裝[編輯 | 編輯原始碼]

官方源 安裝 rtorrent 包。

你也可以從 AUR 中安裝 rtorrent-gitAURrtorrent-extendedAUR[損壞的連結:package not found]

配置[編輯 | 編輯原始碼]

注意: 查看關於此部分的 rTorrent Wiki 文章獲取更多信息: Common Tasks in rTorrent for Dummies

在運行 rTorrent 前,首先要創建默認配置文件,該文件可以從 /usr/share/doc/rtorrent/rtorrent.rc 上找到,並將其另存為 .rtorrent.rc 放到你的主目錄中.

$ cp /usr/share/doc/rtorrent/rtorrent.rc ~/.rtorrent.rc

保存後, 使用你喜愛的文本編輯器打開它並進行有必要的改動. 可以簡單地去掉那些你需要使用的選項的註釋, 如需更詳細的資料,請訪問rTorrent Common Tasks

性能優化[編輯 | 編輯原始碼]

注意: 查看關於此部分的 rTorrent wiki 文章獲得更多信息: 性能優化

下面這些配置的值主要取決於你的系統和網絡速度. 要尋找最佳配置,請訪問下面網站並按照指示操作: 優化 BitTorrent 下載速度

# 每个种子所允许的最大最小连接数
#min_peers = 40
max_peers = 52

# 同上,针对的是已经完成的种子 (-1 表示和下载中的种子一致)
#min_peers_seed = 10
max_peers_seed = 52

# 每个种子的最大同时上传数
max_uploads = 8

# 全局的上传与下载速度限制(以 KB 为单位),“0”表示无限制
download_rate = 200
upload_rate = 28

check_hash 選項將在下載完成或 rTorrent 重新啟動時對文件進行 Hash 校驗。這將確保你獲得/做種的文件沒有錯誤:

check_hash = yes

創建和管理文件[編輯 | 編輯原始碼]

directory 選項將決定你的 torrent 數據被保存在哪. 如果你想改變默認保存目錄,請務必輸入正確的絕對路徑; rtorrent 有一個奇怪的 Bug,一些時候它不考慮相對路徑(如 ~/torrents):

directory = /home/[user]/torrents/

session 選項將允許 rTorrent 保存你的 torrents 的進度. 一定要創建一個會話目錄 .session (普通用戶運行:$ mkdir ~/.session):

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

schedule 選項將使 rTorrent 監視一個特定目錄中的 .torrent 文件。使用這一選項時一定要小心,這將移動 .torrent 文件到你的會話目錄下,並將之重命名為其 Hash 值。 當你看到了一個你想要下載的種子文件,你可以使用你的瀏覽器將這一種子文件保存到這一監視目錄下, rTorrent 將會自動的開始下載這一種子文件的內容。必須確保要監視的目錄已經被創建(以普通用戶身份執行: mkdir ~/watch):

# 监听目录中的新的种子文件,并停止那些已经被删除部分的种子
#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=

下面的 schedule 選項將使 rTorrent 在磁盤空間不足時停止。 這對於Seedbox這種磁盤空間非常有限的設備來說是很有用的。按照你的喜好來改變下面的數值:

# 当磁盘空间不足时停止下载
schedule = low_diskspace,5,60,close_low_diskspace=100M

端口配置[編輯 | 編輯原始碼]

port_range 選項將指定選用哪一個端口去偵聽。建議使用高於 49152 的端口。雖然 rTorrent 允許使用多個的端口,還是建議使用單個的端口。

port_range = 49164-49164

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

附加設置[編輯 | 編輯原始碼]

encryption 選項使能加密功能。 使用加密功能十分重要not only for yourself, but also for your peers in the torrent swarm. 人們也許需要對它們的網絡提供商模糊其帶寬使用。即使你不需要這些保護,開啟加密也不會對你有所負作用。詳細信息請見: Bittorrent Protocol Encryption

# 加密選項,設為0(默認情況)或下面的任何一個:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
#
# 如下例中的值將允許將接入連接加密,開始時以非加密方式作為連接的輸出方式,
# 如行不通則以加密方式進行重試,在加密握手後,優先選擇將純文本以 RC4 加密
#
# encryption = allow_incoming,enable_retry,prefer_plaintext
encryption = allow_incoming,try_outgoing,enable_retry

下面的選項用以加入 DHT 支持。如果你使用了 public trackers,你可能希望使能 DHT 以獲得更多的連接。如果你僅僅使用了私有的連接,請不要使能 DHT,因為這將降低你的速度,並可能造成一些隱密的危險。一些私有連接甚至會就使用 DHT 而向你發出警告。

# 使能對 trackerless torrents 或當所有的 tracker 都停止情況下的 DHT 支持。
# 可以被設置為 "disable" (完全禁止 DHT),「off「(不啟動 DHT), "auto"(按需要啟
# 動或停止 DHT)或者 "on" (即時開啟 DHT)。
# 默認設置為 "off"。要使 DHT 工作,會話目錄必須被定義。
#
# dht = auto

# UDP 使用 UHT的端口 
# 
# dht_port = 6881

# 使能 peer 的交換 (對那些沒有被標記為私有的 torrent)
#
# peer_exchange = yes
注意: See the rTorrent wiki article on this subject for more information: Using DHT

管理[編輯 | 編輯原始碼]

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

rTorrent依靠用戶輸入的專有的快捷鍵.可在官方網站上查看完整的: rTorrent用戶指南

注意: 快速敲擊 Ctrl-q 兩次會使得 rTorrent 關閉,而不會等待向連接的 tracker 發送停止聲明。

這裏是一些最基礎的快速參考:

  • 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.

Redundant mapping[編輯 | 編輯原始碼]

Ctrl-s is often used for terminal control to stop screen output while Ctrl-q 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 ~/.bashrc file.

通過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 rungettyAUR[損壞的連結:package not found] 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[編輯 | 編輯原始碼]

本文內容或本節內容已經過期。

原因: update for systemd (在Talk: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://web.archive.org/web/20160505025153/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
  • To create .torrent files, I recommend mktorrent for commandline interface or RubyTorrent for GUI.

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 -S 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" will not affect anything. I could not get it to work without it.

See Also[編輯 | 編輯原始碼]

Screen Tips

A Detailed Intro to Bittorrent including definition of terms terms