2021-10-08 11:07:24 -04:00
|
|
|
use doku::Document;
|
|
|
|
use serde::{Deserialize, Serialize};
|
2021-08-04 17:13:51 -04:00
|
|
|
use std::net::{IpAddr, Ipv4Addr};
|
2021-03-01 12:24:11 -05:00
|
|
|
|
2021-10-08 11:07:24 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 17:13:51 -04:00
|
|
|
#[serde(default)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub struct Settings {
|
2021-10-08 11:07:24 -04:00
|
|
|
/// settings related to the postgresql database
|
2021-08-04 17:13:51 -04:00
|
|
|
#[serde(default)]
|
|
|
|
pub database: DatabaseConfig,
|
|
|
|
#[default(Some(RateLimitConfig::default()))]
|
2021-10-08 11:07:24 -04:00
|
|
|
/// rate limits for various user actions, by user ip
|
2021-08-04 17:13:51 -04:00
|
|
|
pub rate_limit: Option<RateLimitConfig>,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Settings related to activitypub federation
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(FederationConfig::default())]
|
|
|
|
pub federation: FederationConfig,
|
|
|
|
#[default(CaptchaConfig::default())]
|
|
|
|
pub captcha: CaptchaConfig,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Email sending configuration. All options except login/password are mandatory
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(None)]
|
|
|
|
pub email: Option<EmailConfig>,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Parameters for automatic configuration of new instance (only used at first start)
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(None)]
|
|
|
|
pub setup: Option<SetupConfig>,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// the domain name of your instance (mandatory)
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default("unset")]
|
2021-10-08 11:07:24 -04:00
|
|
|
#[doku(example = "example.com")]
|
2021-08-04 17:13:51 -04:00
|
|
|
pub hostname: String,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Address where lemmy should listen for incoming requests
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
|
2021-10-08 11:07:24 -04:00
|
|
|
#[doku(as = "String")]
|
2021-08-04 17:13:51 -04:00
|
|
|
pub bind: IpAddr,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Port where lemmy should listen for incoming requests
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(8536)]
|
|
|
|
pub port: u16,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Whether the site is available over TLS. Needs to be true for federation to work.
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(true)]
|
|
|
|
pub tls_enabled: bool,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Address where pictrs is available (for image hosting)
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(None)]
|
2021-10-08 11:07:24 -04:00
|
|
|
#[doku(example = "http://localhost:8080")]
|
2021-08-04 17:13:51 -04:00
|
|
|
pub pictrs_url: Option<String>,
|
|
|
|
#[default(None)]
|
2021-10-28 16:47:25 -04:00
|
|
|
#[doku(example = "(\\bThis\\b)|(\\bis\\b)|(\\bsample\\b)")]
|
|
|
|
pub slur_filter: Option<String>,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Maximum length of local community and user names
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(20)]
|
|
|
|
pub actor_name_max_length: usize,
|
2021-12-05 10:03:13 -05:00
|
|
|
/// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
|
|
|
|
#[default(25)]
|
|
|
|
pub http_fetch_retry_limit: i32,
|
2022-01-06 14:10:20 -05:00
|
|
|
|
2022-02-03 17:54:57 -05:00
|
|
|
/// Set the URL for opentelemetry exports. If you do not have an opentelemetry collector, do not set this option
|
2022-01-06 14:10:20 -05:00
|
|
|
#[default(None)]
|
|
|
|
#[doku(example = "http://localhost:4317")]
|
|
|
|
pub opentelemetry_url: Option<String>,
|
2021-03-01 12:24:11 -05:00
|
|
|
}
|
|
|
|
|
2021-10-08 11:07:24 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 17:13:51 -04:00
|
|
|
#[serde(default)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub struct CaptchaConfig {
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Whether captcha is required for signup
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(false)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub enabled: bool,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Can be easy, medium, or hard
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default("medium")]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub difficulty: String,
|
|
|
|
}
|
|
|
|
|
2021-10-08 11:07:24 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 17:13:51 -04:00
|
|
|
#[serde(default)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub struct DatabaseConfig {
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Username to connect to postgres
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default("lemmy")]
|
|
|
|
pub(super) user: String,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Password to connect to postgres
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default("password")]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub password: String,
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default("localhost")]
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Host where postgres is running
|
2021-03-01 12:24:11 -05:00
|
|
|
pub host: String,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Port where postgres can be accessed
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(5432)]
|
|
|
|
pub(super) port: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Name of the postgres database for lemmy
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default("lemmy")]
|
|
|
|
pub(super) database: String,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Maximum number of active sql connections
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(5)]
|
|
|
|
pub pool_size: u32,
|
2021-03-01 12:24:11 -05:00
|
|
|
}
|
|
|
|
|
2022-01-26 11:42:43 -05:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub struct EmailConfig {
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Hostname and port of the smtp server
|
|
|
|
#[doku(example = "localhost:25")]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub smtp_server: String,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Login name for smtp server
|
2021-03-01 12:24:11 -05:00
|
|
|
pub smtp_login: Option<String>,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Password to login to the smtp server
|
2021-03-01 12:24:11 -05:00
|
|
|
pub smtp_password: Option<String>,
|
2021-10-08 11:07:24 -04:00
|
|
|
#[doku(example = "noreply@example.com")]
|
|
|
|
/// Address to send emails from, eg "noreply@your-instance.com"
|
2021-03-01 12:24:11 -05:00
|
|
|
pub smtp_from_address: String,
|
2022-01-26 11:42:43 -05:00
|
|
|
/// Whether or not smtp connections should use tls. Can be none, tls, or starttls
|
|
|
|
#[default("none")]
|
|
|
|
#[doku(example = "none")]
|
|
|
|
pub tls_type: String,
|
2021-03-01 12:24:11 -05:00
|
|
|
}
|
|
|
|
|
2021-10-08 11:07:24 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 17:13:51 -04:00
|
|
|
#[serde(default)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub struct FederationConfig {
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Whether to enable activitypub federation.
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(false)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub enabled: bool,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Allows and blocks are described here:
|
|
|
|
/// https://join-lemmy.org/docs/en/federation/administration.html///instance-allowlist-and-blocklist
|
|
|
|
///
|
|
|
|
/// list of instances with which federation is allowed
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(None)]
|
2021-10-08 11:07:24 -04:00
|
|
|
#[doku(example = "instance1.tld")]
|
|
|
|
#[doku(example = "instance2.tld")]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub allowed_instances: Option<Vec<String>>,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Instances which we never federate anything with (but previously federated objects are unaffected)
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(None)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub blocked_instances: Option<Vec<String>>,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// If true, only federate with instances on the allowlist and block everything else. If false,
|
|
|
|
/// use allowlist only for remote communities, and posts/comments in local communities
|
|
|
|
/// (meaning remote communities will show content from arbitrary instances).
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(true)]
|
|
|
|
pub strict_allowlist: bool,
|
2021-03-01 12:24:11 -05:00
|
|
|
}
|
|
|
|
|
2021-10-08 11:07:24 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 17:13:51 -04:00
|
|
|
#[serde(default)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub struct RateLimitConfig {
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Maximum number of messages created in interval
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(180)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub message: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Interval length for message limit, in seconds
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(60)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub message_per_second: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Maximum number of posts created in interval
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(6)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub post: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Interval length for post limit, in seconds
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(600)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub post_per_second: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Maximum number of registrations in interval
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(3)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub register: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Interval length for registration limit, in seconds
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(3600)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub register_per_second: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Maximum number of image uploads in interval
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(6)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub image: i32,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Interval length for image uploads, in seconds
|
2021-08-04 17:13:51 -04:00
|
|
|
#[default(3600)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub image_per_second: i32,
|
2021-11-11 15:40:25 -05:00
|
|
|
/// Maximum number of comments created in interval
|
|
|
|
#[default(6)]
|
|
|
|
pub comment: i32,
|
|
|
|
/// Interval length for comment limit, in seconds
|
|
|
|
#[default(600)]
|
|
|
|
pub comment_per_second: i32,
|
2021-03-01 12:24:11 -05:00
|
|
|
}
|
|
|
|
|
2021-10-08 11:07:24 -04:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub struct SetupConfig {
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Username for the admin user
|
|
|
|
#[doku(example = "admin")]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub admin_username: String,
|
2021-12-12 11:42:24 -05:00
|
|
|
/// Password for the admin user. It must be at least 10 characters.
|
|
|
|
#[doku(example = "my_passwd_longer_than_ten_characters")]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub admin_password: String,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Name of the site (can be changed later)
|
|
|
|
#[doku(example = "My Lemmy Instance")]
|
2021-03-01 12:24:11 -05:00
|
|
|
pub site_name: String,
|
2021-10-08 11:07:24 -04:00
|
|
|
/// Email for the admin user (optional, can be omitted and set later through the website)
|
2021-08-23 05:44:10 -04:00
|
|
|
#[default(None)]
|
|
|
|
pub admin_email: Option<String>,
|
|
|
|
#[default(None)]
|
|
|
|
pub sidebar: Option<String>,
|
|
|
|
#[default(None)]
|
|
|
|
pub description: Option<String>,
|
|
|
|
#[default(None)]
|
|
|
|
pub icon: Option<String>,
|
|
|
|
#[default(None)]
|
|
|
|
pub banner: Option<String>,
|
|
|
|
#[default(None)]
|
|
|
|
pub enable_downvotes: Option<bool>,
|
|
|
|
#[default(None)]
|
|
|
|
pub open_registration: Option<bool>,
|
|
|
|
#[default(None)]
|
|
|
|
pub enable_nsfw: Option<bool>,
|
|
|
|
#[default(None)]
|
|
|
|
pub community_creation_admin_only: Option<bool>,
|
2021-12-15 14:49:59 -05:00
|
|
|
#[default(None)]
|
|
|
|
pub require_email_verification: Option<bool>,
|
|
|
|
#[default(None)]
|
|
|
|
pub require_application: Option<bool>,
|
|
|
|
#[default(None)]
|
|
|
|
pub application_question: Option<String>,
|
|
|
|
#[default(None)]
|
|
|
|
pub private_instance: Option<bool>,
|
2021-03-01 12:24:11 -05:00
|
|
|
}
|