Skip to content

V4.2.17 - #89

Merged
Power2All merged 4 commits into
masterfrom
v4.2.17
Jul 26, 2026
Merged

V4.2.17#89
Power2All merged 4 commits into
masterfrom
v4.2.17

Conversation

@Power2All

@Power2All Power2All commented Jul 25, 2026

Copy link
Copy Markdown
Owner
  • Full code auditing, and found some possible security issues in the future.
  • Applied a README fix about library installation on Linux (Thanks https://github.com/diederikdehaas).
  • Some small version bumps, nothing special.

Summary by CodeRabbit

  • New Features
    • Added configurable tracker limits for per-torrent peers and queued WebRTC pending answers (defaults + environment overrides).
    • Added trusted proxy allowlists for HTTP/API real-IP handling and UDP Simple Proxy Protocol source validation.
    • Added HTTP announce route /{key}/{userkey}/announce and strengthened UDP BEP15 connection-id validation.
  • Bug Fixes
    • Tightened validation for hashes/query lengths and improved remote-IP/RTC request handling; deactivated user keys are rejected.
    • Corrected RTC-related counting/pending-answer behavior and improved cleanup on very short uptimes.
  • Documentation
    • Updated Linux dependency instructions, changelog entries, and Docker/version tags.

Power2All added 2 commits July 25, 2026 22:06
…future.

* Applied a README fix about library installation on Linux (Thanks https://github.com/diederikdehaas).
* Some small version bumps, nothing special.
@Power2All Power2All self-assigned this Jul 25, 2026
@Power2All Power2All added bug Something isn't working enhancement New feature or request labels Jul 25, 2026
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 97333670-20f0-4404-b0d4-edd189f1d014

📥 Commits

Reviewing files that changed from the base of the PR and between f50c462 and b726075.

📒 Files selected for processing (2)
  • src/database/impls/query_builder.rs
  • src/database/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/database/impls/query_builder.rs

📝 Walkthrough

Walkthrough

The release updates version metadata, proxy and tracker-limit configuration, validation, tracker state, persistence, HTTP/WebSocket responses, and UDP authentication and proxy handling.

Changes

Release metadata and documentation

Layer / File(s) Summary
Release metadata and documentation
Cargo.toml, README.md, docker/...
Release versions, dependencies, Docker tags, Linux dependency instructions, and changelog entries are updated for v4.2.17.

Configuration and validation

Layer / File(s) Summary
Configuration and input validation
src/config/..., src/common/common.rs, src/security/..., tests/config_tests.rs
Proxy allowlists and tracker limits are added and resolved at startup; query, identifier, message, and remote-IP validation behavior is updated and tested.

Tracker and persistence

Layer / File(s) Summary
Tracker limits, counts, and state
src/tracker/impls/..., src/tracker/structs/..., tests/tracker_tests.rs
Peer maps and RTC answer queues are capped, RTC counts flow through snapshots and responses, permanent keys are preserved, and cleanup/user-key behavior is updated.
Torrent update queue and persistence
src/tracker/types/..., src/database/...
Torrent updates use a sharded InfoHash-keyed queue, while flushing and database connectors operate on borrowed maps.

Protocol responses

Layer / File(s) Summary
HTTP and WebSocket announce responses
src/http/http.rs, src/api/api.rs, src/websocket/websocket.rs
HTTP routes and RTC rejection are updated, proxy origin checks use explicit allowlists, and responses use aggregate RTC counts and peer-specific ports.
UDP authentication and proxy handling
src/udp/..., src/main.rs, tests/udp_tests.rs
Trusted proxy addresses are propagated through UDP startup, SPP parsing enforces source allowlists, and connection IDs and announce paths are validated.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main change: a release/version bump to v4.2.17.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v4.2.17

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/tracker/impls/torrent_tracker_keys.rs (1)

52-60: 🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Preserve persisted absolute key expiries during loading.

The database loaders pass stored expiries into add_key, but this method adds SystemTime::now() again. A persisted 0 becomes “expires now,” and any normal absolute expiry is extended by its epoch value. Add a separate absolute-expiry insertion path and use it from all database loaders; otherwise permanent and expired announce-key authorization is incorrect.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tracker/impls/torrent_tracker_keys.rs` around lines 52 - 60, Preserve
stored absolute expiry timestamps when loading announce keys. Keep add_key’s
timeout-relative behavior for callers that provide durations, add a separate
absolute-expiry insertion method with the same entry and statistics handling,
and update every database loader to use it for persisted expiries, including
zero and already-expired values.
🧹 Nitpick comments (1)
src/tracker/impls/torrent_tracker_peers.rs (1)

50-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

max_peers_per_torrent is enforced per map, not per torrent.

peer_cap() feeds enforce_peer_cap for each of the six maps independently (seeds, seeds_ipv6, peers, peers_ipv6, rtc_seeds, rtc_peers), so the actual worst-case per-torrent residency is 6 * max_peers_per_torrent. The internal doc says "per-map", but the config key is user-facing and reads as a torrent-wide bound — worth documenting in the config description so operators size it correctly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/tracker/impls/torrent_tracker_peers.rs` around lines 50 - 55, Update the
user-facing configuration description for max_peers_per_torrent to state that
the limit applies independently to each peer map, not to the torrent as a whole.
Document that the six maps used by enforce_peer_cap can result in up to six
times the configured value per torrent, while preserving the existing
0-means-unlimited semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/database/impls/query_builder.rs`:
- Around line 13-17: Update quote_identifier to quote PostgreSQL identifiers
instead of returning safe unquoted text: escape any embedded double quotes
according to PostgreSQL identifier rules and wrap the result in double quotes.
Preserve the existing backtick quoting for sqlite3 and mysql.

In `@src/http/http.rs`:
- Around line 863-869: Update configuration loading and validation for
trusted_proxies so enabling it with an empty trusted_proxy_addrs emits a clear
operator warning. Preserve the existing proxy handling behavior, including the
explicit allowlist check in the relevant remote-IP validation flow.

In `@src/security/security.rs`:
- Around line 127-129: Update validate_remote_ip to reject IPv6 unique-local
addresses in fc00::/7 and link-local addresses in fe80::/10 when validating
real_ip header claims, including when trusted_proxies is enabled with an empty
source allowlist. Preserve the existing loopback, unspecified, and IPv4
private-address validation behavior.

In `@src/tracker/impls/torrent_sharding.rs`:
- Around line 118-122: Update the cutoff handling in the peer-expiration logic
to compute BT and RTC cutoffs independently instead of returning when either
checked subtraction fails. Guard each corresponding peer comparison with its own
optional cutoff, and ensure the whole-torrent expired_full condition evaluates
false when the BT cutoff is unavailable.

In `@src/udp/impls/udp_server.rs`:
- Around line 58-60: Replace the ahash-based CONNECTION_ID_SECRET with a
cryptographic keyed PRF/MAC key, and update derive_connection_id to compute the
address-bound token using HMAC-SHA256 or keyed BLAKE3 before truncating to
ConnectionId. Preserve per-process regeneration and the existing connection-ID
input and output behavior.

---

Outside diff comments:
In `@src/tracker/impls/torrent_tracker_keys.rs`:
- Around line 52-60: Preserve stored absolute expiry timestamps when loading
announce keys. Keep add_key’s timeout-relative behavior for callers that provide
durations, add a separate absolute-expiry insertion method with the same entry
and statistics handling, and update every database loader to use it for
persisted expiries, including zero and already-expired values.

---

Nitpick comments:
In `@src/tracker/impls/torrent_tracker_peers.rs`:
- Around line 50-55: Update the user-facing configuration description for
max_peers_per_torrent to state that the limit applies independently to each peer
map, not to the torrent as a whole. Document that the six maps used by
enforce_peer_cap can result in up to six times the configured value per torrent,
while preserving the existing 0-means-unlimited semantics.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 58eb9ae2-5474-4a43-afdb-e4da7d60d225

📥 Commits

Reviewing files that changed from the base of the PR and between e83159a and 5407a2b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (46)
  • Cargo.toml
  • README.md
  • docker/Dockerfile
  • docker/build.bat
  • src/api/api.rs
  • src/common/common.rs
  • src/config/config.rs
  • src/config/impls/configuration.rs
  • src/config/structs/api_trackers_config.rs
  • src/config/structs/http_trackers_config.rs
  • src/config/structs/tracker_config.rs
  • src/config/structs/udp_trackers_config.rs
  • src/database/impls/database_connector.rs
  • src/database/impls/database_connector_mysql.rs
  • src/database/impls/database_connector_pgsql.rs
  • src/database/impls/database_connector_sqlite.rs
  • src/database/impls/query_builder.rs
  • src/database/traits/database_backend.rs
  • src/http/http.rs
  • src/main.rs
  • src/security/security.rs
  • src/security/tests.rs
  • src/tracker/impls/announce_entry.rs
  • src/tracker/impls/torrent_counts.rs
  • src/tracker/impls/torrent_sharding.rs
  • src/tracker/impls/torrent_tracker.rs
  • src/tracker/impls/torrent_tracker_handlers.rs
  • src/tracker/impls/torrent_tracker_keys.rs
  • src/tracker/impls/torrent_tracker_peers.rs
  • src/tracker/impls/torrent_tracker_rtctorrent.rs
  • src/tracker/impls/torrent_tracker_torrents.rs
  • src/tracker/impls/torrent_tracker_torrents_updates.rs
  • src/tracker/impls/torrent_tracker_users.rs
  • src/tracker/impls/torrent_update_data.rs
  • src/tracker/structs/torrent_counts.rs
  • src/tracker/types/torrents_updates.rs
  • src/udp/enums/server_error.rs
  • src/udp/impls/parse_pool.rs
  • src/udp/impls/udp_server.rs
  • src/udp/structs/udp_server.rs
  • src/udp/udp.rs
  • src/websocket/websocket.rs
  • tests/common/mod.rs
  • tests/config_tests.rs
  • tests/tracker_tests.rs
  • tests/udp_tests.rs

Comment thread src/database/impls/query_builder.rs Outdated
Comment thread src/http/http.rs
Comment thread src/security/security.rs Outdated
Comment thread src/tracker/impls/torrent_sharding.rs Outdated
Comment thread src/udp/impls/udp_server.rs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/database/impls/query_builder.rs (1)

30-35: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Use PostgreSQL escape literals or bound parameters.

text_literal() escapes quotes by doubling, but PostgreSQL ordinary string literals can interpret a backslash as escaping a doubled quote and \' escape sequence when standard_conforming_strings is off. For the PostgreSQL branch, emit E'...' and escape backslashes/quots consistently, or preferably bind values so sqlx keeps the literal out of client-side string concatenation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/database/impls/query_builder.rs` around lines 30 - 35, Update
QueryBuilder::text_literal for the PostgreSQL branch to avoid unsafe ordinary
string-literal escaping: preferably route values through bound parameters, or
emit an E-prefixed literal while escaping backslashes and single quotes
consistently. Preserve the existing MySQL and SQLite behavior unless required by
the chosen implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/database/impls/query_builder.rs`:
- Around line 30-35: Update QueryBuilder::text_literal for the PostgreSQL branch
to avoid unsafe ordinary string-literal escaping: preferably route values
through bound parameters, or emit an E-prefixed literal while escaping
backslashes and single quotes consistently. Preserve the existing MySQL and
SQLite behavior unless required by the chosen implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dc5e8634-96cf-4066-a748-cdabdf6337d4

📥 Commits

Reviewing files that changed from the base of the PR and between 5407a2b and f50c462.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (14)
  • Cargo.toml
  • src/config/impls/configuration.rs
  • src/config/structs/tracker_config.rs
  • src/database/database.rs
  • src/database/impls/database_connector_mysql.rs
  • src/database/impls/database_connector_pgsql.rs
  • src/database/impls/database_connector_sqlite.rs
  • src/database/impls/query_builder.rs
  • src/security/security.rs
  • src/security/tests.rs
  • src/tracker/impls/torrent_sharding.rs
  • src/tracker/impls/torrent_tracker_keys.rs
  • src/udp/impls/udp_server.rs
  • tests/tracker_tests.rs
🚧 Files skipped from review as they are similar to previous changes (8)
  • src/config/structs/tracker_config.rs
  • src/tracker/impls/torrent_sharding.rs
  • src/database/impls/database_connector_pgsql.rs
  • Cargo.toml
  • src/security/tests.rs
  • src/database/impls/database_connector_sqlite.rs
  • src/config/impls/configuration.rs
  • src/udp/impls/udp_server.rs

@Power2All
Power2All merged commit 988223b into master Jul 26, 2026
2 checks passed
@Power2All
Power2All deleted the v4.2.17 branch July 26, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant