diff --git a/crates/cli/src/modules/database.rs b/crates/cli/src/modules/database.rs index d900d7aa..a469f46b 100644 --- a/crates/cli/src/modules/database.rs +++ b/crates/cli/src/modules/database.rs @@ -38,13 +38,13 @@ impl ServerCommands { } ServerCommands::ReloadCertificates {} => { client - .http_request::(Method::GET, "/api/reload/certificates", None) + .http_request::(Method::GET, "/api/reload/certificate", None) .await; eprintln!("Success."); } ServerCommands::ReloadConfig {} => { client - .http_request::(Method::GET, "/api/reload/settings", None) + .http_request::(Method::GET, "/api/reload", None) .await; eprintln!("Success."); } diff --git a/crates/common/src/config/scripts.rs b/crates/common/src/config/scripts.rs index d5f0e720..ce15bed2 100644 --- a/crates/common/src/config/scripts.rs +++ b/crates/common/src/config/scripts.rs @@ -230,26 +230,39 @@ impl Scripting { .with_max_header_size(10240) .with_valid_notification_uri("mailto") .with_valid_ext_lists(stores.lookup_stores.keys().map(|k| k.to_string())) - .with_functions(&mut fnc_map); + .with_functions(&mut fnc_map) + .with_max_redirects( + config + .property_or_default("sieve.trusted.limits.redirects", "3") + .unwrap_or(3), + ) + .with_max_out_messages( + config + .property_or_default("sieve.trusted.limits.out-messages", "5") + .unwrap_or(5), + ) + .with_cpu_limit( + config + .property_or_default("sieve.trusted.limits.cpu", "1048576") + .unwrap_or(1048576), + ) + .with_max_nested_includes( + config + .property_or_default("sieve.trusted.limits.nested-includes", "5") + .unwrap_or(5), + ) + .with_max_received_headers( + config + .property_or_default("sieve.trusted.limits.received-headers", "50") + .unwrap_or(50), + ) + .with_default_duplicate_expiry( + config + .property_or_default::("sieve.trusted.limits.duplicate-expiry", "7d") + .unwrap_or_else(|| Duration::from_secs(604800)) + .as_secs(), + ); - if let Some(value) = config.property("sieve.trusted.limits.redirects") { - trusted_runtime.set_max_redirects(value); - } - if let Some(value) = config.property("sieve.trusted.limits.out-messages") { - trusted_runtime.set_max_out_messages(value); - } - if let Some(value) = config.property("sieve.trusted.limits.cpu") { - trusted_runtime.set_cpu_limit(value); - } - if let Some(value) = config.property("sieve.trusted.limits.nested-includes") { - trusted_runtime.set_max_nested_includes(value); - } - if let Some(value) = config.property("sieve.trusted.limits.received-headers") { - trusted_runtime.set_max_received_headers(value); - } - if let Some(value) = config.property::("sieve.trusted.limits.duplicate-expiry") { - trusted_runtime.set_default_duplicate_expiry(value.as_secs()); - } let hostname = config .value("sieve.trusted.hostname") .or_else(|| config.value("lookup.default.hostname")) diff --git a/crates/common/src/manager/boot.rs b/crates/common/src/manager/boot.rs index 84e85291..60792a27 100644 --- a/crates/common/src/manager/boot.rs +++ b/crates/common/src/manager/boot.rs @@ -314,6 +314,7 @@ fn quickstart(path: impl Into) { eprintln!("🔑 Your administrator account is 'admin' with password '{admin_pass}'."); } +#[cfg(not(feature = "foundation"))] const QUICKSTART_CONFIG: &str = r#"[server.listener.smtp] bind = "[::]:25" protocol = "smtp" @@ -378,3 +379,68 @@ enable = true user = "admin" secret = "_S_" "#; + +#[cfg(feature = "foundation")] +const QUICKSTART_CONFIG: &str = r#"[server.listener.smtp] +bind = "[::]:25" +protocol = "smtp" + +[server.listener.submission] +bind = "[::]:587" +protocol = "smtp" + +[server.listener.submissions] +bind = "[::]:465" +protocol = "smtp" +tls.implicit = true + +[server.listener.imap] +bind = "[::]:143" +protocol = "imap" + +[server.listener.imaptls] +bind = "[::]:993" +protocol = "imap" +tls.implicit = true + +[server.listener.sieve] +bind = "[::]:4190" +protocol = "managesieve" + +[server.listener.https] +protocol = "http" +bind = "[::]:443" +tls.implicit = true + +[server.listener.http] +protocol = "http" +bind = "[::]:8080" + +[storage] +data = "foundation-db" +fts = "foundation-db" +blob = "foundation-db" +lookup = "foundation-db" +directory = "internal" + +[store.foundation-db] +type = "foundationdb" +compression = "lz4" + +[directory.internal] +type = "internal" +store = "foundation-db" + +[tracer.log] +type = "log" +level = "info" +path = "_P_/logs" +prefix = "stalwart.log" +rotate = "daily" +ansi = false +enable = true + +[authentication.fallback-admin] +user = "admin" +secret = "_S_" +"#; diff --git a/crates/common/src/manager/mod.rs b/crates/common/src/manager/mod.rs index d4255721..466b6ad6 100644 --- a/crates/common/src/manager/mod.rs +++ b/crates/common/src/manager/mod.rs @@ -31,15 +31,10 @@ pub mod reload; pub mod webadmin; pub const SPAMFILTER_URL: &str = "https://get.stalw.art/resources/config/spamfilter.toml"; -pub const WEBADMIN_URL: &str = "file://get.stalw.art/resources/config/webadmin.toml"; +pub const WEBADMIN_URL: &str = "https://get.stalw.art/resources/webadmin.zip"; pub const WEBADMIN_KEY: &[u8] = "STALWART_WEBADMIN".as_bytes(); async fn download_resource(url: &str) -> Result, String> { - let todo = "remove"; - if url == WEBADMIN_URL { - return Ok(tokio::fs::read("/tmp/dist.zip").await.unwrap()); - } - reqwest::Client::builder() .timeout(Duration::from_secs(60)) .user_agent(USER_AGENT) diff --git a/crates/directory/src/core/config.rs b/crates/directory/src/core/config.rs index 665498c0..6e579d34 100644 --- a/crates/directory/src/core/config.rs +++ b/crates/directory/src/core/config.rs @@ -27,7 +27,7 @@ use deadpool::{ }; use std::{sync::Arc, time::Duration}; use store::{Store, Stores}; -use utils::config::{utils::ParseValue, Config}; +use utils::config::Config; use ahash::AHashMap; @@ -146,40 +146,3 @@ pub(crate) fn build_pool( ) }) } - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum LookupType { - List, - Glob, - Regex, - Map, -} - -#[derive(Debug, Clone)] -pub struct LookupFormat { - pub lookup_type: LookupType, - pub comment: Option, - pub separator: Option, -} - -impl Default for LookupFormat { - fn default() -> Self { - Self { - lookup_type: LookupType::Glob, - comment: Default::default(), - separator: Default::default(), - } - } -} - -impl ParseValue for LookupType { - fn parse_value(value: &str) -> utils::config::Result { - match value { - "list" => Ok(LookupType::List), - "glob" => Ok(LookupType::Glob), - "regex" => Ok(LookupType::Regex), - "map" => Ok(LookupType::Map), - _ => Err(format!("Invalid value for lookup type {value:?}",)), - } - } -} diff --git a/crates/main/Cargo.toml b/crates/main/Cargo.toml index 50020161..cf33f12a 100644 --- a/crates/main/Cargo.toml +++ b/crates/main/Cargo.toml @@ -32,9 +32,7 @@ tracing = "0.1" jemallocator = "0.5.0" [features] -default = ["sqlite", "foundationdb", "postgres", "mysql", "rocks", "elastic", "s3", "redis"] -#default = ["sqlite", "postgres", "mysql", "rocks", "elastic", "s3", "redis"] -#default = ["foundationdb", "postgres", "mysql"] +default = ["sqlite", "postgres", "mysql", "rocks", "elastic", "s3", "redis"] sqlite = ["store/sqlite"] foundationdb = ["store/foundation"] postgres = ["store/postgres"] diff --git a/resources/webadmin.zip b/resources/webadmin.zip new file mode 100644 index 00000000..1b9db902 Binary files /dev/null and b/resources/webadmin.zip differ