Import upstream v0.16.22, stripped
Upstream commit: 474dd0229cb20cf513036619781ed97bd8073c3f Enterprise-only files removed or emptied: 63 Enterprise-only snippets removed: 117 in 50 files Dangling module declarations removed: 5 Cargo edits turning enterprise off: 14 Verification: clean Enterprise feature gates left for rebuilt features: 19 in 18 files Produced by tools/fork/strip.py. The full report is in docs/fork/strip-reports/ on main.
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
[package]
|
||||
name = "stalwart"
|
||||
description = "Stalwart Mail and Collaboration Server"
|
||||
authors = [ "Stalwart Labs LLC <[email protected]>"]
|
||||
repository = "https://github.com/stalwartlabs/stalwart"
|
||||
homepage = "https://stalw.art"
|
||||
keywords = ["imap", "jmap", "smtp", "email", "mail", "webdav", "server"]
|
||||
categories = ["email"]
|
||||
license = "AGPL-3.0-only OR LicenseRef-SEL"
|
||||
version = "0.16.22"
|
||||
edition = "2024"
|
||||
|
||||
[[bin]]
|
||||
name = "stalwart"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
store = { path = "../store" }
|
||||
coordinator = { path = "../coordinator" }
|
||||
jmap = { path = "../jmap" }
|
||||
types = { path = "../types" }
|
||||
smtp = { path = "../smtp" }
|
||||
smtp-proto = { version = "0.2", features = ["rkyv", "serde"] }
|
||||
imap = { path = "../imap" }
|
||||
pop3 = { path = "../pop3" }
|
||||
spam-filter = { path = "../spam-filter" }
|
||||
managesieve = { path = "../managesieve" }
|
||||
common = { path = "../common" }
|
||||
email = { path = "../email" }
|
||||
directory = { path = "../directory" }
|
||||
http = { path = "../http" }
|
||||
scim = { path = "../scim" }
|
||||
dav = { path = "../dav" }
|
||||
groupware = { path = "../groupware" }
|
||||
services = { path = "../services" }
|
||||
trc = { path = "../trc" }
|
||||
utils = { path = "../utils" }
|
||||
registry = { path = "../registry" }
|
||||
http_proto = { path = "../http-proto" }
|
||||
migration = { path = "../migration" }
|
||||
tokio = { version = "1.53", features = ["full"] }
|
||||
rustls = { version = "0.23.43", default-features = false, features = ["std", "aws_lc_rs", "tls12"] }
|
||||
|
||||
[target.'cfg(not(any(target_env = "msvc", target_os = "freebsd")))'.dependencies]
|
||||
tikv-jemallocator = "0.7"
|
||||
|
||||
[features]
|
||||
#default = ["sqlite", "postgres", "mysql", "rocks", "s3", "redis", "azure", "nats", "enterprise", "zenoh", "kafka"]
|
||||
#default = ["sqlite", "postgres", "mysql", "rocks", "s3", "redis", "azure", "nats", "enterprise"]
|
||||
default = ["rocks"]
|
||||
sqlite = ["store/sqlite", "directory/sqlite"]
|
||||
foundationdb = ["store/foundation", "common/foundation"]
|
||||
postgres = ["store/postgres", "directory/postgres"]
|
||||
mysql = ["store/mysql", "directory/mysql"]
|
||||
rocks = ["store/rocks"]
|
||||
s3 = ["store/s3"]
|
||||
redis = ["store/redis", "coordinator/redis"]
|
||||
azure = ["store/azure"]
|
||||
nats = ["coordinator/nats"]
|
||||
zenoh = ["coordinator/zenoh"]
|
||||
kafka = ["coordinator/kafka"]
|
||||
enterprise = [ "jmap/enterprise",
|
||||
"smtp/enterprise",
|
||||
"common/enterprise",
|
||||
"store/enterprise",
|
||||
"managesieve/enterprise",
|
||||
"directory/enterprise",
|
||||
"email/enterprise",
|
||||
"spam-filter/enterprise",
|
||||
"http/enterprise",
|
||||
"scim/enterprise",
|
||||
"dav/enterprise",
|
||||
"groupware/enterprise",
|
||||
"trc/enterprise",
|
||||
"services/enterprise",
|
||||
"migration/enterprise" ]
|
||||
dev_mode = [ "common/dev_mode",
|
||||
"trc/dev_mode",
|
||||
"dav/dev_mode",
|
||||
"http/dev_mode",
|
||||
"http_proto/dev_mode",
|
||||
"jmap/dev_mode" ]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
#![warn(clippy::large_futures)]
|
||||
#![warn(clippy::cast_possible_truncation)]
|
||||
#![warn(clippy::cast_possible_wrap)]
|
||||
#![warn(clippy::cast_sign_loss)]
|
||||
|
||||
use common::{BuildServer, config::server::ServerProtocol, manager::boot::BootManager};
|
||||
use http::HttpSessionManager;
|
||||
use imap::core::ImapSessionManager;
|
||||
use managesieve::core::ManageSieveSessionManager;
|
||||
use pop3::Pop3SessionManager;
|
||||
use services::{StartServices, broadcast::subscriber::spawn_broadcast_subscriber};
|
||||
use smtp::{StartQueueManager, core::SmtpSessionManager};
|
||||
use std::time::Duration;
|
||||
use trc::Collector;
|
||||
use utils::wait_for_shutdown;
|
||||
|
||||
#[cfg(feature = "dev_mode")]
|
||||
pub mod test_data;
|
||||
|
||||
#[cfg(not(any(target_env = "msvc", target_os = "freebsd")))]
|
||||
use tikv_jemallocator::Jemalloc;
|
||||
|
||||
#[cfg(not(any(target_env = "msvc", target_os = "freebsd")))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
// Install AWS-LC-RS as the default Rustls crypto provider
|
||||
rustls::crypto::aws_lc_rs::default_provider()
|
||||
.install_default()
|
||||
.expect("failed to install aws-lc-rs as the default rustls crypto provider");
|
||||
|
||||
// Build the shared outbound TLS configurations
|
||||
utils::http::init_shared_tls_configs();
|
||||
|
||||
// Load config and apply macros
|
||||
let mut init = Box::pin(BootManager::init()).await;
|
||||
|
||||
// Migrate database
|
||||
if let Err(err) = migration::try_migrate(&init.inner.build_server()).await {
|
||||
trc::event!(
|
||||
Server(trc::ServerEvent::StartupError),
|
||||
Details = "Failed to migrate database, aborting startup.",
|
||||
Reason = err,
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Init services
|
||||
init.start_services().await;
|
||||
init.start_queue_manager();
|
||||
|
||||
// Log configuration errors
|
||||
init.bootstrap.log_errors();
|
||||
init.bootstrap.log_warnings();
|
||||
|
||||
|
||||
#[cfg(feature = "dev_mode")]
|
||||
if std::env::var("INSERT_TEST_DATA").is_ok() {
|
||||
let server = init.inner.build_server();
|
||||
test_data::insert_test_data(&server).await;
|
||||
server.insert_test_metrics().await;
|
||||
}
|
||||
|
||||
// Spawn servers
|
||||
let (shutdown_tx, shutdown_rx) = init.servers.spawn(|server, acceptor, shutdown_rx| {
|
||||
match &server.protocol {
|
||||
ServerProtocol::Smtp | ServerProtocol::Lmtp => server.spawn(
|
||||
SmtpSessionManager::new(init.inner.clone()),
|
||||
init.inner.clone(),
|
||||
acceptor,
|
||||
shutdown_rx,
|
||||
),
|
||||
ServerProtocol::Http => server.spawn(
|
||||
HttpSessionManager::new(init.inner.clone()),
|
||||
init.inner.clone(),
|
||||
acceptor,
|
||||
shutdown_rx,
|
||||
),
|
||||
ServerProtocol::Imap => server.spawn(
|
||||
ImapSessionManager::new(init.inner.clone()),
|
||||
init.inner.clone(),
|
||||
acceptor,
|
||||
shutdown_rx,
|
||||
),
|
||||
ServerProtocol::Pop3 => server.spawn(
|
||||
Pop3SessionManager::new(init.inner.clone()),
|
||||
init.inner.clone(),
|
||||
acceptor,
|
||||
shutdown_rx,
|
||||
),
|
||||
ServerProtocol::ManageSieve => server.spawn(
|
||||
ManageSieveSessionManager::new(init.inner.clone()),
|
||||
init.inner.clone(),
|
||||
acceptor,
|
||||
shutdown_rx,
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
// Start broadcast subscriber
|
||||
spawn_broadcast_subscriber(init.inner, shutdown_rx);
|
||||
|
||||
// Wait for shutdown signal
|
||||
wait_for_shutdown().await;
|
||||
|
||||
// Shutdown collector
|
||||
Collector::shutdown();
|
||||
|
||||
// Stop services
|
||||
let _ = shutdown_tx.send(true);
|
||||
|
||||
// Wait for services to finish
|
||||
tokio::time::sleep(Duration::from_secs(1)).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user