Detect DDoS-Guard challenge

This commit is contained in:
ngosang
2022-04-17 09:21:10 +02:00
parent 93d8350097
commit d962e1a14e
3 changed files with 7 additions and 6 deletions

View File

@@ -21,7 +21,8 @@ const CAPTCHA_SELECTORS: string[] = [
export default async function resolveChallenge(url: string, page: Page, response: HTTPResponse): Promise<HTTPResponse> {
// look for challenge and return fast if not detected
let cfDetected = response.headers().server && response.headers().server.startsWith('cloudflare');
let cfDetected = response.headers().server &&
(response.headers().server.startsWith('cloudflare') || response.headers().server.startsWith('ddos-guard'));
if (cfDetected) {
if (response.status() == 403 || response.status() == 503) {
cfDetected = true; // Defected CloudFlare and DDoS-GUARD

View File

@@ -15,7 +15,7 @@ const postUrl = "https://ptsv2.com/t/qv4j3-1634496523";
const cfUrl = "https://pirateiro.com/torrents/?search=harry";
const cfCaptchaUrl = "https://idope.se"
const cfBlockedUrl = "https://www.torrentmafya.org/table.php"
const ddgUrl = "https://www.erai-raws.info/feed/?type=magnet";
const ddgUrl = "https://anidex.info/";
const ccfUrl = "https://www.muziekfabriek.org";
beforeAll(async () => {
@@ -189,12 +189,12 @@ describe("Test '/v1' path", () => {
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(solution.response).toContain("<!DOCTYPE html>")
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";
return cookie.name == "__ddg1_";
})[0].value
expect(cfCookie.length).toBeGreaterThan(10)
});