Skip to content

Default the run client to an OS-assigned port, widen the default range - #23

Merged
pratts merged 2 commits into
mainfrom
fix/default-listen-port-fallback
Oct 14, 2026
Merged

pratts merged 2 commits into
mainfrom
fix/default-listen-port-fallback

Conversation

@pratts

@pratts pratts commented Oct 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Run client port fallback: NewDefaultClientConfig sets ListenPort = 42069, and Run only overrode it when a pool port was claimed. In the ephemeral-fallback (range exhausted) and no-range cases, the background process stayed on 42069 and could fail with listen tcp4 :42069: bind: address already in use against whichever torrent already held it. Run now starts from ListenPort = 0 (OS-assigned) and only sets a claimed pool port on top.
  • Default port range: widened from 42069–42069 to 42000–43000, so concurrent torrents get distinct pool ports instead of all but the first falling back to ephemeral ones.

Not in this PR

The add-flow scratch clients (internal/engine/preview.go, internal/engine/metadata.go) still use the library default of 42069. Adding a torrent while another is running can still fail with the same bind error until those set ListenPort = 0 too.

Test plan

  • go build ./...
  • go test ./internal/...

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
@pratts pratts self-assigned this Oct 14, 2026
@pratts
pratts merged commit 5ada284 into main Oct 14, 2026
4 checks passed
@pratts
pratts deleted the fix/default-listen-port-fallback branch October 14, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant