Fix some logic errors in Sender::send, as before it was sending to the

sender rather than the recipient
This commit is contained in:
Nathan Fisher 2023-05-28 11:02:54 -04:00
parent 50644d2d68
commit b7378dba78
2 changed files with 7 additions and 10 deletions

View file

@ -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};

View file

@ -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<Response, Error> {
let dnsname = self
.host_string()
pub fn send(self, recipient: &Mailuser) -> Result<Response, Error> {
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 {