Skip to content

Commit 274374e

Browse files
committed
dev: work on udp tracker service
1 parent 833d14b commit 274374e

34 files changed

+375
-181
lines changed

.github/workflows/coverage.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ jobs:
5555
name: Run Build Checks
5656
run: cargo check --tests --benches --examples --workspace --all-targets --all-features
5757

58+
# Run Test Locally:
59+
# RUSTFLAGS="-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" RUSTDOCFLAGS="-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" CARGO_INCREMENTAL="0" RUST_BACKTRACE=1 cargo test --tests --benches --examples --workspace --all-targets --all-features
60+
5861
- id: test
5962
name: Run Unit Tests
6063
run: cargo test --tests --benches --examples --workspace --all-targets --all-features

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
"[rust]": {
33
"editor.formatOnSave": true
44
},
5+
"[ignore]": { "rust-analyzer.cargo.extraEnv" : {
6+
"RUSTFLAGS": "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests",
7+
"RUSTDOCFLAGS": "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests",
8+
"CARGO_INCREMENTAL": "0",
9+
"RUST_BACKTRACE": "1"
10+
}},
511
"rust-analyzer.checkOnSave": true,
612
"rust-analyzer.check.command": "clippy",
713
"rust-analyzer.check.allTargets": true,

Cargo.lock

+92-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ binascii = "0"
3939
chrono = { version = "0", default-features = false, features = ["clock"] }
4040
config = "0"
4141
derive_more = "0"
42-
fern = "0"
4342
futures = "0"
4443
hyper = "1"
4544
lazy_static = "1"
46-
log = { version = "0", features = ["release_max_level_info"] }
45+
tracing = "0.1"
46+
tracing-subscriber = "0.3"
4747
multimap = "0"
4848
openssl = { version = "0", features = ["vendored"] }
4949
percent-encoding = "2"
@@ -55,6 +55,7 @@ reqwest = "0"
5555
serde = { version = "1", features = ["derive"] }
5656
serde_bencode = "0"
5757
serde_json = "1"
58+
ringbuf = "0.4.0-rc.2"
5859
serde_with = "3"
5960
tdyne-peer-id = "1"
6061
tdyne-peer-id-registry = "0"

cSpell.json

+2
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@
9494
"reannounce",
9595
"Registar",
9696
"repr",
97+
"reqs",
9798
"reqwest",
9899
"rerequests",
100+
"ringbuf",
99101
"rngs",
100102
"routable",
101103
"rusqlite",

packages/located-error/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rust-version.workspace = true
1515
version.workspace = true
1616

1717
[dependencies]
18-
log = { version = "0", features = ["release_max_level_info"] }
18+
tracing = "0.1"
1919

2020
[dev-dependencies]
2121
thiserror = "1"

packages/located-error/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use std::error::Error;
3333
use std::panic::Location;
3434
use std::sync::Arc;
3535

36-
use log::debug;
36+
use tracing::debug;
3737

3838
pub type DynError = Arc<dyn std::error::Error + Send + Sync>;
3939

src/app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ use std::net::SocketAddr;
2626
use std::sync::Arc;
2727

2828
use derive_more::Constructor;
29-
use log::warn;
3029
use tokio::sync::Mutex;
3130
use tokio::task::JoinHandle;
3231
use torrust_tracker_configuration::Configuration;
32+
use tracing::warn;
3333

3434
use crate::bootstrap::jobs::{health_check_api, http_tracker, torrent_cleanup, tracker_apis, udp_tracker};
3535
use crate::{core, servers};

src/bootstrap/jobs/health_check_api.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
//! Refer to the [configuration documentation](https://docs.rs/torrust-tracker-configuration)
1515
//! for the API configuration options.
1616
17-
use log::info;
1817
use tokio::sync::oneshot;
1918
use tokio::task::JoinHandle;
2019
use torrust_tracker_configuration::HealthCheckApi;
20+
use tracing::debug;
2121

2222
use super::Started;
2323
use crate::app::Registry;
@@ -46,18 +46,18 @@ pub async fn start_job(config: &HealthCheckApi, register: Registry) -> JoinHandl
4646

4747
// Run the API server
4848
let join_handle = tokio::spawn(async move {
49-
info!(target: "Health Check API", "Starting on: http://{}", bind_addr);
49+
debug!(target: "Health Check API", "Starting on: http://{}", bind_addr);
5050

5151
let handle = server::start(bind_addr, tx_start, rx_halt, register);
5252

5353
if let Ok(()) = handle.await {
54-
info!(target: "Health Check API", "Stopped server running on: http://{}", bind_addr);
54+
debug!(target: "Health Check API", "Stopped server running on: http://{}", bind_addr);
5555
}
5656
});
5757

5858
// Wait until the API server job is running
5959
match rx_start.await {
60-
Ok(msg) => info!(target: "Health Check API", "Started on: http://{}", msg.address),
60+
Ok(msg) => debug!(target: "Health Check API", "Started on: http://{}", msg.address),
6161
Err(e) => panic!("the Health Check API server was dropped: {e}"),
6262
}
6363

src/bootstrap/jobs/http_tracker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ use std::net::SocketAddr;
1414
use std::sync::Arc;
1515

1616
use axum_server::tls_rustls::RustlsConfig;
17-
use log::info;
1817
use tokio::task::JoinHandle;
1918
use torrust_tracker_configuration::HttpTracker;
19+
use tracing::debug;
2020

2121
use super::make_rust_tls;
2222
use crate::app::RegistrationForm;
@@ -53,7 +53,7 @@ pub async fn start_job(
5353
Version::V1 => Some(start_v1(socket, tls, tracker.clone(), form).await),
5454
}
5555
} else {
56-
info!("Note: Not loading Http Tracker Service, Not Enabled in Configuration.");
56+
debug!("Note: Not loading Http Tracker Service, Not Enabled in Configuration.");
5757
None
5858
}
5959
}

src/bootstrap/jobs/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ pub struct Started {
2222

2323
pub async fn make_rust_tls(enabled: bool, cert: &Option<String>, key: &Option<String>) -> Option<Result<RustlsConfig, Error>> {
2424
if !enabled {
25-
info!("TLS not enabled");
25+
debug!("TLS not enabled");
2626
return None;
2727
}
2828

2929
if let (Some(cert), Some(key)) = (cert, key) {
30-
info!("Using https: cert path: {cert}.");
31-
info!("Using https: key path: {cert}.");
30+
debug!("Using https: cert path: {cert}.");
31+
debug!("Using https: key path: {cert}.");
3232

3333
Some(
3434
RustlsConfig::from_pem_file(cert, key)
@@ -77,9 +77,9 @@ use std::panic::Location;
7777
use std::sync::Arc;
7878

7979
use axum_server::tls_rustls::RustlsConfig;
80-
use log::info;
8180
use thiserror::Error;
8281
use torrust_tracker_located_error::{DynError, LocatedError};
82+
use tracing::debug;
8383

8484
/// Error returned by the Bootstrap Process.
8585
#[derive(Error, Debug)]

0 commit comments

Comments
 (0)