From 87a54d1885b0084b65dcc68247f4911bd2eacfd3 Mon Sep 17 00:00:00 2001 From: siritami <102145692+FiorenMas@users.noreply.github.com> Date: Wed, 8 Jul 2026 12:47:04 +0700 Subject: [PATCH] fix bugs cf bypass --- .github/actions/preparing/action.yml | 8 ------- src/build/utils.sh | 33 +++++++++++++--------------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/.github/actions/preparing/action.yml b/.github/actions/preparing/action.yml index 6df5b18..5511be8 100644 --- a/.github/actions/preparing/action.yml +++ b/.github/actions/preparing/action.yml @@ -16,10 +16,6 @@ inputs: description: 'Path to Python requirements.txt file' required: false default: '' - cf_bypass_solver: - description: 'Cloudflare bypass solver: flaresolverr or cloudflarebypassforscraping' - required: false - default: 'cloudflarebypassforscraping' runs: using: "composite" steps: @@ -42,7 +38,6 @@ runs: sleep 5 curl -x socks5://127.0.0.1:9099 -s -o /dev/null -w "%{http_code}" https://www.google.com && echo "[+] usque SOCKS5 proxy is ready" || echo "[-] usque proxy failed" - name: Start FlareSolverr - if: inputs.cf_bypass_solver == 'flaresolverr' shell: bash run: | docker run -d --name flaresolverr -p 8191:8191 ghcr.io/flaresolverr/flaresolverr:latest @@ -54,9 +49,7 @@ runs: fi sleep 2 done - echo "CF_BYPASS_SOLVER=flaresolverr" >> "$GITHUB_ENV" - name: Start CloudflareBypassForScraping - if: inputs.cf_bypass_solver == 'cloudflarebypassforscraping' shell: bash run: | docker run -d --name cloudflarebypass -p 8000:8000 ghcr.io/sarperavci/cloudflarebypassforscraping:latest @@ -68,7 +61,6 @@ runs: fi sleep 2 done - echo "CF_BYPASS_SOLVER=cloudflarebypassforscraping" >> "$GITHUB_ENV" - name: Set up Python if: inputs.install_python_deps == 'true' uses: actions/setup-python@v6 diff --git a/src/build/utils.sh b/src/build/utils.sh index 855e1ab..f09c745 100644 --- a/src/build/utils.sh +++ b/src/build/utils.sh @@ -270,13 +270,13 @@ detect_version() { _fs_get() { local url=$1 - local max_retries=5 + local max_retries=3 local attempt for attempt in $(seq 1 $max_retries); do local response response=$(curl -s -X POST 'http://localhost:8191/v1' \ -H 'Content-Type: application/json' \ - -d "{\"cmd\":\"request.get\",\"url\":\"$url\",\"maxTimeout\":60000}") + -d "{\"cmd\":\"request.get\",\"url\":\"$url\",\"maxTimeout\":15000}") local status status=$(echo "$response" | jq -r '.status // empty') if [[ "$status" == "ok" ]]; then @@ -287,7 +287,7 @@ _fs_get() { return 0 fi yellow_log "[!] FlareSolverr attempt $attempt/$max_retries failed: $url" - sleep 10 + sleep 5 done red_log "[-] FlareSolverr failed after $max_retries attempts: $url" return 1 @@ -295,16 +295,9 @@ _fs_get() { _cfb_get() { local url=$1 - local max_retries=5 + local max_retries=3 local attempt - local cfb_host - cfb_host=$(echo "$url" | sed -E 's#https?://([^/]+)/?.*#\1#') - - local cfb_path - cfb_path=$(echo "$url" | sed -E 's#https?://[^/]+(/.*)#\1#') - [[ -z "$cfb_path" || "$cfb_path" == "$url" ]] && cfb_path="/" - for attempt in $(seq 1 $max_retries); do local response_file rm -f /tmp/cfb_response_headers.txt @@ -312,9 +305,9 @@ _cfb_get() { local http_code http_code=$(curl -s -o "$response_file" -w '%{http_code}' \ -D /tmp/cfb_response_headers.txt \ - -H "x-hostname: $cfb_host" \ + -G --data-urlencode "url=$url" \ --max-time 120 \ - "http://localhost:8000$cfb_path") + "http://localhost:8000/html") if [[ "$http_code" == "200" ]]; then html=$(cat "$response_file") if [[ -n "$html" ]]; then @@ -326,18 +319,22 @@ _cfb_get() { rm -f "$response_file" /tmp/cfb_response_headers.txt return 0 fi + else + yellow_log "[!] CFB attempt $attempt/$max_retries: HTTP $http_code: $url" fi done - red_log "[-] CloudflareBypassForScraping failed after $max_retries attempts: $url" return 1 } +_FFS_FAILED=0 + _cf_get() { - if [[ "$CF_BYPASS_SOLVER" == "cloudflarebypassforscraping" ]]; then - _cfb_get "$@" - else - _fs_get "$@" + if [[ "$_FFS_FAILED" -eq 0 ]]; then + _fs_get "$@" && return 0 + yellow_log "[!] FlareSolverr failed, falling back to CFB" + _FFS_FAILED=1 fi + _cfb_get "$@" } get_apk() {