pub struct NetworkResolver { /* private fields */ }Expand description
HTTPS-fetching resolver. Hardened by default with multiple SSRF and amplification defenses; the constructor requires a host allowlist so there’s no convenient “any host” mode.
Defaults:
- HTTPS only (use [
with_plaintext_http] to allowhttp://) - Refuses URLs whose resolved IP is RFC 1918 / loopback /
link-local (use [
with_private_ips_allowed] to disable) - 10-second per-request timeout
- 1 MB max response size
- 64 MB in-memory LRU cache (per resolver instance)
Implementations§
Source§impl NetworkResolver
impl NetworkResolver
Sourcepub fn new<I>(allowed_hosts: I) -> NetworkResolverwhere
I: IntoIterator<Item = String>,
pub fn new<I>(allowed_hosts: I) -> NetworkResolverwhere
I: IntoIterator<Item = String>,
Construct with the required host allowlist. Hosts are
matched exactly (no wildcards) against the URL’s host
component. All other settings get safe defaults; use
the with_* builders to relax them.
Sourcepub fn with_plaintext_http(self) -> NetworkResolver
pub fn with_plaintext_http(self) -> NetworkResolver
Allow http:// URLs (default: HTTPS-only). Almost
always wrong; use only for testing or air-gapped
networks where TLS isn’t available.
Sourcepub fn with_private_ips_allowed(self) -> NetworkResolver
pub fn with_private_ips_allowed(self) -> NetworkResolver
Allow URLs whose resolved IP is RFC 1918 private,
loopback, or link-local (default: refused for SSRF
defense). Disable only if your allowed_hosts list
already constrains to trusted internal hosts.
pub fn with_max_response_bytes(self, n: usize) -> NetworkResolver
pub fn with_timeout(self, d: Duration) -> NetworkResolver
pub fn with_cache_size(self, max_total_bytes: usize) -> NetworkResolver
Trait Implementations§
Source§impl Debug for NetworkResolver
impl Debug for NetworkResolver
Auto Trait Implementations§
impl !Freeze for NetworkResolver
impl !RefUnwindSafe for NetworkResolver
impl !UnwindSafe for NetworkResolver
impl Send for NetworkResolver
impl Sync for NetworkResolver
impl Unpin for NetworkResolver
impl UnsafeUnpin for NetworkResolver
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
Mutably borrows from an owned value. Read more