pub struct HostFilter { /* private fields */ }Expand description
A filter for host-based network access control.
Supports exact domain match and wildcard subdomains (*.googleapis.com).
Cloud metadata endpoints are always denied and cannot be overridden. The allowlist determines which hosts are permitted; everything else is denied by default.
Implementations§
Source§impl HostFilter
impl HostFilter
Sourcepub fn new(allowed_hosts: &[String]) -> Self
pub fn new(allowed_hosts: &[String]) -> Self
Create a new host filter with the given allowed hosts.
Cloud metadata endpoints are automatically denied and cannot be removed.
Hosts starting with *. are treated as wildcard subdomain patterns.
All other entries are exact matches. Matching is case-insensitive.
Sourcepub fn allow_all() -> Self
pub fn allow_all() -> Self
Create a host filter that allows everything (no filtering).
Cloud metadata endpoints are still blocked.
Sourcepub fn check_host(&self, host: &str, resolved_ips: &[IpAddr]) -> FilterResult
pub fn check_host(&self, host: &str, resolved_ips: &[IpAddr]) -> FilterResult
Check a host against the filter.
resolved_ips should contain the DNS-resolved IP addresses for the host.
The caller is responsible for performing DNS resolution before calling this
method. This prevents DNS rebinding attacks: the proxy resolves once, checks
the resolved IPs here, then connects to the same resolved IP.
§Check Order
- Deny hosts (exact match against cloud metadata hostnames)
- Link-local IP check (resolved IPs in 169.254.0.0/16 or fe80::/10)
- Allowlist (exact host match, then wildcard subdomain match)
- Default deny (if not in allowlist and allowlist is non-empty)
Sourcepub fn allowed_count(&self) -> usize
pub fn allowed_count(&self) -> usize
Number of allowed hosts (exact + wildcard)
Trait Implementations§
Source§impl Clone for HostFilter
impl Clone for HostFilter
Source§fn clone(&self) -> HostFilter
fn clone(&self) -> HostFilter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more