Skip to content

feat(1671): add client address labels and ipv6_v6only config option - #1928

Merged
josecelano merged 9 commits into
torrust:developfrom
josecelano:1671-ipv4-ipv6-client-metrics
Jun 21, 2026
Merged

josecelano merged 9 commits into
torrust:developfrom
josecelano:1671-ipv4-ipv6-client-metrics

Conversation

@josecelano

@josecelano josecelano commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

Description

Implements #1671 — IPv4/IPv6 client metrics: support per-client IP family labels and separate socket bindings.

Changes

Task 1 — Investigate separate socket bindings:

  • Ran dual-stack experiment locally (contrib/dev-tools/experiments/dual-stack-sockets/)
  • Confirmed IPV6_V6ONLY=1 via socket2 allows 0.0.0.0:<port> + [::]:<port> on same port

Task 2 — Client address labels (primary fix for prometheus metrics):

  • Added client_address_ip_family label (inet/inet6) to all per-request metric counters
  • Added client_address_ip_type label (plain/v4_mapped_v6) to all per-request metric counters
  • Implemented on UDP server, UDP core, and HTTP core ConnectionContext types
  • Added unit tests for label derivation in all three packages

Task 3 — ipv6_v6only config option:

  • Added ipv6_v6only: bool field to UdpTracker and HttpTracker config structs (default false, preserving dual-stack behaviour)
  • Conditionally sets IPV6_V6ONLY socket option only when config is true
  • Updated experiment config, examples, and test helpers
  • Integration tests in both UDP and HTTP server contract tests

Also added:

  • ADR docs/adrs/20260620000000_add_ipv6_v6only_config_option.md
  • Research doc on cross-platform dual-stack behaviour
  • Expanded connection cookie security documentation

Checklist

  • linter all passes
  • Relevant tests pass (270+ across all affected packages)
  • Manual verification executed and recorded
  • Acceptance criteria reviewed after implementation
  • Integration tests for ipv6_v6only config propagation (both UDP and HTTP)

Related

@josecelano josecelano self-assigned this Jun 20, 2026
- Clarify that fingerprint is arithmetic mixing, not cryptographic MAC
- Document scope of gen_remote_fingerprint (full SocketAddr)
- Quantify probability of successful forgery (~1 in 4M per guess)
- Add test for cross-client cookie rejection with realistic addresses
…g option

- Add ADR documenting the decision to use a config toggle
- Update ISSUE.md spec with Task 3 (config option)
- Add research-dual-stack-portability.md with cross-platform analysis
- Add dictionary words for new technical terminology
- Add ipv6_v6only bool field to UdpTracker and HttpTracker (default false)
- Conditionally set IPV6_V6ONLY socket option only when config is true
- Update experiment config and examples with new field
- Add client address labels to per-request metric counters
@josecelano
josecelano force-pushed the 1671-ipv4-ipv6-client-metrics branch from fefac46 to 2efd3d4 Compare June 20, 2026 19:50
@codecov

codecov Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.96386% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.42%. Comparing base (7a62b2e) to head (50da16b).

Files with missing lines Patch % Lines
packages/udp-server/src/server/bound_socket.rs 53.33% 0 Missing and 7 partials ⚠️
packages/axum-http-server/src/server.rs 61.53% 0 Missing and 5 partials ⚠️
packages/configuration/src/v2_0_0/http_tracker.rs 75.00% 1 Missing ⚠️
packages/configuration/src/v2_0_0/udp_tracker.rs 75.00% 1 Missing ⚠️
packages/udp-server/src/event.rs 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1928      +/-   ##
===========================================
+ Coverage    79.31%   79.42%   +0.10%     
===========================================
  Files          324      324              
  Lines        22963    23116     +153     
  Branches     22963    23116     +153     
===========================================
+ Hits         18214    18360     +146     
+ Misses        4486     4479       -7     
- Partials       263      277      +14     

☔ 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.

Verifies that a UDP tracker configured with ipv6_v6only=true on an IPv6
socket accepts native IPv6 client connections.
…socket

Verifies that an HTTP tracker configured with ipv6_v6only=true on an IPv6
socket accepts native IPv6 client connections.
@josecelano
josecelano marked this pull request as ready for review June 20, 2026 20:53
Copilot AI review requested due to automatic review settings June 20, 2026 20:53

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

Implements #1671 by extending tracker request metrics with client IP family/type labels and introducing an ipv6_v6only configuration option to control IPv6 socket binding behavior (to support separate IPv4/IPv6 sockets on the same port), alongside docs/ADR updates and test coverage.

Changes:

  • Add client_address_ip_family (inet/inet6) and client_address_ip_type (plain/v4_mapped_v6) labels via ConnectionContext → LabelSet across UDP server/core and HTTP core.
  • Add ipv6_v6only: bool to UDP/HTTP tracker config and plumb it into UDP/TCP socket creation via socket2.
  • Add/extend integration tests, unit tests, experiments, and documentation (issue spec, research doc, ADR, cspell dictionary).

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
src/bootstrap/jobs/http_tracker.rs Passes ipv6_v6only into the HTTP server launcher.
project-words.txt Adds networking/OS terms to cspell dictionary.
packages/udp-server/tests/server/contract.rs Adds UDP integration test covering ipv6_v6only on IPv6 binds.
packages/udp-server/src/server/launcher.rs Wires ipv6_v6only into UDP socket construction.
packages/udp-server/src/server/bound_socket.rs Switches UDP socket binding to socket2 to support IPV6_V6ONLY.
packages/udp-server/src/event.rs Adds client address labels to UDP server event label set.
packages/udp-server/examples/udp_only_public_tracker.rs Updates example config with new ipv6_v6only field.
packages/udp-server/Cargo.toml Adds socket2 dependency for UDP server.
packages/udp-core/src/event.rs Adds client address label helpers + unit tests for label derivation.
packages/udp-core/src/connection_cookie.rs Expands cookie/fingerprint security documentation and adds a realism-focused rejection test.
packages/test-helpers/src/configuration.rs Updates ephemeral test config to include ipv6_v6only.
packages/http-core/src/event.rs Adds client address labels to HTTP core event label set + unit tests.
packages/configuration/src/v2_0_0/udp_tracker.rs Adds ipv6_v6only to UDP tracker config schema.
packages/configuration/src/v2_0_0/http_tracker.rs Adds ipv6_v6only to HTTP tracker config schema.
packages/axum-http-server/tests/server/v1/contract.rs Adds HTTP integration test covering ipv6_v6only on IPv6 binds.
packages/axum-http-server/src/testing/environment.rs Plumbs ipv6_v6only into test server launcher creation.
packages/axum-http-server/src/server.rs Switches TCP listener creation to socket2 to support IPV6_V6ONLY.
packages/axum-http-server/examples/http_only_public_tracker.rs Updates example config with new ipv6_v6only field.
packages/axum-http-server/Cargo.toml Adds socket2 dependency for HTTP server.
docs/issues/open/1671-ipv4-ipv6-client-metrics/research-dual-stack-portability.md Adds cross-platform research on IPV6_V6ONLY defaults and implications.
docs/issues/open/1671-ipv4-ipv6-client-metrics/ISSUE.md Adds issue spec document (scope, plan, acceptance criteria, verification).
docs/adrs/index.md Adds ADR index entry for the ipv6_v6only decision.
docs/adrs/20260620000000_add_ipv6_v6only_config_option.md New ADR documenting why ipv6_v6only is configurable and defaults remain unchanged.
contrib/dev-tools/experiments/dual-stack-sockets/README.md New experiment doc showing dual-bind feasibility and metrics label validation.
contrib/dev-tools/experiments/dual-stack-sockets/config/tracker.dual-stack.toml Adds experiment config using two sockets per protocol and ipv6_v6only.
Cargo.lock Records dependency resolution updates (includes socket2).

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

Comment thread project-words.txt Resolved
Comment thread packages/udp-core/src/event.rs Resolved
Comment thread packages/http-core/src/event.rs Resolved
- Fix project-words.txt alphabetical order
- Update issue spec paths and Task 1 scope
- Correct OpenBSD platform note (no-op, not runtime error)
- Fix typo in bound_socket.rs
- Fix OpenBSD notes in research doc (no-op, not runtime error)
- Remove stale "next steps" from experiment README (config option implemented)
…Y behaviour

Add platform table to create_socket/create_tcp_listener docs explaining
how each OS handles IPV6_V6ONLY by default. Only call set_only_v6 when
ipv6_v6only is true (avoids EINVAL on OpenBSD).
@josecelano

Copy link
Copy Markdown
Member Author

ACK 50da16b

@josecelano
josecelano merged commit 470f2f7 into torrust:develop Jun 21, 2026
17 checks passed

This branch was previously deployed

1 inactive deployment
coverage — 50da16ba Deployed Jun 21, 2026 by josecelano via Generate Coverage Report #1461
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.

IPv4/IPv6 client metrics: support per-client IP family labels and separate socket bindings

2 participants