mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2024-11-28 09:07:32 +00:00
Configurable milter protocol flags
This commit is contained in:
parent
e73c82e7d8
commit
758280837d
5 changed files with 35 additions and 11 deletions
|
@ -286,6 +286,8 @@ pub struct Milter {
|
|||
pub tempfail_on_error: bool,
|
||||
pub max_frame_len: usize,
|
||||
pub protocol_version: milter::Version,
|
||||
pub flags_actions: Option<u32>,
|
||||
pub flags_protocol: Option<u32>,
|
||||
}
|
||||
|
||||
pub struct SessionConfig {
|
||||
|
|
|
@ -498,6 +498,16 @@ impl ConfigSession for Config {
|
|||
2 => milter::Version::V2,
|
||||
v => return Err(format!("Unsupported milter protocol version: {}", v)),
|
||||
},
|
||||
flags_actions: self.property((
|
||||
"session.data.milter",
|
||||
id,
|
||||
"options.flags.actions",
|
||||
))?,
|
||||
flags_protocol: self.property((
|
||||
"session.data.milter",
|
||||
id,
|
||||
"options.flags.protocol",
|
||||
))?,
|
||||
})
|
||||
}
|
||||
Ok(milters)
|
||||
|
|
|
@ -55,6 +55,17 @@ impl MilterClient<TcpStream> {
|
|||
options: 0,
|
||||
version: config.protocol_version,
|
||||
span,
|
||||
flags_actions: config.flags_actions.unwrap_or(
|
||||
SMFIF_ADDHDRS
|
||||
| SMFIF_CHGBODY
|
||||
| SMFIF_ADDRCPT
|
||||
| SMFIF_DELRCPT
|
||||
| SMFIF_CHGHDRS
|
||||
| SMFIF_QUARANTINE
|
||||
| SMFIF_CHGFROM
|
||||
| SMFIF_ADDRCPT_PAR,
|
||||
),
|
||||
flags_protocol: config.flags_protocol.unwrap_or(0x42),
|
||||
});
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -89,6 +100,8 @@ impl MilterClient<TcpStream> {
|
|||
options: self.options,
|
||||
version: self.version,
|
||||
span: self.span,
|
||||
flags_actions: self.flags_actions,
|
||||
flags_protocol: self.flags_protocol,
|
||||
})
|
||||
})
|
||||
.await
|
||||
|
@ -103,15 +116,8 @@ impl<T: AsyncRead + AsyncWrite + Unpin> MilterClient<T> {
|
|||
Version::V2 => 2,
|
||||
Version::V6 => 6,
|
||||
},
|
||||
actions: SMFIF_ADDHDRS
|
||||
| SMFIF_CHGBODY
|
||||
| SMFIF_ADDRCPT
|
||||
| SMFIF_DELRCPT
|
||||
| SMFIF_CHGHDRS
|
||||
| SMFIF_QUARANTINE
|
||||
| SMFIF_CHGFROM
|
||||
| SMFIF_ADDRCPT_PAR,
|
||||
protocol: SMFIP_SKIP,
|
||||
actions: self.flags_actions,
|
||||
protocol: self.flags_protocol,
|
||||
}))
|
||||
.await?;
|
||||
match self.read().await? {
|
||||
|
|
|
@ -43,6 +43,8 @@ pub struct MilterClient<T: AsyncRead + AsyncWrite> {
|
|||
receiver: Receiver,
|
||||
version: Version,
|
||||
options: u32,
|
||||
flags_actions: u32,
|
||||
flags_protocol: u32,
|
||||
span: tracing::Span,
|
||||
}
|
||||
|
||||
|
|
|
@ -374,12 +374,14 @@ fn milter_frame_receiver() {
|
|||
#[tokio::test]
|
||||
#[ignore]
|
||||
async fn milter_client_test() {
|
||||
//const PORT : u16 = 11332;
|
||||
const PORT: u16 = 7357;
|
||||
let mut client = MilterClient::connect(
|
||||
&Milter {
|
||||
enable: IfBlock::default(),
|
||||
addrs: vec![SocketAddr::from(([127, 0, 0, 1], 11332))],
|
||||
addrs: vec![SocketAddr::from(([127, 0, 0, 1], PORT))],
|
||||
hostname: "localhost".to_string(),
|
||||
port: 11332,
|
||||
port: PORT,
|
||||
timeout_connect: Duration::from_secs(10),
|
||||
timeout_command: Duration::from_secs(30),
|
||||
timeout_data: Duration::from_secs(30),
|
||||
|
@ -388,6 +390,8 @@ async fn milter_client_test() {
|
|||
tempfail_on_error: false,
|
||||
max_frame_len: 5000000,
|
||||
protocol_version: Version::V6,
|
||||
flags_actions: None,
|
||||
flags_protocol: None,
|
||||
},
|
||||
tracing::span!(tracing::Level::TRACE, "hi"),
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue