Skip to content

feat(udp): add IP-ban cleanup configuration and job - #2029

Merged
josecelano merged 7 commits into
torrust:developfrom
josecelano:1453-ip-bans-reset-interval
Jul 24, 2026
Merged

feat(udp): add IP-ban cleanup configuration and job#2029
josecelano merged 7 commits into
torrust:developfrom
josecelano:1453-ip-bans-reset-interval

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

Adds the v3-only UDP tracker server IP-ban reset interval schema and removes duplicate cleanup tasks by registering one cancellation-managed application job for the shared BanService.

Verification

  • Pre-commit gate passed for each signed commit: dictionary formatting, cargo machete --with-metadata, cargo deny check bans, linter all, and cargo test --doc --workspace.
  • Pre-push gate passed: nightly formatting/checks/docs plus full stable workspace tests.
  • Manual M2 verification started two UDP listeners (127.0.0.1:16868, 127.0.0.1:16969) and observed exactly one Starting UDP IP-ban cleanup job log entry at the current 86400-second bootstrap default. Durable evidence: docs/issues/open/1453-1978-ip-bans-reset-interval-configurable/evidence/2026-07-24-manual-runtime-verification.md.

Closes #1453.

Copilot AI review requested due to automatic review settings July 24, 2026 16:39
@josecelano josecelano self-assigned this Jul 24, 2026

Copilot AI 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.

Pull request overview

Adds a v3-only [udp_tracker_server] configuration section to validate an IP-ban reset interval, and consolidates IP-ban cleanup into a single cancellation-managed application job (instead of one task per UDP listener). This fits into the configuration-overhaul EPIC work by introducing a typed v3 schema boundary while improving runtime job ownership/lifecycle.

Changes:

  • Introduces v3_0_0::udp_tracker_server::UdpTrackerServer plus validated scalar newtypes (IpBansResetIntervalInSecs, AtLeastU64) with a 1-hour minimum and 24-hour default.
  • Moves UDP IP-ban cleanup spawning out of the per-listener UDP launcher into a single JobManager-owned bootstrap job.
  • Adds ADR + documentation updates covering validation-layer boundaries and current application job ownership.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/bootstrap/jobs/udp_tracker_server.rs Adds the new cancellation-managed UDP IP-ban cleanup job and unit tests.
src/app.rs Registers the new udp_ban_cleanup job via JobManager during startup.
packages/udp-server/src/server/launcher.rs Removes per-UDP-listener ban cleanup task spawning.
packages/configuration/src/validator.rs Clarifies validator responsibility as cross-field consistency validation (not single-value invariants).
packages/configuration/src/v3_0_0/udp_tracker_server.rs Adds v3 UDP-tracker-server-wide config struct + typed interval validation.
packages/configuration/src/v3_0_0/types.rs Adds reusable validated scalar type(s) (AtLeastU64) for v3 schema invariants.
packages/configuration/src/v3_0_0/mod.rs Wires [udp_tracker_server] into the v3 root config, docs, and tests.
docs/issues/open/1980-1978-configuration-overhaul-final-cleanup.md Updates #1980 scope to include wiring the new v3 setting into runtime consumption later.
docs/issues/open/1978-configuration-overhaul-epic.md Updates EPIC status/notes to reflect staged delivery and the new job behavior.
docs/issues/open/1453-1978-ip-bans-reset-interval-configurable/ISSUE.md Adds the full issue spec in folder form, with staged-delivery boundary documented.
docs/issues/open/1453-1978-ip-bans-reset-interval-configurable/evidence/2026-07-24-manual-runtime-verification.md Adds durable manual runtime verification evidence for “only one cleanup job starts”.
docs/issues/open/1453-1978-ip-bans-reset-interval-configurable.md Removes the old single-file spec in favor of the folder-based spec.
docs/issues/open/1136-1978-configurable-udp-connection-id-validation-policy.md Updates references to the new #1453 spec location.
docs/index.md Adds docs/application-jobs.md to the documentation index.
docs/application-jobs.md Documents current background-job ownership/lifecycle behavior and #1453 as an example.
docs/adrs/index.md Registers the new ADR in the ADR index.
docs/adrs/20260723184019_separate_configuration_value_invariants_from_consistency_validation.md Adds ADR defining the validation-layer boundary (value invariants vs consistency validation vs runtime checks).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/bootstrap/jobs/udp_tracker_server.rs Outdated
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.20000% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.48%. Comparing base (3d98c36) to head (03c53f2).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/app.rs 69.23% 20 Missing ⚠️
src/bootstrap/jobs/udp_tracker_server.rs 80.00% 6 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2029      +/-   ##
===========================================
- Coverage    81.61%   81.48%   -0.13%     
===========================================
  Files          342      342              
  Lines        24337    24448     +111     
  Branches     24337    24448     +111     
===========================================
+ Hits         19862    19921      +59     
- Misses        4177     4231      +54     
+ Partials       298      296       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI review requested due to automatic review settings July 24, 2026 17:10

Copilot AI 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.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Jul 24, 2026
Previously the application checked `config.core.private` in multiple places
when starting individual UDP-related jobs:

- UDP listener launcher (start_the_udp_instances)
- Ban cleanup job launcher (should_start_ban_cleanup_job)

This was an indirect dependency. The real architectural policy is: start the
entire UDP service group when the tracker allows UDP instances to run.

Centralized `should_start_udp_tracker_services` in app.rs gates the complete
group:

- UDP listener instances
- UDP stats event listener
- UDP banning event listener
- Ban cleanup job

The policy function checks two conditions:

1. At least one UDP tracker is configured
2. The tracker is not in private mode

Moved condition tests from udp_tracker_server to app.rs module, since the
policy is now an application orchestration concern.

Updated docs/application-jobs.md and issue spec to reflect service-group gating.

This addresses the design concern raised in PR torrust#2029 review.

Issue: torrust#1453
Co-developed-with: @josecelano
PR: torrust#2029
Copilot AI review requested due to automatic review settings July 24, 2026 17:42
Previously the application checked `config.core.private` in multiple places
when starting individual UDP-related jobs:

- UDP listener launcher (start_the_udp_instances)
- Ban cleanup job launcher (should_start_ban_cleanup_job)

This was an indirect dependency. The real architectural policy is: start the
entire UDP service group when the tracker allows UDP instances to run.

Centralized `should_start_udp_tracker_services` in app.rs gates the complete
group:

- UDP listener instances
- UDP stats event listener
- UDP banning event listener
- Ban cleanup job

The policy function checks two conditions:

1. At least one UDP tracker is configured
2. The tracker is not in private mode

Moved condition tests from udp_tracker_server to app.rs module, since the
policy is now an application orchestration concern.

Updated docs/application-jobs.md and issue spec to reflect service-group gating.

This addresses the design concern raised in PR torrust#2029 review.

Issue: torrust#1453
Co-developed-with: @josecelano
PR: torrust#2029
@josecelano
josecelano force-pushed the 1453-ip-bans-reset-interval branch from 2806a5c to 03c53f2 Compare July 24, 2026 17:46

Copilot AI 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.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 24, 2026 17:46
@josecelano

Copy link
Copy Markdown
Member Author

ACK 03c53f2

Copilot AI 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.

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated no new comments.

@josecelano
josecelano merged commit 314a9e6 into torrust:develop Jul 24, 2026
17 of 18 checks passed
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.

Allow setting the IP bans reset interval via configuration and remove duplicate execution of cronjob to clean bans

2 participants