mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +01:00
[Cloudflare] Fix 503 due to missing value in js challenge. (#1913)
Related issues: inorichi/tachiyomi-extensions#951
This commit is contained in:
parent
9a6f8be28c
commit
9ca0307e1c
@ -12,6 +12,8 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
|
|
||||||
private val challengePattern = Regex("""name="jschl_vc" value="(\w+)"""")
|
private val challengePattern = Regex("""name="jschl_vc" value="(\w+)"""")
|
||||||
|
|
||||||
|
private val sPattern = Regex("""name="s" value="([^"]+)""")
|
||||||
|
|
||||||
private val serverCheck = arrayOf("cloudflare-nginx", "cloudflare")
|
private val serverCheck = arrayOf("cloudflare-nginx", "cloudflare")
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@ -45,8 +47,9 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
val operation = operationPattern.find(content)?.groups?.get(1)?.value
|
val operation = operationPattern.find(content)?.groups?.get(1)?.value
|
||||||
val challenge = challengePattern.find(content)?.groups?.get(1)?.value
|
val challenge = challengePattern.find(content)?.groups?.get(1)?.value
|
||||||
val pass = passPattern.find(content)?.groups?.get(1)?.value
|
val pass = passPattern.find(content)?.groups?.get(1)?.value
|
||||||
|
val s = sPattern.find(content)?.groups?.get(1)?.value
|
||||||
|
|
||||||
if (operation == null || challenge == null || pass == null) {
|
if (operation == null || challenge == null || pass == null || s == null) {
|
||||||
throw Exception("Failed resolving Cloudflare challenge")
|
throw Exception("Failed resolving Cloudflare challenge")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +65,7 @@ class CloudflareInterceptor : Interceptor {
|
|||||||
.newBuilder()
|
.newBuilder()
|
||||||
.addQueryParameter("jschl_vc", challenge)
|
.addQueryParameter("jschl_vc", challenge)
|
||||||
.addQueryParameter("pass", pass)
|
.addQueryParameter("pass", pass)
|
||||||
|
.addQueryParameter("s", s)
|
||||||
.addQueryParameter("jschl_answer", result)
|
.addQueryParameter("jschl_answer", result)
|
||||||
.toString()
|
.toString()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user