Skip to main content

ensure_url_ip_global

Function ensure_url_ip_global 

Source
pub fn ensure_url_ip_global(url: &Url) -> Result<(), DnsResolutionError>
Available on crate feature network only.
Expand description

If url’s host is an IP literal, validates that it is a globally routable address, returning DnsResolutionError::PrivateAddress if not. Hostnames and URLs without a host are passed through; they are expected to be validated by a connector-level DNS resolver at connect time.

This closes the gap that reqwest/hyper custom DNS resolvers are only invoked for hostnames, so IP-literal URLs (e.g. http://127.0.0.1) would otherwise bypass global-address enforcement.