refactor(udp-core, udp-server, udp-protocol, tracker-client): consolidate duplicate UDP types (#1966) - #1991
Merged
josecelano merged 3 commits intoJul 16, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR consolidates previously duplicated UDP types/constants across the workspace to reduce drift and keep UDP packages aligned with the intended architecture (protocol vs domain separation), per #1966.
Changes:
- Consolidated
ConnectionContextintoudp-core(with private fields + accessors) and updated alludp-serverimports accordingly. - Moved
MAX_PACKET_SIZEintoudp-protocoland removed redundant constants fromudp-serverandtracker-client(and removed deadPROTOCOL_ID). - Added ADR cross-references (
adr:comments) to the intentionally duplicated boundary types across protocol/domain crates.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/udp-server/tests/server/contract.rs | Switches MAX_PACKET_SIZE import to udp-protocol. |
| packages/udp-server/src/statistics/event/handler/response_sent.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/statistics/event/handler/request_received.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/statistics/event/handler/request_banned.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/statistics/event/handler/request_accepted.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/statistics/event/handler/request_aborted.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/statistics/event/handler/error.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/server/receiver.rs | Imports MAX_PACKET_SIZE from udp-protocol; adjusts RawRequest import. |
| packages/udp-server/src/server/processor.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/server/mod.rs | Removes unused RawRequest import. |
| packages/udp-server/src/server/launcher.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/lib.rs | Removes MAX_PACKET_SIZE constant from udp-server. |
| packages/udp-server/src/handlers/scrape.rs | Uses udp-core::ConnectionContext instead of udp-server local type (incl. tests). |
| packages/udp-server/src/handlers/error.rs | Uses udp-core::ConnectionContext instead of udp-server local type. |
| packages/udp-server/src/handlers/connect.rs | Uses udp-core::ConnectionContext instead of udp-server local type (incl. tests). |
| packages/udp-server/src/handlers/announce.rs | Uses udp-core::ConnectionContext instead of udp-server local type (incl. tests). |
| packages/udp-server/src/event.rs | Removes duplicated ConnectionContext and imports it from udp-core. |
| packages/udp-protocol/src/common.rs | Adds MAX_PACKET_SIZE and adds ADR note for protocol-local duplication. |
| packages/udp-core/src/event.rs | Makes ConnectionContext fields private while keeping the accessor API. |
| packages/tracker-client/src/udp/mod.rs | Removes duplicated MAX_PACKET_SIZE and dead PROTOCOL_ID. |
| packages/tracker-client/src/udp/client.rs | Imports MAX_PACKET_SIZE from udp-protocol instead of local constant. |
| packages/primitives/src/announce.rs | Adds ADR note explaining intentional domain/protocol duplication. |
| packages/http-protocol/src/v1/responses/scrape/data.rs | Adds ADR note explaining intentional domain/protocol duplication. |
| packages/http-protocol/src/v1/responses/announce/data.rs | Adds ADR note explaining intentional domain/protocol duplication. |
| packages/http-protocol/src/v1/requests/announce.rs | Adds ADR note explaining intentional domain/protocol duplication. |
| docs/issues/open/1966-1669-si-35-consolidate-duplicate-udp-types.md | Updates task/spec status and verification checklist to reflect completion/in-review. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
josecelano
added a commit
to josecelano/torrust-tracker
that referenced
this pull request
Jul 16, 2026
Set related-pr in frontmatter after PR creation.
josecelano
added a commit
to josecelano/torrust-tracker
that referenced
this pull request
Jul 16, 2026
…orrust#1991) The comment in udp-protocol/src/common.rs referenced 'bittorrent-primitives::InfoHash' which is a deprecated crate path. Updated to 'torrust_info_hash::InfoHash' as suggested by Copilot review. Also adds tracking documentation for the PR review process.
…date duplicate UDP types (torrust#1966) - Consolidate ConnectionContext into udp-core, import from udp-server - Move MAX_PACKET_SIZE to udp-protocol, import from consumers - Remove dead PROTOCOL_ID from tracker-client - Add adr: comments referencing protocol/domain decoupling ADR - Update issue spec with completed statuses
Set related-pr in frontmatter after PR creation.
…orrust#1991) The comment in udp-protocol/src/common.rs referenced 'bittorrent-primitives::InfoHash' which is a deprecated crate path. Updated to 'torrust_info_hash::InfoHash' as suggested by Copilot review. Also adds tracking documentation for the PR review process.
josecelano
force-pushed
the
1966-1669-si-35-consolidate-duplicate-udp-types
branch
from
July 16, 2026 13:20
a4d84f4 to
8265e01
Compare
Member
Author
|
ACK 8265e01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consolidates duplicate UDP type definitions across the workspace per the issue spec.
Changes
udp-core(private fields with accessors). Removed duplicate fromudp-server— all consumers now import fromtorrust_tracker_udp_core::event::ConnectionContext.udp-protocol/src/common.rs, imported by bothudp-serverandtracker-client.tracker-client(unused, confirmed via grep).// adr: docs/adrs/20260527175600_keep_protocol_and_domain_types_decoupled.mdto all 5 intentional duplication locations.clippy::doc_markdowninprimitives/src/announce.rs, removed unusedsuper::RawRequestimport inudp-server/src/server/mod.rs.Verification
linter all— exit code 0cargo test --workspace --all-targets— all passcargo machete— no new unused dependenciesConnectionContextorMAX_PACKET_SIZEdefinitions remainCloses #1966