use serde::Deserialize;
use super::empty_string_is_no_values;
#[derive(Debug, Clone, Default, Deserialize)]
#[serde(default)]
pub struct DnsConfig {
pub resolver: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct DatabaseConfig {
pub url: String,
}
impl Default for DatabaseConfig {
fn default() -> Self {
Self {
url: "sqlite://sqlite.db".to_string(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct ServerConfig {
pub bind_address: String,
pub base_url: String,
pub tls: TlsConfig,
pub max_concurrent_requests: usize,
pub admission_wait_ms: u64,
pub request_timeout_ms: u64,
pub max_body_bytes: usize,
}
impl Default for ServerConfig {
fn default() -> Self {
Self {
bind_address: "[::]:3000".to_string(),
base_url: "http://localhost:3000".to_string(),
tls: TlsConfig::default(),
max_concurrent_requests: 100,
admission_wait_ms: 50,
request_timeout_ms: 60_000,
max_body_bytes: 128 * 1024,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct TlsConfig {
pub enabled: bool,
pub cert_path: String,
pub key_path: String,
pub handshake_timeout_ms: u64,
}
impl Default for TlsConfig {
fn default() -> Self {
Self {
enabled: false,
cert_path: "server.pem".to_string(),
key_path: "server.key".to_string(),
handshake_timeout_ms: 10_000,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct AdminConfig {
pub enabled: bool,
pub bind_address: String,
pub base_url: String,
pub session_ttl_seconds: u64,
pub session_idle_timeout_seconds: u64,
pub login_max_attempts: u32,
pub login_window_seconds: u64,
pub require_mfa: bool,
pub max_body_bytes: usize,
pub page_size_max: i64,
pub template_dir: String,
pub tls: AdminTlsConfig,
}
impl Default for AdminConfig {
fn default() -> Self {
Self {
enabled: false,
bind_address: "127.0.0.1:3001".to_string(),
base_url: "http://localhost:3001".to_string(),
session_ttl_seconds: 43_200,
session_idle_timeout_seconds: 3_600,
login_max_attempts: 5,
login_window_seconds: 300,
require_mfa: false,
max_body_bytes: 64 * 1024,
page_size_max: 200,
template_dir: String::new(),
tls: AdminTlsConfig::default(),
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct AdminTlsConfig {
pub enabled: bool,
pub cert_path: String,
pub key_path: String,
pub handshake_timeout_ms: u64,
}
impl Default for AdminTlsConfig {
fn default() -> Self {
Self {
enabled: false,
cert_path: "admin.pem".to_string(),
key_path: "admin.key".to_string(),
handshake_timeout_ms: 10_000,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct NonceConfig {
pub ttl_seconds: u64,
}
impl Default for NonceConfig {
fn default() -> Self {
Self { ttl_seconds: 300 }
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct LoggingConfig {
pub filter: String,
pub json_format: bool,
pub target: String,
pub ansi: bool,
pub span_events: String,
pub flatten_event: bool,
}
impl Default for LoggingConfig {
fn default() -> Self {
Self {
filter: "acme_proxy=info".to_string(),
json_format: false,
target: "stdout".to_string(),
ansi: true,
span_events: "none".to_string(),
flatten_event: false,
}
}
}
#[derive(Debug, Clone, Deserialize)]
#[serde(default)]
pub struct OrderConfig {
pub validity_seconds: u64,
pub max_identifiers: usize,
pub retention_days: u64,
}
impl Default for OrderConfig {
fn default() -> Self {
Self {
validity_seconds: 604800,
max_identifiers: 100,
retention_days: 30,
}
}
}
#[derive(Debug, Clone, Deserialize, Default)]
#[serde(default)]
pub struct MetaConfig {
pub terms_of_service: String,
pub website: String,
#[serde(deserialize_with = "empty_string_is_no_values")]
pub caa_identities: Vec<String>,
}