Tip:
rtorrent以及libtorrent的ipv6 patch包都已经合入了主线版本,所以可以直接使用github上的最新代码来编译
libtorrent
rtorrent


作为一个PT党,尤其是家里上传带宽不够的PT党,想在各种大水管下活下来难道就只能24小时开机或者购买昂贵的seedbox吗,当然不是,我们可以自己购买廉价vps自己搭建盒子 1国外的好多vps都已经普及了G口,如此动人的上行带宽用来刷PT上传自然是再爽不过了

Ubuntu下的BT客户端有很多,比如rtorrent、transmission、deluge等等,其中deluge自带web管理页面,rtorrent需要配套rutorrent才能在网页上进行管理

Ubuntu下安装rtorrent最简单的方法是

1
apt-get install rtorrent

之后再在~目录下配置.rtorrent.rc文件即可使用

1
vim ~/.rtorrent.rc

我的配置文件是这样的

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# This is an example resource file for seeder1rent. Copy to
# ~/.seeder1rent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.
#
# Based on original .seeder1rent.rc file from http://libtorrent.rakshasa.no/
# Modified by Lemonberry for rtGui http://rtgui.googlecode.com/
#
# This assumes the following directory structure:
#
# /Torrents/Downloading - temporaray location for torrents while downloading (see "directory")
# /Torrents/Complete - Torrents are moved here when complete (see "on_finished")
# /Torrents/TorrentFiles/Auto - The 'autoload' directory for seeder1rent to use. Place a file
# in here, and seeder1rent loads it #automatically. (see "schedule = watch_directory")
# /Torrents/Downloading/seeder1rent.session - for storing seeder1rent session information
#
# Maximum and minimum number of peers to connect to per torrent.
min_peers = 400
max_peers = 8000
# Same as above but for seeding completed torrents (-1 = same as downloading)
min_peers_seed = -1
max_peers_seed = -1
# Maximum number of simultanious uploads per torrent.
max_uploads = 850
# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 0
upload_rate = 0
# Default directory to save the downloaded torrents.
directory = /root/download
# Default session directory. Make sure you don't run multiple instance
# of seeder1rent using the same session directory. Perhaps using a
# relative path?
session = /root/download/.session
# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule = watch_directory,5,5,load_start=/home/seeder1/rtorrent/watch/*.torrent
schedule = untied_directory,5,5,stop_untied=
# Close torrents when diskspace is low. */
schedule = low_diskspace,5,60,close_low_diskspace=100M
# Stop torrents when reaching upload ratio in percent,
# when also reaching total upload in bytes, or when
# reaching final upload ratio in percent.
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
#schedule = ratio,60,60,stop_on_ratio=200,200M,2000
# When the torrent finishes, it executes "mv -n <base_path> ~/Download/"
# and then sets the destination directory to "~/Download/". (0.7.7+)
# The ip address reported to the tracker.
#ip = 127.0.0.1
#ip = rakshasa.no
# The ip address the listening socket and outgoing connections is
# bound to.
#bind = 127.0.0.1
#bind = rakshasa.no
# Port range to use for listening.
port_range = 55895-56000
# Start opening ports at a random position within the port range.
port_random = yes
# 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 = no
# Set whetever the client should try to connect to UDP trackers.
use_udp_trackers = yes
# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa
# 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
# 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 = disable
# UDP port to use for DHT.
#
# dht_port = 6881
# Enable peer exchange (for torrents not marked private)
#
peer_exchange = no
#
# Do not modify the following parameters unless you know what you're doing.
#
# Hash read-ahead controls how many MB to request the kernel to read
# ahead. If the value is too low the disk may not be fully utilized,
# while if too high the kernel might not be able to keep the read
# pages in memory thus end up trashing.
#hash_read_ahead = 10
# Interval between attempts to check the hash, in milliseconds.
#hash_interval = 100
# Number of attempts to check the hash while using the mincore status,
# before forcing. Overworked systems might need lower values to get a
# decent hash checking rate.
#hash_max_tries = 10
# Max number of files to keep open simultaniously.
#max_open_files = 128
# Number of sockets to simultaneously keep open.
#max_open_sockets = <no default>
# Example of scheduling commands: Switch between two ip's every 5
# seconds.
#schedule = "ip_tick1,5,10,ip=torretta"
#schedule = "ip_tick2,10,10,ip=lampedusa"
# Remove a scheduled event.
#schedule_remove = "ip_tick1"

建议大家也可以这样配置,默认下载目录为

1
/root/download

但是通过apt-get安装的rtorrent是不支持ipv6的,这对于某些支持ipv6的PT站点来说会少了很多来自ipv6用户的连接数,导致上传和下载速度都会受到一些限制,毕竟只能从ipv4用户那里进行上传和下载了

所以需要我们自己下载rtorrent的源码包,打入ipv6补丁并进行编译安装

首先创建一个临时目录存放接下来需要下载的源码和补丁

1
mkdir rtinstall;cd rtinstall

下载libtorrent0.13.4和rtorrent0.9.4的源码并解压,通过apt-get安装xmlrpc和各种依赖包

1
2
3
4
5
6
7
8
9
10
11
wget 'http://pkgs.fedoraproject.org/repo/pkgs/libtorrent/libtorrent-0.13.4.tar.gz/e82f380a9d4b55b379e0e73339c73895/libtorrent-0.13.4.tar.gz'
wget 'http://pkgs.fedoraproject.org/repo/pkgs/rtorrent/rtorrent-0.9.4.tar.gz/fd9490a2ac67d0fa2a567c6267845876/rtorrent-0.9.4.tar.gz'
tar -xvf libtorrent-0.13.4.tar.gz
tar -xvf rtorrent-0.9.4.tar.gz
apt-get update
apt-get --yes --force-yes install subversion build-essential automake libtool libcppunit-dev libcurl3-dev libsigc++-2.0-dev unzip unrar-free curl libncurses-dev pkg-config libxmlrpc-core-c3 libxmlrpc-core-c3-dev libssl-dev screen

给libtorrent打入ipv6补丁包并进行配置编译安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
cd ~/rtinstall/libtorrent-0.13.4/
wget 'https://static.xuanyu.li/lib_ipv6.patch'
patch -p1<lib_ipv6.patch
//其实上面这个补丁包存在一行代码的错误,github地址为http://github.com/JohnFlowerful/libtorrent-ipv6-patches/blob/master/libtorrent-0.13.4-HEAD.patch
//因此在打补丁之后我们还需要对libtorrent的源文件进行修改
vim ~/rtinstall/libtorrent-0.13.4/src/net/socket_fd.cc
//跳转到第123行,删除这一行,按两下'd'就能删除这一行,之后输入':wq'保存并退出,这样编译就不会出错了
./configure --enable-ipv6
make
make install

如图,需要删除printf(“Unable to open ipv6 socket\n”);这一行代码

其实添加头文件include <stdio.h>应该也能解决,不知道补丁作者为什么引入了一个printf()函数。。。。2

make之后没有任何error信息就说明编译成功了 3make install成功之后是这样的
4

接下来给rtorrent0.9.4的源代码打入支持ipv6的patch补丁 补丁包在github上的地址为
https://github.com/ggggle/rtorrent-ipv6-patches/blob/master/rtorrent-0.9.4-tar.patch

也可以直接我主机上下载https://static.xuanyu.li/rt_ipv6.patch

1
2
3
4
5
6
7
8
9
10
11
cd ~/rtinstall/rtorrent-0.9.4/
wget 'https://static.xuanyu.li/rt_ipv6.patch'
patch -p1<rt_ipv6.patch
./configure --with-xmlrpc-c --enable-ipv6
make
make install

安装完成之后别忘记了执行以下命令

1
2
3
4
5
ldconfig;cd ~
wget 'https://static.xuanyu.li/.rtorrent.rc'
mkdir ~/download/;cd ~/download/;mkdir .session/

之后就可以通过rtorrent命令打开rtorrent客户端了,而且是完全支持ipv6的,建议使用screen进行多个窗口管理,这样就可以把rtorrent丢到后台去一直运行了5

由于我的这家vps提供商对ipv6的限速较少,所以ipv6能达到的速度要远远超过纯ipv4下的速度

可以看到连接用户里有ipv6地址 下载速度也是非常的快,30MB/s左右,而纯ipv4环境下最高只能到8MB/s左右