马春杰杰 Exit Reader Mode

macOS下安装rtorrent并开启webUI

本文标签apt c++ chmod git homebrew linux mkdir npm 权限 终端 远程连接

rtorrent是个非常优秀的种子下载工具,只是国内貌似用的人非常少~~可能是因为配置麻烦吧,这里备份一下macOSrtorrent的安装流程,以及如何将rtorrentflood进行连接开启webUI

1. 安装rtorrent

一个比较简单的方法是使用homebrew进行安装,类似于Linux下面的apt或者yum。如果不知道如何安装homebrew的,可以参考这篇:

 

安装homebrew之后,可以直接使用以下命令安装:

brew install rtorrent

2. 配置rtorrent

直接终端输入rtorrent即可打开:

接下来需要配置一些选项,主要是开启TCP连接,设置缓存之类的.

cd
touch .rtorrent.rc
vi .rtorrent.rc

内容可以直接copy下面的配置:

#############################################################################
# A minimal rTorrent configuration that provides the basic features
# you want to have in addition to the built-in defaults.
#
# See https://github.com/rakshasa/rtorrent/wiki/CONFIG-Template
# for an up-to-date version.
#############################################################################


## Instance layout (base paths)
method.insert = cfg.basedir,  private|const|string, (cat,"/Volumes/WIN10 E盘/rt/")
method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"download/")
method.insert = cfg.logs,     private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile,  private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.session,  private|const|string, (cat,(cfg.basedir),".session/")
method.insert = cfg.watch,    private|const|string, (cat,(cfg.basedir),"watch/")


## Create instance directories
execute.throw = sh, -c, (cat,\
    "mkdir -p \"",(cfg.download),"\" ",\
    "\"",(cfg.logs),"\" ",\
    "\"",(cfg.session),"\" ",\
    "\"",(cfg.watch),"/load\" ",\
    "\"",(cfg.watch),"/start\" ")


## Listening port for incoming peer traffic (fixed; you can also randomize it)
network.port_range.set = 50000-50000
network.port_random.set = no


## Tracker-less torrent and UDP tracker support
## (conservative settings for 'private' trackers, change for 'public')
dht.mode.set = disable
protocol.pex.set = no

trackers.use_udp.set = no


## Peer settings
throttle.max_uploads.set = 100
throttle.max_uploads.global.set = 250

throttle.min_peers.normal.set = 20
throttle.max_peers.normal.set = 60
throttle.min_peers.seed.set = 30
throttle.max_peers.seed.set = 80
trackers.numwant.set = 80

protocol.encryption.set = allow_incoming,try_outgoing,enable_retry


## Limits for file handle resources, this is optimized for
## an `ulimit` of 1024 (a common default). You MUST leave
## a ceiling of handles reserved for rTorrent's internal needs!
network.http.max_open.set = 50
network.max_open_files.set = 600
network.max_open_sockets.set = 300


## Memory resource usage (increase if you have a large number of items loaded,
## and/or the available resources to spend)
pieces.memory.max.set = 1800M
network.xmlrpc.size_limit.set = 4M


## Basic operational settings (no need to change these)
session.path.set = (cat, (cfg.session))
directory.default.set = (cat, (cfg.download))
log.execute = (cat, (cfg.logs), "execute.log")
#log.xmlrpc = (cat, (cfg.logs), "xmlrpc.log")
execute.nothrow = sh, -c, (cat, "echo >",\
    (session.path), "rtorrent.pid", " ",(system.pid))


## Other operational settings (check & adapt)
encoding.add = utf8
system.umask.set = 0027
system.cwd.set = (directory.default)
network.http.dns_cache_timeout.set = 25
schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M))
#pieces.hash.on_completion.set = no
#view.sort_current = seeding, greater=d.ratio=
#keys.layout.set = qwerty
#network.http.capath.set = "/etc/ssl/certs"
#network.http.ssl_verify_peer.set = 0
#network.http.ssl_verify_host.set = 0


## Some additional values and commands
method.insert = system.startup_time, value|const, (system.time)
method.insert = d.data_path, simple,\
    "if=(d.is_multi_file),\
        (cat, (d.directory), /),\
        (cat, (d.directory), /, (d.name))"
method.insert = d.session_file, simple, "cat=(session.path), (d.hash), .torrent"


## Watch directories (add more as you like, but use unique schedule names)
## Add torrent
schedule2 = watch_load, 11, 10, ((load.verbose, (cat, (cfg.watch), "load/*.torrent")))
## Add & download straight away
schedule2 = watch_start, 10, 10, ((load.start_verbose, (cat, (cfg.watch), "start/*.torrent")))


## Run the rTorrent process as a daemon in the background
## (and control via XMLRPC sockets)
#system.daemon.set = true
#network.scgi.open_local = (cat,(session.path),rpc.socket)
network.scgi.open_port = 0.0.0.0:4000
#execute.nothrow = chmod,770,(cat,(session.path),rpc.socket)
pieces.hash.on_completion.set = no

# 设置下载后文件的读写权限,umask 相关知识请自行了解
system.umask.set = 0027

# 设置下载后的单个、最大文件
system.file.max_size.set = 500G

## Logging:
##   Levels = critical error warn notice info debug
##   Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
print = (cat, "Logging to ", (cfg.logfile))
log.open_file = "log", (cfg.logfile)
log.add_output = "info", "log"
#log.add_output = "tracker_debug", "log"

### END of rtorrent.rc ###

3. 安装flood

flood是一款好看的webUI,我们选择它作为rtorrent的界面。

git clone https://gitee.com/fork-project/flood.git
cd flood
npm install --global flood
npx flood

这样就启动flood了。

如果没有安装npm,只是想临时用一下,可以用以下命令:

yum install gcc gcc-c++
wget https://npm.taobao.org/mirrors/node/v16.7.0/node-v16.7.0-linux-x64.tar.gz
tar -xvf node-v16.7.0-linux-x64.tar.gz
cd node-v16.7.0-linux-x64
pwd  # 记住路径
export NODE_HOME=上一步路径
export PATH=$NODE_HOME/bin:$PATH

之后就可以继续:

npm install --global flood
npx flood

浏览器打开http://127.0.0.1:3000即可打开flood界面,首先是创建一个账号,然后选择rtorrent,选择TCP连接

输入:http://127.0.0.1:4000即可连接。

如果需要远程连接的话,需要后面加--host ip,例如:

npx flood --host 0.0.0.0

4. 命令行下使用rtorrent

可以参考这个CLI Usage · rakshasa/rtorrent Wiki (github.com)

简单说一下:

在命令行下按回车,会出现一个输入窗口,这时只需要输入种子的路径然后按enter键即可添加。此时只是添加了种子,还没有下载,只需要按Ctrl+s即可开始下载。

使用方向键可以选择种子,选择之后可以使用快捷键:

Ctrl+o 对选择的 torrent 设置新的下载目录,仅仅对还没有被激活过的 torrent
Ctrl+s 开始下载,先运行 hash ,除非已经做过
Ctrl+d 停止激活的下载,或者删除一个停止的下载
Ctrl+r 初始化 torrent 的 hash 检查
Ctrl+q 关闭 rTorrent,再按一次,强行关闭
左键 回到前一个屏幕
向右键 切换到下载视图
+/- 修改优先度
l 查看日志,空格退出
1 显示所有下载
2 显示所有下载,按文件名排序
3 显示开始的下载
4 显示停止的下载
5 显示完成的下载
6 显示未完成的下载
7 显示正在 hash 的下载
8 显示正在做种的下载

5. rtorrent编程

rtorrent的可玩性非常高,具体可以参考:rTorrent XMLRPC Reference – Emonoda (mdevaev.github.io)

后续有时间我再讲一下怎样通过xmlrpc接口做自己想做的事。

本文最后更新于2021年9月24日,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!