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};
|
2022-07-11 20:38:37 +00:00
|
|
|
use url::Url;
|
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
|
2022-07-11 20:38:37 +00:00
|
|
|
#[default(Default::default())]
|
2021-08-04 21:13:51 +00:00
|
|
|
pub database: DatabaseConfig,
|
2021-10-08 15:07:24 +00:00
|
|
|
/// Settings related to activitypub federation
|
2022-06-13 19:15:04 +00:00
|
|
|
/// Pictrs image server configuration.
|
2022-07-11 20:38:37 +00:00
|
|
|
#[default(Some(Default::default()))]
|
2022-07-14 18:25:10 +00:00
|
|
|
pub(crate) pictrs: Option<PictrsConfig>,
|
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)]
|
2022-07-11 20:38:37 +00:00
|
|
|
#[doku(example = "Some(Default::default())")]
|
2021-08-04 21:13:51 +00:00
|
|
|
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)]
|
2022-07-11 20:38:37 +00:00
|
|
|
#[doku(example = "Some(Default::default())")]
|
2021-08-04 21:13:51 +00:00
|
|
|
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,
|
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-07-11 20:38:37 +00:00
|
|
|
pub opentelemetry_url: Option<Url>,
|
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)
|
2023-01-20 17:46:49 +00:00
|
|
|
#[default(Url::parse("http://localhost:8080").expect("parse pictrs url"))]
|
|
|
|
#[doku(example = "http://localhost:8080")]
|
2022-07-11 20:38:37 +00:00
|
|
|
pub url: Url,
|
2022-06-13 19:15:04 +00:00
|
|
|
|
|
|
|
/// Set a custom pictrs API key. ( Required for deleting images )
|
2022-07-11 20:38:37 +00:00
|
|
|
#[default(None)]
|
|
|
|
pub api_key: Option<String>,
|
2022-06-13 19:15:04 +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 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)]
|
2023-02-28 21:45:37 +00:00
|
|
|
pub pool_size: usize,
|
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-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
|
|
|
}
|