From b7378dba78a97243d67271ec94312e5abf87c22c Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Sun, 28 May 2023 11:02:54 -0400 Subject: [PATCH] Fix some logic errors in Sender::send, as before it was sending to the sender rather than the recipient --- src/mailstore/mod.rs | 5 +---- src/sender/mod.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/mailstore/mod.rs b/src/mailstore/mod.rs index acbb3d3..5186ad1 100644 --- a/src/mailstore/mod.rs +++ b/src/mailstore/mod.rs @@ -1,8 +1,5 @@ use crate::prelude::{Host, Mailbox, Mailuser, Message, ParseMailboxError}; -use std::{ - collections::HashMap, - str::FromStr, -}; +use std::{collections::HashMap, str::FromStr}; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; diff --git a/src/sender/mod.rs b/src/sender/mod.rs index 91c18b1..bb49891 100644 --- a/src/sender/mod.rs +++ b/src/sender/mod.rs @@ -1,5 +1,5 @@ use { - crate::prelude::{CertificateStore, ClientCertificateStore, Request, Response}, + crate::prelude::{CertificateStore, ClientCertificateStore, Mailuser, Request, Response}, rustls::{internal::msgs::codec::Codec, ClientConfig, ClientConnection, StreamOwned}, std::{ io::{self, Read, Write}, @@ -25,7 +25,7 @@ where pub request: Request, /// A [CertificateStore] for servers known to us pub store: S, - /// A [CertificateStore] for mailboxes which exist on this system + /// A [ClientCertificateStore] for mailboxes which exist on this system pub client_store: C, } @@ -47,13 +47,13 @@ where self.request.sender.host.to_string() } - pub fn send(self) -> Result { - let dnsname = self - .host_string() + pub fn send(self, recipient: &Mailuser) -> Result { + let dnsname = recipient + .to_string() .as_str() .try_into() .map_err(|_| Error::DnsError)?; - let mut it = self.request.sender.host.to_socket_addrs()?; + let mut it = recipient.host.to_socket_addrs()?; let client_cert = self.client_store.get_certificate(&self.request.sender); let verifier = Arc::new(Verifier::new(self.store)); let Some(socket_addrs) = it.next() else {