-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
f3afab1 feat(http): [#195] announce request in private mode (Jose Celano) Pull request description: For the new Auxm HTTP tracker implementation. Top commit has no ACKs. Tree-SHA512: 9b2c7fc06511e8293c4acbbfa6c62d029c87ab64b18cb4c09630767a3869f44aa3e1e3f952cd228f684f731141574a91dcdee8942af1e5cee120a2d6ec9bdd95
- Loading branch information
Showing
7 changed files
with
117 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::panic::Location; | ||
use std::sync::Arc; | ||
|
||
use thiserror::Error; | ||
|
||
use crate::http::axum_implementation::responses; | ||
use crate::tracker::auth::{self, KeyId}; | ||
use crate::tracker::Tracker; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum Error { | ||
#[error("Missing authentication key for private tracker. Error in {location}")] | ||
MissingAuthKey { location: &'static Location<'static> }, | ||
} | ||
|
||
/// # Errors | ||
/// | ||
/// Will return an error if the the authentication key cannot be verified. | ||
pub async fn authenticate(key_id: &KeyId, tracker: &Arc<Tracker>) -> Result<(), auth::Error> { | ||
if tracker.is_private() { | ||
tracker.verify_auth_key(key_id).await | ||
} else { | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl From<Error> for responses::error::Error { | ||
fn from(err: Error) -> Self { | ||
responses::error::Error { | ||
failure_reason: format!("Authentication error: {err}"), | ||
} | ||
} | ||
} | ||
|
||
impl From<auth::Error> for responses::error::Error { | ||
fn from(err: auth::Error) -> Self { | ||
responses::error::Error { | ||
failure_reason: format!("Authentication error: {err}"), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod announce; | ||
pub mod auth; | ||
pub mod scrape; | ||
pub mod status; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters