Skip to content

Commit

Permalink
dev: work on udp tracker service
Browse files Browse the repository at this point in the history
  • Loading branch information
da2ce7 committed Jan 16, 2024
1 parent 38a3894 commit c47f548
Show file tree
Hide file tree
Showing 34 changed files with 375 additions and 189 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
name: Run Build Checks
run: cargo check --tests --benches --examples --workspace --all-targets --all-features

# Run Test Locally:
# 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

- id: test
name: Run Unit Tests
run: cargo test --tests --benches --examples --workspace --all-targets --all-features
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"[rust]": {
"editor.formatOnSave": true
},
"[ignore]": { "rust-analyzer.cargo.extraEnv" : {
"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"
}},
"rust-analyzer.checkOnSave": true,
"rust-analyzer.check.command": "clippy",
"rust-analyzer.check.allTargets": true,
Expand Down
104 changes: 92 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ binascii = "0"
chrono = { version = "0", default-features = false, features = ["clock"] }
config = "0"
derive_more = "0"
fern = "0"
futures = "0"
hyper = "1"
lazy_static = "1"
log = { version = "0", features = ["release_max_level_info"] }
tracing = "0.1"
tracing-subscriber = "0.3"
multimap = "0"
openssl = { version = "0", features = ["vendored"] }
percent-encoding = "2"
Expand All @@ -55,6 +55,7 @@ reqwest = "0"
serde = { version = "1", features = ["derive"] }
serde_bencode = "0"
serde_json = "1"
ringbuf = "0.4.0-rc.2"
serde_with = "3"
tdyne-peer-id = "1"
tdyne-peer-id-registry = "0"
Expand Down
2 changes: 2 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@
"reannounce",
"Registar",
"repr",
"reqs",
"reqwest",
"rerequests",
"ringbuf",
"rngs",
"routable",
"rusqlite",
Expand Down
2 changes: 1 addition & 1 deletion packages/located-error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rust-version.workspace = true
version.workspace = true

[dependencies]
log = { version = "0", features = ["release_max_level_info"] }
tracing = "0.1"

[dev-dependencies]
thiserror = "1"
2 changes: 1 addition & 1 deletion packages/located-error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::error::Error;
use std::panic::Location;
use std::sync::Arc;

use log::debug;
use tracing::debug;

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

Expand Down
2 changes: 1 addition & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ use std::net::SocketAddr;
use std::sync::Arc;

use derive_more::Constructor;
use log::warn;
use tokio::sync::Mutex;
use tokio::task::JoinHandle;
use torrust_tracker_configuration::Configuration;
use tracing::warn;

use crate::bootstrap::jobs::{health_check_api, http_tracker, torrent_cleanup, tracker_apis, udp_tracker};
use crate::{core, servers};
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/jobs/health_check_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
//! Refer to the [configuration documentation](https://docs.rs/torrust-tracker-configuration)
//! for the API configuration options.

use log::info;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use torrust_tracker_configuration::HealthCheckApi;
use tracing::debug;

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

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

Check warning on line 49 in src/bootstrap/jobs/health_check_api.rs

View check run for this annotation

Codecov / codecov/patch

src/bootstrap/jobs/health_check_api.rs#L49

Added line #L49 was not covered by tests

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

Check warning on line 51 in src/bootstrap/jobs/health_check_api.rs

View check run for this annotation

Codecov / codecov/patch

src/bootstrap/jobs/health_check_api.rs#L51

Added line #L51 was not covered by tests

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

Check warning on line 54 in src/bootstrap/jobs/health_check_api.rs

View check run for this annotation

Codecov / codecov/patch

src/bootstrap/jobs/health_check_api.rs#L54

Added line #L54 was not covered by tests
}
});

// Wait until the API server job is running
match rx_start.await {
Ok(msg) => info!(target: "Health Check API", "Started on: http://{}", msg.address),
Ok(msg) => debug!(target: "Health Check API", "Started on: http://{}", msg.address),

Check warning on line 60 in src/bootstrap/jobs/health_check_api.rs

View check run for this annotation

Codecov / codecov/patch

src/bootstrap/jobs/health_check_api.rs#L60

Added line #L60 was not covered by tests
Err(e) => panic!("the Health Check API server was dropped: {e}"),
}

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/jobs/http_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use std::net::SocketAddr;
use std::sync::Arc;

use axum_server::tls_rustls::RustlsConfig;
use log::info;
use tokio::task::JoinHandle;
use torrust_tracker_configuration::HttpTracker;
use tracing::debug;

use super::make_rust_tls;
use crate::app::RegistrationForm;
Expand Down Expand Up @@ -53,7 +53,7 @@ pub async fn start_job(
Version::V1 => Some(start_v1(socket, tls, tracker.clone(), form).await),
}
} else {
info!("Note: Not loading Http Tracker Service, Not Enabled in Configuration.");
debug!("Note: Not loading Http Tracker Service, Not Enabled in Configuration.");

Check warning on line 56 in src/bootstrap/jobs/http_tracker.rs

View check run for this annotation

Codecov / codecov/patch

src/bootstrap/jobs/http_tracker.rs#L56

Added line #L56 was not covered by tests
None
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/jobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ pub struct Started {

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

if let (Some(cert), Some(key)) = (cert, key) {
info!("Using https: cert path: {cert}.");
info!("Using https: key path: {cert}.");
debug!("Using https: cert path: {cert}.");
debug!("Using https: key path: {cert}.");

Some(
RustlsConfig::from_pem_file(cert, key)
Expand Down Expand Up @@ -77,9 +77,9 @@ use std::panic::Location;
use std::sync::Arc;

use axum_server::tls_rustls::RustlsConfig;
use log::info;
use thiserror::Error;
use torrust_tracker_located_error::{DynError, LocatedError};
use tracing::debug;

/// Error returned by the Bootstrap Process.
#[derive(Error, Debug)]
Expand Down
Loading

0 comments on commit c47f548

Please sign in to comment.