Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[alias]
cov = "llvm-cov --lcov --output-path=./.coverage/lcov.info"
cov-html = "llvm-cov --html"
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
.env
/target
**/*.rs.bk
/database.json.bz2
/database.db
/.coverage/
/.idea/
/.vscode/launch.json
/config.toml
/data.db
/.vscode/launch.json
/database.db
/database.json.bz2
/storage/


/target
1 change: 1 addition & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"infohashes",
"infoschema",
"intervali",
"lcov",
"leecher",
"leechers",
"libtorrent",
Expand Down
4 changes: 2 additions & 2 deletions src/apis/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub async fn remove_torrent_from_whitelist_handler(
}

pub async fn reload_whitelist_handler(State(tracker): State<Arc<Tracker>>) -> Response {
match tracker.load_whitelist().await {
match tracker.load_whitelist_from_database().await {
Ok(_) => ok_response(),
Err(e) => failed_to_reload_whitelist_response(e),
}
Expand Down Expand Up @@ -117,7 +117,7 @@ pub async fn delete_auth_key_handler(
}

pub async fn reload_keys_handler(State(tracker): State<Arc<Tracker>>) -> Response {
match tracker.load_keys().await {
match tracker.load_keys_from_database().await {
Ok(_) => ok_response(),
Err(e) => failed_to_reload_keys_response(e),
}
Expand Down
8 changes: 4 additions & 4 deletions src/http/axum_implementation/responses/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ impl From<AnnounceData> for NonCompact {
Self {
interval: domain_announce_response.interval,
interval_min: domain_announce_response.interval_min,
complete: domain_announce_response.swam_stats.seeders,
incomplete: domain_announce_response.swam_stats.leechers,
complete: domain_announce_response.swarm_stats.seeders,
incomplete: domain_announce_response.swarm_stats.leechers,
peers,
}
}
Expand Down Expand Up @@ -237,8 +237,8 @@ impl From<AnnounceData> for Compact {
Self {
interval: domain_announce_response.interval,
interval_min: domain_announce_response.interval_min,
complete: domain_announce_response.swam_stats.seeders,
incomplete: domain_announce_response.swam_stats.leechers,
complete: domain_announce_response.swarm_stats.seeders,
incomplete: domain_announce_response.swarm_stats.leechers,
peers,
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/http/axum_implementation/services/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ pub async fn invoke(tracker: &Arc<Tracker>, info_hashes: &Vec<InfoHash>, origina
/// When the peer is not authenticated and the tracker is running in `private` mode,
/// the tracker returns empty stats for all the torrents.
pub async fn fake_invoke(tracker: &Arc<Tracker>, info_hashes: &Vec<InfoHash>, original_peer_ip: &IpAddr) -> ScrapeData {
let scrape_data = tracker.empty_scrape_for(info_hashes);

send_scrape_event(original_peer_ip, tracker).await;

scrape_data
ScrapeData::zeroed(info_hashes)
}

async fn send_scrape_event(original_peer_ip: &IpAddr, tracker: &Arc<Tracker>) {
Expand Down
4 changes: 2 additions & 2 deletions src/http/warp_implementation/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub async fn handle_announce(

send_announce_response(
&announce_request,
&response.swam_stats,
&response.swarm_stats,
&response.peers,
tracker.config.announce_interval,
tracker.config.min_announce_interval,
Expand Down Expand Up @@ -129,7 +129,7 @@ pub async fn handle_scrape(
#[allow(clippy::ptr_arg)]
fn send_announce_response(
announce_request: &request::Announce,
torrent_stats: &torrent::SwamStats,
torrent_stats: &torrent::SwarmStats,
peers: &Vec<peer::Peer>,
interval: u32,
interval_min: u32,
Expand Down
7 changes: 5 additions & 2 deletions src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ pub async fn setup(config: &Configuration, tracker: Arc<tracker::Tracker>) -> Ve

// Load peer keys
if tracker.is_private() {
tracker.load_keys().await.expect("Could not retrieve keys from database.");
tracker
.load_keys_from_database()
.await
.expect("Could not retrieve keys from database.");
}

// Load whitelisted torrents
if tracker.is_whitelisted() {
tracker
.load_whitelist()
.load_whitelist_from_database()
.await
.expect("Could not load whitelist from database.");
}
Expand Down
3 changes: 3 additions & 0 deletions src/tracker/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub fn verify(auth_key: &ExpiringKey) -> Result<(), Error> {
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone)]
pub struct ExpiringKey {
pub id: KeyId,
// todo: we can remove the `Option`. An `ExpiringKey` that does not expire
// is a `KeyId`. In other words, all `ExpiringKeys` must have an
// expiration time.
pub valid_until: Option<DurationSinceUnixEpoch>,
}

Expand Down
Loading