Struct ResolvedDestination
pub struct ResolvedDestination { /* private fields */ }Expand description
A normalized host and the exact address set that passed network policy.
Callers must dial Self::addresses directly. Resolving Self::host
again would reopen the DNS-rebinding window this type closes, so the type
deliberately offers no way to get from a value back to a fresh resolution.
Implementations§
Source§impl ResolvedDestination
impl ResolvedDestination
Sourcepub fn new(
host: &str,
port: u16,
addresses: impl IntoIterator<Item = SocketAddr>,
private_access: PrivateNetworkAccess,
nat64_prefixes: &[Nat64Prefix],
) -> Result<Self, NetworkGuardError>
pub fn new( host: &str, port: u16, addresses: impl IntoIterator<Item = SocketAddr>, private_access: PrivateNetworkAccess, nat64_prefixes: &[Nat64Prefix], ) -> Result<Self, NetworkGuardError>
Validate one DNS result and retain the exact addresses to dial.
nat64_prefixes is the deployment’s security.nat64_prefixes, parsed
once by the caller at construction. Passing an empty slice states that
the host runs no network-specific translator; it does not skip the
well-known 64:ff9b::/96 form, which the address predicates decode
unconditionally.
Three things happen here that a bare validator call does not do:
- Cloud metadata is refused for both access modes, so an operator opt-in for private destinations never re-opens it.
- A mixed public/private answer set is refused even when private access is authorized. Otherwise resolver ordering or connection fallback silently decides which trust zone the connection lands in.
- The surviving addresses are retained, which is the pin.
§Errors
Returns NetworkGuardError for a malformed host or port, an empty or
mismatched answer set, a metadata endpoint, an unauthorized private
address, or an answer spanning both address classes.
Sourcepub fn host(&self) -> &str
pub fn host(&self) -> &str
Canonical lowercase host, without IPv6 brackets or a trailing DNS dot. Use this for SNI and certificate verification, never for a second resolution.
Sourcepub fn addresses(&self) -> &[SocketAddr]
pub fn addresses(&self) -> &[SocketAddr]
Exact validated socket addresses. Dial these instead of resolving again.
Trait Implementations§
Source§impl Clone for ResolvedDestination
impl Clone for ResolvedDestination
Source§fn clone(&self) -> ResolvedDestination
fn clone(&self) -> ResolvedDestination
1.0.0 (const: unstable) · §fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResolvedDestination
impl Debug for ResolvedDestination
impl Eq for ResolvedDestination
Source§impl PartialEq for ResolvedDestination
impl PartialEq for ResolvedDestination
Source§fn eq(&self, other: &ResolvedDestination) -> bool
fn eq(&self, other: &ResolvedDestination) -> bool
self and other values to be equal, and is used by ==.