mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 18:55:32 +00:00
aquatic_common: improve comments, run rustfmt
This commit is contained in:
parent
490c0b037d
commit
ba787c3361
1 changed files with 24 additions and 6 deletions
|
|
@ -8,14 +8,20 @@ use serde::{Deserialize, Serialize};
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum AccessListMode {
|
pub enum AccessListMode {
|
||||||
|
/// Only serve torrents with info hash present in file
|
||||||
Require,
|
Require,
|
||||||
|
/// Do not serve torrents if info hash present in file
|
||||||
Forbid,
|
Forbid,
|
||||||
|
/// Turn off access list functionality
|
||||||
Ignore,
|
Ignore,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
pub struct AccessListConfig {
|
pub struct AccessListConfig {
|
||||||
pub mode: AccessListMode,
|
pub mode: AccessListMode,
|
||||||
|
/// Path to access list file consisting of newline-separated hex-encoded info hashes.
|
||||||
|
///
|
||||||
|
/// If using chroot mode, path must be relative to new root.
|
||||||
pub path: PathBuf,
|
pub path: PathBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,10 +75,22 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_info_hash(){
|
fn test_parse_info_hash() {
|
||||||
assert!(AccessList::parse_info_hash("aaaabbbbccccddddeeeeaaaabbbbccccddddeeee".to_owned()).is_ok());
|
assert!(
|
||||||
assert!(AccessList::parse_info_hash("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeef".to_owned()).is_err());
|
AccessList::parse_info_hash("aaaabbbbccccddddeeeeaaaabbbbccccddddeeee".to_owned())
|
||||||
assert!(AccessList::parse_info_hash("aaaabbbbccccddddeeeeaaaabbbbccccddddeee".to_owned()).is_err());
|
.is_ok()
|
||||||
assert!(AccessList::parse_info_hash("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeö".to_owned()).is_err());
|
);
|
||||||
|
assert!(AccessList::parse_info_hash(
|
||||||
|
"aaaabbbbccccddddeeeeaaaabbbbccccddddeeeef".to_owned()
|
||||||
|
)
|
||||||
|
.is_err());
|
||||||
|
assert!(
|
||||||
|
AccessList::parse_info_hash("aaaabbbbccccddddeeeeaaaabbbbccccddddeee".to_owned())
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
AccessList::parse_info_hash("aaaabbbbccccddddeeeeaaaabbbbccccddddeeeö".to_owned())
|
||||||
|
.is_err()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue