2021-10-08 15:07:24 +00:00
|
|
|
use doku::Document;
|
|
|
|
use serde::{Deserialize, Serialize};
|
2021-08-04 21:13:51 +00:00
|
|
|
use std::net::{IpAddr, Ipv4Addr};
|
2021-03-01 17:24:11 +00:00
|
|
|
|
2021-10-08 15:07:24 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 21:13:51 +00:00
|
|
|
#[serde(default)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub struct Settings {
|
2021-10-08 15:07:24 +00:00
|
|
|
/// settings related to the postgresql database
|
2021-08-04 21:13:51 +00:00
|
|
|
#[serde(default)]
|
|
|
|
pub database: DatabaseConfig,
|
|
|
|
#[default(Some(RateLimitConfig::default()))]
|
2021-10-08 15:07:24 +00:00
|
|
|
/// rate limits for various user actions, by user ip
|
2021-08-04 21:13:51 +00:00
|
|
|
pub rate_limit: Option<RateLimitConfig>,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Settings related to activitypub federation
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(FederationConfig::default())]
|
|
|
|
pub federation: FederationConfig,
|
2022-06-13 19:15:04 +00:00
|
|
|
/// Pictrs image server configuration.
|
|
|
|
#[default(None)]
|
|
|
|
pub(crate) pictrs_config: Option<PictrsConfig>,
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(CaptchaConfig::default())]
|
|
|
|
pub captcha: CaptchaConfig,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Email sending configuration. All options except login/password are mandatory
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(None)]
|
|
|
|
pub email: Option<EmailConfig>,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Parameters for automatic configuration of new instance (only used at first start)
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(None)]
|
|
|
|
pub setup: Option<SetupConfig>,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// the domain name of your instance (mandatory)
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default("unset")]
|
2021-10-08 15:07:24 +00:00
|
|
|
#[doku(example = "example.com")]
|
2021-08-04 21:13:51 +00:00
|
|
|
pub hostname: String,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Address where lemmy should listen for incoming requests
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
|
2021-10-08 15:07:24 +00:00
|
|
|
#[doku(as = "String")]
|
2021-08-04 21:13:51 +00:00
|
|
|
pub bind: IpAddr,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Port where lemmy should listen for incoming requests
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(8536)]
|
|
|
|
pub port: u16,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Whether the site is available over TLS. Needs to be true for federation to work.
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(true)]
|
|
|
|
pub tls_enabled: bool,
|
|
|
|
#[default(None)]
|
2021-10-28 20:47:25 +00:00
|
|
|
#[doku(example = "(\\bThis\\b)|(\\bis\\b)|(\\bsample\\b)")]
|
2022-06-13 19:15:04 +00:00
|
|
|
/// A regex list of slurs to block / hide
|
2021-10-28 20:47:25 +00:00
|
|
|
pub slur_filter: Option<String>,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Maximum length of local community and user names
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(20)]
|
|
|
|
pub actor_name_max_length: usize,
|
2022-01-06 19:10:20 +00:00
|
|
|
|
2022-02-03 22:54:57 +00:00
|
|
|
/// Set the URL for opentelemetry exports. If you do not have an opentelemetry collector, do not set this option
|
2022-01-06 19:10:20 +00:00
|
|
|
#[default(None)]
|
2022-02-07 15:39:37 +00:00
|
|
|
#[doku(skip)]
|
2022-01-06 19:10:20 +00:00
|
|
|
pub opentelemetry_url: Option<String>,
|
2021-03-01 17:24:11 +00:00
|
|
|
}
|
|
|
|
|
2022-06-13 19:15:04 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
|
|
|
#[serde(default)]
|
|
|
|
pub struct PictrsConfig {
|
|
|
|
/// Address where pictrs is available (for image hosting)
|
|
|
|
#[default("http://pictrs:8080")]
|
|
|
|
pub url: String,
|
|
|
|
|
|
|
|
/// Set a custom pictrs API key. ( Required for deleting images )
|
|
|
|
#[default("API_KEY")]
|
|
|
|
pub api_key: String,
|
|
|
|
}
|
|
|
|
|
2021-10-08 15:07:24 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 21:13:51 +00:00
|
|
|
#[serde(default)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub struct CaptchaConfig {
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Whether captcha is required for signup
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(false)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub enabled: bool,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Can be easy, medium, or hard
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default("medium")]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub difficulty: String,
|
|
|
|
}
|
|
|
|
|
2021-10-08 15:07:24 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 21:13:51 +00:00
|
|
|
#[serde(default)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub struct DatabaseConfig {
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Username to connect to postgres
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default("lemmy")]
|
|
|
|
pub(super) user: String,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Password to connect to postgres
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default("password")]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub password: String,
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default("localhost")]
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Host where postgres is running
|
2021-03-01 17:24:11 +00:00
|
|
|
pub host: String,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Port where postgres can be accessed
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(5432)]
|
|
|
|
pub(super) port: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Name of the postgres database for lemmy
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default("lemmy")]
|
|
|
|
pub(super) database: String,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Maximum number of active sql connections
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(5)]
|
|
|
|
pub pool_size: u32,
|
2021-03-01 17:24:11 +00:00
|
|
|
}
|
|
|
|
|
2022-01-26 16:42:43 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub struct EmailConfig {
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Hostname and port of the smtp server
|
|
|
|
#[doku(example = "localhost:25")]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub smtp_server: String,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Login name for smtp server
|
2021-03-01 17:24:11 +00:00
|
|
|
pub smtp_login: Option<String>,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Password to login to the smtp server
|
2021-03-01 17:24:11 +00:00
|
|
|
pub smtp_password: Option<String>,
|
2021-10-08 15:07:24 +00:00
|
|
|
#[doku(example = "noreply@example.com")]
|
|
|
|
/// Address to send emails from, eg "noreply@your-instance.com"
|
2021-03-01 17:24:11 +00:00
|
|
|
pub smtp_from_address: String,
|
2022-01-26 16:42:43 +00: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 17:24:11 +00:00
|
|
|
}
|
|
|
|
|
2021-10-08 15:07:24 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 21:13:51 +00:00
|
|
|
#[serde(default)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub struct FederationConfig {
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Whether to enable activitypub federation.
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(false)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub enabled: bool,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Allows and blocks are described here:
|
2022-04-13 18:27:56 +00:00
|
|
|
/// https://join-lemmy.org/docs/en/administration/federation_getting_started.html
|
2021-10-08 15:07:24 +00:00
|
|
|
///
|
|
|
|
/// list of instances with which federation is allowed
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(None)]
|
2021-10-08 15:07:24 +00:00
|
|
|
#[doku(example = "instance1.tld")]
|
|
|
|
#[doku(example = "instance2.tld")]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub allowed_instances: Option<Vec<String>>,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Instances which we never federate anything with (but previously federated objects are unaffected)
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(None)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub blocked_instances: Option<Vec<String>>,
|
2021-10-08 15:07:24 +00: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 21:13:51 +00:00
|
|
|
#[default(true)]
|
|
|
|
pub strict_allowlist: bool,
|
2022-06-14 05:20:30 +00: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-03-07 22:28:50 +00:00
|
|
|
/// Number of workers for sending outgoing activities. Search logs for "Activity queue stats" to
|
|
|
|
/// see information. If "running" number is consistently close to the worker_count, you should
|
|
|
|
/// increase it.
|
|
|
|
#[default(64)]
|
2022-03-03 18:54:33 +00:00
|
|
|
pub worker_count: u64,
|
2022-06-08 15:45:39 +00:00
|
|
|
/// Use federation debug mode. Allows connecting to http and localhost urls. Also sends outgoing
|
|
|
|
/// activities synchronously for easier testing. Do not use in production.
|
|
|
|
#[default(false)]
|
|
|
|
pub debug: bool,
|
2021-03-01 17:24:11 +00:00
|
|
|
}
|
|
|
|
|
2021-10-08 15:07:24 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-08-04 21:13:51 +00:00
|
|
|
#[serde(default)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub struct RateLimitConfig {
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Maximum number of messages created in interval
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(180)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub message: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Interval length for message limit, in seconds
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(60)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub message_per_second: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Maximum number of posts created in interval
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(6)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub post: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Interval length for post limit, in seconds
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(600)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub post_per_second: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Maximum number of registrations in interval
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(3)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub register: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Interval length for registration limit, in seconds
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(3600)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub register_per_second: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Maximum number of image uploads in interval
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(6)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub image: i32,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Interval length for image uploads, in seconds
|
2021-08-04 21:13:51 +00:00
|
|
|
#[default(3600)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub image_per_second: i32,
|
2021-11-11 20:40:25 +00: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,
|
2022-03-29 15:46:03 +00:00
|
|
|
#[default(6)]
|
|
|
|
pub search: i32,
|
|
|
|
/// Interval length for search limit, in seconds
|
|
|
|
#[default(600)]
|
|
|
|
pub search_per_second: i32,
|
2021-03-01 17:24:11 +00:00
|
|
|
}
|
|
|
|
|
2021-10-08 15:07:24 +00:00
|
|
|
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub struct SetupConfig {
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Username for the admin user
|
|
|
|
#[doku(example = "admin")]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub admin_username: String,
|
2021-12-12 16:42:24 +00:00
|
|
|
/// Password for the admin user. It must be at least 10 characters.
|
2022-06-08 15:44:53 +00:00
|
|
|
#[doku(example = "tf6HHDS4RolWfFhk4Rq9")]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub admin_password: String,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Name of the site (can be changed later)
|
|
|
|
#[doku(example = "My Lemmy Instance")]
|
2021-03-01 17:24:11 +00:00
|
|
|
pub site_name: String,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Email for the admin user (optional, can be omitted and set later through the website)
|
2022-06-08 15:44:53 +00:00
|
|
|
#[doku(example = "user@example.com")]
|
2021-08-23 09:44:10 +00:00
|
|
|
#[default(None)]
|
|
|
|
pub admin_email: Option<String>,
|
2021-03-01 17:24:11 +00:00
|
|
|
}
|