mirror of
https://github.com/stalwartlabs/smtp-server.git
synced 2024-11-24 06:19:41 +00:00
Aggregate report scheduling at later time.
This commit is contained in:
parent
02385536f7
commit
16713781a2
9 changed files with 34 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1633,6 +1633,7 @@ checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
|
|||
[[package]]
|
||||
name = "smtp-proto"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/stalwartlabs/smtp-proto#cf9640069dac6aec0eb8120b84e17e31d8bce958"
|
||||
|
||||
[[package]]
|
||||
name = "smtp-server"
|
||||
|
|
|
@ -3,13 +3,12 @@ name = "smtp-server"
|
|||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[dependencies]
|
||||
mail-auth = { path = "/home/vagrant/code/mail-auth" }
|
||||
mail-send = { path = "/home/vagrant/code/mail-send", default-features = false, features = ["cram-md5", "skip-ehlo"] }
|
||||
mail-parser = { git = "https://github.com/stalwartlabs/mail-parser", features = ["full_encoding", "ludicrous_mode"] }
|
||||
mail-builder = { path = "/home/vagrant/code/mail-builder", features = ["ludicrous_mode"] }
|
||||
smtp-proto = { path = "/home/vagrant/code/smtp-proto" }
|
||||
smtp-proto = { git = "https://github.com/stalwartlabs/smtp-proto" }
|
||||
ahash = { version = "0.8" }
|
||||
rustls = "0.20"
|
||||
rustls-pemfile = "1.0"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
Stalwart SMTP Server
|
||||
|
||||
# TODO
|
||||
- RBL
|
||||
- Greylist
|
||||
- Sieve
|
||||
- Spam filter
|
||||
|
|
|
@ -261,6 +261,7 @@ impl<T: AsyncWrite + AsyncRead + IsTls + Unpin> Session<T> {
|
|||
reply = ?ips,
|
||||
);
|
||||
}
|
||||
Err(mail_auth::Error::DnsRecordNotFound(_)) => (),
|
||||
Err(err) => {
|
||||
tracing::debug!(parent: &self.span,
|
||||
context = "dnsbl",
|
||||
|
|
|
@ -71,6 +71,7 @@ impl<T: AsyncWrite + AsyncRead + Unpin> Session<T> {
|
|||
report,
|
||||
&config.sign,
|
||||
&self.span,
|
||||
true,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -206,6 +206,7 @@ impl<T: AsyncWrite + AsyncRead + Unpin> Session<T> {
|
|||
report,
|
||||
&config.sign,
|
||||
&self.span,
|
||||
true,
|
||||
)
|
||||
.await;
|
||||
} else {
|
||||
|
@ -379,7 +380,14 @@ impl GenerateDmarcReport for Arc<Core> {
|
|||
);
|
||||
|
||||
// Send report
|
||||
handle.block_on(core.send_report(from_addr, rua.iter(), message, &config.sign, &span));
|
||||
handle.block_on(core.send_report(
|
||||
from_addr,
|
||||
rua.iter(),
|
||||
message,
|
||||
&config.sign,
|
||||
&span,
|
||||
false,
|
||||
));
|
||||
|
||||
if let Err(err) = std::fs::remove_file(&path.path) {
|
||||
tracing::warn!(
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
use std::{sync::Arc, time::SystemTime};
|
||||
use std::{
|
||||
sync::Arc,
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
|
||||
use mail_auth::{
|
||||
common::headers::HeaderWriter,
|
||||
|
@ -9,6 +12,7 @@ use mail_auth::{
|
|||
},
|
||||
};
|
||||
use mail_parser::DateTime;
|
||||
use rand::Rng;
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
|
||||
use crate::{
|
||||
|
@ -104,6 +108,7 @@ impl Core {
|
|||
report: Vec<u8>,
|
||||
sign_config: &IfBlock<Vec<Arc<DkimSigner>>>,
|
||||
span: &tracing::Span,
|
||||
deliver_now: bool,
|
||||
) {
|
||||
// Build message
|
||||
let from_addr_lcase = from_addr.to_lowercase();
|
||||
|
@ -133,6 +138,19 @@ impl Core {
|
|||
// Sign message
|
||||
let signature = message.sign(sign_config, &report, span).await;
|
||||
|
||||
// Schedule delivery at a random time between now and the next 3 hours
|
||||
if !deliver_now {
|
||||
#[cfg(not(test))]
|
||||
{
|
||||
let delivery_time = Duration::from_secs(rand::thread_rng().gen_range(0..10800));
|
||||
for domain in &mut message.domains {
|
||||
domain.retry.due += delivery_time;
|
||||
domain.expires += delivery_time;
|
||||
domain.notify.due += delivery_time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Queue message
|
||||
self.queue
|
||||
.queue_message(message, signature.as_deref(), &report, span)
|
||||
|
|
|
@ -71,6 +71,7 @@ impl<T: AsyncWrite + AsyncRead + Unpin> Session<T> {
|
|||
report,
|
||||
&config.sign,
|
||||
&self.span,
|
||||
true,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -238,6 +238,7 @@ impl GenerateTlsReport for Arc<Core> {
|
|||
message,
|
||||
&config.sign,
|
||||
&span,
|
||||
false,
|
||||
));
|
||||
} else {
|
||||
tracing::info!(
|
||||
|
|
Loading…
Reference in a new issue