mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
Rename AccessList variants
This commit is contained in:
parent
5a1e59578f
commit
f3487d4749
4 changed files with 13 additions and 13 deletions
|
|
@ -11,11 +11,11 @@ use serde::{Deserialize, Serialize};
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
pub enum AccessListMode {
|
pub enum AccessListMode {
|
||||||
/// Only serve torrents with info hash present in file
|
/// Only serve torrents with info hash present in file
|
||||||
Require,
|
White,
|
||||||
/// Do not serve torrents if info hash present in file
|
/// Do not serve torrents if info hash present in file
|
||||||
Forbid,
|
Black,
|
||||||
/// Turn off access list functionality
|
/// Turn off access list functionality
|
||||||
Ignore,
|
Off,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
|
@ -31,7 +31,7 @@ impl Default for AccessListConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
path: "".into(),
|
path: "".into(),
|
||||||
mode: AccessListMode::Ignore,
|
mode: AccessListMode::Off,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -70,9 +70,9 @@ impl AccessList {
|
||||||
|
|
||||||
pub fn allows(&self, list_mode: AccessListMode, info_hash_bytes: &[u8; 20]) -> bool {
|
pub fn allows(&self, list_mode: AccessListMode, info_hash_bytes: &[u8; 20]) -> bool {
|
||||||
match list_mode {
|
match list_mode {
|
||||||
AccessListMode::Require => self.0.load().contains(info_hash_bytes),
|
AccessListMode::White => self.0.load().contains(info_hash_bytes),
|
||||||
AccessListMode::Forbid => !self.0.load().contains(info_hash_bytes),
|
AccessListMode::Black => !self.0.load().contains(info_hash_bytes),
|
||||||
AccessListMode::Ignore => true,
|
AccessListMode::Off => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ use crate::{common::*, config::Config};
|
||||||
|
|
||||||
pub fn update_access_list(config: &Config, state: &State) {
|
pub fn update_access_list(config: &Config, state: &State) {
|
||||||
match config.access_list.mode {
|
match config.access_list.mode {
|
||||||
AccessListMode::Require | AccessListMode::Forbid => {
|
AccessListMode::White | AccessListMode::Black => {
|
||||||
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
||||||
::log::error!("Couldn't update access list: {:?}", err);
|
::log::error!("Couldn't update access list: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AccessListMode::Ignore => {}
|
AccessListMode::Off => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,12 @@ use crate::config::Config;
|
||||||
|
|
||||||
pub fn update_access_list(config: &Config, state: &State) {
|
pub fn update_access_list(config: &Config, state: &State) {
|
||||||
match config.access_list.mode {
|
match config.access_list.mode {
|
||||||
AccessListMode::Require | AccessListMode::Forbid => {
|
AccessListMode::White | AccessListMode::Black => {
|
||||||
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
||||||
::log::error!("Update access list from path: {:?}", err);
|
::log::error!("Update access list from path: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AccessListMode::Ignore => {}
|
AccessListMode::Off => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,12 @@ use crate::config::Config;
|
||||||
|
|
||||||
pub fn update_access_list(config: &Config, state: &State) {
|
pub fn update_access_list(config: &Config, state: &State) {
|
||||||
match config.access_list.mode {
|
match config.access_list.mode {
|
||||||
AccessListMode::Require | AccessListMode::Forbid => {
|
AccessListMode::White | AccessListMode::Black => {
|
||||||
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
if let Err(err) = state.access_list.update_from_path(&config.access_list.path) {
|
||||||
::log::error!("Couldn't update access list: {:?}", err);
|
::log::error!("Couldn't update access list: {:?}", err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AccessListMode::Ignore => {}
|
AccessListMode::Off => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue