Repository navigation
fix(torrent): keep silent and forged peers from blocking downloads, and fail closed on upload settings - #544
Conversation
…nd fail closed on upload settings - Incoming handshakes take at most a quarter of the connection budget and 4 per host (TorrentHandshakeGate), so peers that connect and send nothing never stall our dials - Accepted uTP sockets stay half open until a packet acknowledges our SYN answer, so forged SYN sources never reach the budget; at most 64 wait, then SYNs go unanswered - Phones pause uploads when the network can no longer be followed - An unreadable config falls back to the defaults with uploading off
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: 258d9b3069
ℹ️ 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".
… slots under small budgets
Test Results 1 893 files + 478 1 920 suites +478 23m 8s ⏱️ + 6m 17s Results for commit 79b9d30. ± Comparison against base commit bafc86e. This pull request removes 1 and adds 4275 tests. Note that renamed tests count towards both. |
Fixes four findings from a review of torrent uploading, which is now on by default and reachable from the internet through port mapping.
Silent incoming connections (high)
Incoming connections and our own dials share one budget of 200. An incoming socket held its slot for up to 15 s before naming a torrent, so one IP opening about 200 silent connections stalled every download.
TorrentHandshakeGatenow admits incoming handshakes indispatchIncomingonly up to a quarter of the budget (8 to 64), and 4 per host. An IPv6 host is counted by its /64. Loopback counts only against the total. Connections past either limit are closed at once.Forged uTP SYNs (high)
One uTP SYN created a connected socket and took a budget slot, and its source can be forged. An accepted socket now stays half open until a packet acknowledges the random sequence number our SYN answer carried (
UtpSocket.confirmed).Wi-Fi-only uploads failed open (medium)
When the network flow threw,
followUploadNetworkstopped following it and left uploads as they were, so a phone that started on Wi-Fi kept uploading on mobile data. A failed network flow now counts as metered from then on. The settings are still followed.Unreadable config turned uploading back on (medium)
The apps,
ketch <url>andketch mcp --standalonefell back to the defaults (upload = while-downloading) whenconfig.tomlcould not be read, so a user who choseoffstarted uploading. They now fall back toKetchConfig.Unreadable: the defaults, with uploading off.Tests
TorrentHandshakeGateTest: per-host limit, total limit, IPv6 /64 grouping, loopback exemption.UtpSocketTest: data that doesn't acknowledge our answer is dropped, and the dialer confirms at once.UtpEndpointTest: forged SYNs over real UDP never reach the engine and stop being answered past the limit.UploadNetworkTest: a failing network flow pauses uploads and settings are still followed.FileConfigStoreTest: an unreadable file loads with uploads off.:library:torrent:jvmTest(all 199 suites), the app's upload network tests and:config:jvmTestpass.:cli:compileKotlinand the iOS test compile of the torrent module succeed.