From fd8d99895f4d52c9683a681a277332cc87ca15a2 Mon Sep 17 00:00:00 2001 From: Prateek Sharma Date: Wed, 14 Oct 2026 17:43:50 +0530 Subject: [PATCH] Default the run client to an OS-assigned port, widen the default range When no pool port is claimed (range exhausted, or no range configured), the run client kept anacrolix's default ListenPort of 42069 and could collide with whichever torrent already held it. Start from 0 and only override with a claimed pool port. Also widen the default port range to 42000-43000 so concurrent torrents get distinct pool ports instead of all but the first falling back to ephemeral ones. Co-Authored-By: Claude Opus 5.5 --- internal/config/config.go | 4 ++-- internal/engine/run.go | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/config/config.go b/internal/config/config.go index bb62fd8..2d890a4 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -45,8 +45,8 @@ func Default() Config { BaseDownloadDir: filepath.Join(home, "Downloads", "torrents"), MaxUploadBps: 0, MaxDownloadBps: 0, - PortRangeStart: 42069, - PortRangeEnd: 42069, + PortRangeStart: 42000, + PortRangeEnd: 43000, } } diff --git a/internal/engine/run.go b/internal/engine/run.go index a576963..2898287 100644 --- a/internal/engine/run.go +++ b/internal/engine/run.go @@ -79,6 +79,11 @@ func Run(id string) error { clientCfg := torrent.NewDefaultClientConfig() clientCfg.DataDir = tc.SavePath + // OS-assigned unless a port is claimed from the pool below. The + // library default (42069) would otherwise apply in the ephemeral + // fallback and no-range cases, colliding with whichever torrent holds + // that port -- the exact collision the pool exists to prevent. + clientCfg.ListenPort = 0 // Claim a distinct port from the configured range so this process's // inbound listener never collides with another concurrently-running