pub struct Resolver { /* private fields */ }Expand description
Resolves names to addresses from the hosts file, unicast DNS and multicast DNS.
The hosts file and the resolver configuration are read at each resolution
pass, so one resolver kept for the life of a front end resolves as the host
does at the time. Cheap to clone, and shared across the concurrent lookups
resolve_names runs.
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn from_system() -> Self
pub fn from_system() -> Self
Builds a resolver from the host’s own configuration, with mDNS enabled.
A host whose resolver configuration cannot be read, such as a container
or a lab VM with no name server in resolv.conf, still resolves names
in its hosts file and .local names. A name that needed a DNS server
comes back empty, with a warning saying why.
Sourcepub fn with_config(config: ResolveConfig) -> Self
pub fn with_config(config: ResolveConfig) -> Self
Builds a resolver with an explicit ResolveConfig.
Sourcepub fn hosts_file_only() -> Self
pub fn hosts_file_only() -> Self
Builds a resolver that answers from the host’s hosts file alone and puts nothing on the network: no unicast query and no multicast one.
For a caller that must not send name queries, such as a scan under
ZondConfig::no_dns. The hosts
file is where a lab box reached over a VPN gets its name, and reading it
sends nothing. A name the file does not list resolves to nothing, which
the target functions report as an unknown host.
Sourcepub async fn resolve(&self, name: &str) -> Vec<IpAddr>
pub async fn resolve(&self, name: &str) -> Vec<IpAddr>
Resolves one name to every address it stands for, in first-seen order.
An empty result means nothing answered for the name. See the module
documentation for where each kind of name is answered. Reads the host’s
configuration for this one name; a caller with many wants
resolve_names, which reads it once.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resolver
impl RefUnwindSafe for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl UnsafeUnpin for Resolver
impl UnwindSafe for Resolver
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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