#[non_exhaustive]pub struct DomainFilter {
pub allowlist: Vec<String>,
pub denylist: Vec<String>,
pub block_private_ips: bool,
}Expand description
Domain allowlist/denylist with built-in SSRF protection.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.allowlist: Vec<String>§denylist: Vec<String>§block_private_ips: boolImplementations§
Source§impl DomainFilter
impl DomainFilter
Sourcepub fn blocking_private_ips() -> Self
pub fn blocking_private_ips() -> Self
Construct a filter that preserves open-domain access while blocking private, loopback, link-local, and otherwise non-routable IP ranges.
Sourcepub fn is_allowed(&self, url: &Url) -> Result<(), DomainFilterError>
pub fn is_allowed(&self, url: &Url) -> Result<(), DomainFilterError>
Check whether the given URL is permitted by the filter.
Steps:
- Scheme must be
httporhttps. - Host must be extractable.
- If the allowlist is non-empty the host must appear in it.
- The host must not appear in the denylist.
- If
block_private_ipsis enabled, DNS-resolved addresses are checked against private/loopback/link-local ranges (SSRF protection).
Trait Implementations§
Source§impl Clone for DomainFilter
impl Clone for DomainFilter
Source§fn clone(&self) -> DomainFilter
fn clone(&self) -> DomainFilter
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DomainFilter
impl Debug for DomainFilter
Source§impl Default for DomainFilter
impl Default for DomainFilter
Source§fn default() -> DomainFilter
fn default() -> DomainFilter
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DomainFilter
impl RefUnwindSafe for DomainFilter
impl Send for DomainFilter
impl Sync for DomainFilter
impl Unpin for DomainFilter
impl UnsafeUnpin for DomainFilter
impl UnwindSafe for DomainFilter
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