pub struct ServerConfig {Show 24 fields
pub domain: String,
pub postmaster: String,
pub smtp: SmtpServerConfig,
pub imap: Option<ImapServerConfig>,
pub jmap: Option<JmapServerConfig>,
pub pop3: Option<Pop3ServerConfig>,
pub storage: StorageConfig,
pub processors: Vec<ProcessorConfig>,
pub runtime_dir: String,
pub relay: Option<RelayConfig>,
pub auth: Option<AuthConfig>,
pub logging: Option<LoggingConfig>,
pub queue: Option<QueueConfig>,
pub security: Option<SecurityConfig>,
pub domains: Option<DomainsConfig>,
pub metrics: Option<MetricsConfig>,
pub tracing: Option<TracingConfig>,
pub connection_limits: Option<ConnectionLimitsConfig>,
pub performance: PerformanceConfig,
pub tls: Option<TlsConfig>,
pub chroot: bool,
pub run_as_user: String,
pub run_as_group: String,
pub extra: Vec<String>,
}Expand description
Main server configuration.
Loaded from a TOML or YAML file via ServerConfig::from_file.
All optional sections default to None; required fields (domain,
postmaster, smtp, storage, processors) must be present.
Fields§
§domain: StringRequired. Primary mail domain served by this RusMES installation
(e.g. "mail.example.com"). Must be a syntactically valid domain name.
postmaster: StringRequired. RFC 5321 postmaster email address (e.g. "postmaster@example.com").
Used as the envelope sender for system-generated bounce messages.
smtp: SmtpServerConfigRequired. SMTP listener configuration (host, port, TLS port, size limits).
imap: Option<ImapServerConfig>Default: None. IMAP4rev1 listener configuration. When absent the IMAP
service is not started.
jmap: Option<JmapServerConfig>Default: None. JMAP HTTP listener configuration. When absent the JMAP
service is not started.
pop3: Option<Pop3ServerConfig>Default: None. POP3 listener configuration. When absent the POP3
service is not started.
storage: StorageConfigRequired. Mail storage backend (filesystem, PostgreSQL, or AmateRS).
processors: Vec<ProcessorConfig>Required. Ordered list of processor chains. At least one processor
named "root" must be present.
runtime_dir: StringDefault: "/var/run/rusmes". Per-process runtime directory used for
the PID file, the rate-limiter snapshot, and any other ephemeral state
files. Must be writable by the user running rusmes-server.
relay: Option<RelayConfig>Default: None. Outbound SMTP relay configuration. When absent,
rusmes delivers directly via DNS MX lookup.
auth: Option<AuthConfig>Default: None. Authentication backend configuration (file, LDAP,
SQL, or OAuth2). When absent the server falls back to no-auth mode.
logging: Option<LoggingConfig>Default: None. Logging configuration (level, format, output, file
rotation). When absent the server logs info-level messages to stdout
in text format.
queue: Option<QueueConfig>Default: None. Outbound queue configuration (retry delays, back-off).
When absent, reasonable built-in defaults are used.
security: Option<SecurityConfig>Default: None. Security configuration (relay networks, blocked IPs,
recipient validation). When absent all security checks are disabled.
domains: Option<DomainsConfig>Default: None. Local domain and alias mapping configuration.
When absent only the primary domain is considered local.
metrics: Option<MetricsConfig>Default: None. Prometheus metrics endpoint configuration.
When absent the /metrics endpoint is not exposed.
tracing: Option<TracingConfig>Default: None. OpenTelemetry OTLP tracing configuration.
When absent distributed tracing is disabled.
connection_limits: Option<ConnectionLimitsConfig>Default: None. Per-IP and global connection limit configuration.
When absent no connection caps are enforced.
performance: PerformanceConfigDefault: PerformanceConfig::default(). Runtime performance tuning:
Tokio worker threads, connection pool sizes, and per-connection buffer
sizes. Omitting [performance] uses conservative built-in defaults.
tls: Option<TlsConfig>Default: None. TLS certificate and key paths. Supports a shared
[tls.default] endpoint and optional per-protocol overrides
([tls.smtp], [tls.imap], [tls.pop3], [tls.jmap]).
chroot: boolDefault: false. When true, call chroot(runtime_dir) after binding
all sockets and loading TLS material, before dropping privileges.
Has effect only on Linux; on other platforms a tracing::warn! is
emitted and this field is otherwise ignored.
run_as_user: StringDefault: "" (no-op). System user name to setuid to after binding
all sockets. The empty string means “do not change UID”. Only
effective on Linux; ignored on other platforms (with a warning).
run_as_group: StringDefault: "" (no-op). System group name to setgid to after binding
all sockets. The empty string means “do not change GID”. Only
effective on Linux; ignored on other platforms (with a warning).
extra: Vec<String>Unknown TOML/YAML keys captured for diagnostic warnings.
Not serialized to output. Populated by ServerConfig::from_file
via a two-phase parse (raw toml::Value → known-key diff) so that
warn_unknown_keys can emit tracing::warn! for each entry.
Exposed as pub so tests can assert on which keys were captured
without relying on subscriber interception.
Implementations§
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn apply_env_overrides(&mut self)
pub fn apply_env_overrides(&mut self)
Apply environment variable overrides to configuration.
Environment variables follow the convention RUSMES_SECTION_KEY.
Priority: env vars > config file > defaults.
Supported environment variables:
RUSMES_DOMAINRUSMES_POSTMASTERRUSMES_SMTP_HOSTRUSMES_SMTP_PORTRUSMES_SMTP_TLS_PORTRUSMES_SMTP_MAX_MESSAGE_SIZERUSMES_SMTP_REQUIRE_AUTHRUSMES_SMTP_ENABLE_STARTTLSRUSMES_SMTP_RATE_LIMIT_MAX_CONNECTIONS_PER_IPRUSMES_SMTP_RATE_LIMIT_MAX_MESSAGES_PER_HOURRUSMES_SMTP_RATE_LIMIT_WINDOW_DURATIONRUSMES_IMAP_HOSTRUSMES_IMAP_PORTRUSMES_IMAP_TLS_PORTRUSMES_JMAP_HOSTRUSMES_JMAP_PORTRUSMES_JMAP_BASE_URLRUSMES_STORAGE_PATH(for filesystem backend)RUSMES_LOG_LEVELRUSMES_LOG_FORMATRUSMES_LOG_OUTPUTRUSMES_QUEUE_INITIAL_DELAYRUSMES_QUEUE_MAX_DELAYRUSMES_QUEUE_BACKOFF_MULTIPLIERRUSMES_QUEUE_MAX_ATTEMPTSRUSMES_QUEUE_WORKER_THREADSRUSMES_QUEUE_BATCH_SIZERUSMES_METRICS_ENABLEDRUSMES_METRICS_BIND_ADDRESSRUSMES_METRICS_PATHRUSMES_TRACING_ENABLEDRUSMES_TRACING_ENDPOINTRUSMES_TRACING_PROTOCOL(grpc or http)RUSMES_TRACING_SERVICE_NAMERUSMES_TRACING_SAMPLE_RATIORUSMES_CONNECTION_LIMITS_MAX_CONNECTIONS_PER_IPRUSMES_CONNECTION_LIMITS_MAX_TOTAL_CONNECTIONSRUSMES_CONNECTION_LIMITS_IDLE_TIMEOUTRUSMES_CONNECTION_LIMITS_REAPER_INTERVAL
Source§impl ServerConfig
impl ServerConfig
Sourcepub fn from_file(path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(path: impl AsRef<Path>) -> Result<Self>
Load configuration from a TOML or YAML file.
The format is auto-detected based on file extension:
.tomlfiles are parsed as TOML.yamlor.ymlfiles are parsed as YAML
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate the entire configuration.
This method is called automatically when loading configuration from a file. It validates:
- Domain name format
- Postmaster email address
- Port numbers for SMTP, IMAP, JMAP
- Storage path accessibility
- Processor uniqueness
- Local domain names (if configured)
Sourcepub fn postmaster_address(&self) -> Result<MailAddress>
pub fn postmaster_address(&self) -> Result<MailAddress>
Get postmaster address.
Sourcepub fn tls_for_protocol(
&self,
proto: ProtocolKind,
) -> Option<&TlsEndpointConfig>
pub fn tls_for_protocol( &self, proto: ProtocolKind, ) -> Option<&TlsEndpointConfig>
Return the TlsEndpointConfig for proto, or None if no TLS is
configured.
Delegates to TlsConfig::tls_for_protocol which returns the
per-protocol override when present and falls back to tls.default.
Sourcepub fn warn_unknown_keys(&self)
pub fn warn_unknown_keys(&self)
Emit tracing::warn! for every unknown top-level configuration key.
Called automatically by ServerConfig::from_file after
deserialization. Operators can use the warnings to detect typos or
stale keys without causing a hard failure.
Trait Implementations§
Source§impl Clone for ServerConfig
impl Clone for ServerConfig
Source§fn clone(&self) -> ServerConfig
fn clone(&self) -> ServerConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more