diff --git a/README.md b/README.md index 96134f77..9621f8c1 100644 --- a/README.md +++ b/README.md @@ -46,10 +46,10 @@ the table above. ## Copyright and license -Copyright (c) 2020-2023 Joakim Frostegård +Copyright (c) Joakim Frostegård -Distributed under the terms of the Apache 2.0 license. Please refer to the -`LICENSE` file in the repository root directory for details. +Distributed under the terms of the Apache License, Version 2.0. Please refer to +the `LICENSE` file in the repository root directory for details. ## Trivia diff --git a/crates/bencher/README.md b/crates/bencher/README.md index 70cc8a0a..224f638f 100644 --- a/crates/bencher/README.md +++ b/crates/bencher/README.md @@ -1,3 +1,11 @@ # aquatic_bencher -Automated benchmarking of aquatic and other BitTorrent trackers. Linux only. \ No newline at end of file +Automated benchmarking of aquatic and other BitTorrent trackers. Linux only. + +## Supported trackers by protocol + +### UDP + +- [aquatic_udp](https://github.com/greatest-ape/aquatic/) +- [opentracker](https://erdgeist.org/arts/software/opentracker/) +- [chihaya](https://github.com/chihaya/chihaya) \ No newline at end of file diff --git a/crates/bencher/src/set.rs b/crates/bencher/src/set.rs index 7ddeef2d..cae39df0 100644 --- a/crates/bencher/src/set.rs +++ b/crates/bencher/src/set.rs @@ -26,6 +26,7 @@ pub struct SetConfig { pub load_test_runs: Vec<(usize, Priority, TaskSetCpuList)>, } +#[allow(clippy::too_many_arguments)] pub fn run_sets( command: &C, cpu_mode: CpuMode, diff --git a/crates/http/README.md b/crates/http/README.md index 7895386f..36f8c4e3 100644 --- a/crates/http/README.md +++ b/crates/http/README.md @@ -24,11 +24,12 @@ More benchmark details are available [here](../../documents/aquatic-http-load-te ### Compiling - Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended) -- Install cmake with your package manager (e.g., `apt-get install cmake`) -- Clone this git repository and enter its root directory -- Build the application: +- Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`) +- Clone this git repository and build the application: ```sh +git clone https://github.com/greatest-ape/aquatic.git && cd aquatic + # Recommended: tell Rust to enable support for all SIMD extensions present on # current CPU except for those relating to AVX-512. (If you run a processor # that doesn't clock down when using AVX-512, you can enable those instructions @@ -51,7 +52,8 @@ Make necessary adjustments to the file. You will likely want to adjust `address` To run over TLS, configure certificate and private key files. -Running behind a reverse proxy is supported. +Running behind a reverse proxy is supported. Please refer to the config file +for details. ### Running @@ -83,7 +85,9 @@ configuration files in a similar manner to the tracker application. After starting the tracker, run the load tester: ```sh -./scripts/run-load-test-http.sh +. ./scripts/env-native-cpu-without-avx-512 # Optional + +cargo build --release -p aquatic_http_load_test -- --help ``` ## Details @@ -107,7 +111,7 @@ fine in production. ## Copyright and license -Copyright (c) 2020-2023 Joakim Frostegård +Copyright (c) Joakim Frostegård -Distributed under the terms of the Apache 2.0 license. Please refer to the -`LICENSE` file in the repository root directory for details. +Distributed under the terms of the Apache License, Version 2.0. Please refer to +the `LICENSE` file in the repository root directory for details. diff --git a/crates/http/src/workers/swarm/storage.rs b/crates/http/src/workers/swarm/storage.rs index eab15be1..a6419fc1 100644 --- a/crates/http/src/workers/swarm/storage.rs +++ b/crates/http/src/workers/swarm/storage.rs @@ -99,6 +99,7 @@ impl TorrentMaps { } } + #[cfg(feature = "metrics")] pub fn update_torrent_metrics(&self) { self.ipv4.torrent_gauge.set(self.ipv4.torrents.len() as f64); self.ipv6.torrent_gauge.set(self.ipv6.torrents.len() as f64); diff --git a/crates/http_protocol/Cargo.toml b/crates/http_protocol/Cargo.toml index be0273f9..b373072a 100644 --- a/crates/http_protocol/Cargo.toml +++ b/crates/http_protocol/Cargo.toml @@ -7,9 +7,10 @@ authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true -readme.workspace = true rust-version.workspace = true +readme = "./README.md" + [lib] name = "aquatic_http_protocol" diff --git a/crates/http_protocol/README.md b/crates/http_protocol/README.md new file mode 100644 index 00000000..f618dae1 --- /dev/null +++ b/crates/http_protocol/README.md @@ -0,0 +1,15 @@ +# aquatic_http_protocol: HTTP BitTorrent tracker protocol + +HTTP BitTorrent tracker message parsing and serialization. + +[BEP 003]: https://www.bittorrent.org/beps/bep_0003.html +[BEP 007]: https://www.bittorrent.org/beps/bep_0007.html +[BEP 023]: https://www.bittorrent.org/beps/bep_0023.html +[BEP 048]: https://www.bittorrent.org/beps/bep_0048.html + +Implements: + * [BEP 003]: HTTP BitTorrent protocol ([more details](https://wiki.theory.org/index.php/BitTorrentSpecification#Tracker_HTTP.2FHTTPS_Protocol)). Exceptions: + * Only compact responses are supported + * [BEP 023]: Compact HTTP responses + * [BEP 007]: IPv6 support + * [BEP 048]: HTTP scrape support \ No newline at end of file diff --git a/crates/peer_id/Cargo.toml b/crates/peer_id/Cargo.toml index 4acc0995..338bd8c9 100644 --- a/crates/peer_id/Cargo.toml +++ b/crates/peer_id/Cargo.toml @@ -6,9 +6,10 @@ authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true -readme.workspace = true rust-version.workspace = true +readme = "./README.md" + [lib] name = "aquatic_peer_id" diff --git a/crates/peer_id/README.md b/crates/peer_id/README.md new file mode 100644 index 00000000..010f1bfe --- /dev/null +++ b/crates/peer_id/README.md @@ -0,0 +1,3 @@ +# aquatic_peer_id + +Extract BitTorrent client information from announce request peer IDs. \ No newline at end of file diff --git a/crates/udp/README.md b/crates/udp/README.md index 6183c1b6..60a5c2d1 100644 --- a/crates/udp/README.md +++ b/crates/udp/README.md @@ -30,11 +30,12 @@ More benchmark details are available [here](../../documents/aquatic-udp-load-tes ### Compiling - Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended) -- Install cmake with your package manager (e.g., `apt-get install cmake`) -- Clone this git repository and enter its root directory -- Build the application: +- Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`) +- Clone this git repository and build the application: ```sh +git clone https://github.com/greatest-ape/aquatic.git && cd aquatic + # Recommended: tell Rust to enable support for all SIMD extensions present on # current CPU except for those relating to AVX-512. (If you run a processor # that doesn't clock down when using AVX-512, you can enable those instructions @@ -73,7 +74,9 @@ configuration files in a similar manner to the tracker application. After starting the tracker, run the load tester: ```sh -./scripts/run-load-test-udp.sh +. ./scripts/env-native-cpu-without-avx-512 # Optional + +cargo build --release -p aquatic_udp_load_test -- --help ``` ## Details @@ -85,7 +88,7 @@ Implements [BEP 015](https://www.bittorrent.org/beps/bep_0015.html) ([more detai ## Copyright and license -Copyright (c) 2020-2023 Joakim Frostegård +Copyright (c) Joakim Frostegård -Distributed under the terms of the Apache 2.0 license. Please refer to the -`LICENSE` file in the repository root directory for details. +Distributed under the terms of the Apache License, Version 2.0. Please refer to +the `LICENSE` file in the repository root directory for details. diff --git a/crates/udp_protocol/Cargo.toml b/crates/udp_protocol/Cargo.toml index cd4614dd..2142ccfa 100644 --- a/crates/udp_protocol/Cargo.toml +++ b/crates/udp_protocol/Cargo.toml @@ -7,9 +7,10 @@ authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true -readme.workspace = true rust-version.workspace = true +readme = "./README.md" + [dependencies] aquatic_peer_id.workspace = true diff --git a/crates/udp_protocol/README.md b/crates/udp_protocol/README.md new file mode 100644 index 00000000..1b49ec79 --- /dev/null +++ b/crates/udp_protocol/README.md @@ -0,0 +1,4 @@ +# aquatic_udp_protocol: UDP BitTorrent tracker protocol + +[UDP BitTorrent](https://www.bittorrent.org/beps/bep_0015.html) tracker +message parsing and serialization. \ No newline at end of file diff --git a/crates/ws/README.md b/crates/ws/README.md index 19e61f2c..c21fadb7 100644 --- a/crates/ws/README.md +++ b/crates/ws/README.md @@ -28,11 +28,12 @@ More details are available [here](../../documents/aquatic-ws-load-test-2023-01-2 ### Compiling - Install Rust with [rustup](https://rustup.rs/) (latest stable release is recommended) -- Install cmake with your package manager (e.g., `apt-get install cmake`) -- Clone this git repository and enter its root directory -- Build the application: +- Install build dependencies with your package manager (e.g., `apt-get install cmake build-essential`) +- Clone this git repository and build the application: ```sh +git clone https://github.com/greatest-ape/aquatic.git && cd aquatic + # Recommended: tell Rust to enable support for all SIMD extensions present on # current CPU except for those relating to AVX-512. (If you run a processor # that doesn't clock down when using AVX-512, you can enable those instructions @@ -53,6 +54,8 @@ Generate the configuration file: Make necessary adjustments to the file. You will likely want to adjust `address` (listening address) under the `network` section. +To run over TLS, configure certificate and private key files. + Running behind a reverse proxy is supported, as long as IPv4 requests are proxied to IPv4 requests, and IPv6 requests to IPv6 requests. @@ -86,7 +89,9 @@ configuration files in a similar manner to the tracker application. After starting the tracker, run the load tester: ```sh -./scripts/run-load-test-ws.sh +. ./scripts/env-native-cpu-without-avx-512 # Optional + +cargo build --release -p aquatic_ws_load_test -- --help ``` ## Details @@ -102,8 +107,8 @@ fine in production. ## Copyright and license -Copyright (c) 2020-2023 Joakim Frostegård +Copyright (c) Joakim Frostegård -Distributed under the terms of the Apache 2.0 license. Please refer to the -`LICENSE` file in the repository root directory for details. +Distributed under the terms of the Apache License, Version 2.0. Please refer to +the `LICENSE` file in the repository root directory for details. diff --git a/crates/ws/src/workers/socket/connection.rs b/crates/ws/src/workers/socket/connection.rs index 00de5c6f..2587ca16 100644 --- a/crates/ws/src/workers/socket/connection.rs +++ b/crates/ws/src/workers/socket/connection.rs @@ -42,6 +42,7 @@ use crate::workers::socket::calculate_in_message_consumer_index; use crate::workers::socket::{ip_version_to_metrics_str, WORKER_INDEX}; /// Optional second tuple field is for peer id hex representation +#[cfg(feature = "metrics")] type PeerClientGauge = (Gauge, Option); pub struct ConnectionRunner { @@ -68,6 +69,7 @@ impl ConnectionRunner { let clean_up_data = ConnectionCleanupData { announced_info_hashes: Default::default(), ip_version: self.ip_version, + #[cfg(feature = "metrics")] opt_peer_client: Default::default(), #[cfg(feature = "metrics")] active_connections_gauge: ::metrics::gauge!( @@ -597,6 +599,7 @@ impl ConnectionWriter { struct ConnectionCleanupData { announced_info_hashes: Rc>>, ip_version: IpVersion, + #[cfg(feature = "metrics")] opt_peer_client: Rc>>, #[cfg(feature = "metrics")] active_connections_gauge: Gauge, diff --git a/crates/ws/src/workers/socket/mod.rs b/crates/ws/src/workers/socket/mod.rs index 040fce79..8d796798 100644 --- a/crates/ws/src/workers/socket/mod.rs +++ b/crates/ws/src/workers/socket/mod.rs @@ -240,14 +240,14 @@ async fn clean_connections( } }); - ::log::info!( - "cleaned connections in worker {}, {} references remaining", - WORKER_INDEX.get(), - connection_slab.borrow_mut().len() - ); - #[cfg(feature = "metrics")] { + ::log::info!( + "cleaned connections in worker {}, {} references remaining", + WORKER_INDEX.get(), + connection_slab.borrow_mut().len() + ); + // Increment gauges by zero to prevent them from being removed due to // idleness diff --git a/crates/ws/src/workers/swarm/storage.rs b/crates/ws/src/workers/swarm/storage.rs index abb6a225..43820b40 100644 --- a/crates/ws/src/workers/swarm/storage.rs +++ b/crates/ws/src/workers/swarm/storage.rs @@ -176,6 +176,7 @@ impl TorrentMap { server_start_instant, request_sender_meta, &request, + #[cfg(feature = "metrics")] &self.peer_gauge, ); @@ -260,7 +261,11 @@ impl TorrentMap { pub fn handle_connection_closed(&mut self, info_hash: InfoHash, peer_id: PeerId) { if let Some(torrent_data) = self.torrents.get_mut(&info_hash) { - torrent_data.handle_connection_closed(peer_id, &self.peer_gauge); + torrent_data.handle_connection_closed( + peer_id, + #[cfg(feature = "metrics")] + &self.peer_gauge, + ); } } diff --git a/crates/ws_protocol/Cargo.toml b/crates/ws_protocol/Cargo.toml index df05b2dd..4ae72de9 100644 --- a/crates/ws_protocol/Cargo.toml +++ b/crates/ws_protocol/Cargo.toml @@ -8,9 +8,10 @@ authors.workspace = true edition.workspace = true license.workspace = true repository.workspace = true -readme.workspace = true rust-version.workspace = true +readme = "./README.md" + [lib] name = "aquatic_ws_protocol" diff --git a/crates/ws_protocol/README.md b/crates/ws_protocol/README.md new file mode 100644 index 00000000..f17b8be1 --- /dev/null +++ b/crates/ws_protocol/README.md @@ -0,0 +1,4 @@ +# aquatic_ws_protocol: WebTorrent tracker protocol + +[WebTorrent](https://github.com/webtorrent) tracker message parsing and +serialization. \ No newline at end of file diff --git a/docker/aquatic_udp.Dockerfile b/docker/aquatic_udp.Dockerfile index 1d9f4b64..bbcb1683 100644 --- a/docker/aquatic_udp.Dockerfile +++ b/docker/aquatic_udp.Dockerfile @@ -2,6 +2,10 @@ # aquatic_udp # +# Please note that running aquatic_udp under Docker is NOT RECOMMENDED due to +# suboptimal performance. This file is provided as a starting point for those +# who still wish to do so. +# # Customize by setting CONFIG_FILE_CONTENTS and # ACCESS_LIST_CONTENTS environment variables. #