File tree Expand file tree Collapse file tree 3 files changed +45
-6
lines changed
test/FlareSolverrSharp.Tests Expand file tree Collapse file tree 3 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,22 @@ public static class ChallengeDetector
2323 /// <returns>True if the site is protected</returns>
2424 private static bool IsCloudflareProtected ( HttpResponseMessage response )
2525 {
26- // check status code
26+ // check response headers
27+ if ( ! response . Headers . Server . Any ( i =>
28+ i . Product != null && CloudflareServerNames . Contains ( i . Product . Name . ToLower ( ) ) ) )
29+ return false ;
30+
31+ // detect CloudFlare and DDoS-GUARD
2732 if ( response . StatusCode . Equals ( HttpStatusCode . ServiceUnavailable ) ||
2833 response . StatusCode . Equals ( HttpStatusCode . Forbidden ) )
29- {
30- // check response headers
31- return response . Headers . Server . Any ( i =>
32- i . Product != null && CloudflareServerNames . Contains ( i . Product . Name . ToLower ( ) ) ) ;
33- }
34+ return true ; // Defected CloudFlare and DDoS-GUARD
35+
36+ // detect Custom CloudFlare for EbookParadijs, Film-Paleis, MuziekFabriek and Puur-Hollands
37+ if ( response . Headers . Vary . ToString ( ) == "Accept-Encoding,User-Agent" &&
38+ response . Content . Headers . ContentEncoding . ToString ( ) == "" &&
39+ response . Content . ReadAsStringAsync ( ) . Result . ToLower ( ) . Contains ( "ddos" ) )
40+ return true ;
41+
3442 return false ;
3543 }
3644
Original file line number Diff line number Diff line change @@ -95,6 +95,35 @@ public async Task SolveOkProxy()
9595 Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
9696 }
9797
98+ [ TestMethod ]
99+ public async Task SolveOkCloudflareDDoSGuardGet ( )
100+ {
101+ var handler = new ClearanceHandler ( Settings . FlareSolverrApiUrl )
102+ {
103+ MaxTimeout = 60000
104+ } ;
105+
106+ var client = new HttpClient ( handler ) ;
107+ var response = await client . GetAsync ( Settings . ProtectedDdgUri ) ;
108+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
109+ Assert . IsTrue ( ! response . Content . ReadAsStringAsync ( ) . Result . ToLower ( ) . Contains ( "ddos" ) ) ;
110+ }
111+
112+ [ TestMethod ]
113+ public async Task SolveOkCloudflareCustomGet ( )
114+ {
115+ // Custom CloudFlare for EbookParadijs, Film-Paleis, MuziekFabriek and Puur-Hollands
116+ var handler = new ClearanceHandler ( Settings . FlareSolverrApiUrl )
117+ {
118+ MaxTimeout = 60000
119+ } ;
120+
121+ var client = new HttpClient ( handler ) ;
122+ var response = await client . GetAsync ( Settings . ProtectedCcfUri ) ;
123+ Assert . AreEqual ( HttpStatusCode . OK , response . StatusCode ) ;
124+ Assert . IsTrue ( ! response . Content . ReadAsStringAsync ( ) . Result . ToLower ( ) . Contains ( "ddos" ) ) ;
125+ }
126+
98127 [ TestMethod ]
99128 public async Task SolveErrorUrl ( )
100129 {
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ internal static class Settings
77 internal const string FlareSolverrApiUrl = "http://localhost:8191/" ;
88 internal const string ProxyUrl = "http://127.0.0.1:8888/" ;
99 internal static readonly Uri ProtectedUri = new Uri ( "https://pirateiro.com/torrents/?search=harry" ) ;
10+ internal static readonly Uri ProtectedDdgUri = new Uri ( "https://www.erai-raws.info/feed/?type=magnet" ) ;
11+ internal static readonly Uri ProtectedCcfUri = new Uri ( "https://www.muziekfabriek.org" ) ;
1012
1113 /*
1214 To configure TinyProxy in local:
You can’t perform that action at this time.
0 commit comments