summaryrefslogtreecommitdiffstats
path: root/ingress/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ingress/src/main.rs')
-rw-r--r--ingress/src/main.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/ingress/src/main.rs b/ingress/src/main.rs
index 4f8dff6..21da30f 100644
--- a/ingress/src/main.rs
+++ b/ingress/src/main.rs
@@ -41,7 +41,11 @@ fn dry_run() -> bool {
}
fn split_address(address: &str) -> Result<(&str, &str)> {
- if address.len() > 320 || address.chars().any(|c| matches!(c, '\r' | '\n' | '\0' | ' ')) {
+ if address.len() > 320
+ || address
+ .chars()
+ .any(|c| matches!(c, '\r' | '\n' | '\0' | ' '))
+ {
bail!("invalid entry address");
}
let (local, domain) = address
@@ -74,7 +78,10 @@ async fn smtp_read_response<R: AsyncRead + Unpin>(reader: &mut BufReader<R>) ->
let mut line = String::new();
loop {
line.clear();
- let read = reader.read_line(&mut line).await.context("read SMTP response")?;
+ let read = reader
+ .read_line(&mut line)
+ .await
+ .context("read SMTP response")?;
if read == 0 {
bail!("SMTP connection closed");
}
@@ -113,9 +120,7 @@ async fn smtp_command<S: AsyncRead + AsyncWrite + Unpin>(
async fn deliver(entry_address: &str, payload: &[u8]) -> Result<()> {
let (_, host) = split_address(entry_address)?;
let proxy = env::var("YAMN_TOR_SOCKS").unwrap_or_else(|_| "127.0.0.1:9050".to_string());
- let (proxy_host, proxy_port) = proxy
- .rsplit_once(':')
- .context("invalid YAMN_TOR_SOCKS")?;
+ let (proxy_host, proxy_port) = proxy.rsplit_once(':').context("invalid YAMN_TOR_SOCKS")?;
let proxy_port: u16 = proxy_port.parse().context("invalid YAMN_TOR_SOCKS port")?;
let target = format!("{host}:25");
let stream = tokio::time::timeout(
@@ -136,12 +141,7 @@ async fn deliver(entry_address: &str, payload: &[u8]) -> Result<()> {
bail!("invalid YAMN_INGRESS_FROM");
}
smtp_command(&mut reader, b"EHLO yamn-nym-ingress\r\n", 2).await?;
- smtp_command(
- &mut reader,
- format!("MAIL FROM:{from}\r\n").as_bytes(),
- 2,
- )
- .await?;
+ smtp_command(&mut reader, format!("MAIL FROM:{from}\r\n").as_bytes(), 2).await?;
smtp_command(
&mut reader,
format!("RCPT TO:<{entry_address}>\r\n").as_bytes(),