From 9405fc9af2c7140b2ff834f94e3fbf391274eeb0 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski <janne@kuschku.de> Date: Wed, 8 Jun 2022 02:20:25 +0200 Subject: [PATCH] fix: solve bugs with initial implementation --- daemon/entrypoint.sh | 4 +- daemon/src/rtorrent.conf | 118 ++++++++++++--------------------------- wireguard/entrypoint.sh | 13 ++++- 3 files changed, 51 insertions(+), 84 deletions(-) diff --git a/daemon/entrypoint.sh b/daemon/entrypoint.sh index dc50890..2cb0ec1 100755 --- a/daemon/entrypoint.sh +++ b/daemon/entrypoint.sh @@ -3,10 +3,10 @@ set -euo pipefail rm /tmp/rtorrent.log touch /tmp/rtorrent.log -rm /data/.session/rtorrent.lock /data/.session/rtorrent.pid +rm /tmp/.session/rtorrent.lock /tmp/.session/rtorrent.pid # Start rtorrent as a daemon with the setting in the config file # & to actually run it in the background -rtorrent -n -o "import=/rtorrent.conf" & +rtorrent -n -o "import=/rtorrent.rc" & tail -f /tmp/rtorrent.log diff --git a/daemon/src/rtorrent.conf b/daemon/src/rtorrent.conf index 83547ca..5b6c221 100644 --- a/daemon/src/rtorrent.conf +++ b/daemon/src/rtorrent.conf @@ -1,46 +1,26 @@ ############################################################################# # 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. ############################################################################# +method.insert = cfg.download, private|const|string, /data/ +method.insert = cfg.tmp, private|const|string, /tmp/ +method.insert = cfg.logfile, private|const|string, (cat,(cfg.tmp),"rtorrent.log") +method.insert = cfg.session, private|const|string, (cat,(cfg.tmp),".session/") +fs.mkdir = (cat,(cfg.session)) -## Instance layout (base paths) -method.insert = cfg.basedir, private|const|string, (cat,(system.env,RT_BASE_DIR)) -method.insert = cfg.tmpdir, private|const|string, (cat,"/tmp/") -method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"download/") -method.insert = cfg.logs, private|const|string, (cat,(cfg.tmpdir),"log/") -method.insert = cfg.logfile, private|const|string, (cat,(cfg.logs),"rtorrent.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) +# Listening port for incoming peer traffic 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 = (system.env,RT_DHT_MODE) -#dht.port.set = (system.env,RT_DHT_PORT) -protocol.pex.set = (system.env,RT_PROTO_PEX) +# Distributed Hash Table and Peer EXchange +# Enable tracker-less torrents but vulnerable to passive sniffing +# DHT and PEX are always disabled for private torrents +dht.mode.set = disable +protocol.pex.set = no trackers.use_udp.set = (system.env,RT_TRACKER_UDP) - -## Peer settings +# Peer settings throttle.max_uploads.set = (system.env,RT_MAX_UP) throttle.max_uploads.global.set = (system.env,RT_MAX_UP_GLOBAL) throttle.min_peers.normal.set = (system.env,RT_MIN_PEERS) @@ -51,74 +31,50 @@ trackers.numwant.set = (system.env,RT_TRACKERS_WANT) 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! +# 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) +# Memory resource usage (increase if you have a large number of items loaded, +# and/or the available resources to spend) pieces.memory.max.set = (system.env,RT_MEMORY_MAX) -network.xmlrpc.size_limit.set = 4M - +network.xmlrpc.size_limit.set = 16M -## Basic operational settings (no need to change these) +# Basic operational settings 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)) +log.execute = (cat, (cfg.tmp), "execute.log") +##log.xmlrpc = (cat, (cfg.tmp), "xmlrpc.log") - -## Other operational settings (check & adapt) +# Other operational settings 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" +##view.sort_current = seeding, greater=d.ratio= +##keys.layout.set = qwerty +# HTTP and SSL +network.http.max_open.set = 50 +network.http.dns_cache_timeout.set = 25 -## 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"))) - +#network.http.ssl_verify_peer.set = 1 +#network.http.ssl_verify_host.set = 1 -## Run the rTorrent process as a daemon in the background -## (and control via XMLRPC sockets) -system.daemon.set = (system.env,RT_DAEMON) -network.scgi.open_port = (cat,(system.env,RT_XMLRPC_BIND),:,(system.env,RT_XMLRPC_PORT)) -#network.scgi.open_local = (cat,(session.path),rpc.socket) -#execute.nothrow = chmod,770,(cat,(session.path),rpc.socket) +# Run the rTorrent process as a daemon in the background +system.daemon.set = true +# XML-RPC interface +network.scgi.open_port = 0.0.0.0:5000 -## Logging: -## Levels = critical error warn notice info debug -## Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_* +# 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 ### +##log.add_output = "tracker_debug", "log" diff --git a/wireguard/entrypoint.sh b/wireguard/entrypoint.sh index b8d5e20..eb852b9 100755 --- a/wireguard/entrypoint.sh +++ b/wireguard/entrypoint.sh @@ -1,4 +1,15 @@ #!/bin/bash set -euo pipefail -wg-quick up "/wireguard.conf" +if [ -n "$LOCAL_NETWORK" ]; then + gateway=$(ip route list match 0.0.0.0 | grep -v tun0 | cut -d ' ' -f 3) + interface=$(ip route list match 0.0.0.0 | grep -v tun0 | cut -d ' ' -f 5) + echo gateway="$gateway" + echo interface="$interface" +fi + +wg-quick up /wireguard.conf + +if [ -n "$LOCAL_NETWORK" ]; then + ip r add "$LOCAL_NETWORK" via "${gateway}" dev "${interface}" +fi -- GitLab