Skip to content

Make server listen URL available where server socket address is also available #1415

Description

@josecelano

We use the service socket addresses in many places (logs, events, etc.). However we are only using the server URL in few places like logging. When you start the tracker you can see something like:

2025-03-26T10:35:01.306728Z  INFO run_with_graceful_shutdown{cookie_lifetime=120s}: UDP TRACKER: Started on: udp://0.0.0.0:6868
2025-03-26T10:35:01.306818Z  INFO run_with_graceful_shutdown{cookie_lifetime=120s}: UDP TRACKER: Started on: udp://0.0.0.0:6969
2025-03-26T10:35:01.307005Z  INFO start: HTTP TRACKER: Started on: http://0.0.0.0:7070
2025-03-26T10:35:01.307072Z  INFO start: HTTP TRACKER: Started on: http://0.0.0.0:7171
2025-03-26T10:35:01.307247Z  INFO start: API: Started on http://0.0.0.0:1212
2025-03-26T10:35:01.307368Z  INFO start:start_job: HEALTH CHECK API: Started on: http://127.0.0.1:1313

We want to add the service URL in two new places:

  1. The information exposed via the health check API.
  2. The metrics.

We need to add the service URL whenever we are passing the service socket address. We need to store this:

  • udp://127.0.0.1:6969
  • http://127.0.0.1:7070/announce
  • https://127.0.0.1:7171/announce
  • http://127.0.0.1:1212
  • http://127.0.0.1:1313

Instead of just this:

  • 127.0.0.1:6969
  • 127.0.0.1:7070
  • 127.0.0.1:7171
  • 127.0.0.1:1212
  • 127.0.0.1:1313

We have to options:

Option 1

Replace the SocketAddr by Url

Pros:

  • More generic.
  • It will support more services running in new protocols.
  • We can use the URL directly when needed.

Cons:

  • We have to clone the SocketAddr from the Url when we only need that. However we are probably already doing that.

In the Tracker client we are already using a ServiceUrl which is a Url:

use reqwest::Url as ServiceUrl;

pub struct Configuration {
    pub udp_trackers: Vec<ServiceUrl>,
    pub http_trackers: Vec<ServiceUrl>,
    pub health_checks: Vec<ServiceUrl>,
}

Option 2

Just add the scheme argument together with SockerAddr

Cons:

  • More params in the function signatures.

I will implement option 1.

@nuts-rice, I think this is what is needed to finish the implementation of issue #1409. I'm working on this issue now.

cc @da2ce7

IMPORTANT

The tracker can run behind a reverse proxy so, the service public and internal URLs can be different. For example, in the tracker demo:

What I'm going to add in this issue is the last one: the internal service URL. It's the URL that the application can know.

For the public service URL, we would need to add it to the configuration.

The internal service URL could also be public is the tracker is not running behing a proxy.

I'm going to use the name internal_service_url.

Activity

  1. added
    - Developer -
    Code Cleanup / Refactoring
    on Mar 26, 2025
  2. self-assigned this
    on Mar 26, 2025
  3. added theissue type on Mar 26, 2025
  4. josecelano commented on Mar 26, 2025

    @josecelano
    MemberAuthor

    I've changed my mind regarding the name internal_service_url. I will use listen_url because the URL is not a URL a client would use to connect to the server. It's represents the server's listening address (protocol + binding), which is useful for debugging/config visibility but not for client connections.

    I mean the URL http://0.0.0.0:7070 is only used to know that the server is using HTTP on port 7070, but you don't know the IPs.

    I will include the listen_url in the issue #1409 and continue working on this issue make the listen_url value available also for metrics.

  5. changed the title [-]Add server URL together to server socket address[/-] [+]Make server listen URL available where server socket address is also available[/+] on Mar 26, 2025
  6. josecelano commented on Jul 15, 2026

    @josecelano
    MemberAuthor

    Spec update (2026-07-15)

    This issue has been incorporated into EPIC #1978 — Configuration Overhaul (schema v3.0.0) as subissue #5 of 9.

    Spec: docs/issues/open/1415-1978-use-service-binding-instead-of-socket-addr.md

    Scope change

    The original description proposed adding an internal_service_url (with URL path segments like /announce) and building full URLs like http://0.0.0.0:7070/announce. After further analysis, the scope has been narrowed:

    What this issue now does: Replace bare SocketAddr with the existing ServiceBinding type from torrust-net-primitives wherever service identity is used (logs, health check, metrics, events). ServiceBinding already carries both the protocol scheme and the socket address.

    What it does NOT do:

    • No URL path segments (e.g. /announce) — hardcoded per protocol, not useful for identity
    • No resolving bind address to a concrete IP — ServiceBinding carries the configured address as-is
    • No changes to torrust-net-primitives external crate — ServiceBinding is used as-is

    The public-facing URL (https://tracker.torrust-demo.com/announce) is handled by a separate issue #1417 (public_url config field).

    Relation to #1417

    This issue adds protocol context to the internal service binding. Issue #1417 adds the public URL to the configuration. They are complementary and independent.

    EPIC position: Independent — no config changes, no overlap. Can run in parallel with #1453, #1490, #889.

  7. added 3 commits that reference this issue on Jul 15, 2026
  8. changed the issue type fromtoon Jul 15, 2026
  9. added a commit that references this issue on Jul 22, 2026
    81a1e3e
  10. added a commit that references this issue on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

- Developer -Code Cleanup / Refactoring

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions