change back name of domain configuration option

This commit is contained in:
BlockListed 2023-09-09 18:52:16 +02:00
parent 09c0367571
commit 298cf8adcb
No known key found for this signature in database
GPG Key ID: 2D204777C477B588

View File

@ -139,21 +139,21 @@ macro_rules! make_config {
fn build(&self) -> ConfigItems { fn build(&self) -> ConfigItems {
let mut config = ConfigItems::default(); let mut config = ConfigItems::default();
let _domain_set = self.domain_change_back.is_some(); let _domain_set = self.domain.is_some();
$($( $($(
config.$name = make_config!{ @build self.$name.clone(), &config, $none_action, $($default)? }; config.$name = make_config!{ @build self.$name.clone(), &config, $none_action, $($default)? };
)+)+ )+)+
config.domain_set = _domain_set; config.domain_set = _domain_set;
// Remove slash from every domain // Remove slash from every domain
config.domain_change_back = config.domain_change_back.split(',').map(|d| d.trim_end_matches('/')).fold(String::new(), |mut acc, d| { config.domain = config.domain.split(',').map(|d| d.trim_end_matches('/')).fold(String::new(), |mut acc, d| {
acc.push_str(d); acc.push_str(d);
acc.push(','); acc.push(',');
acc acc
}); });
// Remove trailing comma // Remove trailing comma
config.domain_change_back.pop(); config.domain.pop();
config.signups_domains_whitelist = config.signups_domains_whitelist.trim().to_lowercase(); config.signups_domains_whitelist = config.signups_domains_whitelist.trim().to_lowercase();
config.org_creation_users = config.org_creation_users.trim().to_lowercase(); config.org_creation_users = config.org_creation_users.trim().to_lowercase();
@ -428,16 +428,15 @@ make_config! {
settings { settings {
/// Comma seperated list of Domain URLs |> This needs to be set to the URL used to access the server, including /// Comma seperated list of Domain URLs |> This needs to be set to the URL used to access the server, including
/// 'http[s]://' and port, if it's different than the default. Some server functions don't work correctly without this value /// 'http[s]://' and port, if it's different than the default. Some server functions don't work correctly without this value
// TODO: Change back, this is only done to break existing references domain: String, true, def, "http://localhost".to_string();
domain_change_back: String, true, def, "http://localhost".to_string();
/// Domain Set |> Indicates if the domain is set by the admin. Otherwise the default will be used. /// Domain Set |> Indicates if the domain is set by the admin. Otherwise the default will be used.
domain_set: bool, false, def, false; domain_set: bool, false, def, false;
/// Comma seperated list of domain origins |> Domain URL origin (in https://example.com:8443/path, https://example.com:8443 is the origin) /// Comma seperated list of domain origins |> Domain URL origin (in https://example.com:8443/path, https://example.com:8443 is the origin)
/// If specified manually, one entry needs to exist for every url in domain. /// If specified manually, one entry needs to exist for every url in domain.
domain_origin: String, false, auto, |c| extract_origins(&c.domain_change_back); domain_origin: String, false, auto, |c| extract_origins(&c.domain);
/// Domain path |> Domain URL path (in https://example.com:8443/path, /path is the path) /// Domain path |> Domain URL path (in https://example.com:8443/path, /path is the path)
/// MUST be the same for all domains. /// MUST be the same for all domains.
domain_path: String, false, auto, |c| extract_url_path(c.domain_change_back.split(',').next().expect("Missing domain")); domain_path: String, false, auto, |c| extract_url_path(c.domain.split(',').next().expect("Missing domain"));
/// Enable web vault /// Enable web vault
web_vault_enabled: bool, false, def, true; web_vault_enabled: bool, false, def, true;
@ -682,7 +681,7 @@ make_config! {
/// Embed images as email attachments. /// Embed images as email attachments.
smtp_embed_images: bool, true, def, true; smtp_embed_images: bool, true, def, true;
/// _smtp_img_src /// _smtp_img_src
_smtp_img_src: String, false, gen, |c| generate_smtp_img_src(c.smtp_embed_images, &c.domain_change_back); _smtp_img_src: String, false, gen, |c| generate_smtp_img_src(c.smtp_embed_images, &c.domain);
/// Enable SMTP debugging (Know the risks!) |> DANGEROUS: Enabling this will output very detailed SMTP messages. This could contain sensitive information like passwords and usernames! Only enable this during troubleshooting! /// Enable SMTP debugging (Know the risks!) |> DANGEROUS: Enabling this will output very detailed SMTP messages. This could contain sensitive information like passwords and usernames! Only enable this during troubleshooting!
smtp_debug: bool, false, def, false; smtp_debug: bool, false, def, false;
/// Accept Invalid Certs (Know the risks!) |> DANGEROUS: Allow invalid certificates. This option introduces significant vulnerabilities to man-in-the-middle attacks! /// Accept Invalid Certs (Know the risks!) |> DANGEROUS: Allow invalid certificates. This option introduces significant vulnerabilities to man-in-the-middle attacks!
@ -735,7 +734,7 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
} }
} }
let domains = cfg.domain_change_back.split(',').map(|d| d.to_string().to_lowercase()); let domains = cfg.domain.split(',').map(|d| d.to_string().to_lowercase());
for dom in domains { for dom in domains {
if !dom.starts_with("http://") && !dom.starts_with("https://") { if !dom.starts_with("http://") && !dom.starts_with("https://") {
err!( err!(
@ -744,7 +743,7 @@ fn validate_config(cfg: &ConfigItems) -> Result<(), Error> {
} }
} }
if cfg.domain_change_back.split(',').count() != cfg.domain_origin.split(',').count() { if cfg.domain.split(',').count() != cfg.domain_origin.split(',').count() {
err!("Each DOMAIN_ORIGIN entry corresponds to exactly one entry in DOMAIN."); err!("Each DOMAIN_ORIGIN entry corresponds to exactly one entry in DOMAIN.");
} }
@ -1314,7 +1313,7 @@ impl Config {
fn get_domain_hostmap(&self, host: &str) -> Option<HostInfo> { fn get_domain_hostmap(&self, host: &str) -> Option<HostInfo> {
// This is done to prevent deadlock, when read-locking an rwlock twice // This is done to prevent deadlock, when read-locking an rwlock twice
let domains = self.domain_change_back(); let domains = self.domain();
self.inner self.inner
.read() .read()
@ -1348,7 +1347,7 @@ impl Config {
// Yes this is a base_url // Yes this is a base_url
// But the configuration precedent says, that we call this a domain. // But the configuration precedent says, that we call this a domain.
pub fn main_domain(&self) -> String { pub fn main_domain(&self) -> String {
self.domain_change_back().split(',').nth(0).expect("Missing domain").to_string() self.domain().split(',').nth(0).expect("Missing domain").to_string()
} }
} }