Skip to content

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

@josecelano

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.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions