pub struct SsrfProtector { /* private fields */ }Expand description
The SSRF protection engine — validates URLs before they leave the ring.
Blocks requests to private IP ranges, dangerous schemes, and specific hostnames. Supports allow-listing for trusted internal hosts and custom regex-based blocking patterns.
Implementations§
Source§impl SsrfProtector
impl SsrfProtector
Sourcepub fn allow_host(&mut self, host: &str)
pub fn allow_host(&mut self, host: &str)
Add a hostname to the allow-list (bypasses IP range checks).
Sourcepub fn add_blocked_pattern(&mut self, name: &str, pattern: &str)
pub fn add_blocked_pattern(&mut self, name: &str, pattern: &str)
Add a custom regex pattern to block.
Sourcepub fn add_blocked_range(&mut self, cidr: &str)
pub fn add_blocked_range(&mut self, cidr: &str)
Add a custom CIDR range to block.
Sourcepub fn block_host(&mut self, host: &str)
pub fn block_host(&mut self, host: &str)
Block an additional hostname.
Sourcepub fn set_dns_check(&mut self, enabled: bool)
pub fn set_dns_check(&mut self, enabled: bool)
Enable or disable DNS resolution checks.
Sourcepub fn validate_url(&self, url: &str) -> Result<(), SsrfViolation>
pub fn validate_url(&self, url: &str) -> Result<(), SsrfViolation>
Validate a URL, returning Ok(()) if it is safe to request.
Trait Implementations§
Source§impl Clone for SsrfProtector
impl Clone for SsrfProtector
Source§fn clone(&self) -> SsrfProtector
fn clone(&self) -> SsrfProtector
Returns a duplicate of the value. Read more
1.0.0 · 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 SsrfProtector
impl Debug for SsrfProtector
Auto Trait Implementations§
impl Freeze for SsrfProtector
impl RefUnwindSafe for SsrfProtector
impl Send for SsrfProtector
impl Sync for SsrfProtector
impl Unpin for SsrfProtector
impl UnsafeUnpin for SsrfProtector
impl UnwindSafe for SsrfProtector
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