AIOStreamsAIOStreams
Guides

Torrents

Stream torrents from their swarms on your own instance, with the built-in torrent engine.

Debrid services download a torrent to their servers and hand you a link. The built-in torrent engine does that job on your own instance instead: it joins the torrent's swarm when you press play, fetches the part of the file the player is reading first, and serves it as an ordinary stream any device can play.

It is the torrent half of the AIOStreams service, the same service the built-in usenet engine uses, so it fits everywhere a debrid service does: built-in torrent addons check their results with it, the Library addon lists what it has played, and failover moves on from a torrent that won't start.

Everyone in a torrent's swarm can see the address it is downloaded from, which is your instance's unless you route the engine through a VPN. Only turn it on where you are allowed to download what you play.

Turning It On

Turn on Torrent engine under Settings → Torrents in the dashboard, or set TORRENT_ENGINE=true. The Docker image includes the engine program. When running from source, download it for your system from the engine's releases or install it with cargo install --locked --git https://github.com/AIOStreams/engine engine, so aiostreams-engine is on the PATH, or point ENGINE_PATH at it.

Then add the AIOStreams service to a configuration with an AIOStreams Auth Token, a username:password pair from AIOSTREAMS_AUTH, as for the usenet engine. Built-in torrent addons such as Knaben, Torznab, Prowlarr and EZTV now offer it among their services, and Service Wrap can resolve torrents with it. To keep a configuration on the usenet engine only, turn off Torrents under Use for in the service's settings.

What Results Show

  • A torrent the engine has played before is in its library and shows as cached.
  • Any other torrent shows as cached when its trackers report at least Seeders for cached seeders (3 by default), so sorting and filtering by cached status keep the healthy ones first. A result that came without its hash goes by the count its indexer gave, until its .torrent is fetched (see Hash-less Indexers).
  • A torrent that recently failed to start here, finding no peers or none with its details or its file, is left out.

Live seeder counts replace the seeder count each torrent result carries with what its trackers report now, for every configuration on the instance, not only those using the engine. Counts are shared between configurations and kept for an hour, so a title already looked up costs nothing.

Playing

The first play of a torrent waits for its details from the swarm, usually a few seconds, then starts as soon as the opening of the file arrives. The engine fetches ahead of the player, seeks to wherever the player jumps, and checks every piece against the torrent before passing on anything it can't vouch for.

What was played stays in the Disk cache (20 GB by default), so seeking back, playing again or a second person watching the same release reads from disk. When it fills, the torrents not playing go first, least recently played. Memory caps what is held in memory across all torrents; lower it on a small server.

Seeding

Peers send more to those that send back, so the engine uploads while it streams. Upload limit caps it across all torrents. With Seed from the cache on, torrents go on seeding what is in the disk cache after playback ends.

Private torrents are off by default. When on, results from private trackers are added from their .torrent file, downloaded whole and seeded until they reach Seeding ratio or Seeding time, since private trackers count what each member sends back. See Private Trackers.

Incoming Connections

The engine takes connections from peers on Listen port, 6881 by default, which reaches peers that can't be reached themselves and lets others download from your instance. Forward the port to the container, TCP and UDP; until then, it only connects out. Ask the router to forward the port does that by NAT-PMP or UPnP, which only works when the router is on the same network as the engine, such as with host networking.

Blocklist takes a list of address ranges no peer is connected to or accepted from: a file, or an address the engine downloads it from each time it starts. P2P, DAT and CIDR lists work, gzipped or not.

VPNs

Putting the whole AIOStreams container behind a VPN sends your debrid, addon and indexer requests through it too, and debrid services often refuse VPN addresses. These settings keep only the engine's traffic on the VPN:

  • WireGuard: the .conf file your VPN provider gives out for WireGuard. The engine runs the tunnel itself, so there is no VPN container to set up. Name lookups go to the DNS server in the file, and while the tunnel is down the engine waits rather than go around it.
  • Proxy: a SOCKS5 proxy all torrent traffic goes through, such as socks5://user:password@vpn:1080. Many VPN providers offer one. You can also run a SOCKS5 server inside your VPN container's network, sending out through the tunnel. The engine needs a proxy that relays UDP, as Dante does, for DHT and UDP trackers; through one that doesn't, it only uses TCP trackers and peers.
  • Bind: a network interface or address, such as a WireGuard interface wg0, for when the VPN's interface is visible to AIOStreams. While it is gone, the engine waits rather than use another network.

Ask the router to forward the port is skipped with any of them, since the router it would ask is not the VPN's. Where the engine shares the VPN container's network and the provider forwards a port, set Port file to the file the container writes it to, such as gluetun's /tmp/gluetun/forwarded_port, and the engine listens on that port, starting again when it changes.

Apps

The desktop and Android apps can also stream torrents on the device itself, without this engine: turn on Play torrent versions under Settings → Player in the app. See Torrents and Usenet on the device. A torrent the server's engine plays is an ordinary stream, so every device can play it, browsers and TVs included.

On this page