1 use serde::Deserialize;
2 use std::net::{IpAddr, Ipv4Addr};
4 #[derive(Debug, Deserialize, Clone, SmartDefault)]
8 pub database: DatabaseConfig,
9 #[default(Some(RateLimitConfig::default()))]
10 pub rate_limit: Option<RateLimitConfig>,
11 #[default(FederationConfig::default())]
12 pub federation: FederationConfig,
13 #[default(CaptchaConfig::default())]
14 pub captcha: CaptchaConfig,
16 pub email: Option<EmailConfig>,
18 pub setup: Option<SetupConfig>,
21 #[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
26 pub tls_enabled: bool,
27 #[default("changeme")]
28 pub jwt_secret: String,
30 pub pictrs_url: Option<String>,
32 pub iframely_url: Option<String>,
34 pub additional_slurs: Option<String>,
36 pub actor_name_max_length: usize,
39 #[derive(Debug, Deserialize, Clone, SmartDefault)]
41 pub struct CaptchaConfig {
45 pub difficulty: String,
48 #[derive(Debug, Deserialize, Clone, SmartDefault)]
50 pub struct DatabaseConfig {
52 pub(super) user: String,
53 #[default("password")]
55 #[default("localhost")]
60 pub(super) database: String,
65 #[derive(Debug, Deserialize, Clone)]
66 pub struct EmailConfig {
67 pub smtp_server: String,
68 pub smtp_login: Option<String>,
69 pub smtp_password: Option<String>,
70 pub smtp_from_address: String,
74 #[derive(Debug, Deserialize, Clone, SmartDefault)]
76 pub struct FederationConfig {
80 pub allowed_instances: Option<Vec<String>>,
82 pub blocked_instances: Option<Vec<String>>,
84 pub strict_allowlist: bool,
87 #[derive(Debug, Deserialize, Clone, SmartDefault)]
89 pub struct RateLimitConfig {
93 pub message_per_second: i32,
97 pub post_per_second: i32,
101 pub register_per_second: i32,
105 pub image_per_second: i32,
108 #[derive(Debug, Deserialize, Clone)]
109 pub struct SetupConfig {
110 pub admin_username: String,
111 pub admin_password: String,
112 pub admin_email: Option<String>,
113 pub site_name: String,