Enum reachable::resolve_policy::ResolvePolicy
source ·
[−]pub enum ResolvePolicy {
Agnostic,
ResolveToIPv4,
ResolveToIPv6,
}
Expand description
A ResolvePolicy allows control over IP address resolution of network targets like IcmpTarget and TcpTarget.
Variants
Agnostic
Resolve use all IP address versions
ResolveToIPv4
Resolve to IPv4 addresses only
ResolveToIPv6
Resolve to IPv6 addresses only
Implementations
Resolve given “fully qualified domain name” (fancy name for a hostname or ip address) to a series of ip addresses associated with given fqhn.
Arguments
- fqhn: string containing “fully qualified domain name” e.g. “::1”, “localhost”.
Returns
- On success, vector containing all ip addresses the fqhn resolved to.
- On failure, a ResolveTargetError. Either failed the name resolution itself or all addresses were filtered out according to ResolvePolicy.
Example
// FQHN was resolved
assert_eq!(
ResolvePolicy::Agnostic.resolve("127.0.0.1").unwrap(),
vec![IpAddr::V4(Ipv4Addr::LOCALHOST)]
);
// FQHN was resolved, but all Addresses were filtered
assert_eq!(ResolvePolicy::ResolveToIPv6.resolve("127.0.0.1").is_err(), true);