mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:29:16 +01:00
Handle HTTP 403 responses with CloudflareInterceptor
Based on 8d34da591e
Co-authored-by: jmir1 <jmir1@users.noreply.github.com>
This commit is contained in:
parent
b17b882a3b
commit
fadaefeaef
@ -56,7 +56,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||||||
val response = chain.proceed(originalRequest)
|
val response = chain.proceed(originalRequest)
|
||||||
|
|
||||||
// Check if Cloudflare anti-bot is on
|
// Check if Cloudflare anti-bot is on
|
||||||
if (response.code != 503 || response.header("Server") !in SERVER_CHECK) {
|
if (response.code !in ERROR_CODES || response.header("Server") !in SERVER_CHECK) {
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||||||
isMainFrame: Boolean
|
isMainFrame: Boolean
|
||||||
) {
|
) {
|
||||||
if (isMainFrame) {
|
if (isMainFrame) {
|
||||||
if (errorCode == 503) {
|
if (errorCode in ERROR_CODES) {
|
||||||
// Found the Cloudflare challenge page.
|
// Found the Cloudflare challenge page.
|
||||||
challengeFound = true
|
challengeFound = true
|
||||||
} else {
|
} else {
|
||||||
@ -167,6 +167,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private val ERROR_CODES = listOf(403, 503)
|
||||||
private val SERVER_CHECK = arrayOf("cloudflare-nginx", "cloudflare")
|
private val SERVER_CHECK = arrayOf("cloudflare-nginx", "cloudflare")
|
||||||
private val COOKIE_NAMES = listOf("cf_clearance")
|
private val COOKIE_NAMES = listOf("cf_clearance")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user