Skip to content

Latest commit

 

History

History
830 lines (668 loc) · 42.3 KB

CONFIGURATION.md

File metadata and controls

830 lines (668 loc) · 42.3 KB

Configuration

TorrentNG has two runtime configuration surfaces:

  • TorrentNG client — torrentngd, the first-party client daemon and primary owned-transfer runtime.
  • Compatible-client WebUI/API service — torrentng, the service used with rTorrent, qBittorrent, Transmission, Deluge, or a separate TorrentNG client.

The two config files are intentionally separate. The TorrentNG-client config controls durable client state, peer networking, tracker behavior, storage, DHT, and direct API auth. The compatible-client service config controls the selected client adapter, service cache, WebUI serving, and compatibility-facade identity. The sidecar/ source path and existing TNG_* keys remain stable implementation/configuration contracts.

TorrentNG Desktop has a third, client-side file at ~/.config/torrentng-desktop/config.toml on Linux (see the platform paths in DESKTOP.md). Its Local/Remote setting chooses whether Desktop launches torrentngd on this computer or stores a connection URL and API token for a remote torrentngd. It does not configure the compatible-client torrentng service and cannot connect to a WebUI Bridge. In Local mode, torrentngd owns transfers, its app-data directory, and the finished-download folder. In Remote mode, the server process owns those files and settings. WebUI Bridge deployments keep their selected client and storage configuration in the compatible-client service configuration described below.

TorrentNG client (torrentngd)

torrentngd loads TOML config from the first existing path in this order:

  1. TORRENTNGD_CONFIG
  2. ~/.config/torrentngd/config.toml
  3. /etc/torrentngd/config.toml

If no file exists, built-in defaults are used.

Start with an explicit config path:

TORRENTNGD_CONFIG=/config/config.toml torrentngd

[daemon]

Key Default Description
session_dir ~/.local/share/torrentngd or /var/lib/torrentngd Directory for torrent metadata and session state
api_bind 127.0.0.1:8080 Bind address for the REST and compatibility APIs
log_level info Tracing filter, for example info or rt_engine=trace
shutdown_timeout_secs 10 Max seconds to wait for torrent tasks to send stopped announces during shutdown

The daemon's Tokio worker pool defaults to one thread. Set TOKIO_WORKER_THREADS to a positive integer to use more runtime workers for a workload that benefits from higher async concurrency. The daemon continues to use Tokio's multi-thread runtime at every worker count. Storage I/O and hash workers have separate limits.

Release builds use size optimization (opt-level = "s"), thin LTO, one codegen unit, and the system allocator by default. To select the opt-level 3 alternative, build with CARGO_PROFILE_RELEASE_OPT_LEVEL=3 cargo build --release -p torrentngd.

Compatibility API build features

The default torrentngd build includes the native TorrentNG API and the qBittorrent-compatible API. Transmission and Deluge API routers are optional Cargo features to reduce the default binary footprint. This changes the default API surface: deployments using Transmission or Deluge clients should rebuild with the matching feature before upgrading. The native API, WebUI, and qBittorrent API remain available in every build.

# Default: native and qBittorrent APIs
cargo build --release -p torrentngd

# Add one compatibility API, or both
cargo build --release -p torrentngd --features compat-transmission
cargo build --release -p torrentngd --features compat-deluge
cargo build --release -p torrentngd --features full-compat

full-compat enables both optional APIs. These are compile-time build features; selecting them does not change the allocator defaults or the TOKIO_WORKER_THREADS setting.

[network]

Key Default Description
listen_port 6881 Incoming peer TCP port; can be changed through the authenticated session-settings API or qBittorrent setPreferences at runtime, and the active value is persisted in session state
max_peers 200 Maximum peer connections across all torrents
upload_rate_limit 0 Upload limit in bytes/sec; 0 means unlimited
download_rate_limit 0 Download limit in bytes/sec; 0 means unlimited

uTP transport policy is controlled by environment so operators can roll it out without changing durable config. By default, TNG_UTP_OUTGOING=auto attempts uTP first for DHT, PEX, and manually added peers while tracker-discovered peers stay on TCP. TNG_UTP_OUTGOING=prefer|only broadens outbound uTP peer-wire dialing (prefer falls back to TCP, only does not), and TNG_UTP_OUTGOING=tcp-only disables outbound uTP. TNG_UTP_INCOMING=1 binds the incoming uTP endpoint on listen_port; the incoming listener flag is boolean only (1, true, yes, or on) and does not accept policy words such as prefer or utp-only. Because the native DHT and uTP listeners own separate UDP sockets, dht.port = 0 moves the implicit DHT listener to the next UDP port when incoming uTP is enabled (and uses an ephemeral port if listen_port = 65535). An explicit dht.port equal to listen_port is rejected in that mode. TNG_UTP_METADATA=prefer|only enables uTP magnet metadata fetch explicitly.

When dht.port = 0, DHT follows the runtime peer port (using the next UDP port while incoming uTP is enabled). A runtime listen-port change rebinds the peer sockets and restarts DHT on its corresponding port; an explicit dht.port remains fixed.

[storage]

Key Default Description
download_dir ~/Downloads or /tmp Default payload download directory
device_elevator_enabled true Enable per-device peer-read elevator scheduling where storage profiles benefit
file_pool_size 512 Open-file cache entries shared by path-backed schedulers in one process/configuration; maximum 65536
idle_file_ttl_secs 300 Seconds before idle cached file handles are eligible to close
io_worker_threads 2 Shared positioned-I/O worker threads for path-backed schedulers in one process/configuration; maximum 64
io_queue_depth 256 Bounded positioned-I/O queue depth shared by those schedulers; maximum 16384
hash_worker_threads 1 Shared storage hash worker threads for path-backed schedulers in one process/configuration; maximum 64
hash_queue_depth 256 Bounded hash queue depth shared by those schedulers; maximum 16384
preallocation_mode auto Payload preallocation mode: off, auto, sparse, or full
durability_mode checkpoint Payload durability mode: fast, checkpoint, or strict
peer_read_readahead_bytes 524288 Peer-read readahead size used before returning the exact requested slice
peer_read_readahead_sequential_only true Expand readahead only when a read continues the previous read of the same file; isolated block reads stay exact. false expands every miss
peer_read_cache_entries 64 Maximum cached forward ranges per scheduler across all files; a file can retain several useful disjoint ranges, with least-recently-used range eviction. Set to 0 to disable cached readahead reuse
peer_read_cache_bytes 8388608 Maximum payload bytes retained by each scheduler's peer-read cache; least-recently-used ranges are evicted to stay within the byte budget. Maximum 67108864; set to 0 to disable cached readahead reuse
peer_read_elevator_budget_ms 25 HDD/network peer-read elevator batching window; ignored when device_elevator_enabled = false

[crash_safety]

Protection against power loss and crashes; see CRASH_SAFETY.md for what each option does and when to change it. Every key is also editable at runtime (WebUI Settings → Backend → Crash safety, or PUT /api/v1/settings/crash-safety); a runtime change is persisted and overrides this file until reset. Unknown keys are rejected so a typo cannot silently leave a safety setting at its default.

Key Default Description
completion_gate true Hold a finished download at "1 byte left" until its data is synced; only then report it complete
host_crash_detection true Keep a durable run marker (run_marker.json in session_dir) so a host crash can be told apart from a process crash
host_crash_recovery "recent" After a host crash: "watermark" (trust saved state, recheck only unsynced pieces), "recent" (also recheck torrents written inside the window), "full" (recheck everything)
recent_write_window_secs 86400 Look-back for "recent"; 1 to 31536000
structural_audit "on_unclean" Metadata-only check for unwritten/hole extents behind valid pieces: "off", "on_unclean", "always"; Linux, macOS, FreeBSD and Windows (see the platform table in CRASH_SAFETY.md)
mount_probe true Rate each save location's fsync trust from its filesystem (and, on Linux, mount options); Linux, macOS, FreeBSD and Windows
weak_mount_escalation true Recheck weak mounts fully after a host crash (and sample read-back on completion); raise unknown mounts to at least "recent"
weak_mount_paths [] Absolute path prefixes always treated as weak (longest prefix wins over the probe)
strong_mount_paths [] Absolute path prefixes always treated as strong
completion_verify "off" Re-read finished downloads from disk before releasing them: "off", "sample", "full"
completion_verify_sample_percent 5 Percent of pieces re-read for "sample" (file first and last pieces are always included); 1 to 100
path_policies [] Per-location overrides: an array of [[crash_safety.path_policies]] tables, each with an absolute path and any of completion_gate, host_crash_recovery, structural_audit, completion_verify, completion_verify_sample_percent. The longest matching path prefix of a torrent's save path wins; unset keys use the global value. At most 64, no duplicate paths
[[crash_safety.path_policies]]
path = "/mnt/nas"
host_crash_recovery = "full"
completion_verify = "sample"

[storage] durability_mode = "fast" skips the payload fsync between saves; since the crash-safety work, a record saved that way is discarded after a host crash instead of trusted, and the final save when a torrent exits always syncs. [storage] preallocation_mode = "full" uses fallocate(2) and falls back to a sparse length where it is unsupported.

[memory]

Key Default Description
total_cap_mb 512 Process-owned memory cap for governor-managed buffers
storage_frame_cap_mb 128 Storage frame memory class cap
queued_disk_cap_mb 64 Queued disk/hash/elevator memory class cap
piece_assembly_cap_mb 0 Incomplete piece assembly memory class cap; 0 disables in-memory assembly and writes verified blocks directly to storage
piece_index_cap_mb 128 Persistent piece-picker, availability-index, and v1 piece-hash memory class cap
peer_buffer_cap_mb 128 Cap on peer-buffer bytes held by resource-governor leases. Outstanding-request payload capacity and command-queue capacity are reported as separate estimates and may overlap leased bytes.
metadata_cap_mb 32 Metadata, tracker peer cache, DHT table, and API snapshot class baseline cap
pressure_constrained_pct 75 Percent of total cap that reports constrained pressure
pressure_critical_pct 90 Percent of total cap that reports critical pressure

On Linux, torrentngd disables transparent huge pages for its own process at startup. This protects memory use when the host enables huge pages globally, without changing the host's setting or affecting other processes. Set TORRENTNGD_DISABLE_THP=0 to skip the process-level policy; unset or invalid values keep it enabled. The system allocator is the default build; jemalloc and mimalloc are opt-in build features. To build an alternative allocator with Cargo, select exactly one feature and disable defaults:

cargo build --release -p torrentngd --no-default-features --features jemalloc-allocator
cargo build --release -p torrentngd --no-default-features --features mimalloc-allocator

The native Docker Compose build accepts the same feature names through TORRENTNG_CARGO_FEATURES:

TORRENTNG_CARGO_FEATURES=jemalloc-allocator \
  docker compose -f deploy/native/compose.yml build torrentngd

For jemalloc builds, the container entrypoint defaults MALLOC_CONF=thp:never. Set MALLOC_CONF=thp:default to let jemalloc follow the host policy as well.

The queued_disk memory class reports payload bytes reserved by queued or active disk, hash, and peer-read elevator jobs. Leases are acquired before enqueue and released on queue rejection, cancellation, or completion.

[runtime]

Key Default Description
torrent_tiers_enabled true Keep idle torrents in Dormant/Warm tiers so only active torrents own task/runtime resources
tier_hot_idle_secs 120 Idle seconds before a promoted torrent moves from Hot to Warm
tier_warm_idle_secs 1800 Idle seconds before a promoted torrent moves from Warm to Dormant; must exceed tier_hot_idle_secs

[tracker]

Key Default Description
http_timeout_secs 30 HTTP announce timeout
udp_timeout_secs 15 UDP announce timeout
min_interval_secs 0 Minimum announce interval override; 0 uses tracker values
allow_http_trackers true Permit HTTP tracker announces
allow_https_trackers true Permit HTTPS tracker announces
allow_udp_trackers true Permit UDP tracker announces
allow_http_webseeds true Permit HTTP webseed requests
allow_https_webseeds true Permit HTTPS webseed requests
allow_loopback_egress false Permit outbound tracker, webseed, DHT, and peer traffic to loopback IPs
allow_private_egress false Permit outbound tracker, webseed, DHT, and peer traffic to private/ULA/CGNAT IPs and the reserved 198.18.0.0/15 benchmarking network
allow_link_local_egress false Permit outbound tracker, webseed, DHT, and peer traffic to link-local IPs
allow_multicast_egress false Permit outbound tracker, webseed, DHT, and peer traffic to multicast IPs
allow_unspecified_egress false Permit outbound tracker, webseed, DHT, and peer traffic to unspecified IPs

The address-policy switches apply to every outbound peer connection, not only tracker and webseed traffic: DHT bootstrap/routing traffic and peer addresses from trackers, DHT, PEX, or manual requests use the same policy. The reserved benchmarking network is also permitted only when allow_private_egress is enabled; other reserved ranges remain denied. Leave these switches disabled for public-swarm isolation; enable only the address classes needed for a deliberate LAN/private deployment. Denied destinations are skipped and counted by the egress-policy metrics.

[dht]

Key Default Description
enabled true Enable DHT
port 0 UDP DHT port; 0 uses network.listen_port, except that incoming uTP moves the implicit listener to the next UDP port to avoid two independent sockets competing for one port
bootstrap_nodes Public BitTorrent bootstrap routers Bootstrap nodes as host:port strings

The live TorrentNG-client DHT transport supports IPv4 and IPv6. The metainfo and magnet identity model accepts v1, v2, and hybrid identities; tracker and peer address-family coverage still depends on the configured network and external endpoint.

[db]

Key Default Description
path session_dir/state.db SQLite database path; leave empty to use the session directory. Relative custom paths are resolved under session_dir; absolute paths are used as given.
wal_checkpoint_pages 1000 SQLite WAL checkpoint threshold

[auth]

Key Default Description
username torrentng WebUI login username
password unset WebUI login password; unset generates a unique private password on first startup; configured values must be 8-1024 bytes
api_tokens [] Pre-shared bearer/session tokens accepted by the TorrentNG API
api_tokens_file unset Optional newline-delimited token file; loaded in addition to api_tokens
metrics.include_torrent_ids false Include raw infohashes in hot-torrent Prometheus labels; disabled by default because labels are high-cardinality identifiers

OIDC lives in the nested [auth.oidc] section. See OIDC authentication for provider setup and the verified-email admission policy.

An empty token list is valid only when [daemon].api_bind is loopback. A non-loopback bind requires at least one real token of 16 or more characters; placeholder values such as change-me and REPLACE_WITH_* are rejected at startup. Prefer api_tokens_file or a deployment secret over inline tokens. An unset password is generated once and stored in <session_dir>/bootstrap-password with mode 0600. Run torrentngd auth-token from an interactive terminal to display the active WebUI login. The command writes directly to the controlling terminal and refuses to run without one, so redirected stdout and pipelines do not capture credentials. A public bind requires an API token and a WebUI password of at least 16 bytes. API tokens work in either login field. Settings -> Security can update the username/password at runtime; those values persist in <session_dir>/auth-settings.json with mode 0600 and take precedence over the config file until reset from the WebUI.

[logging]

[daemon].log_level remains supported as the legacy filter. The structured logging section takes precedence when filter is set, and RUST_LOG takes precedence over both.

Key Default Description
format json Output format: json or pretty
profile basic Preset filter profile: basic, detailed, or verbose
filter "" Explicit tracing filter, for example rt_engine=debug,tower_http=info
event_retention 10000 Number of newest durable session events to retain for qBit-compatible main logs

TorrentNG-client minimal example

An empty token list is only valid on a loopback API bind. Use a randomly generated token of at least 16 characters before changing api_bind to a non-loopback address; placeholder tokens are rejected at startup.

[daemon]
api_bind = "127.0.0.1:8080"
session_dir = "/var/lib/torrentngd"

[storage]
download_dir = "/data"

[auth]
username = "torrentng"
# Loopback-only TorrentNG-client development mode. Public binds require real tokens.
api_tokens = []
# Production alternative: api_tokens_file = "/run/secrets/torrentngd_api_token"

TorrentNG-client full example

[daemon]
api_bind = "127.0.0.1:8080"
session_dir = "/var/lib/torrentngd"
log_level = "info"
shutdown_timeout_secs = 10

[network]
listen_port = 6881
max_peers = 200
upload_rate_limit = 0
download_rate_limit = 0

[storage]
download_dir = "/data"
preallocation_mode = "auto"
durability_mode = "checkpoint"
peer_read_cache_entries = 64
peer_read_cache_bytes = 8388608

[crash_safety]
# Defaults shown; see docs/CRASH_SAFETY.md.
completion_gate = true
host_crash_detection = true
host_crash_recovery = "recent"
recent_write_window_secs = 86400
structural_audit = "on_unclean"
mount_probe = true
weak_mount_escalation = true
completion_verify = "off"

[tracker]
http_timeout_secs = 30
udp_timeout_secs = 15
min_interval_secs = 0

[dht]
enabled = true
port = 0
bootstrap_nodes = [
  "dht.transmissionbt.com:6881",
  "router.bittorrent.com:6881",
  "router.utorrent.com:6881",
]

[db]
path = "/var/lib/torrentngd/state.db"
wal_checkpoint_pages = 1000

[auth]
username = "torrentng"
api_tokens = ["your-automation-token"]

[logging]
format = "json"
profile = "basic"
filter = ""
event_retention = 10000

Compatible-client WebUI/API service (torrentng)

The compatible-client service loads TOML config from ~/.config/torrentng/config.toml by default. Override the path by passing it as the first argument:

torrentng /path/to/config.toml

Environment variables override file values where listed.

Service options

Key Default Env override Description
listen_addr 127.0.0.1:8080 TNG_LISTEN_ADDR TCP address the service listens on; non-loopback binds require strong API tokens and a session secret
debug false TNG_DEBUG=1 Enable debug logging
sync_interval_secs 5 TNG_SYNC_INTERVAL_SECS Seconds between backend state polls
data_dir ~/.local/share/torrentng - Directory for SQLite cache
storage_roots [] - Paths shown in the storage dashboard; defaults to / when empty
WebUI static dir static TNG_STATIC_DIR Directory served for WebUI assets and SPA fallback

Service [backend]

[backend] selects the compatible torrent client controlled by the service. Existing configs that only define [rtorrent] still load as rTorrent-backed deployments.

Key Default Env override Description
type rtorrent TNG_BACKEND Backend adapter: rtorrent, qbittorrent, transmission, deluge, or torrentng. The former native value is accepted only as a legacy alias for torrentng.

The qBittorrent, Transmission, Deluge, and TorrentNG adapters treat their configured API/RPC URLs as final endpoints and do not follow HTTP redirects. Point each URL directly at the API endpoint, including the required path and scheme, rather than relying on an HTTP-to-HTTPS or path redirect.

[backend]
type = "rtorrent"
[backend]
type = "qbittorrent"

Service [rtorrent]

Key Default Env override Description
scgi_socket /run/rtorrent/rpc.sock TNG_SCGI_SOCKET Path to rTorrent SCGI Unix socket
scgi_addr - TNG_SCGI_ADDR host:port for TCP SCGI; mutually exclusive with scgi_socket
timeout_secs 10 - Timeout for individual XMLRPC calls
identity_timeout_secs 300 - Timeout for the startup tracker-identity rewrite; kept separate from ordinary XMLRPC calls because it can touch a large session

The service's mounted HTTP/XMLRPC routes enforce the configured API token. The crate-level execute_xml helper without a token is a local embedding/test convenience and is not mounted by torrentngd; use the token-aware helper for an independently exposed integration. | user_agent | rtorrent/0.16.28/0.16.28 | TNG_USER_AGENT | Tracker HTTP user-agent pushed to rTorrent on startup | | peer_id | generated + persisted per install | TNG_PEER_ID | 20-byte tracker peer ID pushed to loaded rTorrent downloads on startup |

The packaged rTorrent backend pins the upstream rTorrent/libtorrent 0.16.28 user_agent, but not a fixed peer_id: only the 8-byte client-family prefix (-lt101C-) is fixed. The remaining 12 bytes are generated once per install and persisted to <data_dir>/peer_id_suffix; leave peer_id unset unless you specifically need to pin one install to a literal value. See TRACKER-IDENTITY.md — sharing a fixed peer_id across installs previously caused a private-tracker multi-client ban.

Service [qbittorrent]

The qBittorrent integration talks to qBittorrent-nox through the qBittorrent Web API. The service keeps the TorrentNG WebUI and compatibility API in front while qBittorrent owns torrent execution.

Key Default Env override Description
url http://127.0.0.1:8080 TNG_QBITTORRENT_URL Base URL for qBittorrent Web API
username - TNG_QBITTORRENT_USERNAME Optional WebUI username
password - TNG_QBITTORRENT_PASSWORD Optional WebUI password
timeout_secs 10 - Timeout for qBittorrent Web API requests
no_auth false TNG_QBITTORRENT_NO_AUTH=1 Skip login for trusted no-auth local WebUI deployments
accept_invalid_certs false - Accept invalid TLS certificates for lab deployments

Configured external backend URLs must use http or https and must not embed userinfo; keep credentials in the dedicated username/password or token fields. Backend API clients do not follow redirects.

[backend]
type = "qbittorrent"

[qbittorrent]
url = "http://127.0.0.1:8080"
username = "REPLACE_WITH_QBITTORRENT_WEBUI_USERNAME"
password = "REPLACE_WITH_QBITTORRENT_WEBUI_PASSWORD"
timeout_secs = 10

These are placeholders, not working defaults. Configure authentication on the backend and keep the real credentials out of source control.

Service [transmission]

The Transmission compatible-client integration talks to an external Transmission RPC endpoint. Categories are mapped to Transmission labels where available. File priority, tracker add/edit/remove, pause/resume, remove, add, recheck, location moves, file rename, and share limits are mapped to Transmission RPC where supported. The TorrentNG service uses configured storage-root probes for free-space responses; port testing and operations without a connected TorrentNG client return explicit unsupported errors rather than false success. Tags, torrent rename, sequential toggles, and runtime user-agent changes remain unsupported in this adapter.

Key Default Env override Description
url http://127.0.0.1:9091/transmission/rpc TNG_TRANSMISSION_URL Transmission RPC URL
username - TNG_TRANSMISSION_USERNAME Optional RPC username
password - TNG_TRANSMISSION_PASSWORD Optional RPC password
timeout_secs 10 - Timeout for Transmission RPC requests
accept_invalid_certs false - Accept invalid TLS certificates for lab deployments
[backend]
type = "transmission"

[transmission]
url = "http://127.0.0.1:9091/transmission/rpc"

Service [deluge]

The Deluge compatible-client integration talks to the Deluge Web JSON-RPC endpoint. File priority, tracker replacement, pause/resume, remove, add, recheck, storage moves, file rename, ratio share limits, and seeding-time share limits are mapped to Deluge core methods where supported. In compatible-client mode, path-based torrent loads and daemon/plugin/configuration writes are rejected explicitly, and free-space reads use healthy configured storage roots. Categories, tags, torrent rename, sequential toggles, and runtime user-agent changes are unsupported in this adapter.

Key Default Env override Description
url http://127.0.0.1:8112/json TNG_DELUGE_URL Deluge Web JSON-RPC URL
password - TNG_DELUGE_PASSWORD Optional Deluge Web password
timeout_secs 10 - Timeout for Deluge JSON-RPC requests
accept_invalid_certs false - Accept invalid TLS certificates for lab deployments
[backend]
type = "deluge"

[deluge]
url = "http://127.0.0.1:8112/json"
password = "REPLACE_WITH_DELUGE_WEBUI_PASSWORD"

The password above is a placeholder. Change Deluge's default WebUI password before allowing access beyond a trusted local host.

Service [torrentng]

The TorrentNG integration talks to a separate TorrentNG client over its HTTP API. This is for deployments that want the compatible-client WebUI/API service in front of a separate torrentngd process. The adapter forwards torrent add/remove, pause/resume, recheck/reannounce, category/tag changes, location/name updates, file-priority and file-rename changes, and tracker add/edit/remove operations to the TorrentNG client; service-only catalog metadata such as saved views and RSS rules remains in the service cache. Bounded cache synchronization pins the TorrentNG list snapshot across pages and retries; external qBittorrent synchronization is bounded but eventual because qBittorrent exposes no equivalent snapshot token.

Key Default Env override Description
url http://127.0.0.1:8080 TNG_TORRENTNG_URL Base URL for the TorrentNG client
api_token - TNG_TORRENTNG_API_TOKEN Optional bearer token for mutation endpoints
timeout_secs 10 - Timeout for TorrentNG API requests
accept_invalid_certs false - Accept invalid TLS certificates for lab deployments
[backend]
type = "torrentng"

[torrentng]
url = "http://127.0.0.1:8080"
api_token = "optional-token"

Service [rtorrent.logs]

When enabled, the service tails configured rTorrent log files and stores new lines as durable rtorrent_log app events. These entries are returned by qBittorrent-compatible /api/v2/log/main alongside service app events. Ingestion failures and recovery are also durable operator events (rtorrent_log_ingest_error and rtorrent_log_ingest_recovered) so a broken log path is visible in the same log stream. Startup-time rTorrent connectivity failures, transfer-stat probe failures, and their recoveries are retained as operator events as well. Admin settings mutations and restart requests are retained without storing full config bodies, user-agent strings, or filesystem paths. Ingested lines and ingest errors are redacted before storage: magnet URIs, common token query parameters, cookies, and full filesystem paths are removed or shortened.

By default, first-time ingestion starts at the end of each file to avoid flooding /log/main with old logs. The service persists per-file offsets in its cache DB, so subsequent restarts continue from the last ingested byte and capture lines written while it was down. Set read_from_start = true only for controlled imports.

Key Default Env override Description
enabled false TNG_RTORRENT_LOGS_ENABLED Enable rTorrent log file ingestion
paths [] TNG_RTORRENT_LOG_PATHS Log files to tail; env value is comma-separated
poll_interval_secs 2 TNG_RTORRENT_LOG_POLL_INTERVAL_SECS Seconds between file polls
read_from_start false TNG_RTORRENT_LOG_READ_FROM_START Read existing file contents on startup instead of only new lines

user_agent

The user_agent value is pushed to rTorrent via network.http.user_agent.set on startup when the running rTorrent build exposes that XMLRPC method. TorrentNG's packaged rTorrent 0.16.28 image carries a small build patch that publishes the existing libtorrent HTTP user-agent getter/setter through XMLRPC, so this works in the Docker and certification builds. It can also be changed at runtime via PUT /api/v1/settings/user-agent or the Settings panel in the WebUI. Some older distro rTorrent packages do not expose tracker user-agent control; the certification harness reports that as blocked instead of assuming spoofing works.

For packaged rTorrent 0.16.28, keep this as rtorrent/0.16.28/0.16.28. Do not strip it to rtorrent/0.16.28; upstream rTorrent includes the linked libtorrent version in the tracker User-Agent.

[rtorrent]
user_agent = "rtorrent/0.16.28/0.16.28"
TNG_USER_AGENT="rtorrent/0.16.28/0.16.28" torrentng

peer_id

The peer_id value is pushed to existing rTorrent downloads via the packaged d.local_id.set command on startup, then each session file is saved. The value must be exactly 20 ASCII bytes: an 8-byte client-family prefix plus a 12-byte suffix that must be unique per install — see TRACKER-IDENTITY.md for why a shared/hardcoded suffix got a real user banned from a private tracker for "running multiple instances of the same client."

Leave peer_id unset in normal deployments. The compatible-client service generates a random 12-byte suffix on first start and persists it to <data_dir>/peer_id_suffix, so it stays stable across restarts of that one install while still being unique to it. For packaged rTorrent/libtorrent 0.16.28, the fixed prefix is -lt101C- — libtorrent 0.16.28's upstream peer-name encoding; it is not -lt1011-, and the peer ID is not the literal string rtorrent/0.16.28/000.

Only set peer_id (or TNG_PEER_ID) explicitly when you need one specific install pinned to a reproducible value, e.g. for a test fixture — never in a shared config template, base image, or fleet-wide env var:

[rtorrent]
peer_id = "-lt101C-000000000000"
TNG_PEER_ID="-lt101C-000000000000" torrentng

Known user-agent presets:

Client User-agent string
rTorrent 0.16.28 + libtorrent 0.16.28 rtorrent/0.16.28/0.16.28
qBittorrent 5.0.0 qBittorrent/5.0.0
Deluge 2.2.0 Deluge/2.2.0 libtorrent/2.0.10
Transmission 4.0 Transmission/4.0

Service [identity]

These values control the qBittorrent-compatible API identity presented to automation clients. They do not change the tracker-facing transfer-client identity.

Key Default Env override Description
qbittorrent_version 5.0.0 TNG_QBITTORRENT_VERSION Response for /api/v2/app/version
qbittorrent_webapi_version 2.11.0 TNG_QBITTORRENT_WEBAPI_VERSION Response for /api/v2/app/webapiVersion
qbittorrent_build_libtorrent 0.16.28 TNG_QBITTORRENT_BUILD_LIBTORRENT libtorrent value in /api/v2/app/buildInfo
qbittorrent_build_qt 6.7.0 TNG_QBITTORRENT_BUILD_QT qt value in /api/v2/app/buildInfo

Use these only for lab compatibility testing. Tracker-facing identity is still controlled by the underlying rTorrent build and TNG_USER_AGENT support.

Service [auth]

Key Default Env override Description
username torrentng TNG_USERNAME / RTNG_USERNAME WebUI login username
password unset TNG_PASSWORD / RTNG_PASSWORD WebUI login password; unset generates a private per-install value; configured values must be 8-1024 bytes
secret_key - TNG_SECRET_KEY Secret for signing expiring compatibility session cookies. Required for public binds.
api_tokens [] TNG_API_TOKENS Comma-separated pre-shared bearer tokens for automation tools and WebUI login; enter a token in either login field. Public binds require tokens of at least 16 characters
trust_proxy_header false - Trust a non-empty X-Remote-User only on a loopback listener; the proxy must authenticate the request and discard client-supplied copies before setting its own identity (the bundled Nginx config clears this header)
secure_cookies true - Add Secure to issued and cleared session cookies; required for non-loopback listeners. Set false only for trusted loopback HTTP setups.
oidc.issuer_url unset TNG_OIDC_ISSUER_URL / RTNG_OIDC_ISSUER_URL Exact OIDC issuer URL; core OIDC settings must be configured together
oidc.client_id unset TNG_OIDC_CLIENT_ID / RTNG_OIDC_CLIENT_ID Confidential client ID
oidc.client_secret unset TNG_OIDC_CLIENT_SECRET / RTNG_OIDC_CLIENT_SECRET Confidential client secret; redacted from debug output
oidc.redirect_uri unset TNG_OIDC_REDIRECT_URI / RTNG_OIDC_REDIRECT_URI HTTPS callback URI ending in /api/v1/auth/oidc/callback
oidc.allowed_emails [] TNG_OIDC_ALLOWED_EMAILS / RTNG_OIDC_ALLOWED_EMAILS Exact verified-email allowlist
oidc.allowed_email_domains [] TNG_OIDC_ALLOWED_EMAIL_DOMAINS / RTNG_OIDC_ALLOWED_EMAIL_DOMAINS Exact verified-email-domain allowlist
oidc.allow_any_verified_user false TNG_OIDC_ALLOW_ANY_VERIFIED_USER / RTNG_OIDC_ALLOW_ANY_VERIFIED_USER Explicitly admit any verified email; each admitted user has the app's full operator access
oidc.allow_private_issuer false TNG_OIDC_ALLOW_PRIVATE_ISSUER / RTNG_OIDC_ALLOW_PRIVATE_ISSUER Explicitly allow a private issuer and endpoints; callback must remain HTTPS

Requests authenticated by X-Remote-User require same-origin evidence for browser mutations and WebSocket handshakes. Automation clients should use an API-token Bearer credential instead.

Fresh installs generate a unique WebUI password in the service data directory. Run torrentng auth-token [config.toml] from an interactive terminal to retrieve the active login. The command writes only to the controlling terminal and refuses non-interactive use, so stdout redirection cannot capture the credentials. Change credentials in Settings -> Security or in the service [auth] config. Runtime changes persist in auth-settings.json under the service data directory with mode 0600. Public binds require API tokens and a WebUI password of at least 16 bytes. API tokens can be entered in either login field.

On Unraid, open Docker, click the torrentng-webui container icon, and choose Console; run torrentng auth-token at the prompt. This prints the active TorrentNG WebUI credentials. The backend client's credentials are separate. See the Unraid login steps.

When API tokens are configured, unauthenticated login submissions are limited to 10 per TCP peer per 60 seconds. Further attempts receive 429 Too Many Requests with Retry-After; a successful token login clears that peer's counter. The limiter uses the socket peer address, not caller-supplied X-Forwarded-For. Clients arriving through the same reverse proxy therefore share its bucket; configure an additional login limit at the proxy if that traffic should be separated.

For compatibility with older installed rtorrentng-prod units, the service also accepts the former RTNG_* spelling for environment overrides. When both names are set, the canonical TNG_* value wins.

Service [logging]

debug = true and TNG_DEBUG=1 remain supported as legacy aliases for debug-level logging. RUST_LOG has the highest precedence, followed by TNG_LOG_FILTER or logging.filter, then logging.profile, then the legacy debug setting.

Key Default Env override Description
format json TNG_LOG_FORMAT Output format: json or pretty
profile basic TNG_LOG_PROFILE Preset filter profile: basic, detailed, or verbose
filter "" TNG_LOG_FILTER Explicit tracing filter, for example torrentng=debug,tower_http=info
event_retention 10000 TNG_LOG_EVENT_RETENTION Number of newest durable service app events to retain for qBit-compatible main logs

Service [workflows]

Key Default Env override Description
allow_scripts false TNG_ALLOW_SCRIPTS=1 Enables workflow script actions; requires a non-empty allowed_script_dirs allowlist
script_timeout_secs 30 - Maximum runtime for each script action
allowed_script_dirs [] - Canonical directory allowlist for script paths; required when scripts are enabled
allow_private_webhooks false TNG_ALLOW_PRIVATE_WEBHOOKS=1 Allows workflow webhooks to resolve to private/loopback unicast addresses; redirects remain disabled

Script actions are refused unless allow_scripts is true and allowed_script_dirs is non-empty. The executable path must be absolute, is canonicalized before launch, and must remain under an allowed directory. Production configs should use root-owned or service-owned directories and keep them non-world-writable. Workflow webhooks reject private/local DNS results by default, pin one validated address, reject redirects, and cap responses; set allow_private_webhooks only for an explicitly trusted internal destination. See SECURITY_REVIEW.md.

Compatible-client service minimal example

[backend]
type = "rtorrent"

[rtorrent]
scgi_socket = "/run/rtorrent/rpc.sock"

Compatible-client service container example

See deploy/docker/sidecar.config.toml for the Phase 1 container-oriented compatible-client service config.

The default Compose file contains only the rTorrent-backed service. Each optional external backend has its own overlay and requires backend credentials in the Compose environment. The backend management UI/RPC ports are bound to 127.0.0.1; BitTorrent peer ports remain published for inbound peers.

For qBittorrent, first start the backend and use its temporary first-start password from the container logs to set the permanent WebUI credentials to the same values as QBITTORRENT_USERNAME and QBITTORRENT_PASSWORD. For Deluge, change its default WebUI password to DELUGE_PASSWORD. Transmission's profile passes TRANSMISSION_USERNAME and TRANSMISSION_PASSWORD to the image's supported USER/PASS settings. Keep these values in an untracked, protected environment file; do not commit them.

Start one profile with the matching overlay:

docker compose --env-file .env -f deploy/docker/compose.yml -f deploy/docker/compose.qbittorrent.yml --profile qbittorrent up torrentng-qbittorrent qbittorrent
docker compose --env-file .env -f deploy/docker/compose.yml -f deploy/docker/compose.transmission.yml --profile transmission up torrentng-transmission transmission
docker compose --env-file .env -f deploy/docker/compose.yml -f deploy/docker/compose.deluge.yml --profile deluge up torrentng-deluge deluge

Those profiles expose the authenticated TorrentNG adapters on host ports 8082, 8083, and 8084 respectively, bound to 127.0.0.1 by default. Backend management ports are available only on the local host (8081, 9091, and 8112); the peer ports remain available to remote peers. The base compatible-client stack similarly binds its HTTP/API (8080) and HTTP-only Nginx (80) host ports to loopback. Use an authenticated TLS reverse proxy for remote WebUI/API access.

Compatible-client service full example

listen_addr = "127.0.0.1:8080"
debug = false
sync_interval_secs = 5
data_dir = "/var/lib/torrentng"
storage_roots = ["/data", "/mnt/archive"]

[backend]
type = "rtorrent"

[rtorrent]
scgi_socket = "/run/rtorrent/rpc.sock"
timeout_secs = 10
user_agent = "rtorrent/0.16.28/0.16.28"
# peer_id intentionally omitted — generated and persisted per install.
# See TRACKER-IDENTITY.md.

[rtorrent.logs]
enabled = false
paths = ["/var/log/rtorrent/rtorrent.log"]
poll_interval_secs = 2
read_from_start = false

[auth]
secret_key = "change-me-in-production"
api_tokens = ["your-autobrr-token", "your-prowlarr-token"]
trust_proxy_header = false

[identity]
qbittorrent_version = "5.0.0"
qbittorrent_webapi_version = "2.11.0"
qbittorrent_build_libtorrent = "0.16.28"
qbittorrent_build_qt = "6.7.0"

[logging]
format = "json"
profile = "basic"
filter = ""
event_retention = 10000

[workflows]
allow_scripts = false
script_timeout_secs = 30
allowed_script_dirs = []