mirror of
https://github.com/chatmail/relay.git
synced 2026-09-07 07:53:14 +00:00
feat: configurable hosts for listen and reinject (#84)
Adds configurable listen IP and postfix host via `filtermail_host` and `postfix_host` chatmail.ini config fields.
This commit is contained in:
@@ -1,16 +1,21 @@
|
||||
//! Configuration file handling for filtermail.
|
||||
|
||||
use serde::{Deserialize, Deserializer};
|
||||
use std::net::IpAddr;
|
||||
use std::num::NonZeroU32;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
/// Chatmail configuration subset used by filtermail.
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct Config {
|
||||
#[serde(default = "Config::default_filtermail_host")]
|
||||
pub filtermail_host: IpAddr,
|
||||
#[serde(default = "Config::default_filtermail_smtp_port")]
|
||||
pub filtermail_smtp_port: u16,
|
||||
#[serde(default = "Config::default_filtermail_smtp_port_incoming")]
|
||||
pub filtermail_smtp_port_incoming: u16,
|
||||
#[serde(default = "Config::default_postfix_host")]
|
||||
pub postfix_host: String,
|
||||
#[serde(default = "Config::default_postfix_reinject_port")]
|
||||
pub postfix_reinject_port: u16,
|
||||
#[serde(default = "Config::default_postfix_reinject_port_incoming")]
|
||||
@@ -82,12 +87,18 @@ impl Config {
|
||||
|
||||
// Following are needed since serde does not support default literals.
|
||||
|
||||
const fn default_filtermail_host() -> IpAddr {
|
||||
IpAddr::V4(std::net::Ipv4Addr::LOCALHOST)
|
||||
}
|
||||
const fn default_filtermail_smtp_port() -> u16 {
|
||||
10080
|
||||
}
|
||||
const fn default_filtermail_smtp_port_incoming() -> u16 {
|
||||
10081
|
||||
}
|
||||
fn default_postfix_host() -> String {
|
||||
"127.0.0.1".to_owned()
|
||||
}
|
||||
const fn default_postfix_reinject_port() -> u16 {
|
||||
10025
|
||||
}
|
||||
@@ -112,8 +123,10 @@ impl Default for Config {
|
||||
/// Used for tests.
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
filtermail_host: Self::default_filtermail_host(),
|
||||
filtermail_smtp_port: Self::default_filtermail_smtp_port(),
|
||||
filtermail_smtp_port_incoming: Self::default_filtermail_smtp_port_incoming(),
|
||||
postfix_host: Self::default_postfix_host(),
|
||||
postfix_reinject_port: Self::default_postfix_reinject_port(),
|
||||
postfix_reinject_port_incoming: Self::default_postfix_reinject_port_incoming(),
|
||||
max_message_size: Self::default_max_message_size(),
|
||||
|
||||
Reference in New Issue
Block a user