diff --git a/README.md b/README.md index c17cee7..8d01ffe 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ of configuration is: ```toml [access_list] -# Access list mode. Available modes are white, black and off. +# Access list mode. Available modes are allow, deny and off. mode = "off" # Path to access list file consisting of newline-separated hex-encoded info hashes. path = "" diff --git a/aquatic_common/src/access_list.rs b/aquatic_common/src/access_list.rs index 2eebc4b..d002d2f 100644 --- a/aquatic_common/src/access_list.rs +++ b/aquatic_common/src/access_list.rs @@ -9,14 +9,14 @@ use arc_swap::{ArcSwap, Cache}; use hashbrown::HashSet; use serde::{Deserialize, Serialize}; -/// Access list mode. Available modes are white, black and off. +/// Access list mode. Available modes are allow, deny and off. #[derive(Clone, Copy, Debug, PartialEq, TomlConfig, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum AccessListMode { /// Only serve torrents with info hash present in file - White, + Allow, /// Do not serve torrents if info hash present in file - Black, + Deny, /// Turn off access list functionality Off, } @@ -74,8 +74,8 @@ impl AccessList { pub fn allows(&self, mode: AccessListMode, info_hash: &[u8; 20]) -> bool { match mode { - AccessListMode::White => self.0.contains(info_hash), - AccessListMode::Black => !self.0.contains(info_hash), + AccessListMode::Allow => self.0.contains(info_hash), + AccessListMode::Deny => !self.0.contains(info_hash), AccessListMode::Off => true, } } @@ -102,8 +102,8 @@ impl AccessListQuery for AccessListArcSwap { fn allows(&self, mode: AccessListMode, info_hash_bytes: &[u8; 20]) -> bool { match mode { - AccessListMode::White => self.load().0.contains(info_hash_bytes), - AccessListMode::Black => !self.load().0.contains(info_hash_bytes), + AccessListMode::Allow => self.load().0.contains(info_hash_bytes), + AccessListMode::Deny => !self.load().0.contains(info_hash_bytes), AccessListMode::Off => true, } } @@ -170,13 +170,13 @@ mod tests { let mut access_list_cache = Cache::new(Arc::clone(&access_list)); - assert!(access_list_cache.load().allows(AccessListMode::White, &a)); - assert!(access_list_cache.load().allows(AccessListMode::White, &b)); - assert!(!access_list_cache.load().allows(AccessListMode::White, &c)); + assert!(access_list_cache.load().allows(AccessListMode::Allow, &a)); + assert!(access_list_cache.load().allows(AccessListMode::Allow, &b)); + assert!(!access_list_cache.load().allows(AccessListMode::Allow, &c)); - assert!(!access_list_cache.load().allows(AccessListMode::Black, &a)); - assert!(!access_list_cache.load().allows(AccessListMode::Black, &b)); - assert!(access_list_cache.load().allows(AccessListMode::Black, &c)); + assert!(!access_list_cache.load().allows(AccessListMode::Deny, &a)); + assert!(!access_list_cache.load().allows(AccessListMode::Deny, &b)); + assert!(access_list_cache.load().allows(AccessListMode::Deny, &c)); assert!(access_list_cache.load().allows(AccessListMode::Off, &a)); assert!(access_list_cache.load().allows(AccessListMode::Off, &b)); @@ -184,7 +184,7 @@ mod tests { access_list.store(Arc::new(AccessList::default())); - assert!(access_list_cache.load().allows(AccessListMode::Black, &a)); - assert!(access_list_cache.load().allows(AccessListMode::Black, &b)); + assert!(access_list_cache.load().allows(AccessListMode::Deny, &a)); + assert!(access_list_cache.load().allows(AccessListMode::Deny, &b)); } } diff --git a/documents/aquatic-architecture-2022-02-02.svg b/documents/aquatic-architecture-2022-02-02.svg index 3eb64ee..58fc08c 100644 --- a/documents/aquatic-architecture-2022-02-02.svg +++ b/documents/aquatic-architecture-2022-02-02.svg @@ -1,3 +1,3 @@ -
Socket worker
Socket worker
Socket worker
Socket worker
Responses
Responses
Socket worker
Socket worker
Requests
Requests
Socket
Socket
Request worker
Request worker
Request worker
Request worker
Socket
Socket
Socket
Socket
Responses
Responses
Sharded torrent state
Sharded to...
Sharded torrent state
Sharded to...
  • Establish connections, or in the case of aquatic_udp, validate source IPs
  • Receive and parse requests from peers
  • Run whitelist/blacklist checks
  • Send on announce requests to the responsible request worker
  • Split scrape requests to match state shards and send them to the request workers
  • Receive responses from the request workers, serialize them and send them to peers

Establish connections, or in the case of aqua...
  • Receive announce and scrape requests from the socket workers
  • Update torrent state if appropriate, generate responses
  • Send responses back to the sending socket workers

Receive announce and scrape requests from the...
Connection state
Connection...
Connection state
Connection...
Connection state
Connection...
Requests
Requests
Text is not SVG - cannot display
\ No newline at end of file +
Socket worker
Socket worker
Socket worker
Socket worker
Responses
Responses
Socket worker
Socket worker
Requests
Requests
Socket
Socket
Request worker
Request worker
Request worker
Request worker
Socket
Socket
Socket
Socket
Responses
Responses
Sharded torrent state
Sharded to...
Sharded torrent state
Sharded to...
  • Establish connections, or in the case of aquatic_udp, validate source IPs
  • Receive and parse requests from peers
  • Run access list checks
  • Send on announce requests to the responsible request worker
  • Split scrape requests to match state shards and send them to the request workers
  • Receive responses from the request workers, serialize them and send them to peers

Establish connections, or in the case of aqua...
  • Receive announce and scrape requests from the socket workers
  • Update torrent state if appropriate, generate responses
  • Send responses back to the sending socket workers

Receive announce and scrape requests from the...
Connection state
Connection...
Connection state
Connection...
Connection state
Connection...
Requests
Requests
Text is not SVG - cannot display
\ No newline at end of file