mirror of
https://github.com/FlareSolverr/FlareSolverr.git
synced 2025-06-08 12:35:30 +00:00
Add support for DDoS-GUARD challenge
This commit is contained in:
parent
bc6ac68e52
commit
fdd1d245f4
@ -7,7 +7,10 @@ import log from "../services/log";
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
const BAN_SELECTORS = ['.text-gray-600'];
|
const BAN_SELECTORS = ['.text-gray-600'];
|
||||||
const CHALLENGE_SELECTORS = ['#trk_jschal_js', '.ray_id', '.attack-box', '#cf-please-wait'];
|
const CHALLENGE_SELECTORS = [
|
||||||
|
'#trk_jschal_js', '.ray_id', '.attack-box', '#cf-please-wait', // CloudFlare
|
||||||
|
'#link-ddg' // DDoS-GUARD
|
||||||
|
];
|
||||||
const CAPTCHA_SELECTORS = ['input[name="cf_captcha_kind"]'];
|
const CAPTCHA_SELECTORS = ['input[name="cf_captcha_kind"]'];
|
||||||
|
|
||||||
export default async function resolveChallenge(url: string, page: Page, response: Response): Promise<Response> {
|
export default async function resolveChallenge(url: string, page: Page, response: Response): Promise<Response> {
|
||||||
|
@ -15,6 +15,7 @@ const postUrl = "https://ptsv2.com/t/qv4j3-1634496523";
|
|||||||
const cfUrl = "https://pirateiro.com/torrents/?search=harry";
|
const cfUrl = "https://pirateiro.com/torrents/?search=harry";
|
||||||
const cfCaptchaUrl = "https://idope.se"
|
const cfCaptchaUrl = "https://idope.se"
|
||||||
const cfBlockedUrl = "https://www.torrentmafya.org/table.php"
|
const cfBlockedUrl = "https://www.torrentmafya.org/table.php"
|
||||||
|
const ddgUrl = "https://www.erai-raws.info/feed/?type=magnet";
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
// Init session
|
// Init session
|
||||||
@ -168,6 +169,35 @@ describe("Test '/v1' path", () => {
|
|||||||
expect(apiResponse.solution.url).toContain(cfBlockedUrl)
|
expect(apiResponse.solution.url).toContain(cfBlockedUrl)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Cmd 'request.get' should return OK with DDoS-GUARD JS", async () => {
|
||||||
|
const payload = {
|
||||||
|
"cmd": "request.get",
|
||||||
|
"url": ddgUrl
|
||||||
|
}
|
||||||
|
const response: Response = await request(app).post("/v1").send(payload);
|
||||||
|
expect(response.statusCode).toBe(200);
|
||||||
|
|
||||||
|
const apiResponse: V1ResponseSolution = response.body;
|
||||||
|
expect(apiResponse.status).toBe("ok");
|
||||||
|
expect(apiResponse.message).toBe("");
|
||||||
|
expect(apiResponse.startTimestamp).toBeGreaterThan(1000);
|
||||||
|
expect(apiResponse.endTimestamp).toBeGreaterThan(apiResponse.startTimestamp);
|
||||||
|
expect(apiResponse.version).toBe(version);
|
||||||
|
|
||||||
|
const solution = apiResponse.solution;
|
||||||
|
expect(solution.url).toContain(ddgUrl)
|
||||||
|
expect(solution.status).toBe(200);
|
||||||
|
expect(Object.keys(solution.headers).length).toBeGreaterThan(0)
|
||||||
|
expect(solution.response).toContain("<rss version")
|
||||||
|
expect(Object.keys(solution.cookies).length).toBeGreaterThan(0)
|
||||||
|
expect(solution.userAgent).toContain("Firefox/")
|
||||||
|
|
||||||
|
const cfCookie: string = (solution.cookies as any[]).filter(function(cookie) {
|
||||||
|
return cookie.name == "__ddg1";
|
||||||
|
})[0].value
|
||||||
|
expect(cfCookie.length).toBeGreaterThan(10)
|
||||||
|
});
|
||||||
|
|
||||||
test("Cmd 'request.get' should return OK with 'cookies' param", async () => {
|
test("Cmd 'request.get' should return OK with 'cookies' param", async () => {
|
||||||
const payload = {
|
const payload = {
|
||||||
"cmd": "request.get",
|
"cmd": "request.get",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user