mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-29 18:13:15 -05: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
1 changed files with 5 additions and 1 deletions
|
@ -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 a new issue