pub trait UrlFilter: Send + Sync {
// Required methods
fn check_at_config(
&self,
url: &Url,
version: A2aVersion,
) -> Result<(), FilterDenial>;
fn check_at_delivery(
&self,
url: &Url,
resolved: IpAddr,
version: A2aVersion,
) -> Result<(), FilterDenial>;
}Expand description
The port the push-notification delivery adapter consults.
Two methods because the URL is checked at two moments: at config time, when the only thing available is the URL string, and at delivery time, when the resolved IP is also available. An implementation may deny more aggressively than the two named methods, but must not deny less — the second check exists precisely to close what the first cannot.
Required Methods§
Sourcefn check_at_config(
&self,
url: &Url,
version: A2aVersion,
) -> Result<(), FilterDenial>
fn check_at_config( &self, url: &Url, version: A2aVersion, ) -> Result<(), FilterDenial>
Checks a URL when the client registers a PushNotificationConfig.
Must reject every input check_at_delivery would reject, and may
reject hostnames that look like they will fail the second check
(e.g. a hostname that ends in .internal).
§Errors
FilterDenial on rejection, with the class of the refusal.
Sourcefn check_at_delivery(
&self,
url: &Url,
resolved: IpAddr,
version: A2aVersion,
) -> Result<(), FilterDenial>
fn check_at_delivery( &self, url: &Url, resolved: IpAddr, version: A2aVersion, ) -> Result<(), FilterDenial>
Checks a URL and its resolved IP at delivery time.
The IP is the result of a DNS resolution the delivery adapter did
itself (not the system’s default resolver, which can be poisoned).
The check must not trust the URL string’s Host header against the
resolved IP — a Host: example.com over a socket to 127.0.0.1 is
the textbook DNS-rebind.
§Errors
FilterDenial on rejection. A DeniedIpLiteral from the first
check is not re-raised here; the relevant variant for a rejected
resolved IP is DeniedResolvedIp.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".