Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add FlareSolverr to bypass cloudflare #1124

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

kaiserbh
Copy link

Added https://github.com/FlareSolverr/FlareSolverr to bypass cloudflare anti-bot protection.

A brief summary of FlareSolverr:

FlareSolverr is a proxy server designed to bypass Cloudflare and DDoS-GUARD protection. It works by starting a proxy server that uses Selenium with undetected-chromedriver to open a web browser (Chrome), navigate to a URL with user parameters, and wait until the Cloudflare challenge is solved before sending back the HTML code and cookies. These cookies can then be used to bypass Cloudflare with other HTTP clients.

Before and after

With FlareSolverr Without
Hello OKay

Settings in the advance section.

Video:

Without flareSolverr

Screen_recording_not_working.mp4

With FlareSolverr

flareSolverr_works_compressed_700k.mp4

Note

I think everything works fine but I am not sure if the cookie will be persisted at the start, for example in the flaresolverr video it shows no result found even though it managed to get the cookie. Not sure exactly but unless we restart

Ignore the above pushed a fix for it, I should have used the cookie in the Header asap instead of waiting for it to populate cookie jar. The stuff like no result or click on chapter and clicking retry as well it's fixed. Essentially it should load on first visit. Of course that is if the source is working.

sousou-no-frieren-frieren

I don't think reverse proxy going to work maybe it does but no luck on my end not that I need it tbh, I think using tailscale or wireguard should suffice and safer as there is no security in flaresolverr.

Signed-off-by: KaiserBh <[email protected]>
We should make sure the cookie is attached when the request proceeds that way we don't have to relay on the app cookie jar state, for example we get the result immediately instead of going out of the extension and going back in, same withe the chapters, they use subdomain and it's random, so we need to make sure the cf_clearance is added to the subdomains dynamically.

Signed-off-by: KaiserBh <[email protected]>
@kaiserbh kaiserbh changed the title feat: add flare solverr bypass cloudflare feat: add FlareSolverr bypass cloudflare Mar 18, 2024
@kaiserbh kaiserbh changed the title feat: add FlareSolverr bypass cloudflare feat: add FlareSolverr to bypass cloudflare Mar 18, 2024
Signed-off-by: KaiserBh <[email protected]>
@NeKoOuO

This comment has been minimized.

@kaiserbh
Copy link
Author

Do we still need to enable DoH when using this?🤔

Don't think so, but I tested it with both and works with and without.

@NeKoOuO
Copy link

NeKoOuO commented Apr 5, 2024

Does this PR include the functionality of adding Captcha Solvers in addition ?🤔

@kaiserbh
Copy link
Author

kaiserbh commented Apr 5, 2024

Does this PR include the functionality of adding Captcha Solvers in addition ?🤔

It's possible, but that depends on you, FlareSolverr already has the capability.

https://github.com/FlareSolverr/FlareSolverr?tab=readme-ov-file#environment-variables

You can read more on it.

@NeKoOuO

This comment has been minimized.

Copy link
Owner

@jobobby04 jobobby04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a Suwayomi implementation of FlareSolverr that uses some of my comments. Feel free to take things from it.
https://github.com/Suwayomi/Suwayomi-Server/pull/844/files

@kaiserbh
Copy link
Author

kaiserbh commented Apr 13, 2024

Refactored.
But flareSolverr is not working on my linux for some reason getting hit into timeout loop (FlareSolverr/FlareSolverr#1036), so I will need to test this on windows, don't merge it yet.

@jobobby04
Copy link
Owner

Try changing the timeout on the network okhttpclient

So this kinda works, it sets the cookie in the jar but for some reason fails to retrieve it. But if I directly use CookieManager.getInstance() It works fine??
So this is the working version using CookieManager Directly.
@kaiserbh
Copy link
Author

kaiserbh commented Jun 6, 2024

Okay so @jobobby04, this works well kinda, I can't get it to work when I use the networkhelper cookie manager... But If I use the cookieManager: CookieManager = CookieManager.getInstance() It works fine, well it fails to load the browse page (refer to the video basically that) the first time it fetches but it works afterwards. I don't know how the cookie manager works and It should technically work as we are building new request with the cookies. If you can have a look at this and see what's the issue, I would appreciate it.

I made two commit, one with the network helper cookie jar (8902355) and the other one accessing it directly (edf35a0).

Also I am using this version of FlareSolverr:

---
version: "2.1"
services:
  flaresolverr:
    # DockerHub mirror flaresolverr/flaresolverr:latest
    image: 21hsmw/flaresolverr:nodriver
    container_name: flaresolverr2
    environment:
      - LOG_LEVEL=${LOG_LEVEL:-info}
      - LOG_HTML=${LOG_HTML:-false}
      - CAPTCHA_SOLVER=${CAPTCHA_SOLVER:-none}
      - TZ=UTC
    ports:
      - "${PORT:-8191}:8191"
    restart: unless-stopped

Since the other ones doesn't seem to work.

@NeKoOuO

This comment has been minimized.

@cuong-tran
Copy link

is this working yet?

@NeKoOuO
Copy link

NeKoOuO commented Aug 2, 2024

@kaiserbh Do u wanna try merge on Komikku…?

) {
val json: Json by injectLazy()
val jsonMediaType = "application/json".toMediaType()
val client = OkHttpClient.Builder().build()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the networkManager http client here?

@@ -51,4 +52,40 @@ class AndroidCookieJar : CookieJar {
fun removeAll() {
manager.removeAllCookies {}
}

fun addAll(url: HttpUrl, cookies: List<Cookie>) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove debug logs if you are done with them, cookies shouldn't be logged if possible

<string name="pref_flare_solverr_url_summary">URL of the FlareSolverr instance to use for example http://192.168.1.202:8191/v1</string>
<string name="pref_test_flare_solverr_and_update_user_agent">Test FlareSolverr and update user agent</string>
<string name="pref_test_flare_solverr_and_update_user_agent_summary">Test FlareSolverr to update the user agent. Only required once; then toggle as needed.</string>

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SY strings should go in i18n-sy

return chain.proceed(originalRequest)
}

Log.d("FlareSolverrInterceptor", "Intercepting request: ${originalRequest.url}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All logs should use logcat()

@pixelroll
Copy link

it's abandoning ? the idea was great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants