BREAKING CHANGE(smartmta): Rebrand package to @push.rocks/smartmta, add consolidated email security verification and IPC handler
This commit is contained in:
@@ -491,6 +491,75 @@ async fn handle_ipc_request(req: &IpcRequest) -> IpcResponse {
|
||||
}
|
||||
}
|
||||
|
||||
"verifyEmail" => {
|
||||
let raw_message = req
|
||||
.params
|
||||
.get("rawMessage")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
let ip_str = req.params.get("ip").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let helo = req
|
||||
.params
|
||||
.get("heloDomain")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
let hostname = req
|
||||
.params
|
||||
.get("hostname")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("localhost");
|
||||
let mail_from = req
|
||||
.params
|
||||
.get("mailFrom")
|
||||
.and_then(|v| v.as_str())
|
||||
.unwrap_or("");
|
||||
|
||||
match ip_str.parse::<IpAddr>() {
|
||||
Ok(ip_addr) => {
|
||||
let authenticator = match mailer_security::default_authenticator() {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
return IpcResponse {
|
||||
id: req.id.clone(),
|
||||
success: false,
|
||||
result: None,
|
||||
error: Some(format!("Authenticator error: {}", e)),
|
||||
};
|
||||
}
|
||||
};
|
||||
match mailer_security::verify_email_security(
|
||||
raw_message.as_bytes(),
|
||||
ip_addr,
|
||||
helo,
|
||||
hostname,
|
||||
mail_from,
|
||||
&authenticator,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(result) => IpcResponse {
|
||||
id: req.id.clone(),
|
||||
success: true,
|
||||
result: Some(serde_json::to_value(&result).unwrap()),
|
||||
error: None,
|
||||
},
|
||||
Err(e) => IpcResponse {
|
||||
id: req.id.clone(),
|
||||
success: false,
|
||||
result: None,
|
||||
error: Some(e.to_string()),
|
||||
},
|
||||
}
|
||||
}
|
||||
Err(e) => IpcResponse {
|
||||
id: req.id.clone(),
|
||||
success: false,
|
||||
result: None,
|
||||
error: Some(format!("Invalid IP address: {}", e)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
"checkSpf" => {
|
||||
let ip_str = req.params.get("ip").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let helo = req
|
||||
|
||||
Reference in New Issue
Block a user