Skip to main content

ChallengeResolver

Trait ChallengeResolver 

Source
pub trait ChallengeResolver:
    Send
    + Sync
    + 'static {
    // Required method
    fn resolve<'a>(
        &'a self,
        proxy_url: &'a str,
        body: &'a [u8],
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'a>>;
}
Expand description

Resolves a WAF challenge on behalf of a specific proxy node.

When the scheduler receives a Challenge verdict it calls resolve on the same proxy node that triggered the challenge. A successful return value (some cookie string) is stored in ProxyManager and injected into subsequent requests via a RequestMutator.

Return None to signal that the challenge cannot be solved; the scheduler will mark that proxy node as Dead.

§Example

use scatter_proxy::ChallengeResolver;

struct MyResolver;

impl ChallengeResolver for MyResolver {
    fn resolve<'a>(
        &'a self,
        _proxy_url: &'a str,
        body: &'a [u8],
    ) -> std::pin::Pin<Box<dyn std::future::Future<Output = Option<String>> + Send + 'a>> {
        Box::pin(async move {
            // parse challenge HTML and compute cookie value
            Some("solved_cookie_value".to_string())
        })
    }
}

Required Methods§

Source

fn resolve<'a>( &'a self, proxy_url: &'a str, body: &'a [u8], ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'a>>

Attempt to solve the WAF challenge contained in body.

proxy_url — the proxy node URL that received the challenge page. body — the raw response body (HTML) of the challenge page.

Returns the resolved cookie value (not the full key=value header), or None if solving fails.

Implementors§