Skip to content

Commit

Permalink
Merge pull request #294 from ikatson/prepare-v8.0.0
Browse files Browse the repository at this point in the history
Prepare v8.0.0
  • Loading branch information
ikatson authored Jan 6, 2025
2 parents b9f949c + 7a6a751 commit a2cbf16
Show file tree
Hide file tree
Showing 15 changed files with 856 additions and 1,077 deletions.
972 changes: 405 additions & 567 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions crates/bencode/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "librqbit-bencode"
version = "3.0.1"
version = "3.0.2"
edition = "2021"
description = "Bencode serialization and deserialization using Serde"
license = "Apache-2.0"
Expand All @@ -16,8 +16,8 @@ sha1-ring = ["sha1w/sha1-ring"]

[dependencies]
serde = { version = "1", features = ["derive"] }
buffers = { path = "../buffers", package = "librqbit-buffers", version = "4" }
buffers = { path = "../buffers", package = "librqbit-buffers", version = "4.2" }
clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" }
anyhow = "1"
sha1w = { path = "../sha1w", default-features = false, optional = true, package = "librqbit-sha1-wrapper", version = "4" }
sha1w = { path = "../sha1w", default-features = false, optional = true, package = "librqbit-sha1-wrapper", version = "4.1" }
bytes = "1.7.1"
2 changes: 1 addition & 1 deletion crates/buffers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "librqbit-buffers"
version = "4.1.0"
version = "4.2.0"
edition = "2021"
description = "Utils to work with &[u8] and Vec<u8> in librqbit source code."
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions crates/dht/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "librqbit-dht"
version = "5.1.0"
version = "5.2.0"
edition = "2021"
description = "DHT implementation, used in rqbit torrent client."
license = "Apache-2.0"
Expand Down Expand Up @@ -32,7 +32,7 @@ rand = "0.8"
indexmap = "2"
dashmap = { version = "6", features = ["serde"] }
clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" }
librqbit-core = { path = "../librqbit_core", default-features = false, version = "4" }
librqbit-core = { path = "../librqbit_core", default-features = false, version = "4.1" }
chrono = { version = "0.4.31", features = ["serde"] }
tokio-util = "0.7.10"
bytes = "1.7.1"
Expand Down
36 changes: 20 additions & 16 deletions crates/librqbit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "librqbit"
version = "7.1.0-beta.1"
version = "8.0.0"
authors = ["Igor Katson <[email protected]>"]
edition = "2021"
description = "The main library used by rqbit torrent client. The binary is just a small wrapper on top of it."
Expand Down Expand Up @@ -34,43 +34,47 @@ rust-tls = [
storage_middleware = ["lru"]
storage_examples = []
tracing-subscriber-utils = ["tracing-subscriber"]
postgres = ["sqlx"]
postgres = ["sqlx", "home"]
async-bt = ["async-backtrace"]
watch = ["notify"]
disable-upload = []

[dependencies]
sqlx = { version = "0.8.2", features = [
# sqlx and home are pinned so that we can compile on older Rusts
sqlx = { version = "=0.8.2", features = [
"runtime-tokio",
"macros",
"postgres",
], optional = true }
], default-features = false, optional = true }
home = { version = "=0.5.5", optional = true }

bencode = { path = "../bencode", default-features = false, package = "librqbit-bencode", version = "3" }
tracker_comms = { path = "../tracker_comms", default-features = false, package = "librqbit-tracker-comms", version = "2" }
buffers = { path = "../buffers", package = "librqbit-buffers", version = "4.1" }
librqbit-core = { path = "../librqbit_core", default-features = false, version = "4" }
tracker_comms = { path = "../tracker_comms", default-features = false, package = "librqbit-tracker-comms", version = "2.1" }
buffers = { path = "../buffers", package = "librqbit-buffers", version = "4.2" }
librqbit-core = { path = "../librqbit_core", default-features = false, version = "4.1" }
clone_to_owned = { path = "../clone_to_owned", package = "librqbit-clone-to-owned", version = "3" }
peer_binary_protocol = { path = "../peer_binary_protocol", default-features = false, package = "librqbit-peer-protocol", version = "4.1" }
sha1w = { path = "../sha1w", default-features = false, package = "librqbit-sha1-wrapper", version = "4" }
dht = { path = "../dht", package = "librqbit-dht", version = "5.1.0" }
librqbit-upnp = { path = "../upnp", version = "0.1.1" }
upnp-serve = { path = "../upnp-serve", package = "librqbit-upnp-serve", default-features = false, version = "0.1.0", optional = true }
sha1w = { path = "../sha1w", default-features = false, package = "librqbit-sha1-wrapper", version = "4.1" }
dht = { path = "../dht", package = "librqbit-dht", version = "5.2.0" }
librqbit-upnp = { path = "../upnp", version = "1" }
upnp-serve = { path = "../upnp-serve", package = "librqbit-upnp-serve", default-features = false, version = "1", optional = true }

tokio = { version = "1", features = [
"macros",
"rt-multi-thread",
"fs",
"io-util",
] }
governor = "0.7"
governor = "0.8"
console-subscriber = { version = "0.4", optional = true }
axum = { version = "0.7", optional = true }
tower-http = { version = "0.5", features = ["cors", "trace"], optional = true }
axum = { version = "0.8", optional = true }
tower-http = { version = "0.6", features = ["cors", "trace"], optional = true }
tokio-stream = "0.1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_urlencoded = "0.7"
anyhow = "1"
itertools = "0.13"
itertools = "0.14"
http = "1"
regex = "1"
reqwest = { version = "0.12", default-features = false, features = [
Expand Down Expand Up @@ -109,7 +113,7 @@ mime_guess = { version = "2.0.5", default-features = false }
tokio-socks = "0.5.2"
async-trait = "0.1.81"
async-backtrace = { version = "0.2", optional = true }
notify = { version = "6.1.1", optional = true }
notify = { version = "7", optional = true }
walkdir = "2.5.0"
arc-swap = "1.7.1"

Expand Down
44 changes: 26 additions & 18 deletions crates/librqbit/src/http_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use serde::{Deserialize, Serialize};
use std::io::SeekFrom;
use std::net::SocketAddr;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
use tokio::io::AsyncSeekExt;
use tokio::net::TcpListener;
Expand Down Expand Up @@ -94,7 +95,6 @@ mod timeout {

pub struct Timeout<const DEFAULT_MS: usize, const MAX_MS: usize>(pub Duration);

#[async_trait::async_trait]
impl<S, const DEFAULT_MS: usize, const MAX_MS: usize> axum::extract::FromRequestParts<S>
for Timeout<DEFAULT_MS, MAX_MS>
where
Expand Down Expand Up @@ -456,12 +456,20 @@ impl HttpApi {
state.api_peer_stats(idx, filter).map(axum::Json)
}

#[derive(Deserialize)]
struct StreamPathParams {
id: TorrentIdOrHash,
file_id: usize,
#[serde(rename = "filename")]
_filename: Option<Arc<str>>,
}

async fn torrent_stream_file(
State(state): State<ApiState>,
Path((idx, file_id)): Path<(TorrentIdOrHash, usize)>,
Path(StreamPathParams { id, file_id, .. }): Path<StreamPathParams>,
headers: http::HeaderMap,
) -> Result<impl IntoResponse> {
let mut stream = state.api_stream(idx, file_id)?;
let mut stream = state.api_stream(id, file_id)?;
let mut status = StatusCode::OK;
let mut output_headers = HeaderMap::new();
output_headers.insert("Accept-Ranges", HeaderValue::from_static("bytes"));
Expand Down Expand Up @@ -489,15 +497,15 @@ impl HttpApi {
);
}

if let Ok(mime) = state.torrent_file_mime_type(idx, file_id) {
if let Ok(mime) = state.torrent_file_mime_type(id, file_id) {
output_headers.insert(
http::header::CONTENT_TYPE,
HeaderValue::from_str(mime).context("bug - invalid MIME")?,
);
}

let range_header = headers.get(http::header::RANGE);
trace!(torrent_id=%idx, file_id=file_id, range=?range_header, "request for HTTP stream");
trace!(torrent_id=%id, file_id=file_id, range=?range_header, "request for HTTP stream");

if let Some(range) = range_header {
let offset: Option<u64> = range
Expand Down Expand Up @@ -619,30 +627,30 @@ impl HttpApi {
.route("/dht/table", get(dht_table))
.route("/stats", get(session_stats))
.route("/torrents", get(torrents_list))
.route("/torrents/:id", get(torrent_details))
.route("/torrents/:id/haves", get(torrent_haves))
.route("/torrents/:id/stats", get(torrent_stats_v0))
.route("/torrents/:id/stats/v1", get(torrent_stats_v1))
.route("/torrents/:id/peer_stats", get(peer_stats))
.route("/torrents/:id/stream/:file_id", get(torrent_stream_file))
.route("/torrents/:id/playlist", get(torrent_playlist))
.route("/torrents/{id}", get(torrent_details))
.route("/torrents/{id}/haves", get(torrent_haves))
.route("/torrents/{id}/stats", get(torrent_stats_v0))
.route("/torrents/{id}/stats/v1", get(torrent_stats_v1))
.route("/torrents/{id}/peer_stats", get(peer_stats))
.route("/torrents/{id}/playlist", get(torrent_playlist))
.route("/torrents/playlist", get(global_playlist))
.route("/torrents/resolve_magnet", post(resolve_magnet))
.route("/torrents/{id}/stream/{file_id}", get(torrent_stream_file))
.route(
"/torrents/:id/stream/:file_id/*filename",
"/torrents/{id}/stream/{file_id}/{*filename}",
get(torrent_stream_file),
);

if !self.opts.read_only {
app = app
.route("/torrents", post(torrents_post))
.route("/torrents/limits", post(update_session_ratelimits))
.route("/torrents/:id/pause", post(torrent_action_pause))
.route("/torrents/:id/start", post(torrent_action_start))
.route("/torrents/:id/forget", post(torrent_action_forget))
.route("/torrents/:id/delete", post(torrent_action_delete))
.route("/torrents/{id}/pause", post(torrent_action_pause))
.route("/torrents/{id}/start", post(torrent_action_start))
.route("/torrents/{id}/forget", post(torrent_action_forget))
.route("/torrents/{id}/delete", post(torrent_action_delete))
.route(
"/torrents/:id/update_only_files",
"/torrents/{id}/update_only_files",
post(torrent_action_update_only_files),
);
}
Expand Down
8 changes: 2 additions & 6 deletions crates/librqbit/src/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ use tracing::{error, error_span, info, Instrument};
use crate::{
create_torrent,
tests::test_util::{
create_default_random_dir_with_torrents, setup_test_logging, spawn_debug_server,
wait_until_i_am_the_last_task, DropChecks, TestPeerMetadata,
create_default_random_dir_with_torrents, setup_test_logging, wait_until_i_am_the_last_task,
DropChecks, TestPeerMetadata,
},
AddTorrentOptions, AddTorrentResponse, Session, SessionOptions, SessionPersistenceConfig,
};

#[tokio::test(flavor = "multi_thread", worker_threads = 64)]
async fn test_e2e_download() {
let dbg_srv = spawn_debug_server();

let timeout = std::env::var("E2E_TIMEOUT")
.ok()
.and_then(|v| v.parse().ok())
Expand All @@ -39,8 +37,6 @@ async fn test_e2e_download() {
.context("test_e2e_download timed out")
.unwrap();

dbg_srv.abort();

// Wait to ensure everything is dropped.
wait_until_i_am_the_last_task().await.unwrap();

Expand Down
Loading

0 comments on commit a2cbf16

Please sign in to comment.