A torrent pipeline that survives VPN reconnects
Seeding requires an inbound port, and the VPN rotates that port on every reconnect. Keeping the client, the port mapping and the tracker status in agreement needed automation rather than discipline.
Context
Torrent traffic needs a reachable inbound port to maintain ratio on private trackers. The VPN client assigns a forwarded port that changes on reconnect, while the torrent client holds a static configuration.
Constraints
- The torrent client must stay inside the VPN tunnel — split tunnelling it would leak the real address.
- Manual port updates fail silently after a reconnect, producing gradual ratio decay rather than an obvious error.
- The client has to run outside the agent session so it survives logoff.
Decisions
Read the assigned port from the VPN client, not from configuration
The authoritative port is recorded by the VPN client at connect time. A watcher polls that source and pushes changes to the torrent client over its RPC interface.
Verify reachability, not just agreement
Setting the same port in both places does not prove the mapping works. A port test distinguishes "the client believes it is reachable" from "the tracker agrees", which are different failure modes.
Separate seeding payload from library presentation
Seed data and library files share a single copy where possible, with hardlinks for presentation. Verification predicates on content, so a re-download to "fix" a path would destroy ratio for no benefit.
Outcome
- Port synchronisation runs on a one-minute timer and survives reconnects without intervention.
- Tracker-reported connectivity restored after each reconnect instead of decaying overnight.
- Established a rule that no file operation touches torrent payload without a client stop and an integrity snapshot first.
What it taught me
Any value that changes on its own schedule needs a reconciler, not a documented procedure. Documentation decays; a timer does not.
Addresses, hostnames and identifiers in this write-up are abstracted or generalised. If you would like the specific detail, ask — I am happy to walk through it directly.