mangadex-home-rs/src/config.rs

38 lines
1.5 KiB
Rust
Raw Normal View History

2021-03-26 01:06:54 +00:00
use std::num::{NonZeroU16, NonZeroUsize};
use std::path::PathBuf;
2021-03-26 02:58:07 +00:00
use std::sync::atomic::AtomicBool;
2021-03-26 01:06:54 +00:00
use clap::Clap;
2021-03-26 02:58:07 +00:00
// Validate tokens is an atomic because it's faster than locking on rwlock.
pub static VALIDATE_TOKENS: AtomicBool = AtomicBool::new(false);
// We use an atomic here because it's better for us to not pass the config
// everywhere.
pub static SEND_SERVER_VERSION: AtomicBool = AtomicBool::new(false);
2021-03-26 04:07:32 +00:00
#[derive(Clap, Clone)]
2021-03-26 01:06:54 +00:00
pub struct CliArgs {
/// The port to listen on.
#[clap(short, long, default_value = "42069", env = "PORT")]
pub port: NonZeroU16,
/// How large, in bytes, the in-memory cache should be. Note that this does
/// not include runtime memory usage.
#[clap(long, env = "MEM_CACHE_QUOTA_BYTES")]
pub memory_quota: NonZeroUsize,
/// How large, in bytes, the on-disk cache should be. Note that actual
/// values may be larger for metadata information.
#[clap(long, env = "DISK_CACHE_QUOTA_BYTES")]
pub disk_quota: usize,
/// Sets the location of the disk cache.
#[clap(long, default_value = "./cache", env = "DISK_CACHE_PATH")]
pub cache_path: PathBuf,
/// The network speed to advertise to Mangadex@Home control server.
#[clap(long, env = "MAX_NETWORK_SPEED")]
pub network_speed: NonZeroUsize,
/// Whether or not to provide the Server HTTP header to clients. This is
/// useful for debugging, but is generally not recommended for security
/// reasons.
2021-03-26 02:58:07 +00:00
#[clap(long, env = "ENABLE_SERVER_STRING", takes_value = false)]
2021-03-26 01:06:54 +00:00
pub enable_server_string: bool,
}