Updated resources

This commit is contained in:
mdecimus 2024-04-09 11:57:53 +02:00
parent 23edd40fd0
commit 62aa3be182
7 changed files with 103 additions and 68 deletions

View file

@ -38,13 +38,13 @@ impl ServerCommands {
} }
ServerCommands::ReloadCertificates {} => { ServerCommands::ReloadCertificates {} => {
client client
.http_request::<Value, String>(Method::GET, "/api/reload/certificates", None) .http_request::<Value, String>(Method::GET, "/api/reload/certificate", None)
.await; .await;
eprintln!("Success."); eprintln!("Success.");
} }
ServerCommands::ReloadConfig {} => { ServerCommands::ReloadConfig {} => {
client client
.http_request::<Value, String>(Method::GET, "/api/reload/settings", None) .http_request::<Value, String>(Method::GET, "/api/reload", None)
.await; .await;
eprintln!("Success."); eprintln!("Success.");
} }

View file

@ -230,26 +230,39 @@ impl Scripting {
.with_max_header_size(10240) .with_max_header_size(10240)
.with_valid_notification_uri("mailto") .with_valid_notification_uri("mailto")
.with_valid_ext_lists(stores.lookup_stores.keys().map(|k| k.to_string())) .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::<Duration>("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::<Duration>("sieve.trusted.limits.duplicate-expiry") {
trusted_runtime.set_default_duplicate_expiry(value.as_secs());
}
let hostname = config let hostname = config
.value("sieve.trusted.hostname") .value("sieve.trusted.hostname")
.or_else(|| config.value("lookup.default.hostname")) .or_else(|| config.value("lookup.default.hostname"))

View file

@ -314,6 +314,7 @@ fn quickstart(path: impl Into<PathBuf>) {
eprintln!("🔑 Your administrator account is 'admin' with password '{admin_pass}'."); eprintln!("🔑 Your administrator account is 'admin' with password '{admin_pass}'.");
} }
#[cfg(not(feature = "foundation"))]
const QUICKSTART_CONFIG: &str = r#"[server.listener.smtp] const QUICKSTART_CONFIG: &str = r#"[server.listener.smtp]
bind = "[::]:25" bind = "[::]:25"
protocol = "smtp" protocol = "smtp"
@ -378,3 +379,68 @@ enable = true
user = "admin" user = "admin"
secret = "_S_" 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_"
"#;

View file

@ -31,15 +31,10 @@ pub mod reload;
pub mod webadmin; pub mod webadmin;
pub const SPAMFILTER_URL: &str = "https://get.stalw.art/resources/config/spamfilter.toml"; 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(); pub const WEBADMIN_KEY: &[u8] = "STALWART_WEBADMIN".as_bytes();
async fn download_resource(url: &str) -> Result<Vec<u8>, String> { async fn download_resource(url: &str) -> Result<Vec<u8>, String> {
let todo = "remove";
if url == WEBADMIN_URL {
return Ok(tokio::fs::read("/tmp/dist.zip").await.unwrap());
}
reqwest::Client::builder() reqwest::Client::builder()
.timeout(Duration::from_secs(60)) .timeout(Duration::from_secs(60))
.user_agent(USER_AGENT) .user_agent(USER_AGENT)

View file

@ -27,7 +27,7 @@ use deadpool::{
}; };
use std::{sync::Arc, time::Duration}; use std::{sync::Arc, time::Duration};
use store::{Store, Stores}; use store::{Store, Stores};
use utils::config::{utils::ParseValue, Config}; use utils::config::Config;
use ahash::AHashMap; use ahash::AHashMap;
@ -146,40 +146,3 @@ pub(crate) fn build_pool<M: Manager>(
) )
}) })
} }
#[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<String>,
pub separator: Option<String>,
}
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<Self> {
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:?}",)),
}
}
}

View file

@ -32,9 +32,7 @@ tracing = "0.1"
jemallocator = "0.5.0" jemallocator = "0.5.0"
[features] [features]
default = ["sqlite", "foundationdb", "postgres", "mysql", "rocks", "elastic", "s3", "redis"] default = ["sqlite", "postgres", "mysql", "rocks", "elastic", "s3", "redis"]
#default = ["sqlite", "postgres", "mysql", "rocks", "elastic", "s3", "redis"]
#default = ["foundationdb", "postgres", "mysql"]
sqlite = ["store/sqlite"] sqlite = ["store/sqlite"]
foundationdb = ["store/foundation"] foundationdb = ["store/foundation"]
postgres = ["store/postgres"] postgres = ["store/postgres"]

BIN
resources/webadmin.zip Normal file

Binary file not shown.