소스 검색

[Cloudflare] Fix 503 due to missing value in js challenge. (#1913)

Related issues: inorichi/tachiyomi-extensions#951
DitFranXX 6 년 전
부모
커밋
9ca0307e1c
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt

+ 5 - 1
app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt

@@ -12,6 +12,8 @@ class CloudflareInterceptor : Interceptor {
 
     private val challengePattern = Regex("""name="jschl_vc" value="(\w+)"""")
 
+    private val sPattern = Regex("""name="s" value="([^"]+)""")
+
     private val serverCheck = arrayOf("cloudflare-nginx", "cloudflare")
 
     @Synchronized
@@ -45,8 +47,9 @@ class CloudflareInterceptor : Interceptor {
             val operation = operationPattern.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 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")
             }
 
@@ -62,6 +65,7 @@ class CloudflareInterceptor : Interceptor {
                     .newBuilder()
                     .addQueryParameter("jschl_vc", challenge)
                     .addQueryParameter("pass", pass)
+                    .addQueryParameter("s", s)
                     .addQueryParameter("jschl_answer", result)
                     .toString()