-
Notifications
You must be signed in to change notification settings - Fork 22
Fix missing tracker key in torrent #812
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
Fix missing tracker key in torrent #812
Conversation
c10b379
to
2090942
Compare
2090942
to
9fc18db
Compare
when the tracker URL doesn't have a trailing slash. For example, this tracker URL in the configuration: https://127.0.0.1:7070/announce produces this tracker URL in the torrent: https://127.0.0.1:7070/mCGfCr8nvixxA0h8B4iz0sT8V3FIQLi7 and it should produce: https://127.0.0.1:7070/announce/mCGfCr8nvixxA0h8B4iz0sT8V3FIQLi7
9fc18db
to
649565f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #812 +/- ##
===========================================
- Coverage 47.81% 47.21% -0.60%
===========================================
Files 111 111
Lines 8540 8014 -526
Branches 8540 8014 -526
===========================================
- Hits 4083 3784 -299
+ Misses 4319 4126 -193
+ Partials 138 104 -34 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5fa2055
to
d470f78
Compare
There is a test for this: mod downloading_a_torrent {
use regex::Regex;
use torrust_index::utils::parse_torrent::decode_torrent;
use torrust_index::web::api;
use url::Url;
use crate::common::client::Client;
use crate::e2e::environment::TestEnv;
use crate::e2e::web::api::v1::contexts::torrent::steps::upload_random_torrent_to_index;
use crate::e2e::web::api::v1::contexts::user::steps::new_logged_in_user;
#[tokio::test]
async fn it_should_include_the_tracker_key_when_the_tracker_is_running_in_private_mode() {
let mut env = TestEnv::new();
env.start(api::Version::V1).await;
if !env.provides_a_private_tracker() {
println!("test skipped. It requires a private tracker to be running.");
return;
}
let uploader = new_logged_in_user(&env).await;
let client = Client::authenticated(&env.server_socket_addr().unwrap(), &uploader.token);
// Upload
let (test_torrent, _torrent_listed_in_index) = upload_random_torrent_to_index(&uploader, &env).await;
// Download
let response = client.download_torrent(&test_torrent.file_info_hash()).await;
let torrent = decode_torrent(&response.bytes).expect("could not decode downloaded torrent");
let announce_url = Url::parse(&torrent.announce.unwrap()).unwrap();
let re = Regex::new(r"^http://tracker:7070/[a-zA-Z0-9]{32}$").unwrap(); // DevSkim: ignore DS137138
assert!(re.is_match(announce_url.as_ref()), "Invalid announce URL: '{announce_url}'.");
}
} But it does not include this case because the tracker URL is "http://tracker:7070" [tracker]
api_url = "http://tracker:1212"
listed = false
private = true
token = "MyAccessToken"
url = "http://tracker:7070" I will open a new issue for this; it seems the tracker configuration is wrong. It should be "http://tracker:7070/announce". The test is passing because we don't interact with the tracker in the test. We need to add another test to retrieve the information from the tracker using the provided URL. cc @da2ce7 |
d470f78
to
17aecf9
Compare
ACK 17aecf9 |
Fix missing tracker key in torrent when the tracker URL doesn't have a trailing slash. For example, this tracker URL in the configuration:
https://127.0.0.1:7070/announce
produces this tracker URL in the torrent:
https://127.0.0.1:7070/mCGfCr8nvixxA0h8B4iz0sT8V3FIQLi7
and it should produce:
https://127.0.0.1:7070/announce/mCGfCr8nvixxA0h8B4iz0sT8V3FIQLi7