aboutsummaryrefslogtreecommitdiff
path: root/modules/tlmp/rtorrent.rc
blob: 1a156a5f04ee841e8f60aa3ed695e74305048e01 (plain)
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#############################################################################
# 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,"/var/lib/rtorrent/")
method.insert = cfg.mediadir, private|const|string, (cat,"/mnt/media/")
method.insert = cfg.watch,   private|const|string, (cat,(cfg.basedir),"watch/")
method.insert = cfg.logs,    private|const|string, (cat,"/var/log/rtorrent/")

# Create instance directories
execute.throw = bash, -c, (cat,\
    "builtin cd \"", (cfg.basedir), "\" ",\
    "&& mkdir -p .session watch/{load,start}")


#############################################################################
# Network
#############################################################################

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

network.local_address.set = 45.152.210.73

# Get Public IP
# method.insert = get_public_ip_address, simple|private, "execute.capture=bash,-c,\"eval echo -n \$(natpmpc -g 10.2.0.1 -a 1 0 tcp 60 | awk '/Public IP address :/ { print $5 }')\""
# schedule2 = ip_tick, 5, 45, "network.local_address.set=(get_public_ip_address)"

# Get Forwarded port
# method.insert = get_port_forward, simple|private, "execute.capture=bash,-c,\"eval echo -n \$(natpmpc -g 10.2.0.1 -a 1 0 tcp 60 | awk '/Mapped public port/ { print $4 }')\""
# schedule2 = port_tick, 6, 45, "network.port_range.set=(get_port_forward)"

# 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 = yes

# XMLRPC
network.scgi.open_local = /run/rtorrent/rpc.sock
execute.nothrow = chmod,777,/run/rtorrent/rpc.sock


#############################################################################
# Throttles & Limits
#############################################################################

# throttle.global_down.max_rate.set_kb = 50000
# throttle.global_up.max_rate.set_kb   = 50000

throttle.max_uploads.set = 250
throttle.max_uploads.global.set = 500

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

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 = 500
network.max_open_files.set = 12000
network.max_open_sockets.set = 6000


#############################################################################
# Base Settings
#############################################################################

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

# Basic operational settings (no need to change these)
session.path.set = (cat, (cfg.basedir), ".session")
directory.default.set = (cat, (cfg.mediadir), "download/")
execute.nothrow = bash, -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

# 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)
schedule2 = watch_start, 10, 10, ((load.start_verbose, (cat, (cfg.watch), "start/*.torrent")))
schedule2 = watch_load, 11, 10, ((load.verbose, (cat, (cfg.watch), "load/*.torrent")))


#############################################################################
# Log Rotation, Archival, and Pruning
#############################################################################


# Settings for archival delay, and retention [days]
method.insert.value = pyro.log_retention.days, 2
method.insert.value = pyro.log_archival.days,  7

# Create HUGE xmlrpc log files?
method.insert.value = pyro.log.xmlrpc.enabled, 0
method.insert.value = pyro.extended, 0

method.insert.value = pyro._log.xmlrpc.closing, 0

# Create a "YYYY-mm-dd-HHMMSS" time stamp
method.insert = pyro.date_iso.log_stamp, simple|private,\
    "execute.capture_nothrow = bash, -c, \"echo -n $(date +%Y-%m-%d-%H%M%S)\""

# String value for the currently used time stamp, changed on rotation
method.insert = pyro.log_stamp.current, string

# Create a full logfile path using the current stamp
method.insert = pyro.logfile_path, simple|private,\
    "cat = (cfg.logs), (argument.0), \"-\", (pyro.log_stamp.current), .log"

# (Re-)open all logs with a current time stamp; the main log file
# is just opened, you need to add some logging scopes yourself!
method.insert = pyro.log_rotate, multi|rlookup|static
method.set_key = pyro.log_rotate, !stamp,\
    "pyro.log_stamp.current.set = (cat, (pyro.date_iso.log_stamp))"
method.set_key = pyro.log_rotate, execute,\
    "log.execute = (pyro.logfile_path, execute)"
method.set_key = pyro.log_rotate, messages,\
    "branch = (pyro.extended), ((log.messages, (pyro.logfile_path, messages) ))"
method.set_key = pyro.log_rotate, xmlrpc,\
    "branch = pyro.log.xmlrpc.enabled=, \"log.xmlrpc=(pyro.logfile_path, xmlrpc)\", \
                                        \"log.xmlrpc=(pyro._log.xmlrpc.closing)\""
method.set_key = pyro.log_rotate, ~main,\
    "log.open_file = log, (pyro.logfile_path, rtorrent)"

# Logrotate schedule (rotating shortly after 1AM, so DST shenanigans
# are taken care of, and rotation is always near the begin of the next day)
schedule2 = pyro_daily_log_rotate, 01:05:00, 24:00:00, ((pyro.log_rotate))

# Log file archival and pruning
method.insert = pmb._logfile_find_cmd, simple|private,\
     "cat = \"find \", (cfg.logs),\
            \" -daystart -type f -name '*.\", (argument.0),\"'\",\
            \" -mtime +\", (argument.1),\
            \" -exec nice \", (argument.2), \" '{}' ';'\""

schedule2 = pyro_logfile_archival, 01:10:00, 24:00:00,\
    "execute.nothrow = bash, -c, (pmb._logfile_find_cmd, log, (pyro.log_archival.days), gzip)"

schedule2 = pyro_logfile_pruning, 01:20:00, 24:00:00,\
    "execute.nothrow = bash, -c, (pmb._logfile_find_cmd, log.gz, (pyro.log_retention.days), rm)"

# Open logs initially on startup
# pyro.log_rotate=
schedule2 = pyro_startup_log_xmlrpc_open, 7, 0, \
    "branch = pyro.log.xmlrpc.enabled=, \"log.xmlrpc=(pyro.logfile_path, xmlrpc)\""

pyro.log_stamp.current.set = (cat, (pyro.date_iso.log_stamp))
log.open_file = log, (pyro.logfile_path, rtorrent)
log.add_output = "info", "log"
# log.add_output = "tracker_info", "log"
log.execute = (pyro.logfile_path, execute)


### END of rtorrent.rc ###