Repository navigation
feat(torrent): name Ketch to private trackers and keep their refusal text - #560
Conversation
…text
Private trackers allow clients by peer-ID prefix, so they refused Ketch's
20 random bytes, and the reason they gave was replaced by a generic error.
- Peer ID (BEP 20): -KE plus four version characters from KetchApi.VERSION
and twelve random letters and digits (KT is KTorrent's). The engine uses
one ID for the v1 swarm, v2 and hybrid connections, magnet metadata peers
and trackers.
- BEP 10 handshakes send v ("Ketch <version>") and yourip.
- Tracker announces and scrapes send User-Agent: Ketch/<version> whatever
engine the source was given.
- An HTTP failure reason or UDP error becomes TrackerFailureException.reason
and TrackerStatus.failureReason, a warning message TrackerStatus.warning,
both cleaned by trackerMessage(): control and formatting characters
removed, URLs reduced to scheme://host:port, possible passkeys masked,
200 characters at most. Each is logged at warn when it changes.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b97832cbb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ker text A URL in a tracker's message ends at characters a passkey may hold, such as a comma, so cutting URLs first left most of such a passkey unmasked.
Summary
Private trackers allow clients by peer-ID prefix, so they refused Ketch's 20 random bytes. Users never saw why, because the tracker's own reason was replaced by a generic error. This is item 4 under "Fix first" in the 2026-10-16 torrent review.
Peer ID (BEP 20):
-KE, then four version characters fromKetchApi.VERSION, then twelve random letters and digits. For example, 0.9.1 gives-KE0910-, and a pre-release or dev build ends inZ. I didn't useKT: Transmission, libtorrent, BiglyBT and the theory.org list all assign it to KTorrent. One engine now uses one ID for the v1 swarm, v2 and hybrid connections, magnet metadata peers (which used to pick a fresh random ID on every connection) and trackers. The newTorrentClientobject holds the ID, thevname and the User-Agent.BEP 10: every extension handshake now sends
v(Ketch <version>) andyourip. This covers the v1 swarm, v2 and hybrid connections, and metadata lookups.User-Agent: tracker announces and scrapes now set
User-Agent: Ketch/<version>explicitly, so anHttpEnginethe caller supplies cannot change it. The default engine already sent this. Web seeds keep the engine's default.Tracker text: an HTTP
failure reasonor a UDP error (BEP 15 action 3) now raisesTrackerFailureException(reason). The reason is kept inTrackerStatus.failureReason, and awarning messageinTrackerStatus.warning. Both pass throughtrackerMessage()first, which:scheme://host:port***, the announce URL's credentials and any path or query part that could be a passkey, plus any other run of 16 or more letters and digits that mixes bothEach reason is logged at warn the first time it appears and at debug while it repeats.
Docs: added "How Ketch identifies itself" to
docs/torrent.md, a tracker-messages rule and a log example todocs/logging.md, and anAGENTS.mdentry.Not in this PR
Feeding peers'
youripintoisOwnAddressis a follow-up.youripcomes from untrusted peers, so it needs a tally of distinct voters across the v1 swarms and the v2 sessions, which is more than a small change. For now Ketch only sendsyourip.Tests
TorrentClientTest: the version encoding of the prefix, the ID format, and that IDs are unique.PeerExtensionsTest:vandyouripfor IPv4, IPv4-mapped and IPv6 peers, none for a hostname, and the same keys in the metadata fetcher's handshake.TrackerMessageTest:Unregistered passkey *** at https://tracker.example:443and that the request sent the User-Agent.warning messageis kept.TrackerStatuskeeps the reason and clears it after the next answer.TrackerOnlyMagnetTest: tracker announces and the magnet metadata peer see the same-KEpeer ID, and the peer getsvandyourip.KotlinTorrentEngineRoutingTest: the v1 swarm answers with the prefixed ID../gradlew :library:torrent:jvmTestpasses: 1295 tests, 0 failures.:library:torrent:compileTestKotlinIosSimulatorArm64compiles.