mirror of
https://github.com/chatmail/relay.git
synced 2026-09-13 19:03:14 +00:00
refactor: derive Default for Envelope (#100)
This commit is contained in:
@@ -7,7 +7,7 @@ use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter};
|
|||||||
use tokio::net::{TcpListener, TcpStream};
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
|
|
||||||
/// Represents an SMTP envelope with sender, recipients, and raw message data.
|
/// Represents an SMTP envelope with sender, recipients, and raw message data.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct Envelope {
|
pub struct Envelope {
|
||||||
pub mail_from: String,
|
pub mail_from: String,
|
||||||
pub origin_ip: String,
|
pub origin_ip: String,
|
||||||
@@ -86,12 +86,7 @@ where
|
|||||||
writer.write_all(b"220 filtermail SMTP\r\n").await?;
|
writer.write_all(b"220 filtermail SMTP\r\n").await?;
|
||||||
writer.flush().await?;
|
writer.flush().await?;
|
||||||
|
|
||||||
let mut envelope = Envelope {
|
let mut envelope = Envelope::default();
|
||||||
mail_from: String::new(),
|
|
||||||
origin_ip: String::new(),
|
|
||||||
rcpt_to: Vec::new(),
|
|
||||||
data: Vec::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
'connection: loop {
|
'connection: loop {
|
||||||
line.clear();
|
line.clear();
|
||||||
@@ -199,12 +194,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
envelope = Envelope {
|
envelope = Envelope::default();
|
||||||
mail_from: String::new(),
|
|
||||||
origin_ip: String::new(),
|
|
||||||
rcpt_to: Vec::new(),
|
|
||||||
data: Vec::new(),
|
|
||||||
};
|
|
||||||
} else if cmd.to_uppercase().starts_with("XFORWARD") {
|
} else if cmd.to_uppercase().starts_with("XFORWARD") {
|
||||||
// https://www.postfix.org/XFORWARD_README.html
|
// https://www.postfix.org/XFORWARD_README.html
|
||||||
if let Some(addr_part) = cmd
|
if let Some(addr_part) = cmd
|
||||||
@@ -222,12 +212,7 @@ where
|
|||||||
writer.flush().await?;
|
writer.flush().await?;
|
||||||
break 'connection;
|
break 'connection;
|
||||||
} else if cmd.to_uppercase().starts_with("RSET") {
|
} else if cmd.to_uppercase().starts_with("RSET") {
|
||||||
envelope = Envelope {
|
envelope = Envelope::default();
|
||||||
mail_from: String::new(),
|
|
||||||
origin_ip: String::new(),
|
|
||||||
rcpt_to: Vec::new(),
|
|
||||||
data: Vec::new(),
|
|
||||||
};
|
|
||||||
writer.write_all(b"250 OK\r\n").await?;
|
writer.write_all(b"250 OK\r\n").await?;
|
||||||
writer.flush().await?;
|
writer.flush().await?;
|
||||||
} else if cmd.to_uppercase().starts_with("NOOP") {
|
} else if cmd.to_uppercase().starts_with("NOOP") {
|
||||||
|
|||||||
Reference in New Issue
Block a user