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 additional_slurs: Option<String>,
34 pub actor_name_max_length: usize,
37 #[derive(Debug, Deserialize, Clone, SmartDefault)]
39 pub struct CaptchaConfig {
43 pub difficulty: String,
46 #[derive(Debug, Deserialize, Clone, SmartDefault)]
48 pub struct DatabaseConfig {
50 pub(super) user: String,
51 #[default("password")]
53 #[default("localhost")]
58 pub(super) database: String,
63 #[derive(Debug, Deserialize, Clone)]
64 pub struct EmailConfig {
65 pub smtp_server: String,
66 pub smtp_login: Option<String>,
67 pub smtp_password: Option<String>,
68 pub smtp_from_address: String,
72 #[derive(Debug, Deserialize, Clone, SmartDefault)]
74 pub struct FederationConfig {
78 pub allowed_instances: Option<Vec<String>>,
80 pub blocked_instances: Option<Vec<String>>,
82 pub strict_allowlist: bool,
85 #[derive(Debug, Deserialize, Clone, SmartDefault)]
87 pub struct RateLimitConfig {
91 pub message_per_second: i32,
95 pub post_per_second: i32,
99 pub register_per_second: i32,
103 pub image_per_second: i32,
106 #[derive(Debug, Deserialize, Clone)]
107 pub struct SetupConfig {
108 pub admin_username: String,
109 pub admin_password: String,
110 pub admin_email: Option<String>,
111 pub site_name: String,