elcattivo / CloudFlareUtilities

A .NET Standard Library to bypass Cloudflare's Anti-DDoS measure (JavaScript challenge) using a DelegatingHandler.
MIT License
190 stars 47 forks source link

Stopped working after 2 3 times. #24

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi I want to fetch some data from yobit api,as recently they have changed to cloudflare api. I used your library(built in my system).It worked first 2 times,but after that its not working..After digging more I found that cloudflare server expect max-age 604800.. Please look into this,your library is good library saved lot of time.. Also from nuget I am not able to install this,I had to build this

Here is my code- string url = "https://yobit.net/api/3/info";

            var handler = new ClearanceHandler
            {
                MaxRetries = 3
            };
            var client = new HttpClient(handler);
            var result = await client.GetAsync(url);
            using (var streamReader = new StreamReader(await result.Content.ReadAsStreamAsync()))
            {

var tmp = streamReader.ReadToEnd(); }

kade-robertson commented 6 years ago

Not sure why NuGet wouldn't work for you, Install-Package CloudFlareUtilities works fine here (VS2015).

I tested you code by running it 5 times in parallel, also wasn't able to reproduce your issue. What does 'not working' mean? I seem to be getting valid JSON content perfectly fine each time. If you have a stack trace that would be helpful in tracking the issue down.

static void Main(string[] args) {
    Do(1);
    Do(2);
    Do(3);
    Do(4);
    Do(5);
    Console.Read();
}

static async void Do(int refnum) {
    Console.WriteLine($"Started #{refnum}");
    string url = "https://yobit.net/api/3/info";
    var handler = new ClearanceHandler {
        MaxRetries = 3
    };
    var client = new HttpClient(handler);
    var result = await client.GetAsync(url);
    using (var streamReader = new StreamReader(await result.Content.ReadAsStreamAsync())) {
        var tmp = streamReader.ReadToEnd();
    }
    Console.WriteLine($"Stopped #{refnum}");
}

Edit: This does not appear to be an issue with this plugin. The site itself occasionally will serve non-JSON content, and instead simply displays something like "Ddos, 20-50 min". This is likely your issue.

ghost commented 6 years ago

Thanks for reply.. As I mentioned..the error is-Cloudflare server expects with specific time age. also simultaneously 10 times ,the plugin is working.Then after exactly 4 seconds,it gives above error.

for nuget issue-Have you tried this with uwp platform.

ghost commented 6 years ago

HI,

Is there any update???

elcattivo commented 6 years ago

@tonyyyrocks39 , how did you conclude, that 'max-age 604800' is required in the request headers? When you talk about max-age, do you mean 'Cache-Control: max-age'?

Right now there doesn't seem to be any JavaScript challenges when accessing https://yobit.net/api/3/info, so the clearance handler practically won't do anything. As expected, accessing the page using this library works without any issues. Until they activate the challenge again, there is nothing I can do, to reproduce and possibly fix your problem.

Also, adding the library to my UWP test project using NuGet did work flawlessly.

ByronAP commented 6 years ago

idk if this is related (i am using a proxy so not sure if that is why yet) but c-cex.com api is failing for me

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CloudFlareUtilities.ClearanceHandler.d19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at CloudFlareUtilities.ClearanceHandler.d15.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at ...

ghost commented 6 years ago

I am not sure how it is working your system.Also for UWP thing error is showing incompatible version.. Anyways I am closing this issue,because my main concern was accessing the yobit api. But now I think yobit has changed something,it is now working without using this library.

elcattivo commented 6 years ago

As I said, Yobit isn't using CloudFlare's JS challenge right now. That is the reason why I can't reproduce/fix your issue and why you don't need this library at the moment. But that also means you shouldn't have any trouble accessing Yobit while using the ClearanceHandler in you HttpClient. As long as there is no JS challenge to solve, the ClearanceHandler practically doesn't do anything special.