Skip to main content

validate_url

Function validate_url 

Source
pub async fn validate_url(url: &Url) -> Result<Vec<SocketAddr>, BlockedUrl>
Expand description

Validate a URL’s scheme and resolve+classify its host. On success returns the validated socket addresses (host resolved to public IPs) so the caller can pin the connection and avoid a DNS-rebinding TOCTOU window.

A no-op (returns Ok(vec![])) when the guard is disabled via env.

Async because domain validation resolves DNS via tokio::net::lookup_host rather than the blocking std resolver — important on the async fetch path (and the concurrent MCP server) so a slow lookup never blocks a tokio worker.