pub struct SsrfResolver {
pub allow_hosts: Option<Vec<String>>,
}Expand description
A ureq::Resolver that performs DNS and SSRF validation atomically.
Install on a ureq::Agent via AgentBuilder::resolver and ureq will
call [SsrfResolver::resolve] exactly once per connection attempt,
using whatever socket addresses we return. There is no second lookup
inside ureq, so a DNS rebinding flip between check and use is
structurally impossible.
Fields§
§allow_hosts: Option<Vec<String>>Optional positive allowlist. When Some, every host must match
(case-insensitive) or the resolver rejects with PermissionDenied.
Compared before DNS so the agent never issues a lookup for a
rejected host.
Implementations§
Source§impl SsrfResolver
impl SsrfResolver
Sourcepub fn new() -> Self
pub fn new() -> Self
Build a resolver with no allowlist (all hosts pass except the metadata blocklist and private IP ranges).
Sourcepub fn with_allow_hosts(hosts: Vec<String>) -> Self
pub fn with_allow_hosts(hosts: Vec<String>) -> Self
Build a resolver with an explicit host allowlist.
Sourcepub fn validate_addrs(host: &str, addrs: &[SocketAddr]) -> Result<()>
pub fn validate_addrs(host: &str, addrs: &[SocketAddr]) -> Result<()>
Standalone validation for a list of resolved addresses. Exposed so
tests can exercise the decision logic without going through a ureq
agent, and so Fetch::call can reuse the same predicate for the
early scheme/shape check.
Trait Implementations§
Source§impl Clone for SsrfResolver
impl Clone for SsrfResolver
Source§fn clone(&self) -> SsrfResolver
fn clone(&self) -> SsrfResolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more