mirror of
https://github.com/mailscope/kumomta.git
synced 2026-09-10 12:32:13 +00:00
spf: move top-level error handling into EvalContext::new()
This commit is contained in:
committed by
Wez Furlong
parent
871986cb5e
commit
3a758681d8
@@ -15,11 +15,13 @@ pub struct EvalContext<'a> {
|
||||
}
|
||||
|
||||
impl<'a> EvalContext<'a> {
|
||||
pub fn new(sender: &'a str, domain: &'a str, client_ip: IpAddr) -> Result<Self, String> {
|
||||
pub fn new(sender: &'a str, domain: &'a str, client_ip: IpAddr) -> Result<Self, SpfResult> {
|
||||
let Some((local_part, sender_domain)) = sender.split_once('@') else {
|
||||
return Err(format!(
|
||||
"invalid sender {sender} is missing @ sign to delimit local part and domain"
|
||||
));
|
||||
return Err(SpfResult {
|
||||
disposition: SpfDisposition::PermError,
|
||||
context:
|
||||
"input sender parameter '{sender}' is missing @ sign to delimit local part and domain".to_owned(),
|
||||
});
|
||||
};
|
||||
|
||||
Ok(Self {
|
||||
|
||||
@@ -106,13 +106,7 @@ impl CheckHostParams {
|
||||
|
||||
match EvalContext::new(&self.sender, &self.domain, self.client_ip) {
|
||||
Ok(cx) => record.evaluate(&cx, resolver).await,
|
||||
Err(err) => SpfResult {
|
||||
disposition: SpfDisposition::PermError,
|
||||
context: format!(
|
||||
"input sender parameter '{}' is malformed: {err}",
|
||||
self.sender
|
||||
),
|
||||
},
|
||||
Err(err) => err,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user