pub struct Resolver { /* private fields */ }Expand description
Looks up the DNS sources.
Build one and keep it. It holds the resolver configuration and a cache of answers.
use abuse_contact::Resolver;
let resolver = Resolver::new()?;
// AFRINIC publishes no abuse contact in RDAP. Abusix has one.
for contact in resolver.abusix("196.216.2.1".parse().unwrap()).await? {
println!("{} ({:?})", contact.email, contact.scope);
}Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn new() -> Result<Self, Error>
pub fn new() -> Result<Self, Error>
Returns a resolver that uses the resolver configuration of the system.
§Errors
Returns Error::Dns when the system configuration cannot be read.
Sourcepub fn with_nameservers(nameservers: &[SocketAddr]) -> Result<Self, Error>
pub fn with_nameservers(nameservers: &[SocketAddr]) -> Result<Self, Error>
Returns a resolver that asks these nameservers, over UDP and TCP.
§Errors
Returns Error::Dns when the resolver cannot be built.
Sourcepub async fn abusix(&self, ip: IpAddr) -> Result<Vec<Contact>, Error>
pub async fn abusix(&self, ip: IpAddr) -> Result<Vec<Contact>, Error>
Returns the contacts Abusix gives for the network that holds an address.
Abusix answers for AFRINIC space, where RDAP publishes no abuse entity.
§Errors
Returns Error::NotPublic for a private or reserved address, and
Error::Dns when the lookup does not finish.
Sourcepub async fn abuse_net(
&self,
domain: &DomainName,
) -> Result<Vec<Contact>, Error>
pub async fn abuse_net( &self, domain: &DomainName, ) -> Result<Vec<Contact>, Error>
Returns the contacts abuse.net gives for a domain.
§Errors
Returns Error::Dns when the lookup does not finish.
Sourcepub async fn rfc2142(
&self,
domain: &DomainName,
) -> Result<Option<Contact>, Error>
pub async fn rfc2142( &self, domain: &DomainName, ) -> Result<Option<Contact>, Error>
Returns abuse@ at the domain, when the domain takes mail.
RFC 2142 requires the mailbox, and many domains do not have it, so the address
is a guess. A domain that takes no mail cannot have it at all, and gives None:
a name that does not exist, a null MX, or no MX and no address.
§Errors
Returns Error::Dns when a lookup does not finish.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Resolver
impl !UnwindSafe for Resolver
impl Freeze for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl UnsafeUnpin for Resolver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more