• This repository has been archived on 27/Mar/2020
  • Stars
    star
    190
  • Rank 202,842 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A .NET Standard Library to bypass Cloudflare's Anti-DDoS measure (JavaScript challenge) using a DelegatingHandler.

CloudFlare Utilities

NuGet AppVeyor GitHub license GitHub stars NuGet

A .NET Standard Library to bypass Cloudflare's Anti-DDoS measure (JavaScript challenge) using a DelegatingHandler.

Contributors

Features

  • No dependencies (e.g. no external JavaScript interpreter required)
  • Easily integrated into your project (implemented as DelegatingHandler; e.g. can be used with HttpClient)
  • Usable on many different platforms (NET Standard 1.1)

Usage

try
{
    // Create the clearance handler.
    var handler = new ClearanceHandler
    {
        MaxRetries = 2 // Optionally specify the number of retries, if clearance fails (default is 3).
    };

    // Create a HttpClient that uses the handler to bypass CloudFlare's JavaScript challange.
    var client = new HttpClient(handler);

    // Use the HttpClient as usual. Any JS challenge will be solved automatically for you.
    var content = await client.GetStringAsync("http://protected-site.tld/");
}
catch (AggregateException ex) when (ex.InnerException is CloudFlareClearanceException)
{
    // After all retries, clearance still failed.
}
catch (AggregateException ex) when (ex.InnerException is TaskCanceledException)
{
    // Looks like we ran into a timeout. Too many clearance attempts?
    // Maybe you should increase client.Timeout as each attempt will take about five seconds.
}