Skip to content

Commit

Permalink
[Cloudflare] Fix 503 due to missing value in js challenge. (#1913)
Browse files Browse the repository at this point in the history
  • Loading branch information
DitFranXX authored and inorichi committed Mar 21, 2019
1 parent 9a6f8be commit 9ca0307
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}

Expand All @@ -62,6 +65,7 @@ class CloudflareInterceptor : Interceptor {
.newBuilder()
.addQueryParameter("jschl_vc", challenge)
.addQueryParameter("pass", pass)
.addQueryParameter("s", s)
.addQueryParameter("jschl_answer", result)
.toString()

Expand Down

0 comments on commit 9ca0307

Please sign in to comment.