mirror of
https://github.com/chatmail/relay.git
synced 2026-09-14 11:23:14 +00:00
refactor(transport): Explicitly handle RFC7505 null MX
Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
This commit is contained in:
@@ -62,14 +62,23 @@ impl TransportHandler {
|
|||||||
|
|
||||||
match dns_resolver.mx_lookup(query).await {
|
match dns_resolver.mx_lookup(query).await {
|
||||||
Ok(mx_records) => {
|
Ok(mx_records) => {
|
||||||
let mut hosts: Vec<(u16, String)> = mx_records
|
let mut hosts: Vec<(u16, String)> = Vec::new();
|
||||||
.iter()
|
for mx in mx_records {
|
||||||
.map(|mx| {
|
// Null MX / RFC7505
|
||||||
let host =
|
if mx.exchange().is_root() {
|
||||||
mx.exchange().to_string().trim_end_matches('.').to_string();
|
// From RFC7505 section 3:
|
||||||
(mx.preference(), host)
|
// > A domain that advertises a null MX MUST NOT
|
||||||
})
|
// > advertise any other MX RR.
|
||||||
.collect();
|
// We assume this is the only record and exit early.
|
||||||
|
return Err(
|
||||||
|
"556 5.1.10 Permanent failure: Recipient address has null MX"
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let host = mx.exchange().to_string().trim_end_matches('.').to_string();
|
||||||
|
hosts.push((mx.preference(), host))
|
||||||
|
}
|
||||||
hosts.sort();
|
hosts.sort();
|
||||||
hosts
|
hosts
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user