mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 23:29:16 +01:00
Don't send cache control with cloudflare challenge
This commit is contained in:
parent
7ab16a69df
commit
4bbf78e840
@ -1,6 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.network
|
package eu.kanade.tachiyomi.network
|
||||||
|
|
||||||
import com.squareup.duktape.Duktape
|
import com.squareup.duktape.Duktape
|
||||||
|
import okhttp3.CacheControl
|
||||||
import okhttp3.HttpUrl
|
import okhttp3.HttpUrl
|
||||||
import okhttp3.Interceptor
|
import okhttp3.Interceptor
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
@ -21,7 +22,7 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
val response = chain.proceed(chain.request())
|
val response = chain.proceed(chain.request())
|
||||||
|
|
||||||
// Check if Cloudflare anti-bot is on
|
// Check if Cloudflare anti-bot is on
|
||||||
if (response.code() == 503 && serverCheck.contains(response.header("Server"))) {
|
if (response.code() == 503 && response.header("Server") in serverCheck) {
|
||||||
return chain.proceed(resolveChallenge(response))
|
return chain.proceed(resolveChallenge(response))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
val pass = passPattern.find(content)?.groups?.get(1)?.value
|
val pass = passPattern.find(content)?.groups?.get(1)?.value
|
||||||
|
|
||||||
if (operation == null || challenge == null || pass == null) {
|
if (operation == null || challenge == null || pass == null) {
|
||||||
throw RuntimeException("Failed resolving Cloudflare challenge")
|
throw Exception("Failed resolving Cloudflare challenge")
|
||||||
}
|
}
|
||||||
|
|
||||||
val js = operation
|
val js = operation
|
||||||
@ -52,7 +53,7 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
.replace("t.length", "${domain.length}")
|
.replace("t.length", "${domain.length}")
|
||||||
.replace("\n", "")
|
.replace("\n", "")
|
||||||
|
|
||||||
val result = (duktape.evaluate(js) as Double)
|
val result = duktape.evaluate(js) as Double
|
||||||
|
|
||||||
val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!!
|
val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!!
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
@ -66,7 +67,7 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
.add("Referer", url.toString())
|
.add("Referer", url.toString())
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
return GET(cloudflareUrl, cloudflareHeaders)
|
return GET(cloudflareUrl, cloudflareHeaders, cache = CacheControl.Builder().build())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user