Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracker Checker: Support different types of tracker addresses #675

Closed
Tracked by #669
josecelano opened this issue Feb 2, 2024 · 0 comments · Fixed by #1041
Closed
Tracked by #669

Tracker Checker: Support different types of tracker addresses #675

josecelano opened this issue Feb 2, 2024 · 0 comments · Fixed by #1041
Assignees
Labels
- Admin - Enjoyable to Install and Setup our Software - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat Enhancement / Feature Request Something New Testing Checking Torrust
Milestone

Comments

@josecelano
Copy link
Member

josecelano commented Feb 2, 2024

Parent issue: #669

Currently, you can run the Tracker Checker with this input:

TORRUST_CHECKER_CONFIG='{
    "udp_trackers": ["144.126.245.19:6969"],
    "http_trackers": ["https://tracker.torrust-demo.com"],
    "health_checks": ["https://tracker.torrust-demo.com/health_check"]
}' cargo run --bin tracker_checker

And with some restrictions.

  • URLs for UDP trackers must be a socket address: 144.126.245.19:6969 without the scheme.
  • URLs for HTTP trackers must be:
    • http://domain:port
    • https://domain:port
    • You cannot include the / or the /announce at the end.
  • URLs for health checks have no restrictions. It has to be a valid URL (GET endpoint).

We should be more flexible and allow these input formats:

UDP URL

Valid:

  • 11.22.33.44
  • 11.22.33.44:6969
  • 11.22.33.44:6969/
  • udp://11.22.33.44:6969
  • udp://11.22.33.44:6969/

Also valid but the Tracker Checker makes scrape request too:

  • 11.22.33.44:6969/announce
  • udp://11.22.33.44:6969/announce

HTTP URL

Invalid:

  • tracker.torrust-demo
  • tracker.torrust-demo:6969
  • tracker.torrust-demo:6969/
    • tracker.torrust-demo:6969/announce

NOTICE: The scheme must be specified. HTTP tracker can be running on HTTP to HTTPs.

Valid:

  • http://tracker.torrust-demo:6969
  • http://tracker.torrust-demo:6969/
  • https://tracker.torrust-demo:6969
  • https://tracker.torrust-demo:6969/

Also valid but the Tracker Checker makes scrape request too:

  • http://tracker.torrust-demo:6969/announce
  • https://tracker.torrust-demo:6969/announce

NOTES

We allow the suffix announce because it's very common to get tracker lists with that suffix.

See #650

We should normalize the URL and internally store the canonical one (full URL without path):

  • http://[domain|ip][:port]
  • https://[domain|ip][:port]
  • udp://[domain|ip][:port]

Notice that it might be necessary to resolve the domain to an IP with DNS for the UDP tracker in order to make the request because the UdpClient does not accept a URL:

#[allow(clippy::module_name_repetitions)]
#[derive(Debug)]
pub struct UdpClient {
    /// The socket to connect to
    pub socket: Arc<UdpSocket>,

    /// Timeout for sending and receiving packets
    pub timeout: Duration,
}

It only accepts a socket address. Example:

use std::net::ToSocketAddrs;

fn main() -> std::io::Result<()> {
    let addresses = "example.com:80".to_socket_addrs()?;
    for addr in addresses {
        println!("{}", addr);
    }
    Ok(())
}

Finally, we should support URLs for UDP trackers because they could have dynamic IPs.

@josecelano josecelano added Enhancement / Feature Request Something New Code Cleanup / Refactoring Tidying and Making Neat - Developer - Torrust Improvement Experience - Admin - Enjoyable to Install and Setup our Software Testing Checking Torrust labels Feb 2, 2024
@josecelano josecelano added this to the v3.1.0 milestone Feb 2, 2024
@josecelano josecelano mentioned this issue Feb 2, 2024
21 tasks
@josecelano josecelano self-assigned this Sep 11, 2024
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Sep 12, 2024
…mats

All the following URL for UDP trackers are allow now:

```console
TORRUST_CHECKER_CONFIG='{
    "udp_trackers": [
	"127.0.0.1:6969",
	"127.0.0.1:6969/",
	"127.0.0.1:6969/announce",
	"localhost:6969",
	"localhost:6969/",
	"localhost:6969/announce",
	"udp://127.0.0.1:6969",
	"udp://127.0.0.1:6969/",
	"udp://127.0.0.1:6969/announce",
	"udp://localhost:6969",
	"udp://localhost:6969/",
	"udp://localhost:6969/announce"
    ],
    "http_trackers": [],
    "health_checks": []
}' cargo run --bin tracker_checker
```

NOTICE: the client will resolve the domain to a socket address if
needed.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Sep 12, 2024
…mats

All the following URL for UDP trackers are allow now:

```console
TORRUST_CHECKER_CONFIG='{
    "udp_trackers": [
	"127.0.0.1:6969",
	"127.0.0.1:6969/",
	"127.0.0.1:6969/announce",
	"localhost:6969",
	"localhost:6969/",
	"localhost:6969/announce",
	"udp://127.0.0.1:6969",
	"udp://127.0.0.1:6969/",
	"udp://127.0.0.1:6969/announce",
	"udp://localhost:6969",
	"udp://localhost:6969/",
	"udp://localhost:6969/announce"
    ],
    "http_trackers": [],
    "health_checks": []
}' cargo run --bin tracker_checker
```

NOTICE: the client will resolve the domain to a socket address if
needed.
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Sep 12, 2024
…ice address formats

Now it supports a path prefix. It will be remove by the client to build
the "scrape" URLs.

This type of URL is very common in tracker lists like in
https://newtrackon.com/.

```console
TORRUST_CHECKER_CONFIG='{
    "udp_trackers": [],
    "http_trackers": [
	"http://127.0.0.1:7070",
	"http://127.0.0.1:7070/",
	"http://127.0.0.1:7070/announce"
    ],
    "health_checks": []
}' cargo run --bin tracker_checker
```
@josecelano josecelano linked a pull request Sep 12, 2024 that will close this issue
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Sep 12, 2024
…ice address formats

Now it supports a path prefix. It will be remove by the client to build
the "scrape" URLs.

This type of URL is very common in tracker lists like in
https://newtrackon.com/.

```console
TORRUST_CHECKER_CONFIG='{
    "udp_trackers": [],
    "http_trackers": [
	"http://127.0.0.1:7070",
	"http://127.0.0.1:7070/",
	"http://127.0.0.1:7070/announce"
    ],
    "health_checks": []
}' cargo run --bin tracker_checker
```
josecelano added a commit that referenced this issue Sep 12, 2024
faee02f feat: [#675] tracker checker (HTTP tracker) supports more service address formats (Jose Celano)
520026d feat: [#675] tracker checker supports more service address formats (Jose Celano)

Pull request description:

  ### UDP Trackers

  All the following URLs for UDP trackers are now allowed:

  ```console
  TORRUST_CHECKER_CONFIG='{
      "udp_trackers": [
  "127.0.0.1:6969",
  "127.0.0.1:6969/",
  "127.0.0.1:6969/announce",
  "localhost:6969",
  "localhost:6969/",
  "localhost:6969/announce",
  "udp://127.0.0.1:6969",
  "udp://127.0.0.1:6969/",
  "udp://127.0.0.1:6969/announce",
  "udp://localhost:6969",
  "udp://localhost:6969/",
  "udp://localhost:6969/announce"
      ],
      "http_trackers": [],
      "health_checks": []
  }' cargo run --bin tracker_checker
  ```

  **NOTICE:** the client will resolve the domain to an IP address if it's needed.

  ### HTTP Trackers

    Now, it supports a path suffix (`/` or `/announce`). It will be removed by the client to build
    the "scrape" URLs.

    This type of URL is widespread in tracker lists like https://newtrackon.com/.

    ```console
    TORRUST_CHECKER_CONFIG='{
        "udp_trackers": [],
        "http_trackers": [
            "http://127.0.0.1:7070",
            "http://127.0.0.1:7070/",
            "http://127.0.0.1:7070/announce"
        ],
        "health_checks": []
    }' cargo run --bin tracker_checker
    ```

ACKs for top commit:
  josecelano:
    ACK faee02f

Tree-SHA512: 16f7ada07fc863b03fa40073c020b377188958e53f92a9ef49a81a1d565ab7e55ca6654fa71cf54dde770f85201e72ef08858e14491531ab39381c0c707f1b6f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Admin - Enjoyable to Install and Setup our Software - Developer - Torrust Improvement Experience Code Cleanup / Refactoring Tidying and Making Neat Enhancement / Feature Request Something New Testing Checking Torrust
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant