7 unstable releases
0.4.1 | Feb 10, 2024 |
---|---|
0.4.0 | Feb 12, 2022 |
0.3.0 | May 29, 2021 |
0.2.2 | Aug 25, 2019 |
0.1.0 | Jan 19, 2019 |
#159 in Email
99 downloads per month
18KB
399 lines
MX DNS
DNS utilities for mail servers. Currently this crate supports reverse DNS lookups and lookups against dns based blocklists.
Example
use mxdns::{MxDns, FCrDNS};
let blocklists = vec!["zen.spamhaus.org.","dnsbl-1.uceprotect.net."];
let mxdns = MxDns::new(blocklists).unwrap();
// Check if an IP Address is present on blocklists
let is_blocked = mxdns.is_blocked([127, 0, 0, 2]).unwrap();
assert!(is_blocked);
// Reverse lookup a DNS address
let rdns = mxdns.reverse_dns([193, 25, 101, 5]).unwrap().unwrap();
assert_eq!(rdns, "mail.alienscience.org.");
// Check that the ip resolved from the name obtained by the reverse dns matches the ip
if let Ok(FCrDNS::Confirmed(_domain)) = mxdns.fcrdns([193, 25, 101, 5]) {
// _domain is Confirmed
}
lib.rs
:
DNS utilities for email servers.
Currently, DNS based blocklists and reverse DNS lookups are supported. The crate also supports forward confirmed reverse dns checks.
Because blocklists are IP4 based, these utilities only support IP4 addresses. IP6 addresses are converted to IP4 when possible.
Examples
use mxdns::{MxDns, FCrDNS};
let blocklists = vec!["zen.spamhaus.org.","dnsbl-1.uceprotect.net."];
let mxdns = MxDns::new(blocklists).unwrap();
// Check if an IP Address is present on blocklists
let is_blocked = mxdns.is_blocked([127, 0, 0, 2]).unwrap();
assert!(is_blocked);
// Reverse lookup a DNS address
let rdns = mxdns.reverse_dns([193, 25, 101, 5]).unwrap().unwrap();
assert_eq!(rdns, "mail.alienscience.org.");
// Check that the ip resolved from the name obtained by the reverse dns matches the ip
if let Ok(FCrDNS::Confirmed(_domain)) = mxdns.fcrdns([193, 25, 101, 5]) {
// _domain is Confirmed
}
Dependencies
~5–14MB
~192K SLoC